babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10579. thinInstanceIndex: number;
  10580. /**
  10581. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10582. */
  10583. originMesh: Nullable<AbstractMesh>;
  10584. /**
  10585. * The ray that was used to perform the picking.
  10586. */
  10587. ray: Nullable<Ray>;
  10588. /**
  10589. * Gets the normal correspodning to the face the pick collided with
  10590. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10591. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10592. * @returns The normal correspodning to the face the pick collided with
  10593. */
  10594. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10595. /**
  10596. * Gets the texture coordinates of where the pick occured
  10597. * @returns the vector containing the coordnates of the texture
  10598. */
  10599. getTextureCoordinates(): Nullable<Vector2>;
  10600. }
  10601. }
  10602. declare module "babylonjs/Culling/ray" {
  10603. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10607. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10609. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10610. import { Plane } from "babylonjs/Maths/math.plane";
  10611. /**
  10612. * Class representing a ray with position and direction
  10613. */
  10614. export class Ray {
  10615. /** origin point */
  10616. origin: Vector3;
  10617. /** direction */
  10618. direction: Vector3;
  10619. /** length of the ray */
  10620. length: number;
  10621. private static readonly _TmpVector3;
  10622. private _tmpRay;
  10623. /**
  10624. * Creates a new ray
  10625. * @param origin origin point
  10626. * @param direction direction
  10627. * @param length length of the ray
  10628. */
  10629. constructor(
  10630. /** origin point */
  10631. origin: Vector3,
  10632. /** direction */
  10633. direction: Vector3,
  10634. /** length of the ray */
  10635. length?: number);
  10636. /**
  10637. * Checks if the ray intersects a box
  10638. * This does not account for the ray lenght by design to improve perfs.
  10639. * @param minimum bound of the box
  10640. * @param maximum bound of the box
  10641. * @param intersectionTreshold extra extend to be added to the box in all direction
  10642. * @returns if the box was hit
  10643. */
  10644. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10645. /**
  10646. * Checks if the ray intersects a box
  10647. * This does not account for the ray lenght by design to improve perfs.
  10648. * @param box the bounding box to check
  10649. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10650. * @returns if the box was hit
  10651. */
  10652. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10653. /**
  10654. * If the ray hits a sphere
  10655. * @param sphere the bounding sphere to check
  10656. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10657. * @returns true if it hits the sphere
  10658. */
  10659. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10660. /**
  10661. * If the ray hits a triange
  10662. * @param vertex0 triangle vertex
  10663. * @param vertex1 triangle vertex
  10664. * @param vertex2 triangle vertex
  10665. * @returns intersection information if hit
  10666. */
  10667. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10668. /**
  10669. * Checks if ray intersects a plane
  10670. * @param plane the plane to check
  10671. * @returns the distance away it was hit
  10672. */
  10673. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10674. /**
  10675. * Calculate the intercept of a ray on a given axis
  10676. * @param axis to check 'x' | 'y' | 'z'
  10677. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10678. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10679. */
  10680. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10681. /**
  10682. * Checks if ray intersects a mesh
  10683. * @param mesh the mesh to check
  10684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10685. * @returns picking info of the intersecton
  10686. */
  10687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10688. /**
  10689. * Checks if ray intersects a mesh
  10690. * @param meshes the meshes to check
  10691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10692. * @param results array to store result in
  10693. * @returns Array of picking infos
  10694. */
  10695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10696. private _comparePickingInfo;
  10697. private static smallnum;
  10698. private static rayl;
  10699. /**
  10700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10701. * @param sega the first point of the segment to test the intersection against
  10702. * @param segb the second point of the segment to test the intersection against
  10703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10705. */
  10706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10707. /**
  10708. * Update the ray from viewport position
  10709. * @param x position
  10710. * @param y y position
  10711. * @param viewportWidth viewport width
  10712. * @param viewportHeight viewport height
  10713. * @param world world matrix
  10714. * @param view view matrix
  10715. * @param projection projection matrix
  10716. * @returns this ray updated
  10717. */
  10718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10719. /**
  10720. * Creates a ray with origin and direction of 0,0,0
  10721. * @returns the new ray
  10722. */
  10723. static Zero(): Ray;
  10724. /**
  10725. * Creates a new ray from screen space and viewport
  10726. * @param x position
  10727. * @param y y position
  10728. * @param viewportWidth viewport width
  10729. * @param viewportHeight viewport height
  10730. * @param world world matrix
  10731. * @param view view matrix
  10732. * @param projection projection matrix
  10733. * @returns new ray
  10734. */
  10735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10736. /**
  10737. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10738. * transformed to the given world matrix.
  10739. * @param origin The origin point
  10740. * @param end The end point
  10741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10742. * @returns the new ray
  10743. */
  10744. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10745. /**
  10746. * Transforms a ray by a matrix
  10747. * @param ray ray to transform
  10748. * @param matrix matrix to apply
  10749. * @returns the resulting new ray
  10750. */
  10751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10752. /**
  10753. * Transforms a ray by a matrix
  10754. * @param ray ray to transform
  10755. * @param matrix matrix to apply
  10756. * @param result ray to store result in
  10757. */
  10758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10759. /**
  10760. * Unproject a ray from screen space to object space
  10761. * @param sourceX defines the screen space x coordinate to use
  10762. * @param sourceY defines the screen space y coordinate to use
  10763. * @param viewportWidth defines the current width of the viewport
  10764. * @param viewportHeight defines the current height of the viewport
  10765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10766. * @param view defines the view matrix to use
  10767. * @param projection defines the projection matrix to use
  10768. */
  10769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10770. }
  10771. /**
  10772. * Type used to define predicate used to select faces when a mesh intersection is detected
  10773. */
  10774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10775. module "babylonjs/scene" {
  10776. interface Scene {
  10777. /** @hidden */
  10778. _tempPickingRay: Nullable<Ray>;
  10779. /** @hidden */
  10780. _cachedRayForTransform: Ray;
  10781. /** @hidden */
  10782. _pickWithRayInverseMatrix: Matrix;
  10783. /** @hidden */
  10784. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10785. /** @hidden */
  10786. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10787. /** @hidden */
  10788. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10789. }
  10790. }
  10791. }
  10792. declare module "babylonjs/sceneComponent" {
  10793. import { Scene } from "babylonjs/scene";
  10794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10796. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10798. import { Nullable } from "babylonjs/types";
  10799. import { Camera } from "babylonjs/Cameras/camera";
  10800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10801. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10802. import { AbstractScene } from "babylonjs/abstractScene";
  10803. import { Mesh } from "babylonjs/Meshes/mesh";
  10804. /**
  10805. * Groups all the scene component constants in one place to ease maintenance.
  10806. * @hidden
  10807. */
  10808. export class SceneComponentConstants {
  10809. static readonly NAME_EFFECTLAYER: string;
  10810. static readonly NAME_LAYER: string;
  10811. static readonly NAME_LENSFLARESYSTEM: string;
  10812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10813. static readonly NAME_PARTICLESYSTEM: string;
  10814. static readonly NAME_GAMEPAD: string;
  10815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10817. static readonly NAME_PREPASSRENDERER: string;
  10818. static readonly NAME_DEPTHRENDERER: string;
  10819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10820. static readonly NAME_SPRITE: string;
  10821. static readonly NAME_OUTLINERENDERER: string;
  10822. static readonly NAME_PROCEDURALTEXTURE: string;
  10823. static readonly NAME_SHADOWGENERATOR: string;
  10824. static readonly NAME_OCTREE: string;
  10825. static readonly NAME_PHYSICSENGINE: string;
  10826. static readonly NAME_AUDIO: string;
  10827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10848. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10849. static readonly STEP_AFTERRENDER_AUDIO: number;
  10850. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10855. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10856. static readonly STEP_POINTERMOVE_SPRITE: number;
  10857. static readonly STEP_POINTERDOWN_SPRITE: number;
  10858. static readonly STEP_POINTERUP_SPRITE: number;
  10859. }
  10860. /**
  10861. * This represents a scene component.
  10862. *
  10863. * This is used to decouple the dependency the scene is having on the different workloads like
  10864. * layers, post processes...
  10865. */
  10866. export interface ISceneComponent {
  10867. /**
  10868. * The name of the component. Each component must have a unique name.
  10869. */
  10870. name: string;
  10871. /**
  10872. * The scene the component belongs to.
  10873. */
  10874. scene: Scene;
  10875. /**
  10876. * Register the component to one instance of a scene.
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * This represents a SERIALIZABLE scene component.
  10891. *
  10892. * This extends Scene Component to add Serialization methods on top.
  10893. */
  10894. export interface ISceneSerializableComponent extends ISceneComponent {
  10895. /**
  10896. * Adds all the elements from the container to the scene
  10897. * @param container the container holding the elements
  10898. */
  10899. addFromContainer(container: AbstractScene): void;
  10900. /**
  10901. * Removes all the elements in the container from the scene
  10902. * @param container contains the elements to remove
  10903. * @param dispose if the removed element should be disposed (default: false)
  10904. */
  10905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10906. /**
  10907. * Serializes the component data to the specified json object
  10908. * @param serializationObject The object to serialize to
  10909. */
  10910. serialize(serializationObject: any): void;
  10911. }
  10912. /**
  10913. * Strong typing of a Mesh related stage step action
  10914. */
  10915. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10916. /**
  10917. * Strong typing of a Evaluate Sub Mesh related stage step action
  10918. */
  10919. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10920. /**
  10921. * Strong typing of a Active Mesh related stage step action
  10922. */
  10923. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10924. /**
  10925. * Strong typing of a Camera related stage step action
  10926. */
  10927. export type CameraStageAction = (camera: Camera) => void;
  10928. /**
  10929. * Strong typing of a Camera Frame buffer related stage step action
  10930. */
  10931. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10932. /**
  10933. * Strong typing of a Render Target related stage step action
  10934. */
  10935. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10936. /**
  10937. * Strong typing of a RenderingGroup related stage step action
  10938. */
  10939. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10940. /**
  10941. * Strong typing of a Mesh Render related stage step action
  10942. */
  10943. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10944. /**
  10945. * Strong typing of a simple stage step action
  10946. */
  10947. export type SimpleStageAction = () => void;
  10948. /**
  10949. * Strong typing of a render target action.
  10950. */
  10951. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10952. /**
  10953. * Strong typing of a pointer move action.
  10954. */
  10955. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10956. /**
  10957. * Strong typing of a pointer up/down action.
  10958. */
  10959. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10960. /**
  10961. * Representation of a stage in the scene (Basically a list of ordered steps)
  10962. * @hidden
  10963. */
  10964. export class Stage<T extends Function> extends Array<{
  10965. index: number;
  10966. component: ISceneComponent;
  10967. action: T;
  10968. }> {
  10969. /**
  10970. * Hide ctor from the rest of the world.
  10971. * @param items The items to add.
  10972. */
  10973. private constructor();
  10974. /**
  10975. * Creates a new Stage.
  10976. * @returns A new instance of a Stage
  10977. */
  10978. static Create<T extends Function>(): Stage<T>;
  10979. /**
  10980. * Registers a step in an ordered way in the targeted stage.
  10981. * @param index Defines the position to register the step in
  10982. * @param component Defines the component attached to the step
  10983. * @param action Defines the action to launch during the step
  10984. */
  10985. registerStep(index: number, component: ISceneComponent, action: T): void;
  10986. /**
  10987. * Clears all the steps from the stage.
  10988. */
  10989. clear(): void;
  10990. }
  10991. }
  10992. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10993. import { Nullable } from "babylonjs/types";
  10994. import { Observable } from "babylonjs/Misc/observable";
  10995. import { Scene } from "babylonjs/scene";
  10996. import { Sprite } from "babylonjs/Sprites/sprite";
  10997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10998. import { Ray } from "babylonjs/Culling/ray";
  10999. import { Camera } from "babylonjs/Cameras/camera";
  11000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11001. import { ISceneComponent } from "babylonjs/sceneComponent";
  11002. module "babylonjs/scene" {
  11003. interface Scene {
  11004. /** @hidden */
  11005. _pointerOverSprite: Nullable<Sprite>;
  11006. /** @hidden */
  11007. _pickedDownSprite: Nullable<Sprite>;
  11008. /** @hidden */
  11009. _tempSpritePickingRay: Nullable<Ray>;
  11010. /**
  11011. * All of the sprite managers added to this scene
  11012. * @see https://doc.babylonjs.com/babylon101/sprites
  11013. */
  11014. spriteManagers: Array<ISpriteManager>;
  11015. /**
  11016. * An event triggered when sprites rendering is about to start
  11017. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11018. */
  11019. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11020. /**
  11021. * An event triggered when sprites rendering is done
  11022. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11023. */
  11024. onAfterSpritesRenderingObservable: Observable<Scene>;
  11025. /** @hidden */
  11026. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11027. /** Launch a ray to try to pick a sprite in the scene
  11028. * @param x position on screen
  11029. * @param y position on screen
  11030. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11031. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11032. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11033. * @returns a PickingInfo
  11034. */
  11035. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11036. /** Use the given ray to pick a sprite in the scene
  11037. * @param ray The ray (in world space) to use to pick meshes
  11038. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11039. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11040. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11041. * @returns a PickingInfo
  11042. */
  11043. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11044. /** @hidden */
  11045. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11046. /** Launch a ray to try to pick sprites in the scene
  11047. * @param x position on screen
  11048. * @param y position on screen
  11049. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11051. * @returns a PickingInfo array
  11052. */
  11053. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11054. /** Use the given ray to pick sprites in the scene
  11055. * @param ray The ray (in world space) to use to pick meshes
  11056. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11058. * @returns a PickingInfo array
  11059. */
  11060. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Force the sprite under the pointer
  11063. * @param sprite defines the sprite to use
  11064. */
  11065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11066. /**
  11067. * Gets the sprite under the pointer
  11068. * @returns a Sprite or null if no sprite is under the pointer
  11069. */
  11070. getPointerOverSprite(): Nullable<Sprite>;
  11071. }
  11072. }
  11073. /**
  11074. * Defines the sprite scene component responsible to manage sprites
  11075. * in a given scene.
  11076. */
  11077. export class SpriteSceneComponent implements ISceneComponent {
  11078. /**
  11079. * The component name helpfull to identify the component in the list of scene components.
  11080. */
  11081. readonly name: string;
  11082. /**
  11083. * The scene the component belongs to.
  11084. */
  11085. scene: Scene;
  11086. /** @hidden */
  11087. private _spritePredicate;
  11088. /**
  11089. * Creates a new instance of the component for the given scene
  11090. * @param scene Defines the scene to register the component in
  11091. */
  11092. constructor(scene: Scene);
  11093. /**
  11094. * Registers the component in a given scene
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. private _pickSpriteButKeepRay;
  11107. private _pointerMove;
  11108. private _pointerDown;
  11109. private _pointerUp;
  11110. }
  11111. }
  11112. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11113. /** @hidden */
  11114. export var fogFragmentDeclaration: {
  11115. name: string;
  11116. shader: string;
  11117. };
  11118. }
  11119. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11120. /** @hidden */
  11121. export var fogFragment: {
  11122. name: string;
  11123. shader: string;
  11124. };
  11125. }
  11126. declare module "babylonjs/Shaders/sprites.fragment" {
  11127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11129. /** @hidden */
  11130. export var spritesPixelShader: {
  11131. name: string;
  11132. shader: string;
  11133. };
  11134. }
  11135. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11136. /** @hidden */
  11137. export var fogVertexDeclaration: {
  11138. name: string;
  11139. shader: string;
  11140. };
  11141. }
  11142. declare module "babylonjs/Shaders/sprites.vertex" {
  11143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11144. /** @hidden */
  11145. export var spritesVertexShader: {
  11146. name: string;
  11147. shader: string;
  11148. };
  11149. }
  11150. declare module "babylonjs/Sprites/spriteManager" {
  11151. import { IDisposable, Scene } from "babylonjs/scene";
  11152. import { Nullable } from "babylonjs/types";
  11153. import { Observable } from "babylonjs/Misc/observable";
  11154. import { Sprite } from "babylonjs/Sprites/sprite";
  11155. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11156. import { Camera } from "babylonjs/Cameras/camera";
  11157. import { Texture } from "babylonjs/Materials/Textures/texture";
  11158. import "babylonjs/Shaders/sprites.fragment";
  11159. import "babylonjs/Shaders/sprites.vertex";
  11160. import { Ray } from "babylonjs/Culling/ray";
  11161. /**
  11162. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11163. */
  11164. export interface ISpriteManager extends IDisposable {
  11165. /**
  11166. * Gets manager's name
  11167. */
  11168. name: string;
  11169. /**
  11170. * Restricts the camera to viewing objects with the same layerMask.
  11171. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11172. */
  11173. layerMask: number;
  11174. /**
  11175. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11176. */
  11177. isPickable: boolean;
  11178. /**
  11179. * Gets the hosting scene
  11180. */
  11181. scene: Scene;
  11182. /**
  11183. * Specifies the rendering group id for this mesh (0 by default)
  11184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11185. */
  11186. renderingGroupId: number;
  11187. /**
  11188. * Defines the list of sprites managed by the manager.
  11189. */
  11190. sprites: Array<Sprite>;
  11191. /**
  11192. * Gets or sets the spritesheet texture
  11193. */
  11194. texture: Texture;
  11195. /** Defines the default width of a cell in the spritesheet */
  11196. cellWidth: number;
  11197. /** Defines the default height of a cell in the spritesheet */
  11198. cellHeight: number;
  11199. /**
  11200. * Tests the intersection of a sprite with a specific ray.
  11201. * @param ray The ray we are sending to test the collision
  11202. * @param camera The camera space we are sending rays in
  11203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11205. * @returns picking info or null.
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Renders the list of sprites on screen.
  11218. */
  11219. render(): void;
  11220. }
  11221. /**
  11222. * Class used to manage multiple sprites on the same spritesheet
  11223. * @see https://doc.babylonjs.com/babylon101/sprites
  11224. */
  11225. export class SpriteManager implements ISpriteManager {
  11226. /** defines the manager's name */
  11227. name: string;
  11228. /** Define the Url to load snippets */
  11229. static SnippetUrl: string;
  11230. /** Snippet ID if the manager was created from the snippet server */
  11231. snippetId: string;
  11232. /** Gets the list of sprites */
  11233. sprites: Sprite[];
  11234. /** Gets or sets the rendering group id (0 by default) */
  11235. renderingGroupId: number;
  11236. /** Gets or sets camera layer mask */
  11237. layerMask: number;
  11238. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11239. fogEnabled: boolean;
  11240. /** Gets or sets a boolean indicating if the sprites are pickable */
  11241. isPickable: boolean;
  11242. /** Defines the default width of a cell in the spritesheet */
  11243. cellWidth: number;
  11244. /** Defines the default height of a cell in the spritesheet */
  11245. cellHeight: number;
  11246. /** Associative array from JSON sprite data file */
  11247. private _cellData;
  11248. /** Array of sprite names from JSON sprite data file */
  11249. private _spriteMap;
  11250. /** True when packed cell data from JSON file is ready*/
  11251. private _packedAndReady;
  11252. private _textureContent;
  11253. /**
  11254. * An event triggered when the manager is disposed.
  11255. */
  11256. onDisposeObservable: Observable<SpriteManager>;
  11257. private _onDisposeObserver;
  11258. /**
  11259. * Callback called when the manager is disposed
  11260. */
  11261. set onDispose(callback: () => void);
  11262. private _capacity;
  11263. private _fromPacked;
  11264. private _spriteTexture;
  11265. private _epsilon;
  11266. private _scene;
  11267. private _vertexData;
  11268. private _buffer;
  11269. private _vertexBuffers;
  11270. private _indexBuffer;
  11271. private _effectBase;
  11272. private _effectFog;
  11273. /**
  11274. * Gets or sets the unique id of the sprite
  11275. */
  11276. uniqueId: number;
  11277. /**
  11278. * Gets the array of sprites
  11279. */
  11280. get children(): Sprite[];
  11281. /**
  11282. * Gets the hosting scene
  11283. */
  11284. get scene(): Scene;
  11285. /**
  11286. * Gets the capacity of the manager
  11287. */
  11288. get capacity(): number;
  11289. /**
  11290. * Gets or sets the spritesheet texture
  11291. */
  11292. get texture(): Texture;
  11293. set texture(value: Texture);
  11294. private _blendMode;
  11295. /**
  11296. * Blend mode use to render the particle, it can be any of
  11297. * the static Constants.ALPHA_x properties provided in this class.
  11298. * Default value is Constants.ALPHA_COMBINE
  11299. */
  11300. get blendMode(): number;
  11301. set blendMode(blendMode: number);
  11302. /** Disables writing to the depth buffer when rendering the sprites.
  11303. * It can be handy to disable depth writing when using textures without alpha channel
  11304. * and setting some specific blend modes.
  11305. */
  11306. disableDepthWrite: boolean;
  11307. /**
  11308. * Creates a new sprite manager
  11309. * @param name defines the manager's name
  11310. * @param imgUrl defines the sprite sheet url
  11311. * @param capacity defines the maximum allowed number of sprites
  11312. * @param cellSize defines the size of a sprite cell
  11313. * @param scene defines the hosting scene
  11314. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11315. * @param samplingMode defines the smapling mode to use with spritesheet
  11316. * @param fromPacked set to false; do not alter
  11317. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11318. */
  11319. constructor(
  11320. /** defines the manager's name */
  11321. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11322. /**
  11323. * Returns the string "SpriteManager"
  11324. * @returns "SpriteManager"
  11325. */
  11326. getClassName(): string;
  11327. private _makePacked;
  11328. private _appendSpriteVertex;
  11329. private _checkTextureAlpha;
  11330. /**
  11331. * Intersects the sprites with a ray
  11332. * @param ray defines the ray to intersect with
  11333. * @param camera defines the current active camera
  11334. * @param predicate defines a predicate used to select candidate sprites
  11335. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11336. * @returns null if no hit or a PickingInfo
  11337. */
  11338. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /**
  11340. * Intersects the sprites with a ray
  11341. * @param ray defines the ray to intersect with
  11342. * @param camera defines the current active camera
  11343. * @param predicate defines a predicate used to select candidate sprites
  11344. * @returns null if no hit or a PickingInfo array
  11345. */
  11346. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11347. /**
  11348. * Render all child sprites
  11349. */
  11350. render(): void;
  11351. /**
  11352. * Release associated resources
  11353. */
  11354. dispose(): void;
  11355. /**
  11356. * Serializes the sprite manager to a JSON object
  11357. * @param serializeTexture defines if the texture must be serialized as well
  11358. * @returns the JSON object
  11359. */
  11360. serialize(serializeTexture?: boolean): any;
  11361. /**
  11362. * Parses a JSON object to create a new sprite manager.
  11363. * @param parsedManager The JSON object to parse
  11364. * @param scene The scene to create the sprite managerin
  11365. * @param rootUrl The root url to use to load external dependencies like texture
  11366. * @returns the new sprite manager
  11367. */
  11368. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11369. /**
  11370. * Creates a sprite manager from a snippet saved in a remote file
  11371. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11372. * @param url defines the url to load from
  11373. * @param scene defines the hosting scene
  11374. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11375. * @returns a promise that will resolve to the new sprite manager
  11376. */
  11377. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11378. /**
  11379. * Creates a sprite manager from a snippet saved by the sprite editor
  11380. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11381. * @param scene defines the hosting scene
  11382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11383. * @returns a promise that will resolve to the new sprite manager
  11384. */
  11385. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11386. }
  11387. }
  11388. declare module "babylonjs/Misc/gradients" {
  11389. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11390. /** Interface used by value gradients (color, factor, ...) */
  11391. export interface IValueGradient {
  11392. /**
  11393. * Gets or sets the gradient value (between 0 and 1)
  11394. */
  11395. gradient: number;
  11396. }
  11397. /** Class used to store color4 gradient */
  11398. export class ColorGradient implements IValueGradient {
  11399. /**
  11400. * Gets or sets the gradient value (between 0 and 1)
  11401. */
  11402. gradient: number;
  11403. /**
  11404. * Gets or sets first associated color
  11405. */
  11406. color1: Color4;
  11407. /**
  11408. * Gets or sets second associated color
  11409. */
  11410. color2?: Color4 | undefined;
  11411. /**
  11412. * Creates a new color4 gradient
  11413. * @param gradient gets or sets the gradient value (between 0 and 1)
  11414. * @param color1 gets or sets first associated color
  11415. * @param color2 gets or sets first second color
  11416. */
  11417. constructor(
  11418. /**
  11419. * Gets or sets the gradient value (between 0 and 1)
  11420. */
  11421. gradient: number,
  11422. /**
  11423. * Gets or sets first associated color
  11424. */
  11425. color1: Color4,
  11426. /**
  11427. * Gets or sets second associated color
  11428. */
  11429. color2?: Color4 | undefined);
  11430. /**
  11431. * Will get a color picked randomly between color1 and color2.
  11432. * If color2 is undefined then color1 will be used
  11433. * @param result defines the target Color4 to store the result in
  11434. */
  11435. getColorToRef(result: Color4): void;
  11436. }
  11437. /** Class used to store color 3 gradient */
  11438. export class Color3Gradient implements IValueGradient {
  11439. /**
  11440. * Gets or sets the gradient value (between 0 and 1)
  11441. */
  11442. gradient: number;
  11443. /**
  11444. * Gets or sets the associated color
  11445. */
  11446. color: Color3;
  11447. /**
  11448. * Creates a new color3 gradient
  11449. * @param gradient gets or sets the gradient value (between 0 and 1)
  11450. * @param color gets or sets associated color
  11451. */
  11452. constructor(
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number,
  11457. /**
  11458. * Gets or sets the associated color
  11459. */
  11460. color: Color3);
  11461. }
  11462. /** Class used to store factor gradient */
  11463. export class FactorGradient implements IValueGradient {
  11464. /**
  11465. * Gets or sets the gradient value (between 0 and 1)
  11466. */
  11467. gradient: number;
  11468. /**
  11469. * Gets or sets first associated factor
  11470. */
  11471. factor1: number;
  11472. /**
  11473. * Gets or sets second associated factor
  11474. */
  11475. factor2?: number | undefined;
  11476. /**
  11477. * Creates a new factor gradient
  11478. * @param gradient gets or sets the gradient value (between 0 and 1)
  11479. * @param factor1 gets or sets first associated factor
  11480. * @param factor2 gets or sets second associated factor
  11481. */
  11482. constructor(
  11483. /**
  11484. * Gets or sets the gradient value (between 0 and 1)
  11485. */
  11486. gradient: number,
  11487. /**
  11488. * Gets or sets first associated factor
  11489. */
  11490. factor1: number,
  11491. /**
  11492. * Gets or sets second associated factor
  11493. */
  11494. factor2?: number | undefined);
  11495. /**
  11496. * Will get a number picked randomly between factor1 and factor2.
  11497. * If factor2 is undefined then factor1 will be used
  11498. * @returns the picked number
  11499. */
  11500. getFactor(): number;
  11501. }
  11502. /**
  11503. * Helper used to simplify some generic gradient tasks
  11504. */
  11505. export class GradientHelper {
  11506. /**
  11507. * Gets the current gradient from an array of IValueGradient
  11508. * @param ratio defines the current ratio to get
  11509. * @param gradients defines the array of IValueGradient
  11510. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11511. */
  11512. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11513. }
  11514. }
  11515. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11516. import { Nullable } from "babylonjs/types";
  11517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11518. import { Scene } from "babylonjs/scene";
  11519. module "babylonjs/Engines/thinEngine" {
  11520. interface ThinEngine {
  11521. /**
  11522. * Creates a raw texture
  11523. * @param data defines the data to store in the texture
  11524. * @param width defines the width of the texture
  11525. * @param height defines the height of the texture
  11526. * @param format defines the format of the data
  11527. * @param generateMipMaps defines if the engine should generate the mip levels
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11530. * @param compression defines the compression used (null by default)
  11531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11532. * @returns the raw texture inside an InternalTexture
  11533. */
  11534. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11535. /**
  11536. * Update a raw texture
  11537. * @param texture defines the texture to update
  11538. * @param data defines the data to store in the texture
  11539. * @param format defines the format of the data
  11540. * @param invertY defines if data must be stored with Y axis inverted
  11541. */
  11542. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11543. /**
  11544. * Update a raw texture
  11545. * @param texture defines the texture to update
  11546. * @param data defines the data to store in the texture
  11547. * @param format defines the format of the data
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param compression defines the compression used (null by default)
  11550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11551. */
  11552. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11553. /**
  11554. * Creates a new raw cube texture
  11555. * @param data defines the array of data to use to create each face
  11556. * @param size defines the size of the textures
  11557. * @param format defines the format of the data
  11558. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11559. * @param generateMipMaps defines if the engine should generate the mip levels
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11562. * @param compression defines the compression used (null by default)
  11563. * @returns the cube texture as an InternalTexture
  11564. */
  11565. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11566. /**
  11567. * Update a raw cube texture
  11568. * @param texture defines the texture to udpdate
  11569. * @param data defines the data to store
  11570. * @param format defines the data format
  11571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11572. * @param invertY defines if data must be stored with Y axis inverted
  11573. */
  11574. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11575. /**
  11576. * Update a raw cube texture
  11577. * @param texture defines the texture to udpdate
  11578. * @param data defines the data to store
  11579. * @param format defines the data format
  11580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11581. * @param invertY defines if data must be stored with Y axis inverted
  11582. * @param compression defines the compression used (null by default)
  11583. */
  11584. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11585. /**
  11586. * Update a raw cube texture
  11587. * @param texture defines the texture to udpdate
  11588. * @param data defines the data to store
  11589. * @param format defines the data format
  11590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11591. * @param invertY defines if data must be stored with Y axis inverted
  11592. * @param compression defines the compression used (null by default)
  11593. * @param level defines which level of the texture to update
  11594. */
  11595. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11596. /**
  11597. * Creates a new raw cube texture from a specified url
  11598. * @param url defines the url where the data is located
  11599. * @param scene defines the current scene
  11600. * @param size defines the size of the textures
  11601. * @param format defines the format of the data
  11602. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11603. * @param noMipmap defines if the engine should avoid generating the mip levels
  11604. * @param callback defines a callback used to extract texture data from loaded data
  11605. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11606. * @param onLoad defines a callback called when texture is loaded
  11607. * @param onError defines a callback called if there is an error
  11608. * @returns the cube texture as an InternalTexture
  11609. */
  11610. 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;
  11611. /**
  11612. * Creates a new raw cube texture from a specified url
  11613. * @param url defines the url where the data is located
  11614. * @param scene defines the current scene
  11615. * @param size defines the size of the textures
  11616. * @param format defines the format of the data
  11617. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11618. * @param noMipmap defines if the engine should avoid generating the mip levels
  11619. * @param callback defines a callback used to extract texture data from loaded data
  11620. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11621. * @param onLoad defines a callback called when texture is loaded
  11622. * @param onError defines a callback called if there is an error
  11623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11624. * @param invertY defines if data must be stored with Y axis inverted
  11625. * @returns the cube texture as an InternalTexture
  11626. */
  11627. 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;
  11628. /**
  11629. * Creates a new raw 3D texture
  11630. * @param data defines the data used to create the texture
  11631. * @param width defines the width of the texture
  11632. * @param height defines the height of the texture
  11633. * @param depth defines the depth of the texture
  11634. * @param format defines the format of the texture
  11635. * @param generateMipMaps defines if the engine must generate mip levels
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11638. * @param compression defines the compressed used (can be null)
  11639. * @param textureType defines the compressed used (can be null)
  11640. * @returns a new raw 3D texture (stored in an InternalTexture)
  11641. */
  11642. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11643. /**
  11644. * Update a raw 3D texture
  11645. * @param texture defines the texture to update
  11646. * @param data defines the data to store
  11647. * @param format defines the data format
  11648. * @param invertY defines if data must be stored with Y axis inverted
  11649. */
  11650. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11651. /**
  11652. * Update a raw 3D texture
  11653. * @param texture defines the texture to update
  11654. * @param data defines the data to store
  11655. * @param format defines the data format
  11656. * @param invertY defines if data must be stored with Y axis inverted
  11657. * @param compression defines the used compression (can be null)
  11658. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11659. */
  11660. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11661. /**
  11662. * Creates a new raw 2D array texture
  11663. * @param data defines the data used to create the texture
  11664. * @param width defines the width of the texture
  11665. * @param height defines the height of the texture
  11666. * @param depth defines the number of layers of the texture
  11667. * @param format defines the format of the texture
  11668. * @param generateMipMaps defines if the engine must generate mip levels
  11669. * @param invertY defines if data must be stored with Y axis inverted
  11670. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11671. * @param compression defines the compressed used (can be null)
  11672. * @param textureType defines the compressed used (can be null)
  11673. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11674. */
  11675. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11676. /**
  11677. * Update a raw 2D array texture
  11678. * @param texture defines the texture to update
  11679. * @param data defines the data to store
  11680. * @param format defines the data format
  11681. * @param invertY defines if data must be stored with Y axis inverted
  11682. */
  11683. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11684. /**
  11685. * Update a raw 2D array texture
  11686. * @param texture defines the texture to update
  11687. * @param data defines the data to store
  11688. * @param format defines the data format
  11689. * @param invertY defines if data must be stored with Y axis inverted
  11690. * @param compression defines the used compression (can be null)
  11691. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11692. */
  11693. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11694. }
  11695. }
  11696. }
  11697. declare module "babylonjs/Materials/Textures/rawTexture" {
  11698. import { Scene } from "babylonjs/scene";
  11699. import { Texture } from "babylonjs/Materials/Textures/texture";
  11700. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11701. /**
  11702. * Raw texture can help creating a texture directly from an array of data.
  11703. * This can be super useful if you either get the data from an uncompressed source or
  11704. * if you wish to create your texture pixel by pixel.
  11705. */
  11706. export class RawTexture extends Texture {
  11707. /**
  11708. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11709. */
  11710. format: number;
  11711. /**
  11712. * Instantiates a new RawTexture.
  11713. * Raw texture can help creating a texture directly from an array of data.
  11714. * This can be super useful if you either get the data from an uncompressed source or
  11715. * if you wish to create your texture pixel by pixel.
  11716. * @param data define the array of data to use to create the texture
  11717. * @param width define the width of the texture
  11718. * @param height define the height of the texture
  11719. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11720. * @param scene define the scene the texture belongs to
  11721. * @param generateMipMaps define whether mip maps should be generated or not
  11722. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11723. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11724. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11725. */
  11726. constructor(data: ArrayBufferView, width: number, height: number,
  11727. /**
  11728. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11729. */
  11730. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11731. /**
  11732. * Updates the texture underlying data.
  11733. * @param data Define the new data of the texture
  11734. */
  11735. update(data: ArrayBufferView): void;
  11736. /**
  11737. * Creates a luminance texture from some data.
  11738. * @param data Define the texture data
  11739. * @param width Define the width of the texture
  11740. * @param height Define the height of the texture
  11741. * @param scene Define the scene the texture belongs to
  11742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11745. * @returns the luminance texture
  11746. */
  11747. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11748. /**
  11749. * Creates a luminance alpha texture from some data.
  11750. * @param data Define the texture data
  11751. * @param width Define the width of the texture
  11752. * @param height Define the height of the texture
  11753. * @param scene Define the scene the texture belongs to
  11754. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11755. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11756. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11757. * @returns the luminance alpha texture
  11758. */
  11759. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11760. /**
  11761. * Creates an alpha texture from some data.
  11762. * @param data Define the texture data
  11763. * @param width Define the width of the texture
  11764. * @param height Define the height of the texture
  11765. * @param scene Define the scene the texture belongs to
  11766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11769. * @returns the alpha texture
  11770. */
  11771. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11772. /**
  11773. * Creates a RGB texture from some data.
  11774. * @param data Define the texture data
  11775. * @param width Define the width of the texture
  11776. * @param height Define the height of the texture
  11777. * @param scene Define the scene the texture belongs to
  11778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11781. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11782. * @returns the RGB alpha texture
  11783. */
  11784. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11785. /**
  11786. * Creates a RGBA texture from some data.
  11787. * @param data Define the texture data
  11788. * @param width Define the width of the texture
  11789. * @param height Define the height of the texture
  11790. * @param scene Define the scene the texture belongs to
  11791. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11792. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11793. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11794. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11795. * @returns the RGBA texture
  11796. */
  11797. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11798. /**
  11799. * Creates a R texture from some data.
  11800. * @param data Define the texture data
  11801. * @param width Define the width of the texture
  11802. * @param height Define the height of the texture
  11803. * @param scene Define the scene the texture belongs to
  11804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11807. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11808. * @returns the R texture
  11809. */
  11810. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11811. }
  11812. }
  11813. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11814. import { Scene } from "babylonjs/scene";
  11815. import { ISceneComponent } from "babylonjs/sceneComponent";
  11816. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11817. module "babylonjs/abstractScene" {
  11818. interface AbstractScene {
  11819. /**
  11820. * The list of procedural textures added to the scene
  11821. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11822. */
  11823. proceduralTextures: Array<ProceduralTexture>;
  11824. }
  11825. }
  11826. /**
  11827. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11828. * in a given scene.
  11829. */
  11830. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11831. /**
  11832. * The component name helpfull to identify the component in the list of scene components.
  11833. */
  11834. readonly name: string;
  11835. /**
  11836. * The scene the component belongs to.
  11837. */
  11838. scene: Scene;
  11839. /**
  11840. * Creates a new instance of the component for the given scene
  11841. * @param scene Defines the scene to register the component in
  11842. */
  11843. constructor(scene: Scene);
  11844. /**
  11845. * Registers the component in a given scene
  11846. */
  11847. register(): void;
  11848. /**
  11849. * Rebuilds the elements related to this component in case of
  11850. * context lost for instance.
  11851. */
  11852. rebuild(): void;
  11853. /**
  11854. * Disposes the component and the associated ressources.
  11855. */
  11856. dispose(): void;
  11857. private _beforeClear;
  11858. }
  11859. }
  11860. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11862. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11863. module "babylonjs/Engines/thinEngine" {
  11864. interface ThinEngine {
  11865. /**
  11866. * Creates a new render target cube texture
  11867. * @param size defines the size of the texture
  11868. * @param options defines the options used to create the texture
  11869. * @returns a new render target cube texture stored in an InternalTexture
  11870. */
  11871. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11872. }
  11873. }
  11874. }
  11875. declare module "babylonjs/Shaders/procedural.vertex" {
  11876. /** @hidden */
  11877. export var proceduralVertexShader: {
  11878. name: string;
  11879. shader: string;
  11880. };
  11881. }
  11882. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11883. import { Observable } from "babylonjs/Misc/observable";
  11884. import { Nullable } from "babylonjs/types";
  11885. import { Scene } from "babylonjs/scene";
  11886. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11887. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11888. import { Effect } from "babylonjs/Materials/effect";
  11889. import { Texture } from "babylonjs/Materials/Textures/texture";
  11890. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11891. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11892. import "babylonjs/Shaders/procedural.vertex";
  11893. /**
  11894. * 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.
  11895. * This is the base class of any Procedural texture and contains most of the shareable code.
  11896. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11897. */
  11898. export class ProceduralTexture extends Texture {
  11899. isCube: boolean;
  11900. /**
  11901. * Define if the texture is enabled or not (disabled texture will not render)
  11902. */
  11903. isEnabled: boolean;
  11904. /**
  11905. * Define if the texture must be cleared before rendering (default is true)
  11906. */
  11907. autoClear: boolean;
  11908. /**
  11909. * Callback called when the texture is generated
  11910. */
  11911. onGenerated: () => void;
  11912. /**
  11913. * Event raised when the texture is generated
  11914. */
  11915. onGeneratedObservable: Observable<ProceduralTexture>;
  11916. /** @hidden */
  11917. _generateMipMaps: boolean;
  11918. /** @hidden **/
  11919. _effect: Effect;
  11920. /** @hidden */
  11921. _textures: {
  11922. [key: string]: Texture;
  11923. };
  11924. /** @hidden */
  11925. protected _fallbackTexture: Nullable<Texture>;
  11926. private _size;
  11927. private _currentRefreshId;
  11928. private _frameId;
  11929. private _refreshRate;
  11930. private _vertexBuffers;
  11931. private _indexBuffer;
  11932. private _uniforms;
  11933. private _samplers;
  11934. private _fragment;
  11935. private _floats;
  11936. private _ints;
  11937. private _floatsArrays;
  11938. private _colors3;
  11939. private _colors4;
  11940. private _vectors2;
  11941. private _vectors3;
  11942. private _matrices;
  11943. private _fallbackTextureUsed;
  11944. private _fullEngine;
  11945. private _cachedDefines;
  11946. private _contentUpdateId;
  11947. private _contentData;
  11948. /**
  11949. * Instantiates a new procedural texture.
  11950. * 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.
  11951. * This is the base class of any Procedural texture and contains most of the shareable code.
  11952. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11953. * @param name Define the name of the texture
  11954. * @param size Define the size of the texture to create
  11955. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11956. * @param scene Define the scene the texture belongs to
  11957. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11958. * @param generateMipMaps Define if the texture should creates mip maps or not
  11959. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11960. */
  11961. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11962. /**
  11963. * The effect that is created when initializing the post process.
  11964. * @returns The created effect corresponding the the postprocess.
  11965. */
  11966. getEffect(): Effect;
  11967. /**
  11968. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11969. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11970. */
  11971. getContent(): Nullable<ArrayBufferView>;
  11972. private _createIndexBuffer;
  11973. /** @hidden */
  11974. _rebuild(): void;
  11975. /**
  11976. * Resets the texture in order to recreate its associated resources.
  11977. * This can be called in case of context loss
  11978. */
  11979. reset(): void;
  11980. protected _getDefines(): string;
  11981. /**
  11982. * Is the texture ready to be used ? (rendered at least once)
  11983. * @returns true if ready, otherwise, false.
  11984. */
  11985. isReady(): boolean;
  11986. /**
  11987. * Resets the refresh counter of the texture and start bak from scratch.
  11988. * Could be useful to regenerate the texture if it is setup to render only once.
  11989. */
  11990. resetRefreshCounter(): void;
  11991. /**
  11992. * Set the fragment shader to use in order to render the texture.
  11993. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11994. */
  11995. setFragment(fragment: any): void;
  11996. /**
  11997. * Define the refresh rate of the texture or the rendering frequency.
  11998. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11999. */
  12000. get refreshRate(): number;
  12001. set refreshRate(value: number);
  12002. /** @hidden */
  12003. _shouldRender(): boolean;
  12004. /**
  12005. * Get the size the texture is rendering at.
  12006. * @returns the size (texture is always squared)
  12007. */
  12008. getRenderSize(): number;
  12009. /**
  12010. * Resize the texture to new value.
  12011. * @param size Define the new size the texture should have
  12012. * @param generateMipMaps Define whether the new texture should create mip maps
  12013. */
  12014. resize(size: number, generateMipMaps: boolean): void;
  12015. private _checkUniform;
  12016. /**
  12017. * Set a texture in the shader program used to render.
  12018. * @param name Define the name of the uniform samplers as defined in the shader
  12019. * @param texture Define the texture to bind to this sampler
  12020. * @return the texture itself allowing "fluent" like uniform updates
  12021. */
  12022. setTexture(name: string, texture: Texture): ProceduralTexture;
  12023. /**
  12024. * Set a float in the shader.
  12025. * @param name Define the name of the uniform as defined in the shader
  12026. * @param value Define the value to give to the uniform
  12027. * @return the texture itself allowing "fluent" like uniform updates
  12028. */
  12029. setFloat(name: string, value: number): ProceduralTexture;
  12030. /**
  12031. * Set a int in the shader.
  12032. * @param name Define the name of the uniform as defined in the shader
  12033. * @param value Define the value to give to the uniform
  12034. * @return the texture itself allowing "fluent" like uniform updates
  12035. */
  12036. setInt(name: string, value: number): ProceduralTexture;
  12037. /**
  12038. * Set an array of floats in the shader.
  12039. * @param name Define the name of the uniform as defined in the shader
  12040. * @param value Define the value to give to the uniform
  12041. * @return the texture itself allowing "fluent" like uniform updates
  12042. */
  12043. setFloats(name: string, value: number[]): ProceduralTexture;
  12044. /**
  12045. * Set a vec3 in the shader from a Color3.
  12046. * @param name Define the name of the uniform as defined in the shader
  12047. * @param value Define the value to give to the uniform
  12048. * @return the texture itself allowing "fluent" like uniform updates
  12049. */
  12050. setColor3(name: string, value: Color3): ProceduralTexture;
  12051. /**
  12052. * Set a vec4 in the shader from a Color4.
  12053. * @param name Define the name of the uniform as defined in the shader
  12054. * @param value Define the value to give to the uniform
  12055. * @return the texture itself allowing "fluent" like uniform updates
  12056. */
  12057. setColor4(name: string, value: Color4): ProceduralTexture;
  12058. /**
  12059. * Set a vec2 in the shader from a Vector2.
  12060. * @param name Define the name of the uniform as defined in the shader
  12061. * @param value Define the value to give to the uniform
  12062. * @return the texture itself allowing "fluent" like uniform updates
  12063. */
  12064. setVector2(name: string, value: Vector2): ProceduralTexture;
  12065. /**
  12066. * Set a vec3 in the shader from a Vector3.
  12067. * @param name Define the name of the uniform as defined in the shader
  12068. * @param value Define the value to give to the uniform
  12069. * @return the texture itself allowing "fluent" like uniform updates
  12070. */
  12071. setVector3(name: string, value: Vector3): ProceduralTexture;
  12072. /**
  12073. * Set a mat4 in the shader from a MAtrix.
  12074. * @param name Define the name of the uniform as defined in the shader
  12075. * @param value Define the value to give to the uniform
  12076. * @return the texture itself allowing "fluent" like uniform updates
  12077. */
  12078. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12079. /**
  12080. * Render the texture to its associated render target.
  12081. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12082. */
  12083. render(useCameraPostProcess?: boolean): void;
  12084. /**
  12085. * Clone the texture.
  12086. * @returns the cloned texture
  12087. */
  12088. clone(): ProceduralTexture;
  12089. /**
  12090. * Dispose the texture and release its asoociated resources.
  12091. */
  12092. dispose(): void;
  12093. }
  12094. }
  12095. declare module "babylonjs/Particles/baseParticleSystem" {
  12096. import { Nullable } from "babylonjs/types";
  12097. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12099. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12100. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12101. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12102. import { Scene } from "babylonjs/scene";
  12103. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12104. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12105. import { Texture } from "babylonjs/Materials/Textures/texture";
  12106. import { Color4 } from "babylonjs/Maths/math.color";
  12107. import { Animation } from "babylonjs/Animations/animation";
  12108. /**
  12109. * This represents the base class for particle system in Babylon.
  12110. * 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.
  12111. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12112. * @example https://doc.babylonjs.com/babylon101/particles
  12113. */
  12114. export class BaseParticleSystem {
  12115. /**
  12116. * Source color is added to the destination color without alpha affecting the result
  12117. */
  12118. static BLENDMODE_ONEONE: number;
  12119. /**
  12120. * Blend current color and particle color using particle’s alpha
  12121. */
  12122. static BLENDMODE_STANDARD: number;
  12123. /**
  12124. * Add current color and particle color multiplied by particle’s alpha
  12125. */
  12126. static BLENDMODE_ADD: number;
  12127. /**
  12128. * Multiply current color with particle color
  12129. */
  12130. static BLENDMODE_MULTIPLY: number;
  12131. /**
  12132. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12133. */
  12134. static BLENDMODE_MULTIPLYADD: number;
  12135. /**
  12136. * List of animations used by the particle system.
  12137. */
  12138. animations: Animation[];
  12139. /**
  12140. * Gets or sets the unique id of the particle system
  12141. */
  12142. uniqueId: number;
  12143. /**
  12144. * The id of the Particle system.
  12145. */
  12146. id: string;
  12147. /**
  12148. * The friendly name of the Particle system.
  12149. */
  12150. name: string;
  12151. /**
  12152. * Snippet ID if the particle system was created from the snippet server
  12153. */
  12154. snippetId: string;
  12155. /**
  12156. * The rendering group used by the Particle system to chose when to render.
  12157. */
  12158. renderingGroupId: number;
  12159. /**
  12160. * The emitter represents the Mesh or position we are attaching the particle system to.
  12161. */
  12162. emitter: Nullable<AbstractMesh | Vector3>;
  12163. /**
  12164. * The maximum number of particles to emit per frame
  12165. */
  12166. emitRate: number;
  12167. /**
  12168. * If you want to launch only a few particles at once, that can be done, as well.
  12169. */
  12170. manualEmitCount: number;
  12171. /**
  12172. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12173. */
  12174. updateSpeed: number;
  12175. /**
  12176. * The amount of time the particle system is running (depends of the overall update speed).
  12177. */
  12178. targetStopDuration: number;
  12179. /**
  12180. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12181. */
  12182. disposeOnStop: boolean;
  12183. /**
  12184. * Minimum power of emitting particles.
  12185. */
  12186. minEmitPower: number;
  12187. /**
  12188. * Maximum power of emitting particles.
  12189. */
  12190. maxEmitPower: number;
  12191. /**
  12192. * Minimum life time of emitting particles.
  12193. */
  12194. minLifeTime: number;
  12195. /**
  12196. * Maximum life time of emitting particles.
  12197. */
  12198. maxLifeTime: number;
  12199. /**
  12200. * Minimum Size of emitting particles.
  12201. */
  12202. minSize: number;
  12203. /**
  12204. * Maximum Size of emitting particles.
  12205. */
  12206. maxSize: number;
  12207. /**
  12208. * Minimum scale of emitting particles on X axis.
  12209. */
  12210. minScaleX: number;
  12211. /**
  12212. * Maximum scale of emitting particles on X axis.
  12213. */
  12214. maxScaleX: number;
  12215. /**
  12216. * Minimum scale of emitting particles on Y axis.
  12217. */
  12218. minScaleY: number;
  12219. /**
  12220. * Maximum scale of emitting particles on Y axis.
  12221. */
  12222. maxScaleY: number;
  12223. /**
  12224. * Gets or sets the minimal initial rotation in radians.
  12225. */
  12226. minInitialRotation: number;
  12227. /**
  12228. * Gets or sets the maximal initial rotation in radians.
  12229. */
  12230. maxInitialRotation: number;
  12231. /**
  12232. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12233. */
  12234. minAngularSpeed: number;
  12235. /**
  12236. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12237. */
  12238. maxAngularSpeed: number;
  12239. /**
  12240. * The texture used to render each particle. (this can be a spritesheet)
  12241. */
  12242. particleTexture: Nullable<Texture>;
  12243. /**
  12244. * The layer mask we are rendering the particles through.
  12245. */
  12246. layerMask: number;
  12247. /**
  12248. * This can help using your own shader to render the particle system.
  12249. * The according effect will be created
  12250. */
  12251. customShader: any;
  12252. /**
  12253. * By default particle system starts as soon as they are created. This prevents the
  12254. * automatic start to happen and let you decide when to start emitting particles.
  12255. */
  12256. preventAutoStart: boolean;
  12257. private _noiseTexture;
  12258. /**
  12259. * Gets or sets a texture used to add random noise to particle positions
  12260. */
  12261. get noiseTexture(): Nullable<ProceduralTexture>;
  12262. set noiseTexture(value: Nullable<ProceduralTexture>);
  12263. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12264. noiseStrength: Vector3;
  12265. /**
  12266. * Callback triggered when the particle animation is ending.
  12267. */
  12268. onAnimationEnd: Nullable<() => void>;
  12269. /**
  12270. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12271. */
  12272. blendMode: number;
  12273. /**
  12274. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12275. * to override the particles.
  12276. */
  12277. forceDepthWrite: boolean;
  12278. /** 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 */
  12279. preWarmCycles: number;
  12280. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12281. preWarmStepOffset: number;
  12282. /**
  12283. * 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)
  12284. */
  12285. spriteCellChangeSpeed: number;
  12286. /**
  12287. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12288. */
  12289. startSpriteCellID: number;
  12290. /**
  12291. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12292. */
  12293. endSpriteCellID: number;
  12294. /**
  12295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12296. */
  12297. spriteCellWidth: number;
  12298. /**
  12299. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12300. */
  12301. spriteCellHeight: number;
  12302. /**
  12303. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12304. */
  12305. spriteRandomStartCell: boolean;
  12306. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12307. translationPivot: Vector2;
  12308. /** @hidden */
  12309. protected _isAnimationSheetEnabled: boolean;
  12310. /**
  12311. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12312. */
  12313. beginAnimationOnStart: boolean;
  12314. /**
  12315. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12316. */
  12317. beginAnimationFrom: number;
  12318. /**
  12319. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12320. */
  12321. beginAnimationTo: number;
  12322. /**
  12323. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12324. */
  12325. beginAnimationLoop: boolean;
  12326. /**
  12327. * Gets or sets a world offset applied to all particles
  12328. */
  12329. worldOffset: Vector3;
  12330. /**
  12331. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12332. */
  12333. get isAnimationSheetEnabled(): boolean;
  12334. set isAnimationSheetEnabled(value: boolean);
  12335. /**
  12336. * Get hosting scene
  12337. * @returns the scene
  12338. */
  12339. getScene(): Scene;
  12340. /**
  12341. * You can use gravity if you want to give an orientation to your particles.
  12342. */
  12343. gravity: Vector3;
  12344. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12345. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12346. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12347. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12348. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12349. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12350. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12351. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12352. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12353. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12354. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12355. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12356. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12357. /**
  12358. * Defines the delay in milliseconds before starting the system (0 by default)
  12359. */
  12360. startDelay: number;
  12361. /**
  12362. * Gets the current list of drag gradients.
  12363. * You must use addDragGradient and removeDragGradient to udpate this list
  12364. * @returns the list of drag gradients
  12365. */
  12366. getDragGradients(): Nullable<Array<FactorGradient>>;
  12367. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12368. limitVelocityDamping: number;
  12369. /**
  12370. * Gets the current list of limit velocity gradients.
  12371. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12372. * @returns the list of limit velocity gradients
  12373. */
  12374. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12375. /**
  12376. * Gets the current list of color gradients.
  12377. * You must use addColorGradient and removeColorGradient to udpate this list
  12378. * @returns the list of color gradients
  12379. */
  12380. getColorGradients(): Nullable<Array<ColorGradient>>;
  12381. /**
  12382. * Gets the current list of size gradients.
  12383. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12384. * @returns the list of size gradients
  12385. */
  12386. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12387. /**
  12388. * Gets the current list of color remap gradients.
  12389. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12390. * @returns the list of color remap gradients
  12391. */
  12392. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12393. /**
  12394. * Gets the current list of alpha remap gradients.
  12395. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12396. * @returns the list of alpha remap gradients
  12397. */
  12398. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12399. /**
  12400. * Gets the current list of life time gradients.
  12401. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12402. * @returns the list of life time gradients
  12403. */
  12404. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of angular speed gradients.
  12407. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12408. * @returns the list of angular speed gradients
  12409. */
  12410. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12411. /**
  12412. * Gets the current list of velocity gradients.
  12413. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12414. * @returns the list of velocity gradients
  12415. */
  12416. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of start size gradients.
  12419. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12420. * @returns the list of start size gradients
  12421. */
  12422. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of emit rate gradients.
  12425. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12426. * @returns the list of emit rate gradients
  12427. */
  12428. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12432. */
  12433. get direction1(): Vector3;
  12434. set direction1(value: Vector3);
  12435. /**
  12436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12438. */
  12439. get direction2(): Vector3;
  12440. set direction2(value: Vector3);
  12441. /**
  12442. * 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.
  12443. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12444. */
  12445. get minEmitBox(): Vector3;
  12446. set minEmitBox(value: Vector3);
  12447. /**
  12448. * 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.
  12449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12450. */
  12451. get maxEmitBox(): Vector3;
  12452. set maxEmitBox(value: Vector3);
  12453. /**
  12454. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12455. */
  12456. color1: Color4;
  12457. /**
  12458. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12459. */
  12460. color2: Color4;
  12461. /**
  12462. * Color the particle will have at the end of its lifetime
  12463. */
  12464. colorDead: Color4;
  12465. /**
  12466. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12467. */
  12468. textureMask: Color4;
  12469. /**
  12470. * The particle emitter type defines the emitter used by the particle system.
  12471. * It can be for example box, sphere, or cone...
  12472. */
  12473. particleEmitterType: IParticleEmitterType;
  12474. /** @hidden */
  12475. _isSubEmitter: boolean;
  12476. /**
  12477. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12478. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12479. */
  12480. billboardMode: number;
  12481. protected _isBillboardBased: boolean;
  12482. /**
  12483. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12484. */
  12485. get isBillboardBased(): boolean;
  12486. set isBillboardBased(value: boolean);
  12487. /**
  12488. * The scene the particle system belongs to.
  12489. */
  12490. protected _scene: Scene;
  12491. /**
  12492. * Local cache of defines for image processing.
  12493. */
  12494. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12495. /**
  12496. * Default configuration related to image processing available in the standard Material.
  12497. */
  12498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12499. /**
  12500. * Gets the image processing configuration used either in this material.
  12501. */
  12502. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12503. /**
  12504. * Sets the Default image processing configuration used either in the this material.
  12505. *
  12506. * If sets to null, the scene one is in use.
  12507. */
  12508. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12509. /**
  12510. * Attaches a new image processing configuration to the Standard Material.
  12511. * @param configuration
  12512. */
  12513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12514. /** @hidden */
  12515. protected _reset(): void;
  12516. /** @hidden */
  12517. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12518. /**
  12519. * Instantiates a particle system.
  12520. * 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.
  12521. * @param name The name of the particle system
  12522. */
  12523. constructor(name: string);
  12524. /**
  12525. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12528. * @returns the emitter
  12529. */
  12530. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12531. /**
  12532. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12533. * @param radius The radius of the hemisphere to emit from
  12534. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12535. * @returns the emitter
  12536. */
  12537. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12538. /**
  12539. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12540. * @param radius The radius of the sphere to emit from
  12541. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12542. * @returns the emitter
  12543. */
  12544. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12545. /**
  12546. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12547. * @param radius The radius of the sphere to emit from
  12548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12550. * @returns the emitter
  12551. */
  12552. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12553. /**
  12554. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12555. * @param radius The radius of the emission cylinder
  12556. * @param height The height of the emission cylinder
  12557. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12558. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12559. * @returns the emitter
  12560. */
  12561. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12562. /**
  12563. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12564. * @param radius The radius of the cylinder to emit from
  12565. * @param height The height of the emission cylinder
  12566. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12567. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12568. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12569. * @returns the emitter
  12570. */
  12571. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12572. /**
  12573. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12574. * @param radius The radius of the cone to emit from
  12575. * @param angle The base angle of the cone
  12576. * @returns the emitter
  12577. */
  12578. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12579. /**
  12580. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12581. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12582. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12583. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12584. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12585. * @returns the emitter
  12586. */
  12587. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12588. }
  12589. }
  12590. declare module "babylonjs/Particles/subEmitter" {
  12591. import { Scene } from "babylonjs/scene";
  12592. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12593. /**
  12594. * Type of sub emitter
  12595. */
  12596. export enum SubEmitterType {
  12597. /**
  12598. * Attached to the particle over it's lifetime
  12599. */
  12600. ATTACHED = 0,
  12601. /**
  12602. * Created when the particle dies
  12603. */
  12604. END = 1
  12605. }
  12606. /**
  12607. * Sub emitter class used to emit particles from an existing particle
  12608. */
  12609. export class SubEmitter {
  12610. /**
  12611. * the particle system to be used by the sub emitter
  12612. */
  12613. particleSystem: ParticleSystem;
  12614. /**
  12615. * Type of the submitter (Default: END)
  12616. */
  12617. type: SubEmitterType;
  12618. /**
  12619. * 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)
  12620. * Note: This only is supported when using an emitter of type Mesh
  12621. */
  12622. inheritDirection: boolean;
  12623. /**
  12624. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12625. */
  12626. inheritedVelocityAmount: number;
  12627. /**
  12628. * Creates a sub emitter
  12629. * @param particleSystem the particle system to be used by the sub emitter
  12630. */
  12631. constructor(
  12632. /**
  12633. * the particle system to be used by the sub emitter
  12634. */
  12635. particleSystem: ParticleSystem);
  12636. /**
  12637. * Clones the sub emitter
  12638. * @returns the cloned sub emitter
  12639. */
  12640. clone(): SubEmitter;
  12641. /**
  12642. * Serialize current object to a JSON object
  12643. * @returns the serialized object
  12644. */
  12645. serialize(): any;
  12646. /** @hidden */
  12647. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12648. /**
  12649. * Creates a new SubEmitter from a serialized JSON version
  12650. * @param serializationObject defines the JSON object to read from
  12651. * @param scene defines the hosting scene
  12652. * @param rootUrl defines the rootUrl for data loading
  12653. * @returns a new SubEmitter
  12654. */
  12655. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12656. /** Release associated resources */
  12657. dispose(): void;
  12658. }
  12659. }
  12660. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12661. /** @hidden */
  12662. export var imageProcessingDeclaration: {
  12663. name: string;
  12664. shader: string;
  12665. };
  12666. }
  12667. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12668. /** @hidden */
  12669. export var imageProcessingFunctions: {
  12670. name: string;
  12671. shader: string;
  12672. };
  12673. }
  12674. declare module "babylonjs/Shaders/particles.fragment" {
  12675. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12676. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12677. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12678. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12680. /** @hidden */
  12681. export var particlesPixelShader: {
  12682. name: string;
  12683. shader: string;
  12684. };
  12685. }
  12686. declare module "babylonjs/Shaders/particles.vertex" {
  12687. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12688. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12689. /** @hidden */
  12690. export var particlesVertexShader: {
  12691. name: string;
  12692. shader: string;
  12693. };
  12694. }
  12695. declare module "babylonjs/Particles/particleSystem" {
  12696. import { Nullable } from "babylonjs/types";
  12697. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12698. import { Observable } from "babylonjs/Misc/observable";
  12699. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12700. import { Effect } from "babylonjs/Materials/effect";
  12701. import { Scene, IDisposable } from "babylonjs/scene";
  12702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12703. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12704. import { Particle } from "babylonjs/Particles/particle";
  12705. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12706. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12707. import "babylonjs/Shaders/particles.fragment";
  12708. import "babylonjs/Shaders/particles.vertex";
  12709. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12710. /**
  12711. * This represents a particle system in Babylon.
  12712. * 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.
  12713. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12714. * @example https://doc.babylonjs.com/babylon101/particles
  12715. */
  12716. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12717. /**
  12718. * Billboard mode will only apply to Y axis
  12719. */
  12720. static readonly BILLBOARDMODE_Y: number;
  12721. /**
  12722. * Billboard mode will apply to all axes
  12723. */
  12724. static readonly BILLBOARDMODE_ALL: number;
  12725. /**
  12726. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12727. */
  12728. static readonly BILLBOARDMODE_STRETCHED: number;
  12729. /**
  12730. * This function can be defined to provide custom update for active particles.
  12731. * This function will be called instead of regular update (age, position, color, etc.).
  12732. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12733. */
  12734. updateFunction: (particles: Particle[]) => void;
  12735. private _emitterWorldMatrix;
  12736. /**
  12737. * This function can be defined to specify initial direction for every new particle.
  12738. * It by default use the emitterType defined function
  12739. */
  12740. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12741. /**
  12742. * This function can be defined to specify initial position for every new particle.
  12743. * It by default use the emitterType defined function
  12744. */
  12745. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12746. /**
  12747. * @hidden
  12748. */
  12749. _inheritedVelocityOffset: Vector3;
  12750. /**
  12751. * An event triggered when the system is disposed
  12752. */
  12753. onDisposeObservable: Observable<IParticleSystem>;
  12754. private _onDisposeObserver;
  12755. /**
  12756. * Sets a callback that will be triggered when the system is disposed
  12757. */
  12758. set onDispose(callback: () => void);
  12759. private _particles;
  12760. private _epsilon;
  12761. private _capacity;
  12762. private _stockParticles;
  12763. private _newPartsExcess;
  12764. private _vertexData;
  12765. private _vertexBuffer;
  12766. private _vertexBuffers;
  12767. private _spriteBuffer;
  12768. private _indexBuffer;
  12769. private _effect;
  12770. private _customEffect;
  12771. private _cachedDefines;
  12772. private _scaledColorStep;
  12773. private _colorDiff;
  12774. private _scaledDirection;
  12775. private _scaledGravity;
  12776. private _currentRenderId;
  12777. private _alive;
  12778. private _useInstancing;
  12779. private _started;
  12780. private _stopped;
  12781. private _actualFrame;
  12782. private _scaledUpdateSpeed;
  12783. private _vertexBufferSize;
  12784. /** @hidden */
  12785. _currentEmitRateGradient: Nullable<FactorGradient>;
  12786. /** @hidden */
  12787. _currentEmitRate1: number;
  12788. /** @hidden */
  12789. _currentEmitRate2: number;
  12790. /** @hidden */
  12791. _currentStartSizeGradient: Nullable<FactorGradient>;
  12792. /** @hidden */
  12793. _currentStartSize1: number;
  12794. /** @hidden */
  12795. _currentStartSize2: number;
  12796. private readonly _rawTextureWidth;
  12797. private _rampGradientsTexture;
  12798. private _useRampGradients;
  12799. /** Gets or sets a boolean indicating that ramp gradients must be used
  12800. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12801. */
  12802. get useRampGradients(): boolean;
  12803. set useRampGradients(value: boolean);
  12804. /**
  12805. * 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.
  12806. * 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: [])
  12807. */
  12808. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12809. private _subEmitters;
  12810. /**
  12811. * @hidden
  12812. * If the particle systems emitter should be disposed when the particle system is disposed
  12813. */
  12814. _disposeEmitterOnDispose: boolean;
  12815. /**
  12816. * The current active Sub-systems, this property is used by the root particle system only.
  12817. */
  12818. activeSubSystems: Array<ParticleSystem>;
  12819. /**
  12820. * Specifies if the particles are updated in emitter local space or world space
  12821. */
  12822. isLocal: boolean;
  12823. private _rootParticleSystem;
  12824. /**
  12825. * Gets the current list of active particles
  12826. */
  12827. get particles(): Particle[];
  12828. /**
  12829. * Gets the number of particles active at the same time.
  12830. * @returns The number of active particles.
  12831. */
  12832. getActiveCount(): number;
  12833. /**
  12834. * Returns the string "ParticleSystem"
  12835. * @returns a string containing the class name
  12836. */
  12837. getClassName(): string;
  12838. /**
  12839. * Gets a boolean indicating that the system is stopping
  12840. * @returns true if the system is currently stopping
  12841. */
  12842. isStopping(): boolean;
  12843. /**
  12844. * Gets the custom effect used to render the particles
  12845. * @param blendMode Blend mode for which the effect should be retrieved
  12846. * @returns The effect
  12847. */
  12848. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12849. /**
  12850. * Sets the custom effect used to render the particles
  12851. * @param effect The effect to set
  12852. * @param blendMode Blend mode for which the effect should be set
  12853. */
  12854. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12855. /** @hidden */
  12856. private _onBeforeDrawParticlesObservable;
  12857. /**
  12858. * Observable that will be called just before the particles are drawn
  12859. */
  12860. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12861. /**
  12862. * Gets the name of the particle vertex shader
  12863. */
  12864. get vertexShaderName(): string;
  12865. /**
  12866. * Instantiates a particle system.
  12867. * 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.
  12868. * @param name The name of the particle system
  12869. * @param capacity The max number of particles alive at the same time
  12870. * @param scene The scene the particle system belongs to
  12871. * @param customEffect a custom effect used to change the way particles are rendered by default
  12872. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12873. * @param epsilon Offset used to render the particles
  12874. */
  12875. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12876. private _addFactorGradient;
  12877. private _removeFactorGradient;
  12878. /**
  12879. * Adds a new life time gradient
  12880. * @param gradient defines the gradient to use (between 0 and 1)
  12881. * @param factor defines the life time factor to affect to the specified gradient
  12882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12883. * @returns the current particle system
  12884. */
  12885. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12886. /**
  12887. * Remove a specific life time gradient
  12888. * @param gradient defines the gradient to remove
  12889. * @returns the current particle system
  12890. */
  12891. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12892. /**
  12893. * Adds a new size gradient
  12894. * @param gradient defines the gradient to use (between 0 and 1)
  12895. * @param factor defines the size factor to affect to the specified gradient
  12896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12897. * @returns the current particle system
  12898. */
  12899. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12900. /**
  12901. * Remove a specific size gradient
  12902. * @param gradient defines the gradient to remove
  12903. * @returns the current particle system
  12904. */
  12905. removeSizeGradient(gradient: number): IParticleSystem;
  12906. /**
  12907. * Adds a new color remap gradient
  12908. * @param gradient defines the gradient to use (between 0 and 1)
  12909. * @param min defines the color remap minimal range
  12910. * @param max defines the color remap maximal range
  12911. * @returns the current particle system
  12912. */
  12913. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12914. /**
  12915. * Remove a specific color remap gradient
  12916. * @param gradient defines the gradient to remove
  12917. * @returns the current particle system
  12918. */
  12919. removeColorRemapGradient(gradient: number): IParticleSystem;
  12920. /**
  12921. * Adds a new alpha remap gradient
  12922. * @param gradient defines the gradient to use (between 0 and 1)
  12923. * @param min defines the alpha remap minimal range
  12924. * @param max defines the alpha remap maximal range
  12925. * @returns the current particle system
  12926. */
  12927. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12928. /**
  12929. * Remove a specific alpha remap gradient
  12930. * @param gradient defines the gradient to remove
  12931. * @returns the current particle system
  12932. */
  12933. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12934. /**
  12935. * Adds a new angular speed gradient
  12936. * @param gradient defines the gradient to use (between 0 and 1)
  12937. * @param factor defines the angular speed to affect to the specified gradient
  12938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12939. * @returns the current particle system
  12940. */
  12941. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12942. /**
  12943. * Remove a specific angular speed gradient
  12944. * @param gradient defines the gradient to remove
  12945. * @returns the current particle system
  12946. */
  12947. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12948. /**
  12949. * Adds a new velocity gradient
  12950. * @param gradient defines the gradient to use (between 0 and 1)
  12951. * @param factor defines the velocity to affect to the specified gradient
  12952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12953. * @returns the current particle system
  12954. */
  12955. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12956. /**
  12957. * Remove a specific velocity gradient
  12958. * @param gradient defines the gradient to remove
  12959. * @returns the current particle system
  12960. */
  12961. removeVelocityGradient(gradient: number): IParticleSystem;
  12962. /**
  12963. * Adds a new limit velocity gradient
  12964. * @param gradient defines the gradient to use (between 0 and 1)
  12965. * @param factor defines the limit velocity value to affect to the specified gradient
  12966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12967. * @returns the current particle system
  12968. */
  12969. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12970. /**
  12971. * Remove a specific limit velocity gradient
  12972. * @param gradient defines the gradient to remove
  12973. * @returns the current particle system
  12974. */
  12975. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12976. /**
  12977. * Adds a new drag gradient
  12978. * @param gradient defines the gradient to use (between 0 and 1)
  12979. * @param factor defines the drag value to affect to the specified gradient
  12980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12981. * @returns the current particle system
  12982. */
  12983. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12984. /**
  12985. * Remove a specific drag gradient
  12986. * @param gradient defines the gradient to remove
  12987. * @returns the current particle system
  12988. */
  12989. removeDragGradient(gradient: number): IParticleSystem;
  12990. /**
  12991. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12992. * @param gradient defines the gradient to use (between 0 and 1)
  12993. * @param factor defines the emit rate value to affect to the specified gradient
  12994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12995. * @returns the current particle system
  12996. */
  12997. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12998. /**
  12999. * Remove a specific emit rate gradient
  13000. * @param gradient defines the gradient to remove
  13001. * @returns the current particle system
  13002. */
  13003. removeEmitRateGradient(gradient: number): IParticleSystem;
  13004. /**
  13005. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13006. * @param gradient defines the gradient to use (between 0 and 1)
  13007. * @param factor defines the start size value to affect to the specified gradient
  13008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13009. * @returns the current particle system
  13010. */
  13011. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13012. /**
  13013. * Remove a specific start size gradient
  13014. * @param gradient defines the gradient to remove
  13015. * @returns the current particle system
  13016. */
  13017. removeStartSizeGradient(gradient: number): IParticleSystem;
  13018. private _createRampGradientTexture;
  13019. /**
  13020. * Gets the current list of ramp gradients.
  13021. * You must use addRampGradient and removeRampGradient to udpate this list
  13022. * @returns the list of ramp gradients
  13023. */
  13024. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13025. /** Force the system to rebuild all gradients that need to be resync */
  13026. forceRefreshGradients(): void;
  13027. private _syncRampGradientTexture;
  13028. /**
  13029. * Adds a new ramp gradient used to remap particle colors
  13030. * @param gradient defines the gradient to use (between 0 and 1)
  13031. * @param color defines the color to affect to the specified gradient
  13032. * @returns the current particle system
  13033. */
  13034. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13035. /**
  13036. * Remove a specific ramp gradient
  13037. * @param gradient defines the gradient to remove
  13038. * @returns the current particle system
  13039. */
  13040. removeRampGradient(gradient: number): ParticleSystem;
  13041. /**
  13042. * Adds a new color gradient
  13043. * @param gradient defines the gradient to use (between 0 and 1)
  13044. * @param color1 defines the color to affect to the specified gradient
  13045. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13046. * @returns this particle system
  13047. */
  13048. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13049. /**
  13050. * Remove a specific color gradient
  13051. * @param gradient defines the gradient to remove
  13052. * @returns this particle system
  13053. */
  13054. removeColorGradient(gradient: number): IParticleSystem;
  13055. private _fetchR;
  13056. protected _reset(): void;
  13057. private _resetEffect;
  13058. private _createVertexBuffers;
  13059. private _createIndexBuffer;
  13060. /**
  13061. * Gets the maximum number of particles active at the same time.
  13062. * @returns The max number of active particles.
  13063. */
  13064. getCapacity(): number;
  13065. /**
  13066. * Gets whether there are still active particles in the system.
  13067. * @returns True if it is alive, otherwise false.
  13068. */
  13069. isAlive(): boolean;
  13070. /**
  13071. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13072. * @returns True if it has been started, otherwise false.
  13073. */
  13074. isStarted(): boolean;
  13075. private _prepareSubEmitterInternalArray;
  13076. /**
  13077. * Starts the particle system and begins to emit
  13078. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13079. */
  13080. start(delay?: number): void;
  13081. /**
  13082. * Stops the particle system.
  13083. * @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.
  13084. */
  13085. stop(stopSubEmitters?: boolean): void;
  13086. /**
  13087. * Remove all active particles
  13088. */
  13089. reset(): void;
  13090. /**
  13091. * @hidden (for internal use only)
  13092. */
  13093. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13094. /**
  13095. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13096. * Its lifetime will start back at 0.
  13097. */
  13098. recycleParticle: (particle: Particle) => void;
  13099. private _stopSubEmitters;
  13100. private _createParticle;
  13101. private _removeFromRoot;
  13102. private _emitFromParticle;
  13103. private _update;
  13104. /** @hidden */
  13105. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13106. /** @hidden */
  13107. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13108. /**
  13109. * Fill the defines array according to the current settings of the particle system
  13110. * @param defines Array to be updated
  13111. * @param blendMode blend mode to take into account when updating the array
  13112. */
  13113. fillDefines(defines: Array<string>, blendMode: number): void;
  13114. /**
  13115. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13116. * @param uniforms Uniforms array to fill
  13117. * @param attributes Attributes array to fill
  13118. * @param samplers Samplers array to fill
  13119. */
  13120. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13121. /** @hidden */
  13122. private _getEffect;
  13123. /**
  13124. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13125. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13126. */
  13127. animate(preWarmOnly?: boolean): void;
  13128. private _appendParticleVertices;
  13129. /**
  13130. * Rebuilds the particle system.
  13131. */
  13132. rebuild(): void;
  13133. /**
  13134. * Is this system ready to be used/rendered
  13135. * @return true if the system is ready
  13136. */
  13137. isReady(): boolean;
  13138. private _render;
  13139. /**
  13140. * Renders the particle system in its current state.
  13141. * @returns the current number of particles
  13142. */
  13143. render(): number;
  13144. /**
  13145. * Disposes the particle system and free the associated resources
  13146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13147. */
  13148. dispose(disposeTexture?: boolean): void;
  13149. /**
  13150. * Clones the particle system.
  13151. * @param name The name of the cloned object
  13152. * @param newEmitter The new emitter to use
  13153. * @returns the cloned particle system
  13154. */
  13155. clone(name: string, newEmitter: any): ParticleSystem;
  13156. /**
  13157. * Serializes the particle system to a JSON object
  13158. * @param serializeTexture defines if the texture must be serialized as well
  13159. * @returns the JSON object
  13160. */
  13161. serialize(serializeTexture?: boolean): any;
  13162. /** @hidden */
  13163. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13164. /** @hidden */
  13165. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13166. /**
  13167. * Parses a JSON object to create a particle system.
  13168. * @param parsedParticleSystem The JSON object to parse
  13169. * @param scene The scene to create the particle system in
  13170. * @param rootUrl The root url to use to load external dependencies like texture
  13171. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13172. * @returns the Parsed particle system
  13173. */
  13174. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13175. }
  13176. }
  13177. declare module "babylonjs/Particles/particle" {
  13178. import { Nullable } from "babylonjs/types";
  13179. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13180. import { Color4 } from "babylonjs/Maths/math.color";
  13181. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13182. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13183. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13184. /**
  13185. * A particle represents one of the element emitted by a particle system.
  13186. * This is mainly define by its coordinates, direction, velocity and age.
  13187. */
  13188. export class Particle {
  13189. /**
  13190. * The particle system the particle belongs to.
  13191. */
  13192. particleSystem: ParticleSystem;
  13193. private static _Count;
  13194. /**
  13195. * Unique ID of the particle
  13196. */
  13197. id: number;
  13198. /**
  13199. * The world position of the particle in the scene.
  13200. */
  13201. position: Vector3;
  13202. /**
  13203. * The world direction of the particle in the scene.
  13204. */
  13205. direction: Vector3;
  13206. /**
  13207. * The color of the particle.
  13208. */
  13209. color: Color4;
  13210. /**
  13211. * The color change of the particle per step.
  13212. */
  13213. colorStep: Color4;
  13214. /**
  13215. * Defines how long will the life of the particle be.
  13216. */
  13217. lifeTime: number;
  13218. /**
  13219. * The current age of the particle.
  13220. */
  13221. age: number;
  13222. /**
  13223. * The current size of the particle.
  13224. */
  13225. size: number;
  13226. /**
  13227. * The current scale of the particle.
  13228. */
  13229. scale: Vector2;
  13230. /**
  13231. * The current angle of the particle.
  13232. */
  13233. angle: number;
  13234. /**
  13235. * Defines how fast is the angle changing.
  13236. */
  13237. angularSpeed: number;
  13238. /**
  13239. * Defines the cell index used by the particle to be rendered from a sprite.
  13240. */
  13241. cellIndex: number;
  13242. /**
  13243. * The information required to support color remapping
  13244. */
  13245. remapData: Vector4;
  13246. /** @hidden */
  13247. _randomCellOffset?: number;
  13248. /** @hidden */
  13249. _initialDirection: Nullable<Vector3>;
  13250. /** @hidden */
  13251. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13252. /** @hidden */
  13253. _initialStartSpriteCellID: number;
  13254. /** @hidden */
  13255. _initialEndSpriteCellID: number;
  13256. /** @hidden */
  13257. _currentColorGradient: Nullable<ColorGradient>;
  13258. /** @hidden */
  13259. _currentColor1: Color4;
  13260. /** @hidden */
  13261. _currentColor2: Color4;
  13262. /** @hidden */
  13263. _currentSizeGradient: Nullable<FactorGradient>;
  13264. /** @hidden */
  13265. _currentSize1: number;
  13266. /** @hidden */
  13267. _currentSize2: number;
  13268. /** @hidden */
  13269. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13270. /** @hidden */
  13271. _currentAngularSpeed1: number;
  13272. /** @hidden */
  13273. _currentAngularSpeed2: number;
  13274. /** @hidden */
  13275. _currentVelocityGradient: Nullable<FactorGradient>;
  13276. /** @hidden */
  13277. _currentVelocity1: number;
  13278. /** @hidden */
  13279. _currentVelocity2: number;
  13280. /** @hidden */
  13281. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13282. /** @hidden */
  13283. _currentLimitVelocity1: number;
  13284. /** @hidden */
  13285. _currentLimitVelocity2: number;
  13286. /** @hidden */
  13287. _currentDragGradient: Nullable<FactorGradient>;
  13288. /** @hidden */
  13289. _currentDrag1: number;
  13290. /** @hidden */
  13291. _currentDrag2: number;
  13292. /** @hidden */
  13293. _randomNoiseCoordinates1: Vector3;
  13294. /** @hidden */
  13295. _randomNoiseCoordinates2: Vector3;
  13296. /** @hidden */
  13297. _localPosition?: Vector3;
  13298. /**
  13299. * Creates a new instance Particle
  13300. * @param particleSystem the particle system the particle belongs to
  13301. */
  13302. constructor(
  13303. /**
  13304. * The particle system the particle belongs to.
  13305. */
  13306. particleSystem: ParticleSystem);
  13307. private updateCellInfoFromSystem;
  13308. /**
  13309. * Defines how the sprite cell index is updated for the particle
  13310. */
  13311. updateCellIndex(): void;
  13312. /** @hidden */
  13313. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13314. /** @hidden */
  13315. _inheritParticleInfoToSubEmitters(): void;
  13316. /** @hidden */
  13317. _reset(): void;
  13318. /**
  13319. * Copy the properties of particle to another one.
  13320. * @param other the particle to copy the information to.
  13321. */
  13322. copyTo(other: Particle): void;
  13323. }
  13324. }
  13325. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13326. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13327. import { Effect } from "babylonjs/Materials/effect";
  13328. import { Particle } from "babylonjs/Particles/particle";
  13329. import { Scene } from "babylonjs/scene";
  13330. /**
  13331. * Particle emitter represents a volume emitting particles.
  13332. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13333. */
  13334. export interface IParticleEmitterType {
  13335. /**
  13336. * Called by the particle System when the direction is computed for the created particle.
  13337. * @param worldMatrix is the world matrix of the particle system
  13338. * @param directionToUpdate is the direction vector to update with the result
  13339. * @param particle is the particle we are computed the direction for
  13340. * @param isLocal defines if the direction should be set in local space
  13341. */
  13342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13343. /**
  13344. * Called by the particle System when the position is computed for the created particle.
  13345. * @param worldMatrix is the world matrix of the particle system
  13346. * @param positionToUpdate is the position vector to update with the result
  13347. * @param particle is the particle we are computed the position for
  13348. * @param isLocal defines if the position should be set in local space
  13349. */
  13350. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13351. /**
  13352. * Clones the current emitter and returns a copy of it
  13353. * @returns the new emitter
  13354. */
  13355. clone(): IParticleEmitterType;
  13356. /**
  13357. * Called by the GPUParticleSystem to setup the update shader
  13358. * @param effect defines the update shader
  13359. */
  13360. applyToShader(effect: Effect): void;
  13361. /**
  13362. * Returns a string to use to update the GPU particles update shader
  13363. * @returns the effect defines string
  13364. */
  13365. getEffectDefines(): string;
  13366. /**
  13367. * Returns a string representing the class name
  13368. * @returns a string containing the class name
  13369. */
  13370. getClassName(): string;
  13371. /**
  13372. * Serializes the particle system to a JSON object.
  13373. * @returns the JSON object
  13374. */
  13375. serialize(): any;
  13376. /**
  13377. * Parse properties from a JSON object
  13378. * @param serializationObject defines the JSON object
  13379. * @param scene defines the hosting scene
  13380. */
  13381. parse(serializationObject: any, scene: Scene): void;
  13382. }
  13383. }
  13384. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13385. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13386. import { Effect } from "babylonjs/Materials/effect";
  13387. import { Particle } from "babylonjs/Particles/particle";
  13388. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13389. /**
  13390. * Particle emitter emitting particles from the inside of a box.
  13391. * It emits the particles randomly between 2 given directions.
  13392. */
  13393. export class BoxParticleEmitter implements IParticleEmitterType {
  13394. /**
  13395. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13396. */
  13397. direction1: Vector3;
  13398. /**
  13399. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13400. */
  13401. direction2: Vector3;
  13402. /**
  13403. * 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.
  13404. */
  13405. minEmitBox: Vector3;
  13406. /**
  13407. * 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.
  13408. */
  13409. maxEmitBox: Vector3;
  13410. /**
  13411. * Creates a new instance BoxParticleEmitter
  13412. */
  13413. constructor();
  13414. /**
  13415. * Called by the particle System when the direction is computed for the created particle.
  13416. * @param worldMatrix is the world matrix of the particle system
  13417. * @param directionToUpdate is the direction vector to update with the result
  13418. * @param particle is the particle we are computed the direction for
  13419. * @param isLocal defines if the direction should be set in local space
  13420. */
  13421. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13422. /**
  13423. * Called by the particle System when the position is computed for the created particle.
  13424. * @param worldMatrix is the world matrix of the particle system
  13425. * @param positionToUpdate is the position vector to update with the result
  13426. * @param particle is the particle we are computed the position for
  13427. * @param isLocal defines if the position should be set in local space
  13428. */
  13429. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13430. /**
  13431. * Clones the current emitter and returns a copy of it
  13432. * @returns the new emitter
  13433. */
  13434. clone(): BoxParticleEmitter;
  13435. /**
  13436. * Called by the GPUParticleSystem to setup the update shader
  13437. * @param effect defines the update shader
  13438. */
  13439. applyToShader(effect: Effect): void;
  13440. /**
  13441. * Returns a string to use to update the GPU particles update shader
  13442. * @returns a string containng the defines string
  13443. */
  13444. getEffectDefines(): string;
  13445. /**
  13446. * Returns the string "BoxParticleEmitter"
  13447. * @returns a string containing the class name
  13448. */
  13449. getClassName(): string;
  13450. /**
  13451. * Serializes the particle system to a JSON object.
  13452. * @returns the JSON object
  13453. */
  13454. serialize(): any;
  13455. /**
  13456. * Parse properties from a JSON object
  13457. * @param serializationObject defines the JSON object
  13458. */
  13459. parse(serializationObject: any): void;
  13460. }
  13461. }
  13462. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13463. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13464. import { Effect } from "babylonjs/Materials/effect";
  13465. import { Particle } from "babylonjs/Particles/particle";
  13466. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13467. /**
  13468. * Particle emitter emitting particles from the inside of a cone.
  13469. * It emits the particles alongside the cone volume from the base to the particle.
  13470. * The emission direction might be randomized.
  13471. */
  13472. export class ConeParticleEmitter implements IParticleEmitterType {
  13473. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13474. directionRandomizer: number;
  13475. private _radius;
  13476. private _angle;
  13477. private _height;
  13478. /**
  13479. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13480. */
  13481. radiusRange: number;
  13482. /**
  13483. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13484. */
  13485. heightRange: number;
  13486. /**
  13487. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13488. */
  13489. emitFromSpawnPointOnly: boolean;
  13490. /**
  13491. * Gets or sets the radius of the emission cone
  13492. */
  13493. get radius(): number;
  13494. set radius(value: number);
  13495. /**
  13496. * Gets or sets the angle of the emission cone
  13497. */
  13498. get angle(): number;
  13499. set angle(value: number);
  13500. private _buildHeight;
  13501. /**
  13502. * Creates a new instance ConeParticleEmitter
  13503. * @param radius the radius of the emission cone (1 by default)
  13504. * @param angle the cone base angle (PI by default)
  13505. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13506. */
  13507. constructor(radius?: number, angle?: number,
  13508. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13509. directionRandomizer?: number);
  13510. /**
  13511. * Called by the particle System when the direction is computed for the created particle.
  13512. * @param worldMatrix is the world matrix of the particle system
  13513. * @param directionToUpdate is the direction vector to update with the result
  13514. * @param particle is the particle we are computed the direction for
  13515. * @param isLocal defines if the direction should be set in local space
  13516. */
  13517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13518. /**
  13519. * Called by the particle System when the position is computed for the created particle.
  13520. * @param worldMatrix is the world matrix of the particle system
  13521. * @param positionToUpdate is the position vector to update with the result
  13522. * @param particle is the particle we are computed the position for
  13523. * @param isLocal defines if the position should be set in local space
  13524. */
  13525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13526. /**
  13527. * Clones the current emitter and returns a copy of it
  13528. * @returns the new emitter
  13529. */
  13530. clone(): ConeParticleEmitter;
  13531. /**
  13532. * Called by the GPUParticleSystem to setup the update shader
  13533. * @param effect defines the update shader
  13534. */
  13535. applyToShader(effect: Effect): void;
  13536. /**
  13537. * Returns a string to use to update the GPU particles update shader
  13538. * @returns a string containng the defines string
  13539. */
  13540. getEffectDefines(): string;
  13541. /**
  13542. * Returns the string "ConeParticleEmitter"
  13543. * @returns a string containing the class name
  13544. */
  13545. getClassName(): string;
  13546. /**
  13547. * Serializes the particle system to a JSON object.
  13548. * @returns the JSON object
  13549. */
  13550. serialize(): any;
  13551. /**
  13552. * Parse properties from a JSON object
  13553. * @param serializationObject defines the JSON object
  13554. */
  13555. parse(serializationObject: any): void;
  13556. }
  13557. }
  13558. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13559. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13560. import { Effect } from "babylonjs/Materials/effect";
  13561. import { Particle } from "babylonjs/Particles/particle";
  13562. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13563. /**
  13564. * Particle emitter emitting particles from the inside of a cylinder.
  13565. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13566. */
  13567. export class CylinderParticleEmitter implements IParticleEmitterType {
  13568. /**
  13569. * The radius of the emission cylinder.
  13570. */
  13571. radius: number;
  13572. /**
  13573. * The height of the emission cylinder.
  13574. */
  13575. height: number;
  13576. /**
  13577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13578. */
  13579. radiusRange: number;
  13580. /**
  13581. * How much to randomize the particle direction [0-1].
  13582. */
  13583. directionRandomizer: number;
  13584. /**
  13585. * Creates a new instance CylinderParticleEmitter
  13586. * @param radius the radius of the emission cylinder (1 by default)
  13587. * @param height the height of the emission cylinder (1 by default)
  13588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13589. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13590. */
  13591. constructor(
  13592. /**
  13593. * The radius of the emission cylinder.
  13594. */
  13595. radius?: number,
  13596. /**
  13597. * The height of the emission cylinder.
  13598. */
  13599. height?: number,
  13600. /**
  13601. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13602. */
  13603. radiusRange?: number,
  13604. /**
  13605. * How much to randomize the particle direction [0-1].
  13606. */
  13607. directionRandomizer?: number);
  13608. /**
  13609. * Called by the particle System when the direction is computed for the created particle.
  13610. * @param worldMatrix is the world matrix of the particle system
  13611. * @param directionToUpdate is the direction vector to update with the result
  13612. * @param particle is the particle we are computed the direction for
  13613. * @param isLocal defines if the direction should be set in local space
  13614. */
  13615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13616. /**
  13617. * Called by the particle System when the position is computed for the created particle.
  13618. * @param worldMatrix is the world matrix of the particle system
  13619. * @param positionToUpdate is the position vector to update with the result
  13620. * @param particle is the particle we are computed the position for
  13621. * @param isLocal defines if the position should be set in local space
  13622. */
  13623. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13624. /**
  13625. * Clones the current emitter and returns a copy of it
  13626. * @returns the new emitter
  13627. */
  13628. clone(): CylinderParticleEmitter;
  13629. /**
  13630. * Called by the GPUParticleSystem to setup the update shader
  13631. * @param effect defines the update shader
  13632. */
  13633. applyToShader(effect: Effect): void;
  13634. /**
  13635. * Returns a string to use to update the GPU particles update shader
  13636. * @returns a string containng the defines string
  13637. */
  13638. getEffectDefines(): string;
  13639. /**
  13640. * Returns the string "CylinderParticleEmitter"
  13641. * @returns a string containing the class name
  13642. */
  13643. getClassName(): string;
  13644. /**
  13645. * Serializes the particle system to a JSON object.
  13646. * @returns the JSON object
  13647. */
  13648. serialize(): any;
  13649. /**
  13650. * Parse properties from a JSON object
  13651. * @param serializationObject defines the JSON object
  13652. */
  13653. parse(serializationObject: any): void;
  13654. }
  13655. /**
  13656. * Particle emitter emitting particles from the inside of a cylinder.
  13657. * It emits the particles randomly between two vectors.
  13658. */
  13659. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13660. /**
  13661. * The min limit of the emission direction.
  13662. */
  13663. direction1: Vector3;
  13664. /**
  13665. * The max limit of the emission direction.
  13666. */
  13667. direction2: Vector3;
  13668. /**
  13669. * Creates a new instance CylinderDirectedParticleEmitter
  13670. * @param radius the radius of the emission cylinder (1 by default)
  13671. * @param height the height of the emission cylinder (1 by default)
  13672. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13673. * @param direction1 the min limit of the emission direction (up vector by default)
  13674. * @param direction2 the max limit of the emission direction (up vector by default)
  13675. */
  13676. constructor(radius?: number, height?: number, radiusRange?: number,
  13677. /**
  13678. * The min limit of the emission direction.
  13679. */
  13680. direction1?: Vector3,
  13681. /**
  13682. * The max limit of the emission direction.
  13683. */
  13684. direction2?: Vector3);
  13685. /**
  13686. * Called by the particle System when the direction is computed for the created particle.
  13687. * @param worldMatrix is the world matrix of the particle system
  13688. * @param directionToUpdate is the direction vector to update with the result
  13689. * @param particle is the particle we are computed the direction for
  13690. */
  13691. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13692. /**
  13693. * Clones the current emitter and returns a copy of it
  13694. * @returns the new emitter
  13695. */
  13696. clone(): CylinderDirectedParticleEmitter;
  13697. /**
  13698. * Called by the GPUParticleSystem to setup the update shader
  13699. * @param effect defines the update shader
  13700. */
  13701. applyToShader(effect: Effect): void;
  13702. /**
  13703. * Returns a string to use to update the GPU particles update shader
  13704. * @returns a string containng the defines string
  13705. */
  13706. getEffectDefines(): string;
  13707. /**
  13708. * Returns the string "CylinderDirectedParticleEmitter"
  13709. * @returns a string containing the class name
  13710. */
  13711. getClassName(): string;
  13712. /**
  13713. * Serializes the particle system to a JSON object.
  13714. * @returns the JSON object
  13715. */
  13716. serialize(): any;
  13717. /**
  13718. * Parse properties from a JSON object
  13719. * @param serializationObject defines the JSON object
  13720. */
  13721. parse(serializationObject: any): void;
  13722. }
  13723. }
  13724. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13725. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13726. import { Effect } from "babylonjs/Materials/effect";
  13727. import { Particle } from "babylonjs/Particles/particle";
  13728. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13729. /**
  13730. * Particle emitter emitting particles from the inside of a hemisphere.
  13731. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13732. */
  13733. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13734. /**
  13735. * The radius of the emission hemisphere.
  13736. */
  13737. radius: number;
  13738. /**
  13739. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13740. */
  13741. radiusRange: number;
  13742. /**
  13743. * How much to randomize the particle direction [0-1].
  13744. */
  13745. directionRandomizer: number;
  13746. /**
  13747. * Creates a new instance HemisphericParticleEmitter
  13748. * @param radius the radius of the emission hemisphere (1 by default)
  13749. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13750. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13751. */
  13752. constructor(
  13753. /**
  13754. * The radius of the emission hemisphere.
  13755. */
  13756. radius?: number,
  13757. /**
  13758. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13759. */
  13760. radiusRange?: number,
  13761. /**
  13762. * How much to randomize the particle direction [0-1].
  13763. */
  13764. directionRandomizer?: number);
  13765. /**
  13766. * Called by the particle System when the direction is computed for the created particle.
  13767. * @param worldMatrix is the world matrix of the particle system
  13768. * @param directionToUpdate is the direction vector to update with the result
  13769. * @param particle is the particle we are computed the direction for
  13770. * @param isLocal defines if the direction should be set in local space
  13771. */
  13772. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13773. /**
  13774. * Called by the particle System when the position is computed for the created particle.
  13775. * @param worldMatrix is the world matrix of the particle system
  13776. * @param positionToUpdate is the position vector to update with the result
  13777. * @param particle is the particle we are computed the position for
  13778. * @param isLocal defines if the position should be set in local space
  13779. */
  13780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13781. /**
  13782. * Clones the current emitter and returns a copy of it
  13783. * @returns the new emitter
  13784. */
  13785. clone(): HemisphericParticleEmitter;
  13786. /**
  13787. * Called by the GPUParticleSystem to setup the update shader
  13788. * @param effect defines the update shader
  13789. */
  13790. applyToShader(effect: Effect): void;
  13791. /**
  13792. * Returns a string to use to update the GPU particles update shader
  13793. * @returns a string containng the defines string
  13794. */
  13795. getEffectDefines(): string;
  13796. /**
  13797. * Returns the string "HemisphericParticleEmitter"
  13798. * @returns a string containing the class name
  13799. */
  13800. getClassName(): string;
  13801. /**
  13802. * Serializes the particle system to a JSON object.
  13803. * @returns the JSON object
  13804. */
  13805. serialize(): any;
  13806. /**
  13807. * Parse properties from a JSON object
  13808. * @param serializationObject defines the JSON object
  13809. */
  13810. parse(serializationObject: any): void;
  13811. }
  13812. }
  13813. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13814. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13815. import { Effect } from "babylonjs/Materials/effect";
  13816. import { Particle } from "babylonjs/Particles/particle";
  13817. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13818. /**
  13819. * Particle emitter emitting particles from a point.
  13820. * It emits the particles randomly between 2 given directions.
  13821. */
  13822. export class PointParticleEmitter implements IParticleEmitterType {
  13823. /**
  13824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13825. */
  13826. direction1: Vector3;
  13827. /**
  13828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13829. */
  13830. direction2: Vector3;
  13831. /**
  13832. * Creates a new instance PointParticleEmitter
  13833. */
  13834. constructor();
  13835. /**
  13836. * Called by the particle System when the direction is computed for the created particle.
  13837. * @param worldMatrix is the world matrix of the particle system
  13838. * @param directionToUpdate is the direction vector to update with the result
  13839. * @param particle is the particle we are computed the direction for
  13840. * @param isLocal defines if the direction should be set in local space
  13841. */
  13842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13843. /**
  13844. * Called by the particle System when the position is computed for the created particle.
  13845. * @param worldMatrix is the world matrix of the particle system
  13846. * @param positionToUpdate is the position vector to update with the result
  13847. * @param particle is the particle we are computed the position for
  13848. * @param isLocal defines if the position should be set in local space
  13849. */
  13850. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13851. /**
  13852. * Clones the current emitter and returns a copy of it
  13853. * @returns the new emitter
  13854. */
  13855. clone(): PointParticleEmitter;
  13856. /**
  13857. * Called by the GPUParticleSystem to setup the update shader
  13858. * @param effect defines the update shader
  13859. */
  13860. applyToShader(effect: Effect): void;
  13861. /**
  13862. * Returns a string to use to update the GPU particles update shader
  13863. * @returns a string containng the defines string
  13864. */
  13865. getEffectDefines(): string;
  13866. /**
  13867. * Returns the string "PointParticleEmitter"
  13868. * @returns a string containing the class name
  13869. */
  13870. getClassName(): string;
  13871. /**
  13872. * Serializes the particle system to a JSON object.
  13873. * @returns the JSON object
  13874. */
  13875. serialize(): any;
  13876. /**
  13877. * Parse properties from a JSON object
  13878. * @param serializationObject defines the JSON object
  13879. */
  13880. parse(serializationObject: any): void;
  13881. }
  13882. }
  13883. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13884. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13885. import { Effect } from "babylonjs/Materials/effect";
  13886. import { Particle } from "babylonjs/Particles/particle";
  13887. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13888. /**
  13889. * Particle emitter emitting particles from the inside of a sphere.
  13890. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13891. */
  13892. export class SphereParticleEmitter implements IParticleEmitterType {
  13893. /**
  13894. * The radius of the emission sphere.
  13895. */
  13896. radius: number;
  13897. /**
  13898. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13899. */
  13900. radiusRange: number;
  13901. /**
  13902. * How much to randomize the particle direction [0-1].
  13903. */
  13904. directionRandomizer: number;
  13905. /**
  13906. * Creates a new instance SphereParticleEmitter
  13907. * @param radius the radius of the emission sphere (1 by default)
  13908. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13909. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13910. */
  13911. constructor(
  13912. /**
  13913. * The radius of the emission sphere.
  13914. */
  13915. radius?: number,
  13916. /**
  13917. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13918. */
  13919. radiusRange?: number,
  13920. /**
  13921. * How much to randomize the particle direction [0-1].
  13922. */
  13923. directionRandomizer?: number);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. * @param isLocal defines if the direction should be set in local space
  13930. */
  13931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13932. /**
  13933. * Called by the particle System when the position is computed for the created particle.
  13934. * @param worldMatrix is the world matrix of the particle system
  13935. * @param positionToUpdate is the position vector to update with the result
  13936. * @param particle is the particle we are computed the position for
  13937. * @param isLocal defines if the position should be set in local space
  13938. */
  13939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13940. /**
  13941. * Clones the current emitter and returns a copy of it
  13942. * @returns the new emitter
  13943. */
  13944. clone(): SphereParticleEmitter;
  13945. /**
  13946. * Called by the GPUParticleSystem to setup the update shader
  13947. * @param effect defines the update shader
  13948. */
  13949. applyToShader(effect: Effect): void;
  13950. /**
  13951. * Returns a string to use to update the GPU particles update shader
  13952. * @returns a string containng the defines string
  13953. */
  13954. getEffectDefines(): string;
  13955. /**
  13956. * Returns the string "SphereParticleEmitter"
  13957. * @returns a string containing the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Serializes the particle system to a JSON object.
  13962. * @returns the JSON object
  13963. */
  13964. serialize(): any;
  13965. /**
  13966. * Parse properties from a JSON object
  13967. * @param serializationObject defines the JSON object
  13968. */
  13969. parse(serializationObject: any): void;
  13970. }
  13971. /**
  13972. * Particle emitter emitting particles from the inside of a sphere.
  13973. * It emits the particles randomly between two vectors.
  13974. */
  13975. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13976. /**
  13977. * The min limit of the emission direction.
  13978. */
  13979. direction1: Vector3;
  13980. /**
  13981. * The max limit of the emission direction.
  13982. */
  13983. direction2: Vector3;
  13984. /**
  13985. * Creates a new instance SphereDirectedParticleEmitter
  13986. * @param radius the radius of the emission sphere (1 by default)
  13987. * @param direction1 the min limit of the emission direction (up vector by default)
  13988. * @param direction2 the max limit of the emission direction (up vector by default)
  13989. */
  13990. constructor(radius?: number,
  13991. /**
  13992. * The min limit of the emission direction.
  13993. */
  13994. direction1?: Vector3,
  13995. /**
  13996. * The max limit of the emission direction.
  13997. */
  13998. direction2?: Vector3);
  13999. /**
  14000. * Called by the particle System when the direction is computed for the created particle.
  14001. * @param worldMatrix is the world matrix of the particle system
  14002. * @param directionToUpdate is the direction vector to update with the result
  14003. * @param particle is the particle we are computed the direction for
  14004. */
  14005. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14006. /**
  14007. * Clones the current emitter and returns a copy of it
  14008. * @returns the new emitter
  14009. */
  14010. clone(): SphereDirectedParticleEmitter;
  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 "SphereDirectedParticleEmitter"
  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/customParticleEmitter" {
  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. /**
  14045. * Particle emitter emitting particles from a custom list of positions.
  14046. */
  14047. export class CustomParticleEmitter implements IParticleEmitterType {
  14048. /**
  14049. * Gets or sets the position generator that will create the inital position of each particle.
  14050. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14051. */
  14052. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14053. /**
  14054. * Gets or sets the destination generator that will create the final destination of each particle.
  14055. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14056. */
  14057. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14058. /**
  14059. * Creates a new instance CustomParticleEmitter
  14060. */
  14061. constructor();
  14062. /**
  14063. * Called by the particle System when the direction is computed for the created particle.
  14064. * @param worldMatrix is the world matrix of the particle system
  14065. * @param directionToUpdate is the direction vector to update with the result
  14066. * @param particle is the particle we are computed the direction for
  14067. * @param isLocal defines if the direction should be set in local space
  14068. */
  14069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14070. /**
  14071. * Called by the particle System when the position is computed for the created particle.
  14072. * @param worldMatrix is the world matrix of the particle system
  14073. * @param positionToUpdate is the position vector to update with the result
  14074. * @param particle is the particle we are computed the position for
  14075. * @param isLocal defines if the position should be set in local space
  14076. */
  14077. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14078. /**
  14079. * Clones the current emitter and returns a copy of it
  14080. * @returns the new emitter
  14081. */
  14082. clone(): CustomParticleEmitter;
  14083. /**
  14084. * Called by the GPUParticleSystem to setup the update shader
  14085. * @param effect defines the update shader
  14086. */
  14087. applyToShader(effect: Effect): void;
  14088. /**
  14089. * Returns a string to use to update the GPU particles update shader
  14090. * @returns a string containng the defines string
  14091. */
  14092. getEffectDefines(): string;
  14093. /**
  14094. * Returns the string "PointParticleEmitter"
  14095. * @returns a string containing the class name
  14096. */
  14097. getClassName(): string;
  14098. /**
  14099. * Serializes the particle system to a JSON object.
  14100. * @returns the JSON object
  14101. */
  14102. serialize(): any;
  14103. /**
  14104. * Parse properties from a JSON object
  14105. * @param serializationObject defines the JSON object
  14106. */
  14107. parse(serializationObject: any): void;
  14108. }
  14109. }
  14110. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14111. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14112. import { Effect } from "babylonjs/Materials/effect";
  14113. import { Particle } from "babylonjs/Particles/particle";
  14114. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14115. import { Nullable } from "babylonjs/types";
  14116. import { Scene } from "babylonjs/scene";
  14117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14118. /**
  14119. * Particle emitter emitting particles from the inside of a box.
  14120. * It emits the particles randomly between 2 given directions.
  14121. */
  14122. export class MeshParticleEmitter implements IParticleEmitterType {
  14123. private _indices;
  14124. private _positions;
  14125. private _normals;
  14126. private _storedNormal;
  14127. private _mesh;
  14128. /**
  14129. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14130. */
  14131. direction1: Vector3;
  14132. /**
  14133. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14134. */
  14135. direction2: Vector3;
  14136. /**
  14137. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14138. */
  14139. useMeshNormalsForDirection: boolean;
  14140. /** Defines the mesh to use as source */
  14141. get mesh(): Nullable<AbstractMesh>;
  14142. set mesh(value: Nullable<AbstractMesh>);
  14143. /**
  14144. * Creates a new instance MeshParticleEmitter
  14145. * @param mesh defines the mesh to use as source
  14146. */
  14147. constructor(mesh?: Nullable<AbstractMesh>);
  14148. /**
  14149. * Called by the particle System when the direction is computed for the created particle.
  14150. * @param worldMatrix is the world matrix of the particle system
  14151. * @param directionToUpdate is the direction vector to update with the result
  14152. * @param particle is the particle we are computed the direction for
  14153. * @param isLocal defines if the direction should be set in local space
  14154. */
  14155. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14156. /**
  14157. * Called by the particle System when the position is computed for the created particle.
  14158. * @param worldMatrix is the world matrix of the particle system
  14159. * @param positionToUpdate is the position vector to update with the result
  14160. * @param particle is the particle we are computed the position for
  14161. * @param isLocal defines if the position should be set in local space
  14162. */
  14163. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14164. /**
  14165. * Clones the current emitter and returns a copy of it
  14166. * @returns the new emitter
  14167. */
  14168. clone(): MeshParticleEmitter;
  14169. /**
  14170. * Called by the GPUParticleSystem to setup the update shader
  14171. * @param effect defines the update shader
  14172. */
  14173. applyToShader(effect: Effect): void;
  14174. /**
  14175. * Returns a string to use to update the GPU particles update shader
  14176. * @returns a string containng the defines string
  14177. */
  14178. getEffectDefines(): string;
  14179. /**
  14180. * Returns the string "BoxParticleEmitter"
  14181. * @returns a string containing the class name
  14182. */
  14183. getClassName(): string;
  14184. /**
  14185. * Serializes the particle system to a JSON object.
  14186. * @returns the JSON object
  14187. */
  14188. serialize(): any;
  14189. /**
  14190. * Parse properties from a JSON object
  14191. * @param serializationObject defines the JSON object
  14192. * @param scene defines the hosting scene
  14193. */
  14194. parse(serializationObject: any, scene: Scene): void;
  14195. }
  14196. }
  14197. declare module "babylonjs/Particles/EmitterTypes/index" {
  14198. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14199. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14200. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14201. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14202. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14203. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14204. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14205. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14206. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14207. }
  14208. declare module "babylonjs/Particles/IParticleSystem" {
  14209. import { Nullable } from "babylonjs/types";
  14210. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14211. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14214. import { Texture } from "babylonjs/Materials/Textures/texture";
  14215. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14216. import { Scene } from "babylonjs/scene";
  14217. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14218. import { Effect } from "babylonjs/Materials/effect";
  14219. import { Observable } from "babylonjs/Misc/observable";
  14220. import { Animation } from "babylonjs/Animations/animation";
  14221. /**
  14222. * Interface representing a particle system in Babylon.js.
  14223. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14224. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14225. */
  14226. export interface IParticleSystem {
  14227. /**
  14228. * List of animations used by the particle system.
  14229. */
  14230. animations: Animation[];
  14231. /**
  14232. * The id of the Particle system.
  14233. */
  14234. id: string;
  14235. /**
  14236. * The name of the Particle system.
  14237. */
  14238. name: string;
  14239. /**
  14240. * The emitter represents the Mesh or position we are attaching the particle system to.
  14241. */
  14242. emitter: Nullable<AbstractMesh | Vector3>;
  14243. /**
  14244. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14245. */
  14246. isBillboardBased: boolean;
  14247. /**
  14248. * The rendering group used by the Particle system to chose when to render.
  14249. */
  14250. renderingGroupId: number;
  14251. /**
  14252. * The layer mask we are rendering the particles through.
  14253. */
  14254. layerMask: number;
  14255. /**
  14256. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14257. */
  14258. updateSpeed: number;
  14259. /**
  14260. * The amount of time the particle system is running (depends of the overall update speed).
  14261. */
  14262. targetStopDuration: number;
  14263. /**
  14264. * The texture used to render each particle. (this can be a spritesheet)
  14265. */
  14266. particleTexture: Nullable<Texture>;
  14267. /**
  14268. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14269. */
  14270. blendMode: number;
  14271. /**
  14272. * Minimum life time of emitting particles.
  14273. */
  14274. minLifeTime: number;
  14275. /**
  14276. * Maximum life time of emitting particles.
  14277. */
  14278. maxLifeTime: number;
  14279. /**
  14280. * Minimum Size of emitting particles.
  14281. */
  14282. minSize: number;
  14283. /**
  14284. * Maximum Size of emitting particles.
  14285. */
  14286. maxSize: number;
  14287. /**
  14288. * Minimum scale of emitting particles on X axis.
  14289. */
  14290. minScaleX: number;
  14291. /**
  14292. * Maximum scale of emitting particles on X axis.
  14293. */
  14294. maxScaleX: number;
  14295. /**
  14296. * Minimum scale of emitting particles on Y axis.
  14297. */
  14298. minScaleY: number;
  14299. /**
  14300. * Maximum scale of emitting particles on Y axis.
  14301. */
  14302. maxScaleY: number;
  14303. /**
  14304. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14305. */
  14306. color1: Color4;
  14307. /**
  14308. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14309. */
  14310. color2: Color4;
  14311. /**
  14312. * Color the particle will have at the end of its lifetime.
  14313. */
  14314. colorDead: Color4;
  14315. /**
  14316. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14317. */
  14318. emitRate: number;
  14319. /**
  14320. * You can use gravity if you want to give an orientation to your particles.
  14321. */
  14322. gravity: Vector3;
  14323. /**
  14324. * Minimum power of emitting particles.
  14325. */
  14326. minEmitPower: number;
  14327. /**
  14328. * Maximum power of emitting particles.
  14329. */
  14330. maxEmitPower: number;
  14331. /**
  14332. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14333. */
  14334. minAngularSpeed: number;
  14335. /**
  14336. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14337. */
  14338. maxAngularSpeed: number;
  14339. /**
  14340. * Gets or sets the minimal initial rotation in radians.
  14341. */
  14342. minInitialRotation: number;
  14343. /**
  14344. * Gets or sets the maximal initial rotation in radians.
  14345. */
  14346. maxInitialRotation: number;
  14347. /**
  14348. * The particle emitter type defines the emitter used by the particle system.
  14349. * It can be for example box, sphere, or cone...
  14350. */
  14351. particleEmitterType: Nullable<IParticleEmitterType>;
  14352. /**
  14353. * Defines the delay in milliseconds before starting the system (0 by default)
  14354. */
  14355. startDelay: number;
  14356. /**
  14357. * 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
  14358. */
  14359. preWarmCycles: number;
  14360. /**
  14361. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14362. */
  14363. preWarmStepOffset: number;
  14364. /**
  14365. * 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)
  14366. */
  14367. spriteCellChangeSpeed: number;
  14368. /**
  14369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14370. */
  14371. startSpriteCellID: number;
  14372. /**
  14373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14374. */
  14375. endSpriteCellID: number;
  14376. /**
  14377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14378. */
  14379. spriteCellWidth: number;
  14380. /**
  14381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14382. */
  14383. spriteCellHeight: number;
  14384. /**
  14385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14386. */
  14387. spriteRandomStartCell: boolean;
  14388. /**
  14389. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14390. */
  14391. isAnimationSheetEnabled: boolean;
  14392. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14393. translationPivot: Vector2;
  14394. /**
  14395. * Gets or sets a texture used to add random noise to particle positions
  14396. */
  14397. noiseTexture: Nullable<BaseTexture>;
  14398. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14399. noiseStrength: Vector3;
  14400. /**
  14401. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14402. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14403. */
  14404. billboardMode: number;
  14405. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14406. limitVelocityDamping: number;
  14407. /**
  14408. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14409. */
  14410. beginAnimationOnStart: boolean;
  14411. /**
  14412. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14413. */
  14414. beginAnimationFrom: number;
  14415. /**
  14416. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14417. */
  14418. beginAnimationTo: number;
  14419. /**
  14420. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14421. */
  14422. beginAnimationLoop: boolean;
  14423. /**
  14424. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14425. */
  14426. disposeOnStop: boolean;
  14427. /**
  14428. * Specifies if the particles are updated in emitter local space or world space
  14429. */
  14430. isLocal: boolean;
  14431. /** Snippet ID if the particle system was created from the snippet server */
  14432. snippetId: string;
  14433. /**
  14434. * Gets the maximum number of particles active at the same time.
  14435. * @returns The max number of active particles.
  14436. */
  14437. getCapacity(): number;
  14438. /**
  14439. * Gets the number of particles active at the same time.
  14440. * @returns The number of active particles.
  14441. */
  14442. getActiveCount(): number;
  14443. /**
  14444. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14445. * @returns True if it has been started, otherwise false.
  14446. */
  14447. isStarted(): boolean;
  14448. /**
  14449. * Animates the particle system for this frame.
  14450. */
  14451. animate(): void;
  14452. /**
  14453. * Renders the particle system in its current state.
  14454. * @returns the current number of particles
  14455. */
  14456. render(): number;
  14457. /**
  14458. * Dispose the particle system and frees its associated resources.
  14459. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14460. */
  14461. dispose(disposeTexture?: boolean): void;
  14462. /**
  14463. * An event triggered when the system is disposed
  14464. */
  14465. onDisposeObservable: Observable<IParticleSystem>;
  14466. /**
  14467. * Clones the particle system.
  14468. * @param name The name of the cloned object
  14469. * @param newEmitter The new emitter to use
  14470. * @returns the cloned particle system
  14471. */
  14472. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14473. /**
  14474. * Serializes the particle system to a JSON object
  14475. * @param serializeTexture defines if the texture must be serialized as well
  14476. * @returns the JSON object
  14477. */
  14478. serialize(serializeTexture: boolean): any;
  14479. /**
  14480. * Rebuild the particle system
  14481. */
  14482. rebuild(): void;
  14483. /** Force the system to rebuild all gradients that need to be resync */
  14484. forceRefreshGradients(): void;
  14485. /**
  14486. * Starts the particle system and begins to emit
  14487. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14488. */
  14489. start(delay?: number): void;
  14490. /**
  14491. * Stops the particle system.
  14492. */
  14493. stop(): void;
  14494. /**
  14495. * Remove all active particles
  14496. */
  14497. reset(): void;
  14498. /**
  14499. * Gets a boolean indicating that the system is stopping
  14500. * @returns true if the system is currently stopping
  14501. */
  14502. isStopping(): boolean;
  14503. /**
  14504. * Is this system ready to be used/rendered
  14505. * @return true if the system is ready
  14506. */
  14507. isReady(): boolean;
  14508. /**
  14509. * Returns the string "ParticleSystem"
  14510. * @returns a string containing the class name
  14511. */
  14512. getClassName(): string;
  14513. /**
  14514. * Gets the custom effect used to render the particles
  14515. * @param blendMode Blend mode for which the effect should be retrieved
  14516. * @returns The effect
  14517. */
  14518. getCustomEffect(blendMode: number): Nullable<Effect>;
  14519. /**
  14520. * Sets the custom effect used to render the particles
  14521. * @param effect The effect to set
  14522. * @param blendMode Blend mode for which the effect should be set
  14523. */
  14524. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14525. /**
  14526. * Fill the defines array according to the current settings of the particle system
  14527. * @param defines Array to be updated
  14528. * @param blendMode blend mode to take into account when updating the array
  14529. */
  14530. fillDefines(defines: Array<string>, blendMode: number): void;
  14531. /**
  14532. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14533. * @param uniforms Uniforms array to fill
  14534. * @param attributes Attributes array to fill
  14535. * @param samplers Samplers array to fill
  14536. */
  14537. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14538. /**
  14539. * Observable that will be called just before the particles are drawn
  14540. */
  14541. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14542. /**
  14543. * Gets the name of the particle vertex shader
  14544. */
  14545. vertexShaderName: string;
  14546. /**
  14547. * Adds a new color gradient
  14548. * @param gradient defines the gradient to use (between 0 and 1)
  14549. * @param color1 defines the color to affect to the specified gradient
  14550. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14551. * @returns the current particle system
  14552. */
  14553. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14554. /**
  14555. * Remove a specific color gradient
  14556. * @param gradient defines the gradient to remove
  14557. * @returns the current particle system
  14558. */
  14559. removeColorGradient(gradient: number): IParticleSystem;
  14560. /**
  14561. * Adds a new size gradient
  14562. * @param gradient defines the gradient to use (between 0 and 1)
  14563. * @param factor defines the size factor 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14568. /**
  14569. * Remove a specific size gradient
  14570. * @param gradient defines the gradient to remove
  14571. * @returns the current particle system
  14572. */
  14573. removeSizeGradient(gradient: number): IParticleSystem;
  14574. /**
  14575. * Gets the current list of color gradients.
  14576. * You must use addColorGradient and removeColorGradient to udpate this list
  14577. * @returns the list of color gradients
  14578. */
  14579. getColorGradients(): Nullable<Array<ColorGradient>>;
  14580. /**
  14581. * Gets the current list of size gradients.
  14582. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14583. * @returns the list of size gradients
  14584. */
  14585. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14586. /**
  14587. * Gets the current list of angular speed gradients.
  14588. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14589. * @returns the list of angular speed gradients
  14590. */
  14591. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Adds a new angular speed gradient
  14594. * @param gradient defines the gradient to use (between 0 and 1)
  14595. * @param factor defines the angular speed to affect to the specified gradient
  14596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14597. * @returns the current particle system
  14598. */
  14599. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14600. /**
  14601. * Remove a specific angular speed gradient
  14602. * @param gradient defines the gradient to remove
  14603. * @returns the current particle system
  14604. */
  14605. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14606. /**
  14607. * Gets the current list of velocity gradients.
  14608. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14609. * @returns the list of velocity gradients
  14610. */
  14611. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14612. /**
  14613. * Adds a new velocity gradient
  14614. * @param gradient defines the gradient to use (between 0 and 1)
  14615. * @param factor defines the velocity to affect to the specified gradient
  14616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14617. * @returns the current particle system
  14618. */
  14619. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14620. /**
  14621. * Remove a specific velocity gradient
  14622. * @param gradient defines the gradient to remove
  14623. * @returns the current particle system
  14624. */
  14625. removeVelocityGradient(gradient: number): IParticleSystem;
  14626. /**
  14627. * Gets the current list of limit velocity gradients.
  14628. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14629. * @returns the list of limit velocity gradients
  14630. */
  14631. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Adds a new limit velocity gradient
  14634. * @param gradient defines the gradient to use (between 0 and 1)
  14635. * @param factor defines the limit velocity to affect to the specified gradient
  14636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14637. * @returns the current particle system
  14638. */
  14639. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14640. /**
  14641. * Remove a specific limit velocity gradient
  14642. * @param gradient defines the gradient to remove
  14643. * @returns the current particle system
  14644. */
  14645. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14646. /**
  14647. * Adds a new drag gradient
  14648. * @param gradient defines the gradient to use (between 0 and 1)
  14649. * @param factor defines the drag to affect to the specified gradient
  14650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14651. * @returns the current particle system
  14652. */
  14653. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14654. /**
  14655. * Remove a specific drag gradient
  14656. * @param gradient defines the gradient to remove
  14657. * @returns the current particle system
  14658. */
  14659. removeDragGradient(gradient: number): IParticleSystem;
  14660. /**
  14661. * Gets the current list of drag gradients.
  14662. * You must use addDragGradient and removeDragGradient to udpate this list
  14663. * @returns the list of drag gradients
  14664. */
  14665. getDragGradients(): Nullable<Array<FactorGradient>>;
  14666. /**
  14667. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14668. * @param gradient defines the gradient to use (between 0 and 1)
  14669. * @param factor defines the emit rate to affect to the specified gradient
  14670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14671. * @returns the current particle system
  14672. */
  14673. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14674. /**
  14675. * Remove a specific emit rate gradient
  14676. * @param gradient defines the gradient to remove
  14677. * @returns the current particle system
  14678. */
  14679. removeEmitRateGradient(gradient: number): IParticleSystem;
  14680. /**
  14681. * Gets the current list of emit rate gradients.
  14682. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14683. * @returns the list of emit rate gradients
  14684. */
  14685. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14686. /**
  14687. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14688. * @param gradient defines the gradient to use (between 0 and 1)
  14689. * @param factor defines the start size to affect to the specified gradient
  14690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14691. * @returns the current particle system
  14692. */
  14693. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14694. /**
  14695. * Remove a specific start size gradient
  14696. * @param gradient defines the gradient to remove
  14697. * @returns the current particle system
  14698. */
  14699. removeStartSizeGradient(gradient: number): IParticleSystem;
  14700. /**
  14701. * Gets the current list of start size gradients.
  14702. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14703. * @returns the list of start size gradients
  14704. */
  14705. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14706. /**
  14707. * Adds a new life time gradient
  14708. * @param gradient defines the gradient to use (between 0 and 1)
  14709. * @param factor defines the life time factor to affect to the specified gradient
  14710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14711. * @returns the current particle system
  14712. */
  14713. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14714. /**
  14715. * Remove a specific life time gradient
  14716. * @param gradient defines the gradient to remove
  14717. * @returns the current particle system
  14718. */
  14719. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14720. /**
  14721. * Gets the current list of life time gradients.
  14722. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14723. * @returns the list of life time gradients
  14724. */
  14725. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14726. /**
  14727. * Gets the current list of color gradients.
  14728. * You must use addColorGradient and removeColorGradient to udpate this list
  14729. * @returns the list of color gradients
  14730. */
  14731. getColorGradients(): Nullable<Array<ColorGradient>>;
  14732. /**
  14733. * Adds a new ramp gradient used to remap particle colors
  14734. * @param gradient defines the gradient to use (between 0 and 1)
  14735. * @param color defines the color to affect to the specified gradient
  14736. * @returns the current particle system
  14737. */
  14738. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14739. /**
  14740. * Gets the current list of ramp gradients.
  14741. * You must use addRampGradient and removeRampGradient to udpate this list
  14742. * @returns the list of ramp gradients
  14743. */
  14744. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14745. /** Gets or sets a boolean indicating that ramp gradients must be used
  14746. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14747. */
  14748. useRampGradients: boolean;
  14749. /**
  14750. * Adds a new color remap gradient
  14751. * @param gradient defines the gradient to use (between 0 and 1)
  14752. * @param min defines the color remap minimal range
  14753. * @param max defines the color remap maximal range
  14754. * @returns the current particle system
  14755. */
  14756. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14757. /**
  14758. * Gets the current list of color remap gradients.
  14759. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14760. * @returns the list of color remap gradients
  14761. */
  14762. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14763. /**
  14764. * Adds a new alpha remap gradient
  14765. * @param gradient defines the gradient to use (between 0 and 1)
  14766. * @param min defines the alpha remap minimal range
  14767. * @param max defines the alpha remap maximal range
  14768. * @returns the current particle system
  14769. */
  14770. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14771. /**
  14772. * Gets the current list of alpha remap gradients.
  14773. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14774. * @returns the list of alpha remap gradients
  14775. */
  14776. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14777. /**
  14778. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14779. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14780. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14781. * @returns the emitter
  14782. */
  14783. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14784. /**
  14785. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14786. * @param radius The radius of the hemisphere to emit from
  14787. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14788. * @returns the emitter
  14789. */
  14790. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14791. /**
  14792. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14793. * @param radius The radius of the sphere to emit from
  14794. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14795. * @returns the emitter
  14796. */
  14797. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14798. /**
  14799. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14800. * @param radius The radius of the sphere to emit from
  14801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14803. * @returns the emitter
  14804. */
  14805. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14806. /**
  14807. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14808. * @param radius The radius of the emission cylinder
  14809. * @param height The height of the emission cylinder
  14810. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14811. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14812. * @returns the emitter
  14813. */
  14814. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14815. /**
  14816. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14817. * @param radius The radius of the cylinder to emit from
  14818. * @param height The height of the emission cylinder
  14819. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14822. * @returns the emitter
  14823. */
  14824. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14825. /**
  14826. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14827. * @param radius The radius of the cone to emit from
  14828. * @param angle The base angle of the cone
  14829. * @returns the emitter
  14830. */
  14831. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14832. /**
  14833. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14836. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14837. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14838. * @returns the emitter
  14839. */
  14840. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14841. /**
  14842. * Get hosting scene
  14843. * @returns the scene
  14844. */
  14845. getScene(): Scene;
  14846. }
  14847. }
  14848. declare module "babylonjs/Meshes/transformNode" {
  14849. import { DeepImmutable } from "babylonjs/types";
  14850. import { Observable } from "babylonjs/Misc/observable";
  14851. import { Nullable } from "babylonjs/types";
  14852. import { Camera } from "babylonjs/Cameras/camera";
  14853. import { Scene } from "babylonjs/scene";
  14854. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14855. import { Node } from "babylonjs/node";
  14856. import { Bone } from "babylonjs/Bones/bone";
  14857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14858. import { Space } from "babylonjs/Maths/math.axis";
  14859. /**
  14860. * 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.
  14861. * @see https://doc.babylonjs.com/how_to/transformnode
  14862. */
  14863. export class TransformNode extends Node {
  14864. /**
  14865. * Object will not rotate to face the camera
  14866. */
  14867. static BILLBOARDMODE_NONE: number;
  14868. /**
  14869. * Object will rotate to face the camera but only on the x axis
  14870. */
  14871. static BILLBOARDMODE_X: number;
  14872. /**
  14873. * Object will rotate to face the camera but only on the y axis
  14874. */
  14875. static BILLBOARDMODE_Y: number;
  14876. /**
  14877. * Object will rotate to face the camera but only on the z axis
  14878. */
  14879. static BILLBOARDMODE_Z: number;
  14880. /**
  14881. * Object will rotate to face the camera
  14882. */
  14883. static BILLBOARDMODE_ALL: number;
  14884. /**
  14885. * Object will rotate to face the camera's position instead of orientation
  14886. */
  14887. static BILLBOARDMODE_USE_POSITION: number;
  14888. private static _TmpRotation;
  14889. private static _TmpScaling;
  14890. private static _TmpTranslation;
  14891. private _forward;
  14892. private _forwardInverted;
  14893. private _up;
  14894. private _right;
  14895. private _rightInverted;
  14896. private _position;
  14897. private _rotation;
  14898. private _rotationQuaternion;
  14899. protected _scaling: Vector3;
  14900. protected _isDirty: boolean;
  14901. private _transformToBoneReferal;
  14902. private _isAbsoluteSynced;
  14903. private _billboardMode;
  14904. /**
  14905. * Gets or sets the billboard mode. Default is 0.
  14906. *
  14907. * | Value | Type | Description |
  14908. * | --- | --- | --- |
  14909. * | 0 | BILLBOARDMODE_NONE | |
  14910. * | 1 | BILLBOARDMODE_X | |
  14911. * | 2 | BILLBOARDMODE_Y | |
  14912. * | 4 | BILLBOARDMODE_Z | |
  14913. * | 7 | BILLBOARDMODE_ALL | |
  14914. *
  14915. */
  14916. get billboardMode(): number;
  14917. set billboardMode(value: number);
  14918. private _preserveParentRotationForBillboard;
  14919. /**
  14920. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14921. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14922. */
  14923. get preserveParentRotationForBillboard(): boolean;
  14924. set preserveParentRotationForBillboard(value: boolean);
  14925. /**
  14926. * 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
  14927. */
  14928. scalingDeterminant: number;
  14929. private _infiniteDistance;
  14930. /**
  14931. * Gets or sets the distance of the object to max, often used by skybox
  14932. */
  14933. get infiniteDistance(): boolean;
  14934. set infiniteDistance(value: boolean);
  14935. /**
  14936. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14937. * By default the system will update normals to compensate
  14938. */
  14939. ignoreNonUniformScaling: boolean;
  14940. /**
  14941. * 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
  14942. */
  14943. reIntegrateRotationIntoRotationQuaternion: boolean;
  14944. /** @hidden */
  14945. _poseMatrix: Nullable<Matrix>;
  14946. /** @hidden */
  14947. _localMatrix: Matrix;
  14948. private _usePivotMatrix;
  14949. private _absolutePosition;
  14950. private _absoluteScaling;
  14951. private _absoluteRotationQuaternion;
  14952. private _pivotMatrix;
  14953. private _pivotMatrixInverse;
  14954. protected _postMultiplyPivotMatrix: boolean;
  14955. protected _isWorldMatrixFrozen: boolean;
  14956. /** @hidden */
  14957. _indexInSceneTransformNodesArray: number;
  14958. /**
  14959. * An event triggered after the world matrix is updated
  14960. */
  14961. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14962. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14963. /**
  14964. * Gets a string identifying the name of the class
  14965. * @returns "TransformNode" string
  14966. */
  14967. getClassName(): string;
  14968. /**
  14969. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14970. */
  14971. get position(): Vector3;
  14972. set position(newPosition: Vector3);
  14973. /**
  14974. * 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)).
  14975. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14976. */
  14977. get rotation(): Vector3;
  14978. set rotation(newRotation: Vector3);
  14979. /**
  14980. * 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)).
  14981. */
  14982. get scaling(): Vector3;
  14983. set scaling(newScaling: Vector3);
  14984. /**
  14985. * 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).
  14986. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14987. */
  14988. get rotationQuaternion(): Nullable<Quaternion>;
  14989. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14990. /**
  14991. * The forward direction of that transform in world space.
  14992. */
  14993. get forward(): Vector3;
  14994. /**
  14995. * The up direction of that transform in world space.
  14996. */
  14997. get up(): Vector3;
  14998. /**
  14999. * The right direction of that transform in world space.
  15000. */
  15001. get right(): Vector3;
  15002. /**
  15003. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15004. * @param matrix the matrix to copy the pose from
  15005. * @returns this TransformNode.
  15006. */
  15007. updatePoseMatrix(matrix: Matrix): TransformNode;
  15008. /**
  15009. * Returns the mesh Pose matrix.
  15010. * @returns the pose matrix
  15011. */
  15012. getPoseMatrix(): Matrix;
  15013. /** @hidden */
  15014. _isSynchronized(): boolean;
  15015. /** @hidden */
  15016. _initCache(): void;
  15017. /**
  15018. * Flag the transform node as dirty (Forcing it to update everything)
  15019. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15020. * @returns this transform node
  15021. */
  15022. markAsDirty(property: string): TransformNode;
  15023. /**
  15024. * Returns the current mesh absolute position.
  15025. * Returns a Vector3.
  15026. */
  15027. get absolutePosition(): Vector3;
  15028. /**
  15029. * Returns the current mesh absolute scaling.
  15030. * Returns a Vector3.
  15031. */
  15032. get absoluteScaling(): Vector3;
  15033. /**
  15034. * Returns the current mesh absolute rotation.
  15035. * Returns a Quaternion.
  15036. */
  15037. get absoluteRotationQuaternion(): Quaternion;
  15038. /**
  15039. * Sets a new matrix to apply before all other transformation
  15040. * @param matrix defines the transform matrix
  15041. * @returns the current TransformNode
  15042. */
  15043. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15044. /**
  15045. * Sets a new pivot matrix to the current node
  15046. * @param matrix defines the new pivot matrix to use
  15047. * @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
  15048. * @returns the current TransformNode
  15049. */
  15050. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15051. /**
  15052. * Returns the mesh pivot matrix.
  15053. * Default : Identity.
  15054. * @returns the matrix
  15055. */
  15056. getPivotMatrix(): Matrix;
  15057. /**
  15058. * Instantiate (when possible) or clone that node with its hierarchy
  15059. * @param newParent defines the new parent to use for the instance (or clone)
  15060. * @param options defines options to configure how copy is done
  15061. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15062. * @returns an instance (or a clone) of the current node with its hiearchy
  15063. */
  15064. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15065. doNotInstantiate: boolean;
  15066. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15067. /**
  15068. * Prevents the World matrix to be computed any longer
  15069. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15070. * @returns the TransformNode.
  15071. */
  15072. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15073. /**
  15074. * Allows back the World matrix computation.
  15075. * @returns the TransformNode.
  15076. */
  15077. unfreezeWorldMatrix(): this;
  15078. /**
  15079. * True if the World matrix has been frozen.
  15080. */
  15081. get isWorldMatrixFrozen(): boolean;
  15082. /**
  15083. * Retuns the mesh absolute position in the World.
  15084. * @returns a Vector3.
  15085. */
  15086. getAbsolutePosition(): Vector3;
  15087. /**
  15088. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15089. * @param absolutePosition the absolute position to set
  15090. * @returns the TransformNode.
  15091. */
  15092. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15093. /**
  15094. * Sets the mesh position in its local space.
  15095. * @param vector3 the position to set in localspace
  15096. * @returns the TransformNode.
  15097. */
  15098. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15099. /**
  15100. * Returns the mesh position in the local space from the current World matrix values.
  15101. * @returns a new Vector3.
  15102. */
  15103. getPositionExpressedInLocalSpace(): Vector3;
  15104. /**
  15105. * Translates the mesh along the passed Vector3 in its local space.
  15106. * @param vector3 the distance to translate in localspace
  15107. * @returns the TransformNode.
  15108. */
  15109. locallyTranslate(vector3: Vector3): TransformNode;
  15110. private static _lookAtVectorCache;
  15111. /**
  15112. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15113. * @param targetPoint the position (must be in same space as current mesh) to look at
  15114. * @param yawCor optional yaw (y-axis) correction in radians
  15115. * @param pitchCor optional pitch (x-axis) correction in radians
  15116. * @param rollCor optional roll (z-axis) correction in radians
  15117. * @param space the choosen space of the target
  15118. * @returns the TransformNode.
  15119. */
  15120. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15121. /**
  15122. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15123. * This Vector3 is expressed in the World space.
  15124. * @param localAxis axis to rotate
  15125. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15126. */
  15127. getDirection(localAxis: Vector3): Vector3;
  15128. /**
  15129. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15130. * localAxis is expressed in the mesh local space.
  15131. * result is computed in the Wordl space from the mesh World matrix.
  15132. * @param localAxis axis to rotate
  15133. * @param result the resulting transformnode
  15134. * @returns this TransformNode.
  15135. */
  15136. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15137. /**
  15138. * Sets this transform node rotation to the given local axis.
  15139. * @param localAxis the axis in local space
  15140. * @param yawCor optional yaw (y-axis) correction in radians
  15141. * @param pitchCor optional pitch (x-axis) correction in radians
  15142. * @param rollCor optional roll (z-axis) correction in radians
  15143. * @returns this TransformNode
  15144. */
  15145. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15146. /**
  15147. * Sets a new pivot point to the current node
  15148. * @param point defines the new pivot point to use
  15149. * @param space defines if the point is in world or local space (local by default)
  15150. * @returns the current TransformNode
  15151. */
  15152. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15153. /**
  15154. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15155. * @returns the pivot point
  15156. */
  15157. getPivotPoint(): Vector3;
  15158. /**
  15159. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15160. * @param result the vector3 to store the result
  15161. * @returns this TransformNode.
  15162. */
  15163. getPivotPointToRef(result: Vector3): TransformNode;
  15164. /**
  15165. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15166. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15167. */
  15168. getAbsolutePivotPoint(): Vector3;
  15169. /**
  15170. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15171. * @param result vector3 to store the result
  15172. * @returns this TransformNode.
  15173. */
  15174. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15175. /**
  15176. * Defines the passed node as the parent of the current node.
  15177. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15178. * @see https://doc.babylonjs.com/how_to/parenting
  15179. * @param node the node ot set as the parent
  15180. * @returns this TransformNode.
  15181. */
  15182. setParent(node: Nullable<Node>): TransformNode;
  15183. private _nonUniformScaling;
  15184. /**
  15185. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15186. */
  15187. get nonUniformScaling(): boolean;
  15188. /** @hidden */
  15189. _updateNonUniformScalingState(value: boolean): boolean;
  15190. /**
  15191. * Attach the current TransformNode to another TransformNode associated with a bone
  15192. * @param bone Bone affecting the TransformNode
  15193. * @param affectedTransformNode TransformNode associated with the bone
  15194. * @returns this object
  15195. */
  15196. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15197. /**
  15198. * Detach the transform node if its associated with a bone
  15199. * @returns this object
  15200. */
  15201. detachFromBone(): TransformNode;
  15202. private static _rotationAxisCache;
  15203. /**
  15204. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15205. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15206. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15207. * The passed axis is also normalized.
  15208. * @param axis the axis to rotate around
  15209. * @param amount the amount to rotate in radians
  15210. * @param space Space to rotate in (Default: local)
  15211. * @returns the TransformNode.
  15212. */
  15213. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15214. /**
  15215. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15216. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15217. * The passed axis is also normalized. .
  15218. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15219. * @param point the point to rotate around
  15220. * @param axis the axis to rotate around
  15221. * @param amount the amount to rotate in radians
  15222. * @returns the TransformNode
  15223. */
  15224. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15225. /**
  15226. * Translates the mesh along the axis vector for the passed distance in the given space.
  15227. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15228. * @param axis the axis to translate in
  15229. * @param distance the distance to translate
  15230. * @param space Space to rotate in (Default: local)
  15231. * @returns the TransformNode.
  15232. */
  15233. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15234. /**
  15235. * Adds a rotation step to the mesh current rotation.
  15236. * x, y, z are Euler angles expressed in radians.
  15237. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15238. * This means this rotation is made in the mesh local space only.
  15239. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15240. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15241. * ```javascript
  15242. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15243. * ```
  15244. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15245. * 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.
  15246. * @param x Rotation to add
  15247. * @param y Rotation to add
  15248. * @param z Rotation to add
  15249. * @returns the TransformNode.
  15250. */
  15251. addRotation(x: number, y: number, z: number): TransformNode;
  15252. /**
  15253. * @hidden
  15254. */
  15255. protected _getEffectiveParent(): Nullable<Node>;
  15256. /**
  15257. * Computes the world matrix of the node
  15258. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15259. * @returns the world matrix
  15260. */
  15261. computeWorldMatrix(force?: boolean): Matrix;
  15262. /**
  15263. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15264. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15265. */
  15266. resetLocalMatrix(independentOfChildren?: boolean): void;
  15267. protected _afterComputeWorldMatrix(): void;
  15268. /**
  15269. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15270. * @param func callback function to add
  15271. *
  15272. * @returns the TransformNode.
  15273. */
  15274. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15275. /**
  15276. * Removes a registered callback function.
  15277. * @param func callback function to remove
  15278. * @returns the TransformNode.
  15279. */
  15280. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15281. /**
  15282. * Gets the position of the current mesh in camera space
  15283. * @param camera defines the camera to use
  15284. * @returns a position
  15285. */
  15286. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15287. /**
  15288. * Returns the distance from the mesh to the active camera
  15289. * @param camera defines the camera to use
  15290. * @returns the distance
  15291. */
  15292. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15293. /**
  15294. * Clone the current transform node
  15295. * @param name Name of the new clone
  15296. * @param newParent New parent for the clone
  15297. * @param doNotCloneChildren Do not clone children hierarchy
  15298. * @returns the new transform node
  15299. */
  15300. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15301. /**
  15302. * Serializes the objects information.
  15303. * @param currentSerializationObject defines the object to serialize in
  15304. * @returns the serialized object
  15305. */
  15306. serialize(currentSerializationObject?: any): any;
  15307. /**
  15308. * Returns a new TransformNode object parsed from the source provided.
  15309. * @param parsedTransformNode is the source.
  15310. * @param scene the scne the object belongs to
  15311. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15312. * @returns a new TransformNode object parsed from the source provided.
  15313. */
  15314. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15315. /**
  15316. * Get all child-transformNodes of this node
  15317. * @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
  15318. * @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
  15319. * @returns an array of TransformNode
  15320. */
  15321. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15322. /**
  15323. * Releases resources associated with this transform node.
  15324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15326. */
  15327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15328. /**
  15329. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15330. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15331. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15332. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15333. * @returns the current mesh
  15334. */
  15335. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15336. private _syncAbsoluteScalingAndRotation;
  15337. }
  15338. }
  15339. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15340. /**
  15341. * Class used to override all child animations of a given target
  15342. */
  15343. export class AnimationPropertiesOverride {
  15344. /**
  15345. * Gets or sets a value indicating if animation blending must be used
  15346. */
  15347. enableBlending: boolean;
  15348. /**
  15349. * Gets or sets the blending speed to use when enableBlending is true
  15350. */
  15351. blendingSpeed: number;
  15352. /**
  15353. * Gets or sets the default loop mode to use
  15354. */
  15355. loopMode: number;
  15356. }
  15357. }
  15358. declare module "babylonjs/Bones/bone" {
  15359. import { Skeleton } from "babylonjs/Bones/skeleton";
  15360. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15361. import { Nullable } from "babylonjs/types";
  15362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15363. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15364. import { Node } from "babylonjs/node";
  15365. import { Space } from "babylonjs/Maths/math.axis";
  15366. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15367. /**
  15368. * Class used to store bone information
  15369. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15370. */
  15371. export class Bone extends Node {
  15372. /**
  15373. * defines the bone name
  15374. */
  15375. name: string;
  15376. private static _tmpVecs;
  15377. private static _tmpQuat;
  15378. private static _tmpMats;
  15379. /**
  15380. * Gets the list of child bones
  15381. */
  15382. children: Bone[];
  15383. /** Gets the animations associated with this bone */
  15384. animations: import("babylonjs/Animations/animation").Animation[];
  15385. /**
  15386. * Gets or sets bone length
  15387. */
  15388. length: number;
  15389. /**
  15390. * @hidden Internal only
  15391. * Set this value to map this bone to a different index in the transform matrices
  15392. * Set this value to -1 to exclude the bone from the transform matrices
  15393. */
  15394. _index: Nullable<number>;
  15395. private _skeleton;
  15396. private _localMatrix;
  15397. private _restPose;
  15398. private _baseMatrix;
  15399. private _absoluteTransform;
  15400. private _invertedAbsoluteTransform;
  15401. private _parent;
  15402. private _scalingDeterminant;
  15403. private _worldTransform;
  15404. private _localScaling;
  15405. private _localRotation;
  15406. private _localPosition;
  15407. private _needToDecompose;
  15408. private _needToCompose;
  15409. /** @hidden */
  15410. _linkedTransformNode: Nullable<TransformNode>;
  15411. /** @hidden */
  15412. _waitingTransformNodeId: Nullable<string>;
  15413. /** @hidden */
  15414. get _matrix(): Matrix;
  15415. /** @hidden */
  15416. set _matrix(value: Matrix);
  15417. /**
  15418. * Create a new bone
  15419. * @param name defines the bone name
  15420. * @param skeleton defines the parent skeleton
  15421. * @param parentBone defines the parent (can be null if the bone is the root)
  15422. * @param localMatrix defines the local matrix
  15423. * @param restPose defines the rest pose matrix
  15424. * @param baseMatrix defines the base matrix
  15425. * @param index defines index of the bone in the hiearchy
  15426. */
  15427. constructor(
  15428. /**
  15429. * defines the bone name
  15430. */
  15431. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15432. /**
  15433. * Gets the current object class name.
  15434. * @return the class name
  15435. */
  15436. getClassName(): string;
  15437. /**
  15438. * Gets the parent skeleton
  15439. * @returns a skeleton
  15440. */
  15441. getSkeleton(): Skeleton;
  15442. /**
  15443. * Gets parent bone
  15444. * @returns a bone or null if the bone is the root of the bone hierarchy
  15445. */
  15446. getParent(): Nullable<Bone>;
  15447. /**
  15448. * Returns an array containing the root bones
  15449. * @returns an array containing the root bones
  15450. */
  15451. getChildren(): Array<Bone>;
  15452. /**
  15453. * Gets the node index in matrix array generated for rendering
  15454. * @returns the node index
  15455. */
  15456. getIndex(): number;
  15457. /**
  15458. * Sets the parent bone
  15459. * @param parent defines the parent (can be null if the bone is the root)
  15460. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15461. */
  15462. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15463. /**
  15464. * Gets the local matrix
  15465. * @returns a matrix
  15466. */
  15467. getLocalMatrix(): Matrix;
  15468. /**
  15469. * Gets the base matrix (initial matrix which remains unchanged)
  15470. * @returns a matrix
  15471. */
  15472. getBaseMatrix(): Matrix;
  15473. /**
  15474. * Gets the rest pose matrix
  15475. * @returns a matrix
  15476. */
  15477. getRestPose(): Matrix;
  15478. /**
  15479. * Sets the rest pose matrix
  15480. * @param matrix the local-space rest pose to set for this bone
  15481. */
  15482. setRestPose(matrix: Matrix): void;
  15483. /**
  15484. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15485. */
  15486. getWorldMatrix(): Matrix;
  15487. /**
  15488. * Sets the local matrix to rest pose matrix
  15489. */
  15490. returnToRest(): void;
  15491. /**
  15492. * Gets the inverse of the absolute transform matrix.
  15493. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15494. * @returns a matrix
  15495. */
  15496. getInvertedAbsoluteTransform(): Matrix;
  15497. /**
  15498. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15499. * @returns a matrix
  15500. */
  15501. getAbsoluteTransform(): Matrix;
  15502. /**
  15503. * Links with the given transform node.
  15504. * The local matrix of this bone is copied from the transform node every frame.
  15505. * @param transformNode defines the transform node to link to
  15506. */
  15507. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15508. /**
  15509. * Gets the node used to drive the bone's transformation
  15510. * @returns a transform node or null
  15511. */
  15512. getTransformNode(): Nullable<TransformNode>;
  15513. /** Gets or sets current position (in local space) */
  15514. get position(): Vector3;
  15515. set position(newPosition: Vector3);
  15516. /** Gets or sets current rotation (in local space) */
  15517. get rotation(): Vector3;
  15518. set rotation(newRotation: Vector3);
  15519. /** Gets or sets current rotation quaternion (in local space) */
  15520. get rotationQuaternion(): Quaternion;
  15521. set rotationQuaternion(newRotation: Quaternion);
  15522. /** Gets or sets current scaling (in local space) */
  15523. get scaling(): Vector3;
  15524. set scaling(newScaling: Vector3);
  15525. /**
  15526. * Gets the animation properties override
  15527. */
  15528. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15529. private _decompose;
  15530. private _compose;
  15531. /**
  15532. * Update the base and local matrices
  15533. * @param matrix defines the new base or local matrix
  15534. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15535. * @param updateLocalMatrix defines if the local matrix should be updated
  15536. */
  15537. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15538. /** @hidden */
  15539. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15540. /**
  15541. * Flag the bone as dirty (Forcing it to update everything)
  15542. */
  15543. markAsDirty(): void;
  15544. /** @hidden */
  15545. _markAsDirtyAndCompose(): void;
  15546. private _markAsDirtyAndDecompose;
  15547. /**
  15548. * Translate the bone in local or world space
  15549. * @param vec The amount to translate the bone
  15550. * @param space The space that the translation is in
  15551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15552. */
  15553. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15554. /**
  15555. * Set the postion of the bone in local or world space
  15556. * @param position The position to set the bone
  15557. * @param space The space that the position is in
  15558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15559. */
  15560. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15561. /**
  15562. * Set the absolute position of the bone (world space)
  15563. * @param position The position to set the bone
  15564. * @param mesh The mesh that this bone is attached to
  15565. */
  15566. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15567. /**
  15568. * Scale the bone on the x, y and z axes (in local space)
  15569. * @param x The amount to scale the bone on the x axis
  15570. * @param y The amount to scale the bone on the y axis
  15571. * @param z The amount to scale the bone on the z axis
  15572. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15573. */
  15574. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15575. /**
  15576. * Set the bone scaling in local space
  15577. * @param scale defines the scaling vector
  15578. */
  15579. setScale(scale: Vector3): void;
  15580. /**
  15581. * Gets the current scaling in local space
  15582. * @returns the current scaling vector
  15583. */
  15584. getScale(): Vector3;
  15585. /**
  15586. * Gets the current scaling in local space and stores it in a target vector
  15587. * @param result defines the target vector
  15588. */
  15589. getScaleToRef(result: Vector3): void;
  15590. /**
  15591. * Set the yaw, pitch, and roll of the bone in local or world space
  15592. * @param yaw The rotation of the bone on the y axis
  15593. * @param pitch The rotation of the bone on the x axis
  15594. * @param roll The rotation of the bone on the z axis
  15595. * @param space The space that the axes of rotation are in
  15596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15597. */
  15598. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15599. /**
  15600. * Add a rotation to the bone on an axis in local or world space
  15601. * @param axis The axis to rotate the bone on
  15602. * @param amount The amount to rotate the bone
  15603. * @param space The space that the axis is in
  15604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15605. */
  15606. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15607. /**
  15608. * Set the rotation of the bone to a particular axis angle in local or world space
  15609. * @param axis The axis to rotate the bone on
  15610. * @param angle The angle that the bone should be rotated to
  15611. * @param space The space that the axis is in
  15612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15613. */
  15614. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15615. /**
  15616. * Set the euler rotation of the bone in local of world space
  15617. * @param rotation The euler rotation that the bone should be set to
  15618. * @param space The space that the rotation is in
  15619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15620. */
  15621. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15622. /**
  15623. * Set the quaternion rotation of the bone in local of world space
  15624. * @param quat The quaternion rotation that the bone should be set to
  15625. * @param space The space that the rotation is in
  15626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15627. */
  15628. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15629. /**
  15630. * Set the rotation matrix of the bone in local of world space
  15631. * @param rotMat The rotation matrix that the bone should be set to
  15632. * @param space The space that the rotation is in
  15633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15634. */
  15635. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15636. private _rotateWithMatrix;
  15637. private _getNegativeRotationToRef;
  15638. /**
  15639. * Get the position of the bone in local or world space
  15640. * @param space The space that the returned position is in
  15641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15642. * @returns The position of the bone
  15643. */
  15644. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15645. /**
  15646. * Copy the position of the bone to a vector3 in local or world space
  15647. * @param space The space that the returned position is in
  15648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15649. * @param result The vector3 to copy the position to
  15650. */
  15651. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15652. /**
  15653. * Get the absolute position of the bone (world space)
  15654. * @param mesh The mesh that this bone is attached to
  15655. * @returns The absolute position of the bone
  15656. */
  15657. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15658. /**
  15659. * Copy the absolute position of the bone (world space) to the result param
  15660. * @param mesh The mesh that this bone is attached to
  15661. * @param result The vector3 to copy the absolute position to
  15662. */
  15663. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15664. /**
  15665. * Compute the absolute transforms of this bone and its children
  15666. */
  15667. computeAbsoluteTransforms(): void;
  15668. /**
  15669. * Get the world direction from an axis that is in the local space of the bone
  15670. * @param localAxis The local direction that is used to compute the world direction
  15671. * @param mesh The mesh that this bone is attached to
  15672. * @returns The world direction
  15673. */
  15674. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15675. /**
  15676. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15677. * @param localAxis The local direction that is used to compute the world direction
  15678. * @param mesh The mesh that this bone is attached to
  15679. * @param result The vector3 that the world direction will be copied to
  15680. */
  15681. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15682. /**
  15683. * Get the euler rotation of the bone in local or world space
  15684. * @param space The space that the rotation should be in
  15685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15686. * @returns The euler rotation
  15687. */
  15688. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15689. /**
  15690. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15691. * @param space The space that the rotation should be in
  15692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15693. * @param result The vector3 that the rotation should be copied to
  15694. */
  15695. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15696. /**
  15697. * Get the quaternion rotation of the bone in either local or world space
  15698. * @param space The space that the rotation should be in
  15699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15700. * @returns The quaternion rotation
  15701. */
  15702. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15703. /**
  15704. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15705. * @param space The space that the rotation should be in
  15706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15707. * @param result The quaternion that the rotation should be copied to
  15708. */
  15709. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15710. /**
  15711. * Get the rotation matrix of the bone in local or world space
  15712. * @param space The space that the rotation should be in
  15713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15714. * @returns The rotation matrix
  15715. */
  15716. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15717. /**
  15718. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15719. * @param space The space that the rotation should be in
  15720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15721. * @param result The quaternion that the rotation should be copied to
  15722. */
  15723. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15724. /**
  15725. * Get the world position of a point that is in the local space of the bone
  15726. * @param position The local position
  15727. * @param mesh The mesh that this bone is attached to
  15728. * @returns The world position
  15729. */
  15730. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15731. /**
  15732. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15733. * @param position The local position
  15734. * @param mesh The mesh that this bone is attached to
  15735. * @param result The vector3 that the world position should be copied to
  15736. */
  15737. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15738. /**
  15739. * Get the local position of a point that is in world space
  15740. * @param position The world position
  15741. * @param mesh The mesh that this bone is attached to
  15742. * @returns The local position
  15743. */
  15744. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15745. /**
  15746. * Get the local position of a point that is in world space and copy it to the result param
  15747. * @param position The world position
  15748. * @param mesh The mesh that this bone is attached to
  15749. * @param result The vector3 that the local position should be copied to
  15750. */
  15751. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15752. }
  15753. }
  15754. declare module "babylonjs/Animations/runtimeAnimation" {
  15755. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15756. import { Animatable } from "babylonjs/Animations/animatable";
  15757. import { Scene } from "babylonjs/scene";
  15758. /**
  15759. * Defines a runtime animation
  15760. */
  15761. export class RuntimeAnimation {
  15762. private _events;
  15763. /**
  15764. * The current frame of the runtime animation
  15765. */
  15766. private _currentFrame;
  15767. /**
  15768. * The animation used by the runtime animation
  15769. */
  15770. private _animation;
  15771. /**
  15772. * The target of the runtime animation
  15773. */
  15774. private _target;
  15775. /**
  15776. * The initiating animatable
  15777. */
  15778. private _host;
  15779. /**
  15780. * The original value of the runtime animation
  15781. */
  15782. private _originalValue;
  15783. /**
  15784. * The original blend value of the runtime animation
  15785. */
  15786. private _originalBlendValue;
  15787. /**
  15788. * The offsets cache of the runtime animation
  15789. */
  15790. private _offsetsCache;
  15791. /**
  15792. * The high limits cache of the runtime animation
  15793. */
  15794. private _highLimitsCache;
  15795. /**
  15796. * Specifies if the runtime animation has been stopped
  15797. */
  15798. private _stopped;
  15799. /**
  15800. * The blending factor of the runtime animation
  15801. */
  15802. private _blendingFactor;
  15803. /**
  15804. * The BabylonJS scene
  15805. */
  15806. private _scene;
  15807. /**
  15808. * The current value of the runtime animation
  15809. */
  15810. private _currentValue;
  15811. /** @hidden */
  15812. _animationState: _IAnimationState;
  15813. /**
  15814. * The active target of the runtime animation
  15815. */
  15816. private _activeTargets;
  15817. private _currentActiveTarget;
  15818. private _directTarget;
  15819. /**
  15820. * The target path of the runtime animation
  15821. */
  15822. private _targetPath;
  15823. /**
  15824. * The weight of the runtime animation
  15825. */
  15826. private _weight;
  15827. /**
  15828. * The ratio offset of the runtime animation
  15829. */
  15830. private _ratioOffset;
  15831. /**
  15832. * The previous delay of the runtime animation
  15833. */
  15834. private _previousDelay;
  15835. /**
  15836. * The previous ratio of the runtime animation
  15837. */
  15838. private _previousRatio;
  15839. private _enableBlending;
  15840. private _keys;
  15841. private _minFrame;
  15842. private _maxFrame;
  15843. private _minValue;
  15844. private _maxValue;
  15845. private _targetIsArray;
  15846. /**
  15847. * Gets the current frame of the runtime animation
  15848. */
  15849. get currentFrame(): number;
  15850. /**
  15851. * Gets the weight of the runtime animation
  15852. */
  15853. get weight(): number;
  15854. /**
  15855. * Gets the current value of the runtime animation
  15856. */
  15857. get currentValue(): any;
  15858. /**
  15859. * Gets the target path of the runtime animation
  15860. */
  15861. get targetPath(): string;
  15862. /**
  15863. * Gets the actual target of the runtime animation
  15864. */
  15865. get target(): any;
  15866. /**
  15867. * Gets the additive state of the runtime animation
  15868. */
  15869. get isAdditive(): boolean;
  15870. /** @hidden */
  15871. _onLoop: () => void;
  15872. /**
  15873. * Create a new RuntimeAnimation object
  15874. * @param target defines the target of the animation
  15875. * @param animation defines the source animation object
  15876. * @param scene defines the hosting scene
  15877. * @param host defines the initiating Animatable
  15878. */
  15879. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15880. private _preparePath;
  15881. /**
  15882. * Gets the animation from the runtime animation
  15883. */
  15884. get animation(): Animation;
  15885. /**
  15886. * Resets the runtime animation to the beginning
  15887. * @param restoreOriginal defines whether to restore the target property to the original value
  15888. */
  15889. reset(restoreOriginal?: boolean): void;
  15890. /**
  15891. * Specifies if the runtime animation is stopped
  15892. * @returns Boolean specifying if the runtime animation is stopped
  15893. */
  15894. isStopped(): boolean;
  15895. /**
  15896. * Disposes of the runtime animation
  15897. */
  15898. dispose(): void;
  15899. /**
  15900. * Apply the interpolated value to the target
  15901. * @param currentValue defines the value computed by the animation
  15902. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15903. */
  15904. setValue(currentValue: any, weight: number): void;
  15905. private _getOriginalValues;
  15906. private _setValue;
  15907. /**
  15908. * Gets the loop pmode of the runtime animation
  15909. * @returns Loop Mode
  15910. */
  15911. private _getCorrectLoopMode;
  15912. /**
  15913. * Move the current animation to a given frame
  15914. * @param frame defines the frame to move to
  15915. */
  15916. goToFrame(frame: number): void;
  15917. /**
  15918. * @hidden Internal use only
  15919. */
  15920. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15921. /**
  15922. * Execute the current animation
  15923. * @param delay defines the delay to add to the current frame
  15924. * @param from defines the lower bound of the animation range
  15925. * @param to defines the upper bound of the animation range
  15926. * @param loop defines if the current animation must loop
  15927. * @param speedRatio defines the current speed ratio
  15928. * @param weight defines the weight of the animation (default is -1 so no weight)
  15929. * @param onLoop optional callback called when animation loops
  15930. * @returns a boolean indicating if the animation is running
  15931. */
  15932. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15933. }
  15934. }
  15935. declare module "babylonjs/Animations/animatable" {
  15936. import { Animation } from "babylonjs/Animations/animation";
  15937. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15938. import { Nullable } from "babylonjs/types";
  15939. import { Observable } from "babylonjs/Misc/observable";
  15940. import { Scene } from "babylonjs/scene";
  15941. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15942. import { Node } from "babylonjs/node";
  15943. /**
  15944. * Class used to store an actual running animation
  15945. */
  15946. export class Animatable {
  15947. /** defines the target object */
  15948. target: any;
  15949. /** defines the starting frame number (default is 0) */
  15950. fromFrame: number;
  15951. /** defines the ending frame number (default is 100) */
  15952. toFrame: number;
  15953. /** defines if the animation must loop (default is false) */
  15954. loopAnimation: boolean;
  15955. /** defines a callback to call when animation ends if it is not looping */
  15956. onAnimationEnd?: (() => void) | null | undefined;
  15957. /** defines a callback to call when animation loops */
  15958. onAnimationLoop?: (() => void) | null | undefined;
  15959. /** defines whether the animation should be evaluated additively */
  15960. isAdditive: boolean;
  15961. private _localDelayOffset;
  15962. private _pausedDelay;
  15963. private _runtimeAnimations;
  15964. private _paused;
  15965. private _scene;
  15966. private _speedRatio;
  15967. private _weight;
  15968. private _syncRoot;
  15969. /**
  15970. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15971. * This will only apply for non looping animation (default is true)
  15972. */
  15973. disposeOnEnd: boolean;
  15974. /**
  15975. * Gets a boolean indicating if the animation has started
  15976. */
  15977. animationStarted: boolean;
  15978. /**
  15979. * Observer raised when the animation ends
  15980. */
  15981. onAnimationEndObservable: Observable<Animatable>;
  15982. /**
  15983. * Observer raised when the animation loops
  15984. */
  15985. onAnimationLoopObservable: Observable<Animatable>;
  15986. /**
  15987. * Gets the root Animatable used to synchronize and normalize animations
  15988. */
  15989. get syncRoot(): Nullable<Animatable>;
  15990. /**
  15991. * Gets the current frame of the first RuntimeAnimation
  15992. * Used to synchronize Animatables
  15993. */
  15994. get masterFrame(): number;
  15995. /**
  15996. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15997. */
  15998. get weight(): number;
  15999. set weight(value: number);
  16000. /**
  16001. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16002. */
  16003. get speedRatio(): number;
  16004. set speedRatio(value: number);
  16005. /**
  16006. * Creates a new Animatable
  16007. * @param scene defines the hosting scene
  16008. * @param target defines the target object
  16009. * @param fromFrame defines the starting frame number (default is 0)
  16010. * @param toFrame defines the ending frame number (default is 100)
  16011. * @param loopAnimation defines if the animation must loop (default is false)
  16012. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16013. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16014. * @param animations defines a group of animation to add to the new Animatable
  16015. * @param onAnimationLoop defines a callback to call when animation loops
  16016. * @param isAdditive defines whether the animation should be evaluated additively
  16017. */
  16018. constructor(scene: Scene,
  16019. /** defines the target object */
  16020. target: any,
  16021. /** defines the starting frame number (default is 0) */
  16022. fromFrame?: number,
  16023. /** defines the ending frame number (default is 100) */
  16024. toFrame?: number,
  16025. /** defines if the animation must loop (default is false) */
  16026. loopAnimation?: boolean, speedRatio?: number,
  16027. /** defines a callback to call when animation ends if it is not looping */
  16028. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16029. /** defines a callback to call when animation loops */
  16030. onAnimationLoop?: (() => void) | null | undefined,
  16031. /** defines whether the animation should be evaluated additively */
  16032. isAdditive?: boolean);
  16033. /**
  16034. * Synchronize and normalize current Animatable with a source Animatable
  16035. * This is useful when using animation weights and when animations are not of the same length
  16036. * @param root defines the root Animatable to synchronize with
  16037. * @returns the current Animatable
  16038. */
  16039. syncWith(root: Animatable): Animatable;
  16040. /**
  16041. * Gets the list of runtime animations
  16042. * @returns an array of RuntimeAnimation
  16043. */
  16044. getAnimations(): RuntimeAnimation[];
  16045. /**
  16046. * Adds more animations to the current animatable
  16047. * @param target defines the target of the animations
  16048. * @param animations defines the new animations to add
  16049. */
  16050. appendAnimations(target: any, animations: Animation[]): void;
  16051. /**
  16052. * Gets the source animation for a specific property
  16053. * @param property defines the propertyu to look for
  16054. * @returns null or the source animation for the given property
  16055. */
  16056. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16057. /**
  16058. * Gets the runtime animation for a specific property
  16059. * @param property defines the propertyu to look for
  16060. * @returns null or the runtime animation for the given property
  16061. */
  16062. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16063. /**
  16064. * Resets the animatable to its original state
  16065. */
  16066. reset(): void;
  16067. /**
  16068. * Allows the animatable to blend with current running animations
  16069. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16070. * @param blendingSpeed defines the blending speed to use
  16071. */
  16072. enableBlending(blendingSpeed: number): void;
  16073. /**
  16074. * Disable animation blending
  16075. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16076. */
  16077. disableBlending(): void;
  16078. /**
  16079. * Jump directly to a given frame
  16080. * @param frame defines the frame to jump to
  16081. */
  16082. goToFrame(frame: number): void;
  16083. /**
  16084. * Pause the animation
  16085. */
  16086. pause(): void;
  16087. /**
  16088. * Restart the animation
  16089. */
  16090. restart(): void;
  16091. private _raiseOnAnimationEnd;
  16092. /**
  16093. * Stop and delete the current animation
  16094. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16095. * @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)
  16096. */
  16097. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16098. /**
  16099. * Wait asynchronously for the animation to end
  16100. * @returns a promise which will be fullfilled when the animation ends
  16101. */
  16102. waitAsync(): Promise<Animatable>;
  16103. /** @hidden */
  16104. _animate(delay: number): boolean;
  16105. }
  16106. module "babylonjs/scene" {
  16107. interface Scene {
  16108. /** @hidden */
  16109. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16110. /** @hidden */
  16111. _processLateAnimationBindingsForMatrices(holder: {
  16112. totalWeight: number;
  16113. totalAdditiveWeight: number;
  16114. animations: RuntimeAnimation[];
  16115. additiveAnimations: RuntimeAnimation[];
  16116. originalValue: Matrix;
  16117. }): any;
  16118. /** @hidden */
  16119. _processLateAnimationBindingsForQuaternions(holder: {
  16120. totalWeight: number;
  16121. totalAdditiveWeight: number;
  16122. animations: RuntimeAnimation[];
  16123. additiveAnimations: RuntimeAnimation[];
  16124. originalValue: Quaternion;
  16125. }, refQuaternion: Quaternion): Quaternion;
  16126. /** @hidden */
  16127. _processLateAnimationBindings(): void;
  16128. /**
  16129. * Will start the animation sequence of a given target
  16130. * @param target defines the target
  16131. * @param from defines from which frame should animation start
  16132. * @param to defines until which frame should animation run.
  16133. * @param weight defines the weight to apply to the animation (1.0 by default)
  16134. * @param loop defines if the animation loops
  16135. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16136. * @param onAnimationEnd defines the function to be executed when the animation ends
  16137. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16138. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16139. * @param onAnimationLoop defines the callback to call when an animation loops
  16140. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16141. * @returns the animatable object created for this animation
  16142. */
  16143. 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;
  16144. /**
  16145. * Will start the animation sequence of a given target
  16146. * @param target defines the target
  16147. * @param from defines from which frame should animation start
  16148. * @param to defines until which frame should animation run.
  16149. * @param loop defines if the animation loops
  16150. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16151. * @param onAnimationEnd defines the function to be executed when the animation ends
  16152. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16153. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16154. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16155. * @param onAnimationLoop defines the callback to call when an animation loops
  16156. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16157. * @returns the animatable object created for this animation
  16158. */
  16159. 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;
  16160. /**
  16161. * Will start the animation sequence of a given target and its hierarchy
  16162. * @param target defines the target
  16163. * @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.
  16164. * @param from defines from which frame should animation start
  16165. * @param to defines until which frame should animation run.
  16166. * @param loop defines if the animation loops
  16167. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16168. * @param onAnimationEnd defines the function to be executed when the animation ends
  16169. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16170. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16171. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16172. * @param onAnimationLoop defines the callback to call when an animation loops
  16173. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16174. * @returns the list of created animatables
  16175. */
  16176. 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[];
  16177. /**
  16178. * Begin a new animation on a given node
  16179. * @param target defines the target where the animation will take place
  16180. * @param animations defines the list of animations to start
  16181. * @param from defines the initial value
  16182. * @param to defines the final value
  16183. * @param loop defines if you want animation to loop (off by default)
  16184. * @param speedRatio defines the speed ratio to apply to all animations
  16185. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16186. * @param onAnimationLoop defines the callback to call when an animation loops
  16187. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16188. * @returns the list of created animatables
  16189. */
  16190. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16191. /**
  16192. * Begin a new animation on a given node and its hierarchy
  16193. * @param target defines the root node where the animation will take place
  16194. * @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.
  16195. * @param animations defines the list of animations to start
  16196. * @param from defines the initial value
  16197. * @param to defines the final value
  16198. * @param loop defines if you want animation to loop (off by default)
  16199. * @param speedRatio defines the speed ratio to apply to all animations
  16200. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16201. * @param onAnimationLoop defines the callback to call when an animation loops
  16202. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16203. * @returns the list of animatables created for all nodes
  16204. */
  16205. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16206. /**
  16207. * Gets the animatable associated with a specific target
  16208. * @param target defines the target of the animatable
  16209. * @returns the required animatable if found
  16210. */
  16211. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16212. /**
  16213. * Gets all animatables associated with a given target
  16214. * @param target defines the target to look animatables for
  16215. * @returns an array of Animatables
  16216. */
  16217. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16218. /**
  16219. * Stops and removes all animations that have been applied to the scene
  16220. */
  16221. stopAllAnimations(): void;
  16222. /**
  16223. * Gets the current delta time used by animation engine
  16224. */
  16225. deltaTime: number;
  16226. }
  16227. }
  16228. module "babylonjs/Bones/bone" {
  16229. interface Bone {
  16230. /**
  16231. * Copy an animation range from another bone
  16232. * @param source defines the source bone
  16233. * @param rangeName defines the range name to copy
  16234. * @param frameOffset defines the frame offset
  16235. * @param rescaleAsRequired defines if rescaling must be applied if required
  16236. * @param skelDimensionsRatio defines the scaling ratio
  16237. * @returns true if operation was successful
  16238. */
  16239. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16240. }
  16241. }
  16242. }
  16243. declare module "babylonjs/Bones/skeleton" {
  16244. import { Bone } from "babylonjs/Bones/bone";
  16245. import { Observable } from "babylonjs/Misc/observable";
  16246. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16247. import { Scene } from "babylonjs/scene";
  16248. import { Nullable } from "babylonjs/types";
  16249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16250. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16251. import { Animatable } from "babylonjs/Animations/animatable";
  16252. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16253. import { Animation } from "babylonjs/Animations/animation";
  16254. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16255. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16256. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16257. /**
  16258. * Class used to handle skinning animations
  16259. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16260. */
  16261. export class Skeleton implements IAnimatable {
  16262. /** defines the skeleton name */
  16263. name: string;
  16264. /** defines the skeleton Id */
  16265. id: string;
  16266. /**
  16267. * Defines the list of child bones
  16268. */
  16269. bones: Bone[];
  16270. /**
  16271. * Defines an estimate of the dimension of the skeleton at rest
  16272. */
  16273. dimensionsAtRest: Vector3;
  16274. /**
  16275. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16276. */
  16277. needInitialSkinMatrix: boolean;
  16278. /**
  16279. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16280. */
  16281. overrideMesh: Nullable<AbstractMesh>;
  16282. /**
  16283. * Gets the list of animations attached to this skeleton
  16284. */
  16285. animations: Array<Animation>;
  16286. private _scene;
  16287. private _isDirty;
  16288. private _transformMatrices;
  16289. private _transformMatrixTexture;
  16290. private _meshesWithPoseMatrix;
  16291. private _animatables;
  16292. private _identity;
  16293. private _synchronizedWithMesh;
  16294. private _ranges;
  16295. private _lastAbsoluteTransformsUpdateId;
  16296. private _canUseTextureForBones;
  16297. private _uniqueId;
  16298. /** @hidden */
  16299. _numBonesWithLinkedTransformNode: number;
  16300. /** @hidden */
  16301. _hasWaitingData: Nullable<boolean>;
  16302. /**
  16303. * Specifies if the skeleton should be serialized
  16304. */
  16305. doNotSerialize: boolean;
  16306. private _useTextureToStoreBoneMatrices;
  16307. /**
  16308. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16309. * Please note that this option is not available if the hardware does not support it
  16310. */
  16311. get useTextureToStoreBoneMatrices(): boolean;
  16312. set useTextureToStoreBoneMatrices(value: boolean);
  16313. private _animationPropertiesOverride;
  16314. /**
  16315. * Gets or sets the animation properties override
  16316. */
  16317. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16318. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16319. /**
  16320. * List of inspectable custom properties (used by the Inspector)
  16321. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16322. */
  16323. inspectableCustomProperties: IInspectable[];
  16324. /**
  16325. * An observable triggered before computing the skeleton's matrices
  16326. */
  16327. onBeforeComputeObservable: Observable<Skeleton>;
  16328. /**
  16329. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16330. */
  16331. get isUsingTextureForMatrices(): boolean;
  16332. /**
  16333. * Gets the unique ID of this skeleton
  16334. */
  16335. get uniqueId(): number;
  16336. /**
  16337. * Creates a new skeleton
  16338. * @param name defines the skeleton name
  16339. * @param id defines the skeleton Id
  16340. * @param scene defines the hosting scene
  16341. */
  16342. constructor(
  16343. /** defines the skeleton name */
  16344. name: string,
  16345. /** defines the skeleton Id */
  16346. id: string, scene: Scene);
  16347. /**
  16348. * Gets the current object class name.
  16349. * @return the class name
  16350. */
  16351. getClassName(): string;
  16352. /**
  16353. * Returns an array containing the root bones
  16354. * @returns an array containing the root bones
  16355. */
  16356. getChildren(): Array<Bone>;
  16357. /**
  16358. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16359. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16360. * @returns a Float32Array containing matrices data
  16361. */
  16362. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16363. /**
  16364. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16365. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16366. * @returns a raw texture containing the data
  16367. */
  16368. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16369. /**
  16370. * Gets the current hosting scene
  16371. * @returns a scene object
  16372. */
  16373. getScene(): Scene;
  16374. /**
  16375. * Gets a string representing the current skeleton data
  16376. * @param fullDetails defines a boolean indicating if we want a verbose version
  16377. * @returns a string representing the current skeleton data
  16378. */
  16379. toString(fullDetails?: boolean): string;
  16380. /**
  16381. * Get bone's index searching by name
  16382. * @param name defines bone's name to search for
  16383. * @return the indice of the bone. Returns -1 if not found
  16384. */
  16385. getBoneIndexByName(name: string): number;
  16386. /**
  16387. * Creater a new animation range
  16388. * @param name defines the name of the range
  16389. * @param from defines the start key
  16390. * @param to defines the end key
  16391. */
  16392. createAnimationRange(name: string, from: number, to: number): void;
  16393. /**
  16394. * Delete a specific animation range
  16395. * @param name defines the name of the range
  16396. * @param deleteFrames defines if frames must be removed as well
  16397. */
  16398. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16399. /**
  16400. * Gets a specific animation range
  16401. * @param name defines the name of the range to look for
  16402. * @returns the requested animation range or null if not found
  16403. */
  16404. getAnimationRange(name: string): Nullable<AnimationRange>;
  16405. /**
  16406. * Gets the list of all animation ranges defined on this skeleton
  16407. * @returns an array
  16408. */
  16409. getAnimationRanges(): Nullable<AnimationRange>[];
  16410. /**
  16411. * Copy animation range from a source skeleton.
  16412. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16413. * @param source defines the source skeleton
  16414. * @param name defines the name of the range to copy
  16415. * @param rescaleAsRequired defines if rescaling must be applied if required
  16416. * @returns true if operation was successful
  16417. */
  16418. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16419. /**
  16420. * Forces the skeleton to go to rest pose
  16421. */
  16422. returnToRest(): void;
  16423. private _getHighestAnimationFrame;
  16424. /**
  16425. * Begin a specific animation range
  16426. * @param name defines the name of the range to start
  16427. * @param loop defines if looping must be turned on (false by default)
  16428. * @param speedRatio defines the speed ratio to apply (1 by default)
  16429. * @param onAnimationEnd defines a callback which will be called when animation will end
  16430. * @returns a new animatable
  16431. */
  16432. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16433. /**
  16434. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16435. * @param skeleton defines the Skeleton containing the animation range to convert
  16436. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16437. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16438. * @returns the original skeleton
  16439. */
  16440. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16441. /** @hidden */
  16442. _markAsDirty(): void;
  16443. /** @hidden */
  16444. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16445. /** @hidden */
  16446. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16447. private _computeTransformMatrices;
  16448. /**
  16449. * Build all resources required to render a skeleton
  16450. */
  16451. prepare(): void;
  16452. /**
  16453. * Gets the list of animatables currently running for this skeleton
  16454. * @returns an array of animatables
  16455. */
  16456. getAnimatables(): IAnimatable[];
  16457. /**
  16458. * Clone the current skeleton
  16459. * @param name defines the name of the new skeleton
  16460. * @param id defines the id of the new skeleton
  16461. * @returns the new skeleton
  16462. */
  16463. clone(name: string, id?: string): Skeleton;
  16464. /**
  16465. * Enable animation blending for this skeleton
  16466. * @param blendingSpeed defines the blending speed to apply
  16467. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16468. */
  16469. enableBlending(blendingSpeed?: number): void;
  16470. /**
  16471. * Releases all resources associated with the current skeleton
  16472. */
  16473. dispose(): void;
  16474. /**
  16475. * Serialize the skeleton in a JSON object
  16476. * @returns a JSON object
  16477. */
  16478. serialize(): any;
  16479. /**
  16480. * Creates a new skeleton from serialized data
  16481. * @param parsedSkeleton defines the serialized data
  16482. * @param scene defines the hosting scene
  16483. * @returns a new skeleton
  16484. */
  16485. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16486. /**
  16487. * Compute all node absolute transforms
  16488. * @param forceUpdate defines if computation must be done even if cache is up to date
  16489. */
  16490. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16491. /**
  16492. * Gets the root pose matrix
  16493. * @returns a matrix
  16494. */
  16495. getPoseMatrix(): Nullable<Matrix>;
  16496. /**
  16497. * Sorts bones per internal index
  16498. */
  16499. sortBones(): void;
  16500. private _sortBones;
  16501. }
  16502. }
  16503. declare module "babylonjs/Meshes/instancedMesh" {
  16504. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16505. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16506. import { Camera } from "babylonjs/Cameras/camera";
  16507. import { Node } from "babylonjs/node";
  16508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16509. import { Mesh } from "babylonjs/Meshes/mesh";
  16510. import { Material } from "babylonjs/Materials/material";
  16511. import { Skeleton } from "babylonjs/Bones/skeleton";
  16512. import { Light } from "babylonjs/Lights/light";
  16513. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16514. /**
  16515. * Creates an instance based on a source mesh.
  16516. */
  16517. export class InstancedMesh extends AbstractMesh {
  16518. private _sourceMesh;
  16519. private _currentLOD;
  16520. /** @hidden */
  16521. _indexInSourceMeshInstanceArray: number;
  16522. constructor(name: string, source: Mesh);
  16523. /**
  16524. * Returns the string "InstancedMesh".
  16525. */
  16526. getClassName(): string;
  16527. /** Gets the list of lights affecting that mesh */
  16528. get lightSources(): Light[];
  16529. _resyncLightSources(): void;
  16530. _resyncLightSource(light: Light): void;
  16531. _removeLightSource(light: Light, dispose: boolean): void;
  16532. /**
  16533. * If the source mesh receives shadows
  16534. */
  16535. get receiveShadows(): boolean;
  16536. /**
  16537. * The material of the source mesh
  16538. */
  16539. get material(): Nullable<Material>;
  16540. /**
  16541. * Visibility of the source mesh
  16542. */
  16543. get visibility(): number;
  16544. /**
  16545. * Skeleton of the source mesh
  16546. */
  16547. get skeleton(): Nullable<Skeleton>;
  16548. /**
  16549. * Rendering ground id of the source mesh
  16550. */
  16551. get renderingGroupId(): number;
  16552. set renderingGroupId(value: number);
  16553. /**
  16554. * Returns the total number of vertices (integer).
  16555. */
  16556. getTotalVertices(): number;
  16557. /**
  16558. * Returns a positive integer : the total number of indices in this mesh geometry.
  16559. * @returns the numner of indices or zero if the mesh has no geometry.
  16560. */
  16561. getTotalIndices(): number;
  16562. /**
  16563. * The source mesh of the instance
  16564. */
  16565. get sourceMesh(): Mesh;
  16566. /**
  16567. * Creates a new InstancedMesh object from the mesh model.
  16568. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16569. * @param name defines the name of the new instance
  16570. * @returns a new InstancedMesh
  16571. */
  16572. createInstance(name: string): InstancedMesh;
  16573. /**
  16574. * Is this node ready to be used/rendered
  16575. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16576. * @return {boolean} is it ready
  16577. */
  16578. isReady(completeCheck?: boolean): boolean;
  16579. /**
  16580. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16581. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16582. * @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.
  16583. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16584. */
  16585. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16586. /**
  16587. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16588. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16589. * The `data` are either a numeric array either a Float32Array.
  16590. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16591. * 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).
  16592. * Note that a new underlying VertexBuffer object is created each call.
  16593. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16594. *
  16595. * Possible `kind` values :
  16596. * - VertexBuffer.PositionKind
  16597. * - VertexBuffer.UVKind
  16598. * - VertexBuffer.UV2Kind
  16599. * - VertexBuffer.UV3Kind
  16600. * - VertexBuffer.UV4Kind
  16601. * - VertexBuffer.UV5Kind
  16602. * - VertexBuffer.UV6Kind
  16603. * - VertexBuffer.ColorKind
  16604. * - VertexBuffer.MatricesIndicesKind
  16605. * - VertexBuffer.MatricesIndicesExtraKind
  16606. * - VertexBuffer.MatricesWeightsKind
  16607. * - VertexBuffer.MatricesWeightsExtraKind
  16608. *
  16609. * Returns the Mesh.
  16610. */
  16611. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16612. /**
  16613. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16614. * If the mesh has no geometry, it is simply returned as it is.
  16615. * The `data` are either a numeric array either a Float32Array.
  16616. * No new underlying VertexBuffer object is created.
  16617. * 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.
  16618. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16619. *
  16620. * Possible `kind` values :
  16621. * - VertexBuffer.PositionKind
  16622. * - VertexBuffer.UVKind
  16623. * - VertexBuffer.UV2Kind
  16624. * - VertexBuffer.UV3Kind
  16625. * - VertexBuffer.UV4Kind
  16626. * - VertexBuffer.UV5Kind
  16627. * - VertexBuffer.UV6Kind
  16628. * - VertexBuffer.ColorKind
  16629. * - VertexBuffer.MatricesIndicesKind
  16630. * - VertexBuffer.MatricesIndicesExtraKind
  16631. * - VertexBuffer.MatricesWeightsKind
  16632. * - VertexBuffer.MatricesWeightsExtraKind
  16633. *
  16634. * Returns the Mesh.
  16635. */
  16636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16637. /**
  16638. * Sets the mesh indices.
  16639. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16640. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16641. * This method creates a new index buffer each call.
  16642. * Returns the Mesh.
  16643. */
  16644. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16645. /**
  16646. * Boolean : True if the mesh owns the requested kind of data.
  16647. */
  16648. isVerticesDataPresent(kind: string): boolean;
  16649. /**
  16650. * Returns an array of indices (IndicesArray).
  16651. */
  16652. getIndices(): Nullable<IndicesArray>;
  16653. get _positions(): Nullable<Vector3[]>;
  16654. /**
  16655. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16656. * This means the mesh underlying bounding box and sphere are recomputed.
  16657. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16658. * @returns the current mesh
  16659. */
  16660. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16661. /** @hidden */
  16662. _preActivate(): InstancedMesh;
  16663. /** @hidden */
  16664. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16665. /** @hidden */
  16666. _postActivate(): void;
  16667. getWorldMatrix(): Matrix;
  16668. get isAnInstance(): boolean;
  16669. /**
  16670. * Returns the current associated LOD AbstractMesh.
  16671. */
  16672. getLOD(camera: Camera): AbstractMesh;
  16673. /** @hidden */
  16674. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16675. /** @hidden */
  16676. _syncSubMeshes(): InstancedMesh;
  16677. /** @hidden */
  16678. _generatePointsArray(): boolean;
  16679. /**
  16680. * Creates a new InstancedMesh from the current mesh.
  16681. * - name (string) : the cloned mesh name
  16682. * - newParent (optional Node) : the optional Node to parent the clone to.
  16683. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16684. *
  16685. * Returns the clone.
  16686. */
  16687. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16688. /**
  16689. * Disposes the InstancedMesh.
  16690. * Returns nothing.
  16691. */
  16692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16693. }
  16694. module "babylonjs/Meshes/mesh" {
  16695. interface Mesh {
  16696. /**
  16697. * Register a custom buffer that will be instanced
  16698. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16699. * @param kind defines the buffer kind
  16700. * @param stride defines the stride in floats
  16701. */
  16702. registerInstancedBuffer(kind: string, stride: number): void;
  16703. /**
  16704. * true to use the edge renderer for all instances of this mesh
  16705. */
  16706. edgesShareWithInstances: boolean;
  16707. /** @hidden */
  16708. _userInstancedBuffersStorage: {
  16709. data: {
  16710. [key: string]: Float32Array;
  16711. };
  16712. sizes: {
  16713. [key: string]: number;
  16714. };
  16715. vertexBuffers: {
  16716. [key: string]: Nullable<VertexBuffer>;
  16717. };
  16718. strides: {
  16719. [key: string]: number;
  16720. };
  16721. };
  16722. }
  16723. }
  16724. module "babylonjs/Meshes/abstractMesh" {
  16725. interface AbstractMesh {
  16726. /**
  16727. * Object used to store instanced buffers defined by user
  16728. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16729. */
  16730. instancedBuffers: {
  16731. [key: string]: any;
  16732. };
  16733. }
  16734. }
  16735. }
  16736. declare module "babylonjs/Materials/shaderMaterial" {
  16737. import { Nullable } from "babylonjs/types";
  16738. import { Scene } from "babylonjs/scene";
  16739. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16741. import { Mesh } from "babylonjs/Meshes/mesh";
  16742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16744. import { Effect } from "babylonjs/Materials/effect";
  16745. import { Material } from "babylonjs/Materials/material";
  16746. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16747. /**
  16748. * Defines the options associated with the creation of a shader material.
  16749. */
  16750. export interface IShaderMaterialOptions {
  16751. /**
  16752. * Does the material work in alpha blend mode
  16753. */
  16754. needAlphaBlending: boolean;
  16755. /**
  16756. * Does the material work in alpha test mode
  16757. */
  16758. needAlphaTesting: boolean;
  16759. /**
  16760. * The list of attribute names used in the shader
  16761. */
  16762. attributes: string[];
  16763. /**
  16764. * The list of unifrom names used in the shader
  16765. */
  16766. uniforms: string[];
  16767. /**
  16768. * The list of UBO names used in the shader
  16769. */
  16770. uniformBuffers: string[];
  16771. /**
  16772. * The list of sampler names used in the shader
  16773. */
  16774. samplers: string[];
  16775. /**
  16776. * The list of defines used in the shader
  16777. */
  16778. defines: string[];
  16779. }
  16780. /**
  16781. * 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.
  16782. *
  16783. * This returned material effects how the mesh will look based on the code in the shaders.
  16784. *
  16785. * @see https://doc.babylonjs.com/how_to/shader_material
  16786. */
  16787. export class ShaderMaterial extends Material {
  16788. private _shaderPath;
  16789. private _options;
  16790. private _textures;
  16791. private _textureArrays;
  16792. private _floats;
  16793. private _ints;
  16794. private _floatsArrays;
  16795. private _colors3;
  16796. private _colors3Arrays;
  16797. private _colors4;
  16798. private _colors4Arrays;
  16799. private _vectors2;
  16800. private _vectors3;
  16801. private _vectors4;
  16802. private _matrices;
  16803. private _matrixArrays;
  16804. private _matrices3x3;
  16805. private _matrices2x2;
  16806. private _vectors2Arrays;
  16807. private _vectors3Arrays;
  16808. private _vectors4Arrays;
  16809. private _cachedWorldViewMatrix;
  16810. private _cachedWorldViewProjectionMatrix;
  16811. private _renderId;
  16812. private _multiview;
  16813. private _cachedDefines;
  16814. /** Define the Url to load snippets */
  16815. static SnippetUrl: string;
  16816. /** Snippet ID if the material was created from the snippet server */
  16817. snippetId: string;
  16818. /**
  16819. * Instantiate a new shader material.
  16820. * 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.
  16821. * This returned material effects how the mesh will look based on the code in the shaders.
  16822. * @see https://doc.babylonjs.com/how_to/shader_material
  16823. * @param name Define the name of the material in the scene
  16824. * @param scene Define the scene the material belongs to
  16825. * @param shaderPath Defines the route to the shader code in one of three ways:
  16826. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16827. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16828. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16829. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16830. * @param options Define the options used to create the shader
  16831. */
  16832. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16833. /**
  16834. * Gets the shader path used to define the shader code
  16835. * It can be modified to trigger a new compilation
  16836. */
  16837. get shaderPath(): any;
  16838. /**
  16839. * Sets the shader path used to define the shader code
  16840. * It can be modified to trigger a new compilation
  16841. */
  16842. set shaderPath(shaderPath: any);
  16843. /**
  16844. * Gets the options used to compile the shader.
  16845. * They can be modified to trigger a new compilation
  16846. */
  16847. get options(): IShaderMaterialOptions;
  16848. /**
  16849. * Gets the current class name of the material e.g. "ShaderMaterial"
  16850. * Mainly use in serialization.
  16851. * @returns the class name
  16852. */
  16853. getClassName(): string;
  16854. /**
  16855. * Specifies if the material will require alpha blending
  16856. * @returns a boolean specifying if alpha blending is needed
  16857. */
  16858. needAlphaBlending(): boolean;
  16859. /**
  16860. * Specifies if this material should be rendered in alpha test mode
  16861. * @returns a boolean specifying if an alpha test is needed.
  16862. */
  16863. needAlphaTesting(): boolean;
  16864. private _checkUniform;
  16865. /**
  16866. * Set a texture in the shader.
  16867. * @param name Define the name of the uniform samplers as defined in the shader
  16868. * @param texture Define the texture to bind to this sampler
  16869. * @return the material itself allowing "fluent" like uniform updates
  16870. */
  16871. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16872. /**
  16873. * Set a texture array in the shader.
  16874. * @param name Define the name of the uniform sampler array as defined in the shader
  16875. * @param textures Define the list of textures to bind to this sampler
  16876. * @return the material itself allowing "fluent" like uniform updates
  16877. */
  16878. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16879. /**
  16880. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  16886. /**
  16887. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  16893. /**
  16894. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  16900. /**
  16901. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  16907. /**
  16908. * Set a vec3 array in the shader from a Color3 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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16914. /**
  16915. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  16921. /**
  16922. * Set a vec4 array in the shader from a Color4 array.
  16923. * @param name Define the name of the uniform as defined in the shader
  16924. * @param value Define the value to give to the uniform
  16925. * @return the material itself allowing "fluent" like uniform updates
  16926. */
  16927. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16928. /**
  16929. * Set a vec2 in the shader from a Vector2.
  16930. * @param name Define the name of the uniform as defined in the shader
  16931. * @param value Define the value to give to the uniform
  16932. * @return the material itself allowing "fluent" like uniform updates
  16933. */
  16934. setVector2(name: string, value: Vector2): ShaderMaterial;
  16935. /**
  16936. * Set a vec3 in the shader from a Vector3.
  16937. * @param name Define the name of the uniform as defined in the shader
  16938. * @param value Define the value to give to the uniform
  16939. * @return the material itself allowing "fluent" like uniform updates
  16940. */
  16941. setVector3(name: string, value: Vector3): ShaderMaterial;
  16942. /**
  16943. * Set a vec4 in the shader from a Vector4.
  16944. * @param name Define the name of the uniform as defined in the shader
  16945. * @param value Define the value to give to the uniform
  16946. * @return the material itself allowing "fluent" like uniform updates
  16947. */
  16948. setVector4(name: string, value: Vector4): ShaderMaterial;
  16949. /**
  16950. * Set a mat4 in the shader from a Matrix.
  16951. * @param name Define the name of the uniform as defined in the shader
  16952. * @param value Define the value to give to the uniform
  16953. * @return the material itself allowing "fluent" like uniform updates
  16954. */
  16955. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16956. /**
  16957. * Set a float32Array in the shader from a matrix array.
  16958. * @param name Define the name of the uniform as defined in the shader
  16959. * @param value Define the value to give to the uniform
  16960. * @return the material itself allowing "fluent" like uniform updates
  16961. */
  16962. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16963. /**
  16964. * Set a mat3 in the shader from a Float32Array.
  16965. * @param name Define the name of the uniform as defined in the shader
  16966. * @param value Define the value to give to the uniform
  16967. * @return the material itself allowing "fluent" like uniform updates
  16968. */
  16969. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16970. /**
  16971. * Set a mat2 in the shader from a Float32Array.
  16972. * @param name Define the name of the uniform as defined in the shader
  16973. * @param value Define the value to give to the uniform
  16974. * @return the material itself allowing "fluent" like uniform updates
  16975. */
  16976. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16977. /**
  16978. * Set a vec2 array in the shader from a number array.
  16979. * @param name Define the name of the uniform as defined in the shader
  16980. * @param value Define the value to give to the uniform
  16981. * @return the material itself allowing "fluent" like uniform updates
  16982. */
  16983. setArray2(name: string, value: number[]): ShaderMaterial;
  16984. /**
  16985. * Set a vec3 array in the shader from a number array.
  16986. * @param name Define the name of the uniform as defined in the shader
  16987. * @param value Define the value to give to the uniform
  16988. * @return the material itself allowing "fluent" like uniform updates
  16989. */
  16990. setArray3(name: string, value: number[]): ShaderMaterial;
  16991. /**
  16992. * Set a vec4 array in the shader from a number array.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the material itself allowing "fluent" like uniform updates
  16996. */
  16997. setArray4(name: string, value: number[]): ShaderMaterial;
  16998. private _checkCache;
  16999. /**
  17000. * Specifies that the submesh is ready to be used
  17001. * @param mesh defines the mesh to check
  17002. * @param subMesh defines which submesh to check
  17003. * @param useInstances specifies that instances should be used
  17004. * @returns a boolean indicating that the submesh is ready or not
  17005. */
  17006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17007. /**
  17008. * Checks if the material is ready to render the requested mesh
  17009. * @param mesh Define the mesh to render
  17010. * @param useInstances Define whether or not the material is used with instances
  17011. * @returns true if ready, otherwise false
  17012. */
  17013. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17014. /**
  17015. * Binds the world matrix to the material
  17016. * @param world defines the world transformation matrix
  17017. * @param effectOverride - If provided, use this effect instead of internal effect
  17018. */
  17019. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17020. /**
  17021. * Binds the submesh to this material by preparing the effect and shader to draw
  17022. * @param world defines the world transformation matrix
  17023. * @param mesh defines the mesh containing the submesh
  17024. * @param subMesh defines the submesh to bind the material to
  17025. */
  17026. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17027. /**
  17028. * Binds the material to the mesh
  17029. * @param world defines the world transformation matrix
  17030. * @param mesh defines the mesh to bind the material to
  17031. * @param effectOverride - If provided, use this effect instead of internal effect
  17032. */
  17033. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17034. protected _afterBind(mesh?: Mesh): void;
  17035. /**
  17036. * Gets the active textures from the material
  17037. * @returns an array of textures
  17038. */
  17039. getActiveTextures(): BaseTexture[];
  17040. /**
  17041. * Specifies if the material uses a texture
  17042. * @param texture defines the texture to check against the material
  17043. * @returns a boolean specifying if the material uses the texture
  17044. */
  17045. hasTexture(texture: BaseTexture): boolean;
  17046. /**
  17047. * Makes a duplicate of the material, and gives it a new name
  17048. * @param name defines the new name for the duplicated material
  17049. * @returns the cloned material
  17050. */
  17051. clone(name: string): ShaderMaterial;
  17052. /**
  17053. * Disposes the material
  17054. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17055. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17056. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17057. */
  17058. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17059. /**
  17060. * Serializes this material in a JSON representation
  17061. * @returns the serialized material object
  17062. */
  17063. serialize(): any;
  17064. /**
  17065. * Creates a shader material from parsed shader material data
  17066. * @param source defines the JSON represnetation of the material
  17067. * @param scene defines the hosting scene
  17068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17069. * @returns a new material
  17070. */
  17071. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17072. /**
  17073. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17074. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17075. * @param url defines the url to load from
  17076. * @param scene defines the hosting scene
  17077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17078. * @returns a promise that will resolve to the new ShaderMaterial
  17079. */
  17080. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17081. /**
  17082. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17083. * @param snippetId defines the snippet to load
  17084. * @param scene defines the hosting scene
  17085. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17086. * @returns a promise that will resolve to the new ShaderMaterial
  17087. */
  17088. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17089. }
  17090. }
  17091. declare module "babylonjs/Shaders/color.fragment" {
  17092. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17093. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17094. /** @hidden */
  17095. export var colorPixelShader: {
  17096. name: string;
  17097. shader: string;
  17098. };
  17099. }
  17100. declare module "babylonjs/Shaders/color.vertex" {
  17101. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17102. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17103. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17104. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17105. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17106. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17107. /** @hidden */
  17108. export var colorVertexShader: {
  17109. name: string;
  17110. shader: string;
  17111. };
  17112. }
  17113. declare module "babylonjs/Meshes/linesMesh" {
  17114. import { Nullable } from "babylonjs/types";
  17115. import { Scene } from "babylonjs/scene";
  17116. import { Color3 } from "babylonjs/Maths/math.color";
  17117. import { Node } from "babylonjs/node";
  17118. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17119. import { Mesh } from "babylonjs/Meshes/mesh";
  17120. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17121. import { Effect } from "babylonjs/Materials/effect";
  17122. import { Material } from "babylonjs/Materials/material";
  17123. import "babylonjs/Shaders/color.fragment";
  17124. import "babylonjs/Shaders/color.vertex";
  17125. /**
  17126. * Line mesh
  17127. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17128. */
  17129. export class LinesMesh extends Mesh {
  17130. /**
  17131. * If vertex color should be applied to the mesh
  17132. */
  17133. readonly useVertexColor?: boolean | undefined;
  17134. /**
  17135. * If vertex alpha should be applied to the mesh
  17136. */
  17137. readonly useVertexAlpha?: boolean | undefined;
  17138. /**
  17139. * Color of the line (Default: White)
  17140. */
  17141. color: Color3;
  17142. /**
  17143. * Alpha of the line (Default: 1)
  17144. */
  17145. alpha: number;
  17146. /**
  17147. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17148. * This margin is expressed in world space coordinates, so its value may vary.
  17149. * Default value is 0.1
  17150. */
  17151. intersectionThreshold: number;
  17152. private _colorShader;
  17153. private color4;
  17154. /**
  17155. * Creates a new LinesMesh
  17156. * @param name defines the name
  17157. * @param scene defines the hosting scene
  17158. * @param parent defines the parent mesh if any
  17159. * @param source defines the optional source LinesMesh used to clone data from
  17160. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17161. * When false, achieved by calling a clone(), also passing False.
  17162. * This will make creation of children, recursive.
  17163. * @param useVertexColor defines if this LinesMesh supports vertex color
  17164. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17165. */
  17166. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17167. /**
  17168. * If vertex color should be applied to the mesh
  17169. */
  17170. useVertexColor?: boolean | undefined,
  17171. /**
  17172. * If vertex alpha should be applied to the mesh
  17173. */
  17174. useVertexAlpha?: boolean | undefined);
  17175. private _addClipPlaneDefine;
  17176. private _removeClipPlaneDefine;
  17177. isReady(): boolean;
  17178. /**
  17179. * Returns the string "LineMesh"
  17180. */
  17181. getClassName(): string;
  17182. /**
  17183. * @hidden
  17184. */
  17185. get material(): Material;
  17186. /**
  17187. * @hidden
  17188. */
  17189. set material(value: Material);
  17190. /**
  17191. * @hidden
  17192. */
  17193. get checkCollisions(): boolean;
  17194. /** @hidden */
  17195. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17196. /** @hidden */
  17197. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17198. /**
  17199. * Disposes of the line mesh
  17200. * @param doNotRecurse If children should be disposed
  17201. */
  17202. dispose(doNotRecurse?: boolean): void;
  17203. /**
  17204. * Returns a new LineMesh object cloned from the current one.
  17205. */
  17206. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17207. /**
  17208. * Creates a new InstancedLinesMesh object from the mesh model.
  17209. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17210. * @param name defines the name of the new instance
  17211. * @returns a new InstancedLinesMesh
  17212. */
  17213. createInstance(name: string): InstancedLinesMesh;
  17214. }
  17215. /**
  17216. * Creates an instance based on a source LinesMesh
  17217. */
  17218. export class InstancedLinesMesh extends InstancedMesh {
  17219. /**
  17220. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17221. * This margin is expressed in world space coordinates, so its value may vary.
  17222. * Initilized with the intersectionThreshold value of the source LinesMesh
  17223. */
  17224. intersectionThreshold: number;
  17225. constructor(name: string, source: LinesMesh);
  17226. /**
  17227. * Returns the string "InstancedLinesMesh".
  17228. */
  17229. getClassName(): string;
  17230. }
  17231. }
  17232. declare module "babylonjs/Shaders/line.fragment" {
  17233. /** @hidden */
  17234. export var linePixelShader: {
  17235. name: string;
  17236. shader: string;
  17237. };
  17238. }
  17239. declare module "babylonjs/Shaders/line.vertex" {
  17240. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17241. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17242. /** @hidden */
  17243. export var lineVertexShader: {
  17244. name: string;
  17245. shader: string;
  17246. };
  17247. }
  17248. declare module "babylonjs/Rendering/edgesRenderer" {
  17249. import { Nullable } from "babylonjs/types";
  17250. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17252. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17253. import { IDisposable } from "babylonjs/scene";
  17254. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17255. import "babylonjs/Shaders/line.fragment";
  17256. import "babylonjs/Shaders/line.vertex";
  17257. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17258. import { SmartArray } from "babylonjs/Misc/smartArray";
  17259. module "babylonjs/scene" {
  17260. interface Scene {
  17261. /** @hidden */
  17262. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17263. }
  17264. }
  17265. module "babylonjs/Meshes/abstractMesh" {
  17266. interface AbstractMesh {
  17267. /**
  17268. * Gets the edgesRenderer associated with the mesh
  17269. */
  17270. edgesRenderer: Nullable<EdgesRenderer>;
  17271. }
  17272. }
  17273. module "babylonjs/Meshes/linesMesh" {
  17274. interface LinesMesh {
  17275. /**
  17276. * Enables the edge rendering mode on the mesh.
  17277. * This mode makes the mesh edges visible
  17278. * @param epsilon defines the maximal distance between two angles to detect a face
  17279. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17280. * @returns the currentAbstractMesh
  17281. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17282. */
  17283. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17284. }
  17285. }
  17286. module "babylonjs/Meshes/linesMesh" {
  17287. interface InstancedLinesMesh {
  17288. /**
  17289. * Enables the edge rendering mode on the mesh.
  17290. * This mode makes the mesh edges visible
  17291. * @param epsilon defines the maximal distance between two angles to detect a face
  17292. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17293. * @returns the current InstancedLinesMesh
  17294. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17295. */
  17296. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17297. }
  17298. }
  17299. /**
  17300. * Defines the minimum contract an Edges renderer should follow.
  17301. */
  17302. export interface IEdgesRenderer extends IDisposable {
  17303. /**
  17304. * Gets or sets a boolean indicating if the edgesRenderer is active
  17305. */
  17306. isEnabled: boolean;
  17307. /**
  17308. * Renders the edges of the attached mesh,
  17309. */
  17310. render(): void;
  17311. /**
  17312. * Checks wether or not the edges renderer is ready to render.
  17313. * @return true if ready, otherwise false.
  17314. */
  17315. isReady(): boolean;
  17316. /**
  17317. * List of instances to render in case the source mesh has instances
  17318. */
  17319. customInstances: SmartArray<Matrix>;
  17320. }
  17321. /**
  17322. * Defines the additional options of the edges renderer
  17323. */
  17324. export interface IEdgesRendererOptions {
  17325. /**
  17326. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17327. * If not defined, the default value is true
  17328. */
  17329. useAlternateEdgeFinder?: boolean;
  17330. /**
  17331. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17332. * If not defined, the default value is true.
  17333. * 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)
  17334. * This option is used only if useAlternateEdgeFinder = true
  17335. */
  17336. useFastVertexMerger?: boolean;
  17337. /**
  17338. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17339. * The default value is 1e-6
  17340. * This option is used only if useAlternateEdgeFinder = true
  17341. */
  17342. epsilonVertexMerge?: number;
  17343. /**
  17344. * 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
  17345. * 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.
  17346. * This option is used only if useAlternateEdgeFinder = true
  17347. */
  17348. applyTessellation?: boolean;
  17349. /**
  17350. * 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
  17351. * The default value is 1e-6
  17352. * This option is used only if useAlternateEdgeFinder = true
  17353. */
  17354. epsilonVertexAligned?: number;
  17355. }
  17356. /**
  17357. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17358. */
  17359. export class EdgesRenderer implements IEdgesRenderer {
  17360. /**
  17361. * Define the size of the edges with an orthographic camera
  17362. */
  17363. edgesWidthScalerForOrthographic: number;
  17364. /**
  17365. * Define the size of the edges with a perspective camera
  17366. */
  17367. edgesWidthScalerForPerspective: number;
  17368. protected _source: AbstractMesh;
  17369. protected _linesPositions: number[];
  17370. protected _linesNormals: number[];
  17371. protected _linesIndices: number[];
  17372. protected _epsilon: number;
  17373. protected _indicesCount: number;
  17374. protected _lineShader: ShaderMaterial;
  17375. protected _ib: DataBuffer;
  17376. protected _buffers: {
  17377. [key: string]: Nullable<VertexBuffer>;
  17378. };
  17379. protected _buffersForInstances: {
  17380. [key: string]: Nullable<VertexBuffer>;
  17381. };
  17382. protected _checkVerticesInsteadOfIndices: boolean;
  17383. protected _options: Nullable<IEdgesRendererOptions>;
  17384. private _meshRebuildObserver;
  17385. private _meshDisposeObserver;
  17386. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17387. isEnabled: boolean;
  17388. /**
  17389. * List of instances to render in case the source mesh has instances
  17390. */
  17391. customInstances: SmartArray<Matrix>;
  17392. private static GetShader;
  17393. /**
  17394. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17395. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17396. * @param source Mesh used to create edges
  17397. * @param epsilon sum of angles in adjacency to check for edge
  17398. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17399. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17400. * @param options The options to apply when generating the edges
  17401. */
  17402. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17403. protected _prepareRessources(): void;
  17404. /** @hidden */
  17405. _rebuild(): void;
  17406. /**
  17407. * Releases the required resources for the edges renderer
  17408. */
  17409. dispose(): void;
  17410. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17411. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17412. /**
  17413. * Checks if the pair of p0 and p1 is en edge
  17414. * @param faceIndex
  17415. * @param edge
  17416. * @param faceNormals
  17417. * @param p0
  17418. * @param p1
  17419. * @private
  17420. */
  17421. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17422. /**
  17423. * push line into the position, normal and index buffer
  17424. * @protected
  17425. */
  17426. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17427. /**
  17428. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17429. */
  17430. private _tessellateTriangle;
  17431. private _generateEdgesLinesAlternate;
  17432. /**
  17433. * Generates lines edges from adjacencjes
  17434. * @private
  17435. */
  17436. _generateEdgesLines(): void;
  17437. /**
  17438. * Checks wether or not the edges renderer is ready to render.
  17439. * @return true if ready, otherwise false.
  17440. */
  17441. isReady(): boolean;
  17442. /**
  17443. * Renders the edges of the attached mesh,
  17444. */
  17445. render(): void;
  17446. }
  17447. /**
  17448. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17449. */
  17450. export class LineEdgesRenderer extends EdgesRenderer {
  17451. /**
  17452. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17453. * @param source LineMesh used to generate edges
  17454. * @param epsilon not important (specified angle for edge detection)
  17455. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17456. */
  17457. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17458. /**
  17459. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17460. */
  17461. _generateEdgesLines(): void;
  17462. }
  17463. }
  17464. declare module "babylonjs/Rendering/renderingGroup" {
  17465. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17468. import { Nullable } from "babylonjs/types";
  17469. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17470. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17471. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17472. import { Material } from "babylonjs/Materials/material";
  17473. import { Scene } from "babylonjs/scene";
  17474. /**
  17475. * This represents the object necessary to create a rendering group.
  17476. * This is exclusively used and created by the rendering manager.
  17477. * To modify the behavior, you use the available helpers in your scene or meshes.
  17478. * @hidden
  17479. */
  17480. export class RenderingGroup {
  17481. index: number;
  17482. private static _zeroVector;
  17483. private _scene;
  17484. private _opaqueSubMeshes;
  17485. private _transparentSubMeshes;
  17486. private _alphaTestSubMeshes;
  17487. private _depthOnlySubMeshes;
  17488. private _particleSystems;
  17489. private _spriteManagers;
  17490. private _opaqueSortCompareFn;
  17491. private _alphaTestSortCompareFn;
  17492. private _transparentSortCompareFn;
  17493. private _renderOpaque;
  17494. private _renderAlphaTest;
  17495. private _renderTransparent;
  17496. /** @hidden */
  17497. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17498. onBeforeTransparentRendering: () => void;
  17499. /**
  17500. * Set the opaque sort comparison function.
  17501. * If null the sub meshes will be render in the order they were created
  17502. */
  17503. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17504. /**
  17505. * Set the alpha test sort comparison function.
  17506. * If null the sub meshes will be render in the order they were created
  17507. */
  17508. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17509. /**
  17510. * Set the transparent sort comparison function.
  17511. * If null the sub meshes will be render in the order they were created
  17512. */
  17513. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17514. /**
  17515. * Creates a new rendering group.
  17516. * @param index The rendering group index
  17517. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17518. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17519. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17520. */
  17521. 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>);
  17522. /**
  17523. * Render all the sub meshes contained in the group.
  17524. * @param customRenderFunction Used to override the default render behaviour of the group.
  17525. * @returns true if rendered some submeshes.
  17526. */
  17527. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17528. /**
  17529. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17530. * @param subMeshes The submeshes to render
  17531. */
  17532. private renderOpaqueSorted;
  17533. /**
  17534. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17535. * @param subMeshes The submeshes to render
  17536. */
  17537. private renderAlphaTestSorted;
  17538. /**
  17539. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17540. * @param subMeshes The submeshes to render
  17541. */
  17542. private renderTransparentSorted;
  17543. /**
  17544. * Renders the submeshes in a specified order.
  17545. * @param subMeshes The submeshes to sort before render
  17546. * @param sortCompareFn The comparison function use to sort
  17547. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17548. * @param transparent Specifies to activate blending if true
  17549. */
  17550. private static renderSorted;
  17551. /**
  17552. * Renders the submeshes in the order they were dispatched (no sort applied).
  17553. * @param subMeshes The submeshes to render
  17554. */
  17555. private static renderUnsorted;
  17556. /**
  17557. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17558. * are rendered back to front if in the same alpha index.
  17559. *
  17560. * @param a The first submesh
  17561. * @param b The second submesh
  17562. * @returns The result of the comparison
  17563. */
  17564. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17565. /**
  17566. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17567. * are rendered back to front.
  17568. *
  17569. * @param a The first submesh
  17570. * @param b The second submesh
  17571. * @returns The result of the comparison
  17572. */
  17573. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17574. /**
  17575. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17576. * are rendered front to back (prevent overdraw).
  17577. *
  17578. * @param a The first submesh
  17579. * @param b The second submesh
  17580. * @returns The result of the comparison
  17581. */
  17582. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17583. /**
  17584. * Resets the different lists of submeshes to prepare a new frame.
  17585. */
  17586. prepare(): void;
  17587. dispose(): void;
  17588. /**
  17589. * Inserts the submesh in its correct queue depending on its material.
  17590. * @param subMesh The submesh to dispatch
  17591. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17592. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17593. */
  17594. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17595. dispatchSprites(spriteManager: ISpriteManager): void;
  17596. dispatchParticles(particleSystem: IParticleSystem): void;
  17597. private _renderParticles;
  17598. private _renderSprites;
  17599. }
  17600. }
  17601. declare module "babylonjs/Rendering/renderingManager" {
  17602. import { Nullable } from "babylonjs/types";
  17603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17605. import { SmartArray } from "babylonjs/Misc/smartArray";
  17606. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17608. import { Material } from "babylonjs/Materials/material";
  17609. import { Scene } from "babylonjs/scene";
  17610. import { Camera } from "babylonjs/Cameras/camera";
  17611. /**
  17612. * Interface describing the different options available in the rendering manager
  17613. * regarding Auto Clear between groups.
  17614. */
  17615. export interface IRenderingManagerAutoClearSetup {
  17616. /**
  17617. * Defines whether or not autoclear is enable.
  17618. */
  17619. autoClear: boolean;
  17620. /**
  17621. * Defines whether or not to autoclear the depth buffer.
  17622. */
  17623. depth: boolean;
  17624. /**
  17625. * Defines whether or not to autoclear the stencil buffer.
  17626. */
  17627. stencil: boolean;
  17628. }
  17629. /**
  17630. * This class is used by the onRenderingGroupObservable
  17631. */
  17632. export class RenderingGroupInfo {
  17633. /**
  17634. * The Scene that being rendered
  17635. */
  17636. scene: Scene;
  17637. /**
  17638. * The camera currently used for the rendering pass
  17639. */
  17640. camera: Nullable<Camera>;
  17641. /**
  17642. * The ID of the renderingGroup being processed
  17643. */
  17644. renderingGroupId: number;
  17645. }
  17646. /**
  17647. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17648. * It is enable to manage the different groups as well as the different necessary sort functions.
  17649. * This should not be used directly aside of the few static configurations
  17650. */
  17651. export class RenderingManager {
  17652. /**
  17653. * The max id used for rendering groups (not included)
  17654. */
  17655. static MAX_RENDERINGGROUPS: number;
  17656. /**
  17657. * The min id used for rendering groups (included)
  17658. */
  17659. static MIN_RENDERINGGROUPS: number;
  17660. /**
  17661. * Used to globally prevent autoclearing scenes.
  17662. */
  17663. static AUTOCLEAR: boolean;
  17664. /**
  17665. * @hidden
  17666. */
  17667. _useSceneAutoClearSetup: boolean;
  17668. private _scene;
  17669. private _renderingGroups;
  17670. private _depthStencilBufferAlreadyCleaned;
  17671. private _autoClearDepthStencil;
  17672. private _customOpaqueSortCompareFn;
  17673. private _customAlphaTestSortCompareFn;
  17674. private _customTransparentSortCompareFn;
  17675. private _renderingGroupInfo;
  17676. /**
  17677. * Instantiates a new rendering group for a particular scene
  17678. * @param scene Defines the scene the groups belongs to
  17679. */
  17680. constructor(scene: Scene);
  17681. private _clearDepthStencilBuffer;
  17682. /**
  17683. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17684. * @hidden
  17685. */
  17686. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17687. /**
  17688. * Resets the different information of the group to prepare a new frame
  17689. * @hidden
  17690. */
  17691. reset(): void;
  17692. /**
  17693. * Dispose and release the group and its associated resources.
  17694. * @hidden
  17695. */
  17696. dispose(): void;
  17697. /**
  17698. * Clear the info related to rendering groups preventing retention points during dispose.
  17699. */
  17700. freeRenderingGroups(): void;
  17701. private _prepareRenderingGroup;
  17702. /**
  17703. * Add a sprite manager to the rendering manager in order to render it this frame.
  17704. * @param spriteManager Define the sprite manager to render
  17705. */
  17706. dispatchSprites(spriteManager: ISpriteManager): void;
  17707. /**
  17708. * Add a particle system to the rendering manager in order to render it this frame.
  17709. * @param particleSystem Define the particle system to render
  17710. */
  17711. dispatchParticles(particleSystem: IParticleSystem): void;
  17712. /**
  17713. * Add a submesh to the manager in order to render it this frame
  17714. * @param subMesh The submesh to dispatch
  17715. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17716. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17717. */
  17718. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17719. /**
  17720. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17721. * This allowed control for front to back rendering or reversly depending of the special needs.
  17722. *
  17723. * @param renderingGroupId The rendering group id corresponding to its index
  17724. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17725. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17726. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17727. */
  17728. 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;
  17729. /**
  17730. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17731. *
  17732. * @param renderingGroupId The rendering group id corresponding to its index
  17733. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17734. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17735. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17736. */
  17737. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17738. /**
  17739. * Gets the current auto clear configuration for one rendering group of the rendering
  17740. * manager.
  17741. * @param index the rendering group index to get the information for
  17742. * @returns The auto clear setup for the requested rendering group
  17743. */
  17744. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17745. }
  17746. }
  17747. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17748. import { SmartArray } from "babylonjs/Misc/smartArray";
  17749. import { Nullable } from "babylonjs/types";
  17750. import { Scene } from "babylonjs/scene";
  17751. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17754. import { Mesh } from "babylonjs/Meshes/mesh";
  17755. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17756. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17757. import { Effect } from "babylonjs/Materials/effect";
  17758. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17759. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17760. import "babylonjs/Shaders/shadowMap.fragment";
  17761. import "babylonjs/Shaders/shadowMap.vertex";
  17762. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17763. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17764. import { Observable } from "babylonjs/Misc/observable";
  17765. /**
  17766. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17767. */
  17768. export interface ICustomShaderOptions {
  17769. /**
  17770. * Gets or sets the custom shader name to use
  17771. */
  17772. shaderName: string;
  17773. /**
  17774. * The list of attribute names used in the shader
  17775. */
  17776. attributes?: string[];
  17777. /**
  17778. * The list of unifrom names used in the shader
  17779. */
  17780. uniforms?: string[];
  17781. /**
  17782. * The list of sampler names used in the shader
  17783. */
  17784. samplers?: string[];
  17785. /**
  17786. * The list of defines used in the shader
  17787. */
  17788. defines?: string[];
  17789. }
  17790. /**
  17791. * Interface to implement to create a shadow generator compatible with BJS.
  17792. */
  17793. export interface IShadowGenerator {
  17794. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17795. id: string;
  17796. /**
  17797. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17798. * @returns The render target texture if present otherwise, null
  17799. */
  17800. getShadowMap(): Nullable<RenderTargetTexture>;
  17801. /**
  17802. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17803. * @param subMesh The submesh we want to render in the shadow map
  17804. * @param useInstances Defines wether will draw in the map using instances
  17805. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17806. * @returns true if ready otherwise, false
  17807. */
  17808. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17809. /**
  17810. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17811. * @param defines Defines of the material we want to update
  17812. * @param lightIndex Index of the light in the enabled light list of the material
  17813. */
  17814. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17815. /**
  17816. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17817. * defined in the generator but impacting the effect).
  17818. * It implies the unifroms available on the materials are the standard BJS ones.
  17819. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17820. * @param effect The effect we are binfing the information for
  17821. */
  17822. bindShadowLight(lightIndex: string, effect: Effect): void;
  17823. /**
  17824. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17825. * (eq to shadow prjection matrix * light transform matrix)
  17826. * @returns The transform matrix used to create the shadow map
  17827. */
  17828. getTransformMatrix(): Matrix;
  17829. /**
  17830. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17831. * Cube and 2D textures for instance.
  17832. */
  17833. recreateShadowMap(): void;
  17834. /**
  17835. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17836. * @param onCompiled Callback triggered at the and of the effects compilation
  17837. * @param options Sets of optional options forcing the compilation with different modes
  17838. */
  17839. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17840. useInstances: boolean;
  17841. }>): void;
  17842. /**
  17843. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17844. * @param options Sets of optional options forcing the compilation with different modes
  17845. * @returns A promise that resolves when the compilation completes
  17846. */
  17847. forceCompilationAsync(options?: Partial<{
  17848. useInstances: boolean;
  17849. }>): Promise<void>;
  17850. /**
  17851. * Serializes the shadow generator setup to a json object.
  17852. * @returns The serialized JSON object
  17853. */
  17854. serialize(): any;
  17855. /**
  17856. * Disposes the Shadow map and related Textures and effects.
  17857. */
  17858. dispose(): void;
  17859. }
  17860. /**
  17861. * Default implementation IShadowGenerator.
  17862. * This is the main object responsible of generating shadows in the framework.
  17863. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17864. */
  17865. export class ShadowGenerator implements IShadowGenerator {
  17866. /**
  17867. * Name of the shadow generator class
  17868. */
  17869. static CLASSNAME: string;
  17870. /**
  17871. * Shadow generator mode None: no filtering applied.
  17872. */
  17873. static readonly FILTER_NONE: number;
  17874. /**
  17875. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17876. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17877. */
  17878. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17879. /**
  17880. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17881. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17882. */
  17883. static readonly FILTER_POISSONSAMPLING: number;
  17884. /**
  17885. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17886. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17887. */
  17888. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17889. /**
  17890. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17891. * edge artifacts on steep falloff.
  17892. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17893. */
  17894. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17895. /**
  17896. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17897. * edge artifacts on steep falloff.
  17898. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17899. */
  17900. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17901. /**
  17902. * Shadow generator mode PCF: Percentage Closer Filtering
  17903. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17904. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17905. */
  17906. static readonly FILTER_PCF: number;
  17907. /**
  17908. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17909. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17910. * Contact Hardening
  17911. */
  17912. static readonly FILTER_PCSS: number;
  17913. /**
  17914. * Reserved for PCF and PCSS
  17915. * Highest Quality.
  17916. *
  17917. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17918. *
  17919. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17920. */
  17921. static readonly QUALITY_HIGH: number;
  17922. /**
  17923. * Reserved for PCF and PCSS
  17924. * Good tradeoff for quality/perf cross devices
  17925. *
  17926. * Execute PCF on a 3*3 kernel.
  17927. *
  17928. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17929. */
  17930. static readonly QUALITY_MEDIUM: number;
  17931. /**
  17932. * Reserved for PCF and PCSS
  17933. * The lowest quality but the fastest.
  17934. *
  17935. * Execute PCF on a 1*1 kernel.
  17936. *
  17937. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17938. */
  17939. static readonly QUALITY_LOW: number;
  17940. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17941. id: string;
  17942. /** Gets or sets the custom shader name to use */
  17943. customShaderOptions: ICustomShaderOptions;
  17944. /**
  17945. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17946. */
  17947. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17948. /**
  17949. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17950. */
  17951. onAfterShadowMapRenderObservable: Observable<Effect>;
  17952. /**
  17953. * Observable triggered before a mesh is rendered in the shadow map.
  17954. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17955. */
  17956. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17957. /**
  17958. * Observable triggered after a mesh is rendered in the shadow map.
  17959. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17960. */
  17961. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17962. protected _bias: number;
  17963. /**
  17964. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17965. */
  17966. get bias(): number;
  17967. /**
  17968. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17969. */
  17970. set bias(bias: number);
  17971. protected _normalBias: number;
  17972. /**
  17973. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17974. */
  17975. get normalBias(): number;
  17976. /**
  17977. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17978. */
  17979. set normalBias(normalBias: number);
  17980. protected _blurBoxOffset: number;
  17981. /**
  17982. * Gets the blur box offset: offset applied during the blur pass.
  17983. * Only useful if useKernelBlur = false
  17984. */
  17985. get blurBoxOffset(): number;
  17986. /**
  17987. * Sets the blur box offset: offset applied during the blur pass.
  17988. * Only useful if useKernelBlur = false
  17989. */
  17990. set blurBoxOffset(value: number);
  17991. protected _blurScale: number;
  17992. /**
  17993. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17994. * 2 means half of the size.
  17995. */
  17996. get blurScale(): number;
  17997. /**
  17998. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17999. * 2 means half of the size.
  18000. */
  18001. set blurScale(value: number);
  18002. protected _blurKernel: number;
  18003. /**
  18004. * Gets the blur kernel: kernel size of the blur pass.
  18005. * Only useful if useKernelBlur = true
  18006. */
  18007. get blurKernel(): number;
  18008. /**
  18009. * Sets the blur kernel: kernel size of the blur pass.
  18010. * Only useful if useKernelBlur = true
  18011. */
  18012. set blurKernel(value: number);
  18013. protected _useKernelBlur: boolean;
  18014. /**
  18015. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18016. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18017. */
  18018. get useKernelBlur(): boolean;
  18019. /**
  18020. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18021. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18022. */
  18023. set useKernelBlur(value: boolean);
  18024. protected _depthScale: number;
  18025. /**
  18026. * Gets the depth scale used in ESM mode.
  18027. */
  18028. get depthScale(): number;
  18029. /**
  18030. * Sets the depth scale used in ESM mode.
  18031. * This can override the scale stored on the light.
  18032. */
  18033. set depthScale(value: number);
  18034. protected _validateFilter(filter: number): number;
  18035. protected _filter: number;
  18036. /**
  18037. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18038. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18039. */
  18040. get filter(): number;
  18041. /**
  18042. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18043. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18044. */
  18045. set filter(value: number);
  18046. /**
  18047. * Gets if the current filter is set to Poisson Sampling.
  18048. */
  18049. get usePoissonSampling(): boolean;
  18050. /**
  18051. * Sets the current filter to Poisson Sampling.
  18052. */
  18053. set usePoissonSampling(value: boolean);
  18054. /**
  18055. * Gets if the current filter is set to ESM.
  18056. */
  18057. get useExponentialShadowMap(): boolean;
  18058. /**
  18059. * Sets the current filter is to ESM.
  18060. */
  18061. set useExponentialShadowMap(value: boolean);
  18062. /**
  18063. * Gets if the current filter is set to filtered ESM.
  18064. */
  18065. get useBlurExponentialShadowMap(): boolean;
  18066. /**
  18067. * Gets if the current filter is set to filtered ESM.
  18068. */
  18069. set useBlurExponentialShadowMap(value: boolean);
  18070. /**
  18071. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18072. * exponential to prevent steep falloff artifacts).
  18073. */
  18074. get useCloseExponentialShadowMap(): boolean;
  18075. /**
  18076. * Sets the current filter to "close ESM" (using the inverse of the
  18077. * exponential to prevent steep falloff artifacts).
  18078. */
  18079. set useCloseExponentialShadowMap(value: boolean);
  18080. /**
  18081. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18082. * exponential to prevent steep falloff artifacts).
  18083. */
  18084. get useBlurCloseExponentialShadowMap(): boolean;
  18085. /**
  18086. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18087. * exponential to prevent steep falloff artifacts).
  18088. */
  18089. set useBlurCloseExponentialShadowMap(value: boolean);
  18090. /**
  18091. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18092. */
  18093. get usePercentageCloserFiltering(): boolean;
  18094. /**
  18095. * Sets the current filter to "PCF" (percentage closer filtering).
  18096. */
  18097. set usePercentageCloserFiltering(value: boolean);
  18098. protected _filteringQuality: number;
  18099. /**
  18100. * Gets the PCF or PCSS Quality.
  18101. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18102. */
  18103. get filteringQuality(): number;
  18104. /**
  18105. * Sets the PCF or PCSS Quality.
  18106. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18107. */
  18108. set filteringQuality(filteringQuality: number);
  18109. /**
  18110. * Gets if the current filter is set to "PCSS" (contact hardening).
  18111. */
  18112. get useContactHardeningShadow(): boolean;
  18113. /**
  18114. * Sets the current filter to "PCSS" (contact hardening).
  18115. */
  18116. set useContactHardeningShadow(value: boolean);
  18117. protected _contactHardeningLightSizeUVRatio: number;
  18118. /**
  18119. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18120. * Using a ratio helps keeping shape stability independently of the map size.
  18121. *
  18122. * It does not account for the light projection as it was having too much
  18123. * instability during the light setup or during light position changes.
  18124. *
  18125. * Only valid if useContactHardeningShadow is true.
  18126. */
  18127. get contactHardeningLightSizeUVRatio(): number;
  18128. /**
  18129. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18130. * Using a ratio helps keeping shape stability independently of the map size.
  18131. *
  18132. * It does not account for the light projection as it was having too much
  18133. * instability during the light setup or during light position changes.
  18134. *
  18135. * Only valid if useContactHardeningShadow is true.
  18136. */
  18137. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18138. protected _darkness: number;
  18139. /** Gets or sets the actual darkness of a shadow */
  18140. get darkness(): number;
  18141. set darkness(value: number);
  18142. /**
  18143. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18144. * 0 means strongest and 1 would means no shadow.
  18145. * @returns the darkness.
  18146. */
  18147. getDarkness(): number;
  18148. /**
  18149. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18150. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18151. * @returns the shadow generator allowing fluent coding.
  18152. */
  18153. setDarkness(darkness: number): ShadowGenerator;
  18154. protected _transparencyShadow: boolean;
  18155. /** Gets or sets the ability to have transparent shadow */
  18156. get transparencyShadow(): boolean;
  18157. set transparencyShadow(value: boolean);
  18158. /**
  18159. * Sets the ability to have transparent shadow (boolean).
  18160. * @param transparent True if transparent else False
  18161. * @returns the shadow generator allowing fluent coding
  18162. */
  18163. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18164. /**
  18165. * Enables or disables shadows with varying strength based on the transparency
  18166. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18167. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18168. * mesh.visibility * alphaTexture.a
  18169. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18170. */
  18171. enableSoftTransparentShadow: boolean;
  18172. protected _shadowMap: Nullable<RenderTargetTexture>;
  18173. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18174. /**
  18175. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18176. * @returns The render target texture if present otherwise, null
  18177. */
  18178. getShadowMap(): Nullable<RenderTargetTexture>;
  18179. /**
  18180. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18181. * @returns The render target texture if the shadow map is present otherwise, null
  18182. */
  18183. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18184. /**
  18185. * Gets the class name of that object
  18186. * @returns "ShadowGenerator"
  18187. */
  18188. getClassName(): string;
  18189. /**
  18190. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18191. * @param mesh Mesh to add
  18192. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18193. * @returns the Shadow Generator itself
  18194. */
  18195. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18196. /**
  18197. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18198. * @param mesh Mesh to remove
  18199. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18200. * @returns the Shadow Generator itself
  18201. */
  18202. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18203. /**
  18204. * Controls the extent to which the shadows fade out at the edge of the frustum
  18205. */
  18206. frustumEdgeFalloff: number;
  18207. protected _light: IShadowLight;
  18208. /**
  18209. * Returns the associated light object.
  18210. * @returns the light generating the shadow
  18211. */
  18212. getLight(): IShadowLight;
  18213. /**
  18214. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18215. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18216. * It might on the other hand introduce peter panning.
  18217. */
  18218. forceBackFacesOnly: boolean;
  18219. protected _scene: Scene;
  18220. protected _lightDirection: Vector3;
  18221. protected _effect: Effect;
  18222. protected _viewMatrix: Matrix;
  18223. protected _projectionMatrix: Matrix;
  18224. protected _transformMatrix: Matrix;
  18225. protected _cachedPosition: Vector3;
  18226. protected _cachedDirection: Vector3;
  18227. protected _cachedDefines: string;
  18228. protected _currentRenderID: number;
  18229. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18230. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18231. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18232. protected _blurPostProcesses: PostProcess[];
  18233. protected _mapSize: number;
  18234. protected _currentFaceIndex: number;
  18235. protected _currentFaceIndexCache: number;
  18236. protected _textureType: number;
  18237. protected _defaultTextureMatrix: Matrix;
  18238. protected _storedUniqueId: Nullable<number>;
  18239. /** @hidden */
  18240. static _SceneComponentInitialization: (scene: Scene) => void;
  18241. /**
  18242. * Creates a ShadowGenerator object.
  18243. * A ShadowGenerator is the required tool to use the shadows.
  18244. * Each light casting shadows needs to use its own ShadowGenerator.
  18245. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18246. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18247. * @param light The light object generating the shadows.
  18248. * @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.
  18249. */
  18250. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18251. protected _initializeGenerator(): void;
  18252. protected _createTargetRenderTexture(): void;
  18253. protected _initializeShadowMap(): void;
  18254. protected _initializeBlurRTTAndPostProcesses(): void;
  18255. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18256. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18257. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18258. protected _applyFilterValues(): void;
  18259. /**
  18260. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18261. * @param onCompiled Callback triggered at the and of the effects compilation
  18262. * @param options Sets of optional options forcing the compilation with different modes
  18263. */
  18264. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18265. useInstances: boolean;
  18266. }>): void;
  18267. /**
  18268. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18269. * @param options Sets of optional options forcing the compilation with different modes
  18270. * @returns A promise that resolves when the compilation completes
  18271. */
  18272. forceCompilationAsync(options?: Partial<{
  18273. useInstances: boolean;
  18274. }>): Promise<void>;
  18275. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18276. private _prepareShadowDefines;
  18277. /**
  18278. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18279. * @param subMesh The submesh we want to render in the shadow map
  18280. * @param useInstances Defines wether will draw in the map using instances
  18281. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18282. * @returns true if ready otherwise, false
  18283. */
  18284. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18285. /**
  18286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18287. * @param defines Defines of the material we want to update
  18288. * @param lightIndex Index of the light in the enabled light list of the material
  18289. */
  18290. prepareDefines(defines: any, lightIndex: number): void;
  18291. /**
  18292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18293. * defined in the generator but impacting the effect).
  18294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18295. * @param effect The effect we are binfing the information for
  18296. */
  18297. bindShadowLight(lightIndex: string, effect: Effect): void;
  18298. /**
  18299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18300. * (eq to shadow prjection matrix * light transform matrix)
  18301. * @returns The transform matrix used to create the shadow map
  18302. */
  18303. getTransformMatrix(): Matrix;
  18304. /**
  18305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18306. * Cube and 2D textures for instance.
  18307. */
  18308. recreateShadowMap(): void;
  18309. protected _disposeBlurPostProcesses(): void;
  18310. protected _disposeRTTandPostProcesses(): void;
  18311. /**
  18312. * Disposes the ShadowGenerator.
  18313. * Returns nothing.
  18314. */
  18315. dispose(): void;
  18316. /**
  18317. * Serializes the shadow generator setup to a json object.
  18318. * @returns The serialized JSON object
  18319. */
  18320. serialize(): any;
  18321. /**
  18322. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18323. * @param parsedShadowGenerator The JSON object to parse
  18324. * @param scene The scene to create the shadow map for
  18325. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18326. * @returns The parsed shadow generator
  18327. */
  18328. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18329. }
  18330. }
  18331. declare module "babylonjs/Lights/light" {
  18332. import { Nullable } from "babylonjs/types";
  18333. import { Scene } from "babylonjs/scene";
  18334. import { Vector3 } from "babylonjs/Maths/math.vector";
  18335. import { Color3 } from "babylonjs/Maths/math.color";
  18336. import { Node } from "babylonjs/node";
  18337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18338. import { Effect } from "babylonjs/Materials/effect";
  18339. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18340. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18341. /**
  18342. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18343. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18344. * 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.
  18345. */
  18346. export abstract class Light extends Node {
  18347. /**
  18348. * Falloff Default: light is falling off following the material specification:
  18349. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18350. */
  18351. static readonly FALLOFF_DEFAULT: number;
  18352. /**
  18353. * Falloff Physical: light is falling off following the inverse squared distance law.
  18354. */
  18355. static readonly FALLOFF_PHYSICAL: number;
  18356. /**
  18357. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18358. * to enhance interoperability with other engines.
  18359. */
  18360. static readonly FALLOFF_GLTF: number;
  18361. /**
  18362. * Falloff Standard: light is falling off like in the standard material
  18363. * to enhance interoperability with other materials.
  18364. */
  18365. static readonly FALLOFF_STANDARD: number;
  18366. /**
  18367. * If every light affecting the material is in this lightmapMode,
  18368. * material.lightmapTexture adds or multiplies
  18369. * (depends on material.useLightmapAsShadowmap)
  18370. * after every other light calculations.
  18371. */
  18372. static readonly LIGHTMAP_DEFAULT: number;
  18373. /**
  18374. * material.lightmapTexture as only diffuse lighting from this light
  18375. * adds only specular lighting from this light
  18376. * adds dynamic shadows
  18377. */
  18378. static readonly LIGHTMAP_SPECULAR: number;
  18379. /**
  18380. * material.lightmapTexture as only lighting
  18381. * no light calculation from this light
  18382. * only adds dynamic shadows from this light
  18383. */
  18384. static readonly LIGHTMAP_SHADOWSONLY: number;
  18385. /**
  18386. * Each light type uses the default quantity according to its type:
  18387. * point/spot lights use luminous intensity
  18388. * directional lights use illuminance
  18389. */
  18390. static readonly INTENSITYMODE_AUTOMATIC: number;
  18391. /**
  18392. * lumen (lm)
  18393. */
  18394. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18395. /**
  18396. * candela (lm/sr)
  18397. */
  18398. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18399. /**
  18400. * lux (lm/m^2)
  18401. */
  18402. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18403. /**
  18404. * nit (cd/m^2)
  18405. */
  18406. static readonly INTENSITYMODE_LUMINANCE: number;
  18407. /**
  18408. * Light type const id of the point light.
  18409. */
  18410. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18411. /**
  18412. * Light type const id of the directional light.
  18413. */
  18414. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18415. /**
  18416. * Light type const id of the spot light.
  18417. */
  18418. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18419. /**
  18420. * Light type const id of the hemispheric light.
  18421. */
  18422. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18423. /**
  18424. * Diffuse gives the basic color to an object.
  18425. */
  18426. diffuse: Color3;
  18427. /**
  18428. * Specular produces a highlight color on an object.
  18429. * Note: This is note affecting PBR materials.
  18430. */
  18431. specular: Color3;
  18432. /**
  18433. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18434. * falling off base on range or angle.
  18435. * This can be set to any values in Light.FALLOFF_x.
  18436. *
  18437. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18438. * other types of materials.
  18439. */
  18440. falloffType: number;
  18441. /**
  18442. * Strength of the light.
  18443. * Note: By default it is define in the framework own unit.
  18444. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18445. */
  18446. intensity: number;
  18447. private _range;
  18448. protected _inverseSquaredRange: number;
  18449. /**
  18450. * Defines how far from the source the light is impacting in scene units.
  18451. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18452. */
  18453. get range(): number;
  18454. /**
  18455. * Defines how far from the source the light is impacting in scene units.
  18456. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18457. */
  18458. set range(value: number);
  18459. /**
  18460. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18461. * of light.
  18462. */
  18463. private _photometricScale;
  18464. private _intensityMode;
  18465. /**
  18466. * Gets the photometric scale used to interpret the intensity.
  18467. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18468. */
  18469. get intensityMode(): number;
  18470. /**
  18471. * Sets the photometric scale used to interpret the intensity.
  18472. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18473. */
  18474. set intensityMode(value: number);
  18475. private _radius;
  18476. /**
  18477. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18478. */
  18479. get radius(): number;
  18480. /**
  18481. * sets the light radius used by PBR Materials to simulate soft area lights.
  18482. */
  18483. set radius(value: number);
  18484. private _renderPriority;
  18485. /**
  18486. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18487. * exceeding the number allowed of the materials.
  18488. */
  18489. renderPriority: number;
  18490. private _shadowEnabled;
  18491. /**
  18492. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18493. * the current shadow generator.
  18494. */
  18495. get shadowEnabled(): boolean;
  18496. /**
  18497. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18498. * the current shadow generator.
  18499. */
  18500. set shadowEnabled(value: boolean);
  18501. private _includedOnlyMeshes;
  18502. /**
  18503. * Gets the only meshes impacted by this light.
  18504. */
  18505. get includedOnlyMeshes(): AbstractMesh[];
  18506. /**
  18507. * Sets the only meshes impacted by this light.
  18508. */
  18509. set includedOnlyMeshes(value: AbstractMesh[]);
  18510. private _excludedMeshes;
  18511. /**
  18512. * Gets the meshes not impacted by this light.
  18513. */
  18514. get excludedMeshes(): AbstractMesh[];
  18515. /**
  18516. * Sets the meshes not impacted by this light.
  18517. */
  18518. set excludedMeshes(value: AbstractMesh[]);
  18519. private _excludeWithLayerMask;
  18520. /**
  18521. * Gets the layer id use to find what meshes are not impacted by the light.
  18522. * Inactive if 0
  18523. */
  18524. get excludeWithLayerMask(): number;
  18525. /**
  18526. * Sets the layer id use to find what meshes are not impacted by the light.
  18527. * Inactive if 0
  18528. */
  18529. set excludeWithLayerMask(value: number);
  18530. private _includeOnlyWithLayerMask;
  18531. /**
  18532. * Gets the layer id use to find what meshes are impacted by the light.
  18533. * Inactive if 0
  18534. */
  18535. get includeOnlyWithLayerMask(): number;
  18536. /**
  18537. * Sets the layer id use to find what meshes are impacted by the light.
  18538. * Inactive if 0
  18539. */
  18540. set includeOnlyWithLayerMask(value: number);
  18541. private _lightmapMode;
  18542. /**
  18543. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18544. */
  18545. get lightmapMode(): number;
  18546. /**
  18547. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18548. */
  18549. set lightmapMode(value: number);
  18550. /**
  18551. * Shadow generator associted to the light.
  18552. * @hidden Internal use only.
  18553. */
  18554. _shadowGenerator: Nullable<IShadowGenerator>;
  18555. /**
  18556. * @hidden Internal use only.
  18557. */
  18558. _excludedMeshesIds: string[];
  18559. /**
  18560. * @hidden Internal use only.
  18561. */
  18562. _includedOnlyMeshesIds: string[];
  18563. /**
  18564. * The current light unifom buffer.
  18565. * @hidden Internal use only.
  18566. */
  18567. _uniformBuffer: UniformBuffer;
  18568. /** @hidden */
  18569. _renderId: number;
  18570. /**
  18571. * Creates a Light object in the scene.
  18572. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18573. * @param name The firendly name of the light
  18574. * @param scene The scene the light belongs too
  18575. */
  18576. constructor(name: string, scene: Scene);
  18577. protected abstract _buildUniformLayout(): void;
  18578. /**
  18579. * Sets the passed Effect "effect" with the Light information.
  18580. * @param effect The effect to update
  18581. * @param lightIndex The index of the light in the effect to update
  18582. * @returns The light
  18583. */
  18584. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18585. /**
  18586. * Sets the passed Effect "effect" with the Light textures.
  18587. * @param effect The effect to update
  18588. * @param lightIndex The index of the light in the effect to update
  18589. * @returns The light
  18590. */
  18591. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18592. /**
  18593. * Binds the lights information from the scene to the effect for the given mesh.
  18594. * @param lightIndex Light index
  18595. * @param scene The scene where the light belongs to
  18596. * @param effect The effect we are binding the data to
  18597. * @param useSpecular Defines if specular is supported
  18598. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18599. */
  18600. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18601. /**
  18602. * Sets the passed Effect "effect" with the Light information.
  18603. * @param effect The effect to update
  18604. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18605. * @returns The light
  18606. */
  18607. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18608. /**
  18609. * Returns the string "Light".
  18610. * @returns the class name
  18611. */
  18612. getClassName(): string;
  18613. /** @hidden */
  18614. readonly _isLight: boolean;
  18615. /**
  18616. * Converts the light information to a readable string for debug purpose.
  18617. * @param fullDetails Supports for multiple levels of logging within scene loading
  18618. * @returns the human readable light info
  18619. */
  18620. toString(fullDetails?: boolean): string;
  18621. /** @hidden */
  18622. protected _syncParentEnabledState(): void;
  18623. /**
  18624. * Set the enabled state of this node.
  18625. * @param value - the new enabled state
  18626. */
  18627. setEnabled(value: boolean): void;
  18628. /**
  18629. * Returns the Light associated shadow generator if any.
  18630. * @return the associated shadow generator.
  18631. */
  18632. getShadowGenerator(): Nullable<IShadowGenerator>;
  18633. /**
  18634. * Returns a Vector3, the absolute light position in the World.
  18635. * @returns the world space position of the light
  18636. */
  18637. getAbsolutePosition(): Vector3;
  18638. /**
  18639. * Specifies if the light will affect the passed mesh.
  18640. * @param mesh The mesh to test against the light
  18641. * @return true the mesh is affected otherwise, false.
  18642. */
  18643. canAffectMesh(mesh: AbstractMesh): boolean;
  18644. /**
  18645. * Sort function to order lights for rendering.
  18646. * @param a First Light object to compare to second.
  18647. * @param b Second Light object to compare first.
  18648. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18649. */
  18650. static CompareLightsPriority(a: Light, b: Light): number;
  18651. /**
  18652. * Releases resources associated with this node.
  18653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18655. */
  18656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18657. /**
  18658. * Returns the light type ID (integer).
  18659. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18660. */
  18661. getTypeID(): number;
  18662. /**
  18663. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18664. * @returns the scaled intensity in intensity mode unit
  18665. */
  18666. getScaledIntensity(): number;
  18667. /**
  18668. * Returns a new Light object, named "name", from the current one.
  18669. * @param name The name of the cloned light
  18670. * @param newParent The parent of this light, if it has one
  18671. * @returns the new created light
  18672. */
  18673. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18674. /**
  18675. * Serializes the current light into a Serialization object.
  18676. * @returns the serialized object.
  18677. */
  18678. serialize(): any;
  18679. /**
  18680. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18681. * This new light is named "name" and added to the passed scene.
  18682. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18683. * @param name The friendly name of the light
  18684. * @param scene The scene the new light will belong to
  18685. * @returns the constructor function
  18686. */
  18687. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18688. /**
  18689. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18690. * @param parsedLight The JSON representation of the light
  18691. * @param scene The scene to create the parsed light in
  18692. * @returns the created light after parsing
  18693. */
  18694. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18695. private _hookArrayForExcluded;
  18696. private _hookArrayForIncludedOnly;
  18697. private _resyncMeshes;
  18698. /**
  18699. * Forces the meshes to update their light related information in their rendering used effects
  18700. * @hidden Internal Use Only
  18701. */
  18702. _markMeshesAsLightDirty(): void;
  18703. /**
  18704. * Recomputes the cached photometric scale if needed.
  18705. */
  18706. private _computePhotometricScale;
  18707. /**
  18708. * Returns the Photometric Scale according to the light type and intensity mode.
  18709. */
  18710. private _getPhotometricScale;
  18711. /**
  18712. * Reorder the light in the scene according to their defined priority.
  18713. * @hidden Internal Use Only
  18714. */
  18715. _reorderLightsInScene(): void;
  18716. /**
  18717. * Prepares the list of defines specific to the light type.
  18718. * @param defines the list of defines
  18719. * @param lightIndex defines the index of the light for the effect
  18720. */
  18721. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18722. }
  18723. }
  18724. declare module "babylonjs/Cameras/targetCamera" {
  18725. import { Nullable } from "babylonjs/types";
  18726. import { Camera } from "babylonjs/Cameras/camera";
  18727. import { Scene } from "babylonjs/scene";
  18728. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18729. /**
  18730. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18731. * This is the base of the follow, arc rotate cameras and Free camera
  18732. * @see https://doc.babylonjs.com/features/cameras
  18733. */
  18734. export class TargetCamera extends Camera {
  18735. private static _RigCamTransformMatrix;
  18736. private static _TargetTransformMatrix;
  18737. private static _TargetFocalPoint;
  18738. private _tmpUpVector;
  18739. private _tmpTargetVector;
  18740. /**
  18741. * Define the current direction the camera is moving to
  18742. */
  18743. cameraDirection: Vector3;
  18744. /**
  18745. * Define the current rotation the camera is rotating to
  18746. */
  18747. cameraRotation: Vector2;
  18748. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18749. ignoreParentScaling: boolean;
  18750. /**
  18751. * When set, the up vector of the camera will be updated by the rotation of the camera
  18752. */
  18753. updateUpVectorFromRotation: boolean;
  18754. private _tmpQuaternion;
  18755. /**
  18756. * Define the current rotation of the camera
  18757. */
  18758. rotation: Vector3;
  18759. /**
  18760. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18761. */
  18762. rotationQuaternion: Quaternion;
  18763. /**
  18764. * Define the current speed of the camera
  18765. */
  18766. speed: number;
  18767. /**
  18768. * Add constraint to the camera to prevent it to move freely in all directions and
  18769. * around all axis.
  18770. */
  18771. noRotationConstraint: boolean;
  18772. /**
  18773. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18774. * panning
  18775. */
  18776. invertRotation: boolean;
  18777. /**
  18778. * Speed multiplier for inverse camera panning
  18779. */
  18780. inverseRotationSpeed: number;
  18781. /**
  18782. * Define the current target of the camera as an object or a position.
  18783. */
  18784. lockedTarget: any;
  18785. /** @hidden */
  18786. _currentTarget: Vector3;
  18787. /** @hidden */
  18788. _initialFocalDistance: number;
  18789. /** @hidden */
  18790. _viewMatrix: Matrix;
  18791. /** @hidden */
  18792. _camMatrix: Matrix;
  18793. /** @hidden */
  18794. _cameraTransformMatrix: Matrix;
  18795. /** @hidden */
  18796. _cameraRotationMatrix: Matrix;
  18797. /** @hidden */
  18798. _referencePoint: Vector3;
  18799. /** @hidden */
  18800. _transformedReferencePoint: Vector3;
  18801. /** @hidden */
  18802. _reset: () => void;
  18803. private _defaultUp;
  18804. /**
  18805. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18806. * This is the base of the follow, arc rotate cameras and Free camera
  18807. * @see https://doc.babylonjs.com/features/cameras
  18808. * @param name Defines the name of the camera in the scene
  18809. * @param position Defines the start position of the camera in the scene
  18810. * @param scene Defines the scene the camera belongs to
  18811. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18812. */
  18813. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18814. /**
  18815. * Gets the position in front of the camera at a given distance.
  18816. * @param distance The distance from the camera we want the position to be
  18817. * @returns the position
  18818. */
  18819. getFrontPosition(distance: number): Vector3;
  18820. /** @hidden */
  18821. _getLockedTargetPosition(): Nullable<Vector3>;
  18822. private _storedPosition;
  18823. private _storedRotation;
  18824. private _storedRotationQuaternion;
  18825. /**
  18826. * Store current camera state of the camera (fov, position, rotation, etc..)
  18827. * @returns the camera
  18828. */
  18829. storeState(): Camera;
  18830. /**
  18831. * Restored camera state. You must call storeState() first
  18832. * @returns whether it was successful or not
  18833. * @hidden
  18834. */
  18835. _restoreStateValues(): boolean;
  18836. /** @hidden */
  18837. _initCache(): void;
  18838. /** @hidden */
  18839. _updateCache(ignoreParentClass?: boolean): void;
  18840. /** @hidden */
  18841. _isSynchronizedViewMatrix(): boolean;
  18842. /** @hidden */
  18843. _computeLocalCameraSpeed(): number;
  18844. /**
  18845. * Defines the target the camera should look at.
  18846. * @param target Defines the new target as a Vector or a mesh
  18847. */
  18848. setTarget(target: Vector3): void;
  18849. /**
  18850. * Return the current target position of the camera. This value is expressed in local space.
  18851. * @returns the target position
  18852. */
  18853. getTarget(): Vector3;
  18854. /** @hidden */
  18855. _decideIfNeedsToMove(): boolean;
  18856. /** @hidden */
  18857. _updatePosition(): void;
  18858. /** @hidden */
  18859. _checkInputs(): void;
  18860. protected _updateCameraRotationMatrix(): void;
  18861. /**
  18862. * 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)
  18863. * @returns the current camera
  18864. */
  18865. private _rotateUpVectorWithCameraRotationMatrix;
  18866. private _cachedRotationZ;
  18867. private _cachedQuaternionRotationZ;
  18868. /** @hidden */
  18869. _getViewMatrix(): Matrix;
  18870. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18871. /**
  18872. * @hidden
  18873. */
  18874. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18875. /**
  18876. * @hidden
  18877. */
  18878. _updateRigCameras(): void;
  18879. private _getRigCamPositionAndTarget;
  18880. /**
  18881. * Gets the current object class name.
  18882. * @return the class name
  18883. */
  18884. getClassName(): string;
  18885. }
  18886. }
  18887. declare module "babylonjs/Events/keyboardEvents" {
  18888. /**
  18889. * Gather the list of keyboard event types as constants.
  18890. */
  18891. export class KeyboardEventTypes {
  18892. /**
  18893. * The keydown event is fired when a key becomes active (pressed).
  18894. */
  18895. static readonly KEYDOWN: number;
  18896. /**
  18897. * The keyup event is fired when a key has been released.
  18898. */
  18899. static readonly KEYUP: number;
  18900. }
  18901. /**
  18902. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18903. */
  18904. export class KeyboardInfo {
  18905. /**
  18906. * Defines the type of event (KeyboardEventTypes)
  18907. */
  18908. type: number;
  18909. /**
  18910. * Defines the related dom event
  18911. */
  18912. event: KeyboardEvent;
  18913. /**
  18914. * Instantiates a new keyboard info.
  18915. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18916. * @param type Defines the type of event (KeyboardEventTypes)
  18917. * @param event Defines the related dom event
  18918. */
  18919. constructor(
  18920. /**
  18921. * Defines the type of event (KeyboardEventTypes)
  18922. */
  18923. type: number,
  18924. /**
  18925. * Defines the related dom event
  18926. */
  18927. event: KeyboardEvent);
  18928. }
  18929. /**
  18930. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18931. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18932. */
  18933. export class KeyboardInfoPre extends KeyboardInfo {
  18934. /**
  18935. * Defines the type of event (KeyboardEventTypes)
  18936. */
  18937. type: number;
  18938. /**
  18939. * Defines the related dom event
  18940. */
  18941. event: KeyboardEvent;
  18942. /**
  18943. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18944. */
  18945. skipOnPointerObservable: boolean;
  18946. /**
  18947. * Instantiates a new keyboard pre info.
  18948. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18949. * @param type Defines the type of event (KeyboardEventTypes)
  18950. * @param event Defines the related dom event
  18951. */
  18952. constructor(
  18953. /**
  18954. * Defines the type of event (KeyboardEventTypes)
  18955. */
  18956. type: number,
  18957. /**
  18958. * Defines the related dom event
  18959. */
  18960. event: KeyboardEvent);
  18961. }
  18962. }
  18963. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18964. import { Nullable } from "babylonjs/types";
  18965. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18966. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18967. /**
  18968. * Manage the keyboard inputs to control the movement of a free camera.
  18969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18970. */
  18971. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18972. /**
  18973. * Defines the camera the input is attached to.
  18974. */
  18975. camera: FreeCamera;
  18976. /**
  18977. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18978. */
  18979. keysUp: number[];
  18980. /**
  18981. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18982. */
  18983. keysUpward: number[];
  18984. /**
  18985. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18986. */
  18987. keysDown: number[];
  18988. /**
  18989. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18990. */
  18991. keysDownward: number[];
  18992. /**
  18993. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18994. */
  18995. keysLeft: number[];
  18996. /**
  18997. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18998. */
  18999. keysRight: number[];
  19000. private _keys;
  19001. private _onCanvasBlurObserver;
  19002. private _onKeyboardObserver;
  19003. private _engine;
  19004. private _scene;
  19005. /**
  19006. * Attach the input controls to a specific dom element to get the input from.
  19007. * @param element Defines the element the controls should be listened from
  19008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19009. */
  19010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19011. /**
  19012. * Detach the current controls from the specified dom element.
  19013. * @param element Defines the element to stop listening the inputs from
  19014. */
  19015. detachControl(element: Nullable<HTMLElement>): void;
  19016. /**
  19017. * Update the current camera state depending on the inputs that have been used this frame.
  19018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19019. */
  19020. checkInputs(): void;
  19021. /**
  19022. * Gets the class name of the current intput.
  19023. * @returns the class name
  19024. */
  19025. getClassName(): string;
  19026. /** @hidden */
  19027. _onLostFocus(): void;
  19028. /**
  19029. * Get the friendly name associated with the input class.
  19030. * @returns the input friendly name
  19031. */
  19032. getSimpleName(): string;
  19033. }
  19034. }
  19035. declare module "babylonjs/Events/pointerEvents" {
  19036. import { Nullable } from "babylonjs/types";
  19037. import { Vector2 } from "babylonjs/Maths/math.vector";
  19038. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19039. import { Ray } from "babylonjs/Culling/ray";
  19040. /**
  19041. * Gather the list of pointer event types as constants.
  19042. */
  19043. export class PointerEventTypes {
  19044. /**
  19045. * 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.
  19046. */
  19047. static readonly POINTERDOWN: number;
  19048. /**
  19049. * The pointerup event is fired when a pointer is no longer active.
  19050. */
  19051. static readonly POINTERUP: number;
  19052. /**
  19053. * The pointermove event is fired when a pointer changes coordinates.
  19054. */
  19055. static readonly POINTERMOVE: number;
  19056. /**
  19057. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19058. */
  19059. static readonly POINTERWHEEL: number;
  19060. /**
  19061. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19062. */
  19063. static readonly POINTERPICK: number;
  19064. /**
  19065. * The pointertap event is fired when a the object has been touched and released without drag.
  19066. */
  19067. static readonly POINTERTAP: number;
  19068. /**
  19069. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19070. */
  19071. static readonly POINTERDOUBLETAP: number;
  19072. }
  19073. /**
  19074. * Base class of pointer info types.
  19075. */
  19076. export class PointerInfoBase {
  19077. /**
  19078. * Defines the type of event (PointerEventTypes)
  19079. */
  19080. type: number;
  19081. /**
  19082. * Defines the related dom event
  19083. */
  19084. event: PointerEvent | MouseWheelEvent;
  19085. /**
  19086. * Instantiates the base class of pointers info.
  19087. * @param type Defines the type of event (PointerEventTypes)
  19088. * @param event Defines the related dom event
  19089. */
  19090. constructor(
  19091. /**
  19092. * Defines the type of event (PointerEventTypes)
  19093. */
  19094. type: number,
  19095. /**
  19096. * Defines the related dom event
  19097. */
  19098. event: PointerEvent | MouseWheelEvent);
  19099. }
  19100. /**
  19101. * This class is used to store pointer related info for the onPrePointerObservable event.
  19102. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19103. */
  19104. export class PointerInfoPre extends PointerInfoBase {
  19105. /**
  19106. * Ray from a pointer if availible (eg. 6dof controller)
  19107. */
  19108. ray: Nullable<Ray>;
  19109. /**
  19110. * Defines the local position of the pointer on the canvas.
  19111. */
  19112. localPosition: Vector2;
  19113. /**
  19114. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19115. */
  19116. skipOnPointerObservable: boolean;
  19117. /**
  19118. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19119. * @param type Defines the type of event (PointerEventTypes)
  19120. * @param event Defines the related dom event
  19121. * @param localX Defines the local x coordinates of the pointer when the event occured
  19122. * @param localY Defines the local y coordinates of the pointer when the event occured
  19123. */
  19124. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19125. }
  19126. /**
  19127. * This type contains all the data related to a pointer event in Babylon.js.
  19128. * 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.
  19129. */
  19130. export class PointerInfo extends PointerInfoBase {
  19131. /**
  19132. * Defines the picking info associated to the info (if any)\
  19133. */
  19134. pickInfo: Nullable<PickingInfo>;
  19135. /**
  19136. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19137. * @param type Defines the type of event (PointerEventTypes)
  19138. * @param event Defines the related dom event
  19139. * @param pickInfo Defines the picking info associated to the info (if any)\
  19140. */
  19141. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19142. /**
  19143. * Defines the picking info associated to the info (if any)\
  19144. */
  19145. pickInfo: Nullable<PickingInfo>);
  19146. }
  19147. /**
  19148. * Data relating to a touch event on the screen.
  19149. */
  19150. export interface PointerTouch {
  19151. /**
  19152. * X coordinate of touch.
  19153. */
  19154. x: number;
  19155. /**
  19156. * Y coordinate of touch.
  19157. */
  19158. y: number;
  19159. /**
  19160. * Id of touch. Unique for each finger.
  19161. */
  19162. pointerId: number;
  19163. /**
  19164. * Event type passed from DOM.
  19165. */
  19166. type: any;
  19167. }
  19168. }
  19169. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19170. import { Observable } from "babylonjs/Misc/observable";
  19171. import { Nullable } from "babylonjs/types";
  19172. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19173. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19174. /**
  19175. * Manage the mouse inputs to control the movement of a free camera.
  19176. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19177. */
  19178. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19179. /**
  19180. * Define if touch is enabled in the mouse input
  19181. */
  19182. touchEnabled: boolean;
  19183. /**
  19184. * Defines the camera the input is attached to.
  19185. */
  19186. camera: FreeCamera;
  19187. /**
  19188. * Defines the buttons associated with the input to handle camera move.
  19189. */
  19190. buttons: number[];
  19191. /**
  19192. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19193. */
  19194. angularSensibility: number;
  19195. private _pointerInput;
  19196. private _onMouseMove;
  19197. private _observer;
  19198. private previousPosition;
  19199. /**
  19200. * Observable for when a pointer move event occurs containing the move offset
  19201. */
  19202. onPointerMovedObservable: Observable<{
  19203. offsetX: number;
  19204. offsetY: number;
  19205. }>;
  19206. /**
  19207. * @hidden
  19208. * If the camera should be rotated automatically based on pointer movement
  19209. */
  19210. _allowCameraRotation: boolean;
  19211. /**
  19212. * Manage the mouse inputs to control the movement of a free camera.
  19213. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19214. * @param touchEnabled Defines if touch is enabled or not
  19215. */
  19216. constructor(
  19217. /**
  19218. * Define if touch is enabled in the mouse input
  19219. */
  19220. touchEnabled?: boolean);
  19221. /**
  19222. * Attach the input controls to a specific dom element to get the input from.
  19223. * @param element Defines the element the controls should be listened from
  19224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19225. */
  19226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19227. /**
  19228. * Called on JS contextmenu event.
  19229. * Override this method to provide functionality.
  19230. */
  19231. protected onContextMenu(evt: PointerEvent): void;
  19232. /**
  19233. * Detach the current controls from the specified dom element.
  19234. * @param element Defines the element to stop listening the inputs from
  19235. */
  19236. detachControl(element: Nullable<HTMLElement>): void;
  19237. /**
  19238. * Gets the class name of the current intput.
  19239. * @returns the class name
  19240. */
  19241. getClassName(): string;
  19242. /**
  19243. * Get the friendly name associated with the input class.
  19244. * @returns the input friendly name
  19245. */
  19246. getSimpleName(): string;
  19247. }
  19248. }
  19249. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19250. import { Nullable } from "babylonjs/types";
  19251. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19252. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19253. /**
  19254. * Manage the touch inputs to control the movement of a free camera.
  19255. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19256. */
  19257. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19258. /**
  19259. * Defines the camera the input is attached to.
  19260. */
  19261. camera: FreeCamera;
  19262. /**
  19263. * Defines the touch sensibility for rotation.
  19264. * The higher the faster.
  19265. */
  19266. touchAngularSensibility: number;
  19267. /**
  19268. * Defines the touch sensibility for move.
  19269. * The higher the faster.
  19270. */
  19271. touchMoveSensibility: number;
  19272. private _offsetX;
  19273. private _offsetY;
  19274. private _pointerPressed;
  19275. private _pointerInput;
  19276. private _observer;
  19277. private _onLostFocus;
  19278. /**
  19279. * Attach the input controls to a specific dom element to get the input from.
  19280. * @param element Defines the element the controls should be listened from
  19281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19282. */
  19283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19284. /**
  19285. * Detach the current controls from the specified dom element.
  19286. * @param element Defines the element to stop listening the inputs from
  19287. */
  19288. detachControl(element: Nullable<HTMLElement>): void;
  19289. /**
  19290. * Update the current camera state depending on the inputs that have been used this frame.
  19291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19292. */
  19293. checkInputs(): void;
  19294. /**
  19295. * Gets the class name of the current intput.
  19296. * @returns the class name
  19297. */
  19298. getClassName(): string;
  19299. /**
  19300. * Get the friendly name associated with the input class.
  19301. * @returns the input friendly name
  19302. */
  19303. getSimpleName(): string;
  19304. }
  19305. }
  19306. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19307. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19308. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19309. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19310. import { Nullable } from "babylonjs/types";
  19311. /**
  19312. * Default Inputs manager for the FreeCamera.
  19313. * It groups all the default supported inputs for ease of use.
  19314. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19315. */
  19316. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19317. /**
  19318. * @hidden
  19319. */
  19320. _mouseInput: Nullable<FreeCameraMouseInput>;
  19321. /**
  19322. * Instantiates a new FreeCameraInputsManager.
  19323. * @param camera Defines the camera the inputs belong to
  19324. */
  19325. constructor(camera: FreeCamera);
  19326. /**
  19327. * Add keyboard input support to the input manager.
  19328. * @returns the current input manager
  19329. */
  19330. addKeyboard(): FreeCameraInputsManager;
  19331. /**
  19332. * Add mouse input support to the input manager.
  19333. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19334. * @returns the current input manager
  19335. */
  19336. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19337. /**
  19338. * Removes the mouse input support from the manager
  19339. * @returns the current input manager
  19340. */
  19341. removeMouse(): FreeCameraInputsManager;
  19342. /**
  19343. * Add touch input support to the input manager.
  19344. * @returns the current input manager
  19345. */
  19346. addTouch(): FreeCameraInputsManager;
  19347. /**
  19348. * Remove all attached input methods from a camera
  19349. */
  19350. clear(): void;
  19351. }
  19352. }
  19353. declare module "babylonjs/Cameras/freeCamera" {
  19354. import { Vector3 } from "babylonjs/Maths/math.vector";
  19355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19356. import { Scene } from "babylonjs/scene";
  19357. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19358. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19359. /**
  19360. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19361. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19362. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19363. */
  19364. export class FreeCamera extends TargetCamera {
  19365. /**
  19366. * Define the collision ellipsoid of the camera.
  19367. * This is helpful to simulate a camera body like the player body around the camera
  19368. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19369. */
  19370. ellipsoid: Vector3;
  19371. /**
  19372. * Define an offset for the position of the ellipsoid around the camera.
  19373. * This can be helpful to determine the center of the body near the gravity center of the body
  19374. * instead of its head.
  19375. */
  19376. ellipsoidOffset: Vector3;
  19377. /**
  19378. * Enable or disable collisions of the camera with the rest of the scene objects.
  19379. */
  19380. checkCollisions: boolean;
  19381. /**
  19382. * Enable or disable gravity on the camera.
  19383. */
  19384. applyGravity: boolean;
  19385. /**
  19386. * Define the input manager associated to the camera.
  19387. */
  19388. inputs: FreeCameraInputsManager;
  19389. /**
  19390. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19391. * Higher values reduce sensitivity.
  19392. */
  19393. get angularSensibility(): number;
  19394. /**
  19395. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19396. * Higher values reduce sensitivity.
  19397. */
  19398. set angularSensibility(value: number);
  19399. /**
  19400. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19401. */
  19402. get keysUp(): number[];
  19403. set keysUp(value: number[]);
  19404. /**
  19405. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19406. */
  19407. get keysUpward(): number[];
  19408. set keysUpward(value: number[]);
  19409. /**
  19410. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19411. */
  19412. get keysDown(): number[];
  19413. set keysDown(value: number[]);
  19414. /**
  19415. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19416. */
  19417. get keysDownward(): number[];
  19418. set keysDownward(value: number[]);
  19419. /**
  19420. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19421. */
  19422. get keysLeft(): number[];
  19423. set keysLeft(value: number[]);
  19424. /**
  19425. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19426. */
  19427. get keysRight(): number[];
  19428. set keysRight(value: number[]);
  19429. /**
  19430. * Event raised when the camera collide with a mesh in the scene.
  19431. */
  19432. onCollide: (collidedMesh: AbstractMesh) => void;
  19433. private _collider;
  19434. private _needMoveForGravity;
  19435. private _oldPosition;
  19436. private _diffPosition;
  19437. private _newPosition;
  19438. /** @hidden */
  19439. _localDirection: Vector3;
  19440. /** @hidden */
  19441. _transformedDirection: Vector3;
  19442. /**
  19443. * Instantiates a Free Camera.
  19444. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19445. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19446. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19447. * @param name Define the name of the camera in the scene
  19448. * @param position Define the start position of the camera in the scene
  19449. * @param scene Define the scene the camera belongs to
  19450. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19451. */
  19452. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19453. /**
  19454. * Attached controls to the current camera.
  19455. * @param element Defines the element the controls should be listened from
  19456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19457. */
  19458. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19459. /**
  19460. * Detach the current controls from the camera.
  19461. * The camera will stop reacting to inputs.
  19462. * @param element Defines the element to stop listening the inputs from
  19463. */
  19464. detachControl(element: HTMLElement): void;
  19465. private _collisionMask;
  19466. /**
  19467. * Define a collision mask to limit the list of object the camera can collide with
  19468. */
  19469. get collisionMask(): number;
  19470. set collisionMask(mask: number);
  19471. /** @hidden */
  19472. _collideWithWorld(displacement: Vector3): void;
  19473. private _onCollisionPositionChange;
  19474. /** @hidden */
  19475. _checkInputs(): void;
  19476. /** @hidden */
  19477. _decideIfNeedsToMove(): boolean;
  19478. /** @hidden */
  19479. _updatePosition(): void;
  19480. /**
  19481. * Destroy the camera and release the current resources hold by it.
  19482. */
  19483. dispose(): void;
  19484. /**
  19485. * Gets the current object class name.
  19486. * @return the class name
  19487. */
  19488. getClassName(): string;
  19489. }
  19490. }
  19491. declare module "babylonjs/Gamepads/gamepad" {
  19492. import { Observable } from "babylonjs/Misc/observable";
  19493. /**
  19494. * Represents a gamepad control stick position
  19495. */
  19496. export class StickValues {
  19497. /**
  19498. * The x component of the control stick
  19499. */
  19500. x: number;
  19501. /**
  19502. * The y component of the control stick
  19503. */
  19504. y: number;
  19505. /**
  19506. * Initializes the gamepad x and y control stick values
  19507. * @param x The x component of the gamepad control stick value
  19508. * @param y The y component of the gamepad control stick value
  19509. */
  19510. constructor(
  19511. /**
  19512. * The x component of the control stick
  19513. */
  19514. x: number,
  19515. /**
  19516. * The y component of the control stick
  19517. */
  19518. y: number);
  19519. }
  19520. /**
  19521. * An interface which manages callbacks for gamepad button changes
  19522. */
  19523. export interface GamepadButtonChanges {
  19524. /**
  19525. * Called when a gamepad has been changed
  19526. */
  19527. changed: boolean;
  19528. /**
  19529. * Called when a gamepad press event has been triggered
  19530. */
  19531. pressChanged: boolean;
  19532. /**
  19533. * Called when a touch event has been triggered
  19534. */
  19535. touchChanged: boolean;
  19536. /**
  19537. * Called when a value has changed
  19538. */
  19539. valueChanged: boolean;
  19540. }
  19541. /**
  19542. * Represents a gamepad
  19543. */
  19544. export class Gamepad {
  19545. /**
  19546. * The id of the gamepad
  19547. */
  19548. id: string;
  19549. /**
  19550. * The index of the gamepad
  19551. */
  19552. index: number;
  19553. /**
  19554. * The browser gamepad
  19555. */
  19556. browserGamepad: any;
  19557. /**
  19558. * Specifies what type of gamepad this represents
  19559. */
  19560. type: number;
  19561. private _leftStick;
  19562. private _rightStick;
  19563. /** @hidden */
  19564. _isConnected: boolean;
  19565. private _leftStickAxisX;
  19566. private _leftStickAxisY;
  19567. private _rightStickAxisX;
  19568. private _rightStickAxisY;
  19569. /**
  19570. * Triggered when the left control stick has been changed
  19571. */
  19572. private _onleftstickchanged;
  19573. /**
  19574. * Triggered when the right control stick has been changed
  19575. */
  19576. private _onrightstickchanged;
  19577. /**
  19578. * Represents a gamepad controller
  19579. */
  19580. static GAMEPAD: number;
  19581. /**
  19582. * Represents a generic controller
  19583. */
  19584. static GENERIC: number;
  19585. /**
  19586. * Represents an XBox controller
  19587. */
  19588. static XBOX: number;
  19589. /**
  19590. * Represents a pose-enabled controller
  19591. */
  19592. static POSE_ENABLED: number;
  19593. /**
  19594. * Represents an Dual Shock controller
  19595. */
  19596. static DUALSHOCK: number;
  19597. /**
  19598. * Specifies whether the left control stick should be Y-inverted
  19599. */
  19600. protected _invertLeftStickY: boolean;
  19601. /**
  19602. * Specifies if the gamepad has been connected
  19603. */
  19604. get isConnected(): boolean;
  19605. /**
  19606. * Initializes the gamepad
  19607. * @param id The id of the gamepad
  19608. * @param index The index of the gamepad
  19609. * @param browserGamepad The browser gamepad
  19610. * @param leftStickX The x component of the left joystick
  19611. * @param leftStickY The y component of the left joystick
  19612. * @param rightStickX The x component of the right joystick
  19613. * @param rightStickY The y component of the right joystick
  19614. */
  19615. constructor(
  19616. /**
  19617. * The id of the gamepad
  19618. */
  19619. id: string,
  19620. /**
  19621. * The index of the gamepad
  19622. */
  19623. index: number,
  19624. /**
  19625. * The browser gamepad
  19626. */
  19627. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19628. /**
  19629. * Callback triggered when the left joystick has changed
  19630. * @param callback
  19631. */
  19632. onleftstickchanged(callback: (values: StickValues) => void): void;
  19633. /**
  19634. * Callback triggered when the right joystick has changed
  19635. * @param callback
  19636. */
  19637. onrightstickchanged(callback: (values: StickValues) => void): void;
  19638. /**
  19639. * Gets the left joystick
  19640. */
  19641. get leftStick(): StickValues;
  19642. /**
  19643. * Sets the left joystick values
  19644. */
  19645. set leftStick(newValues: StickValues);
  19646. /**
  19647. * Gets the right joystick
  19648. */
  19649. get rightStick(): StickValues;
  19650. /**
  19651. * Sets the right joystick value
  19652. */
  19653. set rightStick(newValues: StickValues);
  19654. /**
  19655. * Updates the gamepad joystick positions
  19656. */
  19657. update(): void;
  19658. /**
  19659. * Disposes the gamepad
  19660. */
  19661. dispose(): void;
  19662. }
  19663. /**
  19664. * Represents a generic gamepad
  19665. */
  19666. export class GenericPad extends Gamepad {
  19667. private _buttons;
  19668. private _onbuttondown;
  19669. private _onbuttonup;
  19670. /**
  19671. * Observable triggered when a button has been pressed
  19672. */
  19673. onButtonDownObservable: Observable<number>;
  19674. /**
  19675. * Observable triggered when a button has been released
  19676. */
  19677. onButtonUpObservable: Observable<number>;
  19678. /**
  19679. * Callback triggered when a button has been pressed
  19680. * @param callback Called when a button has been pressed
  19681. */
  19682. onbuttondown(callback: (buttonPressed: number) => void): void;
  19683. /**
  19684. * Callback triggered when a button has been released
  19685. * @param callback Called when a button has been released
  19686. */
  19687. onbuttonup(callback: (buttonReleased: number) => void): void;
  19688. /**
  19689. * Initializes the generic gamepad
  19690. * @param id The id of the generic gamepad
  19691. * @param index The index of the generic gamepad
  19692. * @param browserGamepad The browser gamepad
  19693. */
  19694. constructor(id: string, index: number, browserGamepad: any);
  19695. private _setButtonValue;
  19696. /**
  19697. * Updates the generic gamepad
  19698. */
  19699. update(): void;
  19700. /**
  19701. * Disposes the generic gamepad
  19702. */
  19703. dispose(): void;
  19704. }
  19705. }
  19706. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19707. import { Observable } from "babylonjs/Misc/observable";
  19708. import { Nullable } from "babylonjs/types";
  19709. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19710. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19712. import { Ray } from "babylonjs/Culling/ray";
  19713. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19714. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19715. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19716. /**
  19717. * Defines the types of pose enabled controllers that are supported
  19718. */
  19719. export enum PoseEnabledControllerType {
  19720. /**
  19721. * HTC Vive
  19722. */
  19723. VIVE = 0,
  19724. /**
  19725. * Oculus Rift
  19726. */
  19727. OCULUS = 1,
  19728. /**
  19729. * Windows mixed reality
  19730. */
  19731. WINDOWS = 2,
  19732. /**
  19733. * Samsung gear VR
  19734. */
  19735. GEAR_VR = 3,
  19736. /**
  19737. * Google Daydream
  19738. */
  19739. DAYDREAM = 4,
  19740. /**
  19741. * Generic
  19742. */
  19743. GENERIC = 5
  19744. }
  19745. /**
  19746. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19747. */
  19748. export interface MutableGamepadButton {
  19749. /**
  19750. * Value of the button/trigger
  19751. */
  19752. value: number;
  19753. /**
  19754. * If the button/trigger is currently touched
  19755. */
  19756. touched: boolean;
  19757. /**
  19758. * If the button/trigger is currently pressed
  19759. */
  19760. pressed: boolean;
  19761. }
  19762. /**
  19763. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19764. * @hidden
  19765. */
  19766. export interface ExtendedGamepadButton extends GamepadButton {
  19767. /**
  19768. * If the button/trigger is currently pressed
  19769. */
  19770. readonly pressed: boolean;
  19771. /**
  19772. * If the button/trigger is currently touched
  19773. */
  19774. readonly touched: boolean;
  19775. /**
  19776. * Value of the button/trigger
  19777. */
  19778. readonly value: number;
  19779. }
  19780. /** @hidden */
  19781. export interface _GamePadFactory {
  19782. /**
  19783. * Returns whether or not the current gamepad can be created for this type of controller.
  19784. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19785. * @returns true if it can be created, otherwise false
  19786. */
  19787. canCreate(gamepadInfo: any): boolean;
  19788. /**
  19789. * Creates a new instance of the Gamepad.
  19790. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19791. * @returns the new gamepad instance
  19792. */
  19793. create(gamepadInfo: any): Gamepad;
  19794. }
  19795. /**
  19796. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19797. */
  19798. export class PoseEnabledControllerHelper {
  19799. /** @hidden */
  19800. static _ControllerFactories: _GamePadFactory[];
  19801. /** @hidden */
  19802. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19803. /**
  19804. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19805. * @param vrGamepad the gamepad to initialized
  19806. * @returns a vr controller of the type the gamepad identified as
  19807. */
  19808. static InitiateController(vrGamepad: any): Gamepad;
  19809. }
  19810. /**
  19811. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19812. */
  19813. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19814. /**
  19815. * If the controller is used in a webXR session
  19816. */
  19817. isXR: boolean;
  19818. private _deviceRoomPosition;
  19819. private _deviceRoomRotationQuaternion;
  19820. /**
  19821. * The device position in babylon space
  19822. */
  19823. devicePosition: Vector3;
  19824. /**
  19825. * The device rotation in babylon space
  19826. */
  19827. deviceRotationQuaternion: Quaternion;
  19828. /**
  19829. * The scale factor of the device in babylon space
  19830. */
  19831. deviceScaleFactor: number;
  19832. /**
  19833. * (Likely devicePosition should be used instead) The device position in its room space
  19834. */
  19835. position: Vector3;
  19836. /**
  19837. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19838. */
  19839. rotationQuaternion: Quaternion;
  19840. /**
  19841. * The type of controller (Eg. Windows mixed reality)
  19842. */
  19843. controllerType: PoseEnabledControllerType;
  19844. protected _calculatedPosition: Vector3;
  19845. private _calculatedRotation;
  19846. /**
  19847. * The raw pose from the device
  19848. */
  19849. rawPose: DevicePose;
  19850. private _trackPosition;
  19851. private _maxRotationDistFromHeadset;
  19852. private _draggedRoomRotation;
  19853. /**
  19854. * @hidden
  19855. */
  19856. _disableTrackPosition(fixedPosition: Vector3): void;
  19857. /**
  19858. * Internal, the mesh attached to the controller
  19859. * @hidden
  19860. */
  19861. _mesh: Nullable<AbstractMesh>;
  19862. private _poseControlledCamera;
  19863. private _leftHandSystemQuaternion;
  19864. /**
  19865. * Internal, matrix used to convert room space to babylon space
  19866. * @hidden
  19867. */
  19868. _deviceToWorld: Matrix;
  19869. /**
  19870. * Node to be used when casting a ray from the controller
  19871. * @hidden
  19872. */
  19873. _pointingPoseNode: Nullable<TransformNode>;
  19874. /**
  19875. * Name of the child mesh that can be used to cast a ray from the controller
  19876. */
  19877. static readonly POINTING_POSE: string;
  19878. /**
  19879. * Creates a new PoseEnabledController from a gamepad
  19880. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19881. */
  19882. constructor(browserGamepad: any);
  19883. private _workingMatrix;
  19884. /**
  19885. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19886. */
  19887. update(): void;
  19888. /**
  19889. * Updates only the pose device and mesh without doing any button event checking
  19890. */
  19891. protected _updatePoseAndMesh(): void;
  19892. /**
  19893. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19894. * @param poseData raw pose fromthe device
  19895. */
  19896. updateFromDevice(poseData: DevicePose): void;
  19897. /**
  19898. * @hidden
  19899. */
  19900. _meshAttachedObservable: Observable<AbstractMesh>;
  19901. /**
  19902. * Attaches a mesh to the controller
  19903. * @param mesh the mesh to be attached
  19904. */
  19905. attachToMesh(mesh: AbstractMesh): void;
  19906. /**
  19907. * Attaches the controllers mesh to a camera
  19908. * @param camera the camera the mesh should be attached to
  19909. */
  19910. attachToPoseControlledCamera(camera: TargetCamera): void;
  19911. /**
  19912. * Disposes of the controller
  19913. */
  19914. dispose(): void;
  19915. /**
  19916. * The mesh that is attached to the controller
  19917. */
  19918. get mesh(): Nullable<AbstractMesh>;
  19919. /**
  19920. * Gets the ray of the controller in the direction the controller is pointing
  19921. * @param length the length the resulting ray should be
  19922. * @returns a ray in the direction the controller is pointing
  19923. */
  19924. getForwardRay(length?: number): Ray;
  19925. }
  19926. }
  19927. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19928. import { Observable } from "babylonjs/Misc/observable";
  19929. import { Scene } from "babylonjs/scene";
  19930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19931. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19932. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19933. import { Nullable } from "babylonjs/types";
  19934. /**
  19935. * Defines the WebVRController object that represents controllers tracked in 3D space
  19936. */
  19937. export abstract class WebVRController extends PoseEnabledController {
  19938. /**
  19939. * Internal, the default controller model for the controller
  19940. */
  19941. protected _defaultModel: Nullable<AbstractMesh>;
  19942. /**
  19943. * Fired when the trigger state has changed
  19944. */
  19945. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19946. /**
  19947. * Fired when the main button state has changed
  19948. */
  19949. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19950. /**
  19951. * Fired when the secondary button state has changed
  19952. */
  19953. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19954. /**
  19955. * Fired when the pad state has changed
  19956. */
  19957. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19958. /**
  19959. * Fired when controllers stick values have changed
  19960. */
  19961. onPadValuesChangedObservable: Observable<StickValues>;
  19962. /**
  19963. * Array of button availible on the controller
  19964. */
  19965. protected _buttons: Array<MutableGamepadButton>;
  19966. private _onButtonStateChange;
  19967. /**
  19968. * Fired when a controller button's state has changed
  19969. * @param callback the callback containing the button that was modified
  19970. */
  19971. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19972. /**
  19973. * X and Y axis corresponding to the controllers joystick
  19974. */
  19975. pad: StickValues;
  19976. /**
  19977. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19978. */
  19979. hand: string;
  19980. /**
  19981. * The default controller model for the controller
  19982. */
  19983. get defaultModel(): Nullable<AbstractMesh>;
  19984. /**
  19985. * Creates a new WebVRController from a gamepad
  19986. * @param vrGamepad the gamepad that the WebVRController should be created from
  19987. */
  19988. constructor(vrGamepad: any);
  19989. /**
  19990. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19991. */
  19992. update(): void;
  19993. /**
  19994. * Function to be called when a button is modified
  19995. */
  19996. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19997. /**
  19998. * Loads a mesh and attaches it to the controller
  19999. * @param scene the scene the mesh should be added to
  20000. * @param meshLoaded callback for when the mesh has been loaded
  20001. */
  20002. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20003. private _setButtonValue;
  20004. private _changes;
  20005. private _checkChanges;
  20006. /**
  20007. * Disposes of th webVRCOntroller
  20008. */
  20009. dispose(): void;
  20010. }
  20011. }
  20012. declare module "babylonjs/Lights/hemisphericLight" {
  20013. import { Nullable } from "babylonjs/types";
  20014. import { Scene } from "babylonjs/scene";
  20015. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20016. import { Color3 } from "babylonjs/Maths/math.color";
  20017. import { Effect } from "babylonjs/Materials/effect";
  20018. import { Light } from "babylonjs/Lights/light";
  20019. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20020. /**
  20021. * The HemisphericLight simulates the ambient environment light,
  20022. * so the passed direction is the light reflection direction, not the incoming direction.
  20023. */
  20024. export class HemisphericLight extends Light {
  20025. /**
  20026. * The groundColor is the light in the opposite direction to the one specified during creation.
  20027. * 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.
  20028. */
  20029. groundColor: Color3;
  20030. /**
  20031. * The light reflection direction, not the incoming direction.
  20032. */
  20033. direction: Vector3;
  20034. /**
  20035. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20036. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20037. * The HemisphericLight can't cast shadows.
  20038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20039. * @param name The friendly name of the light
  20040. * @param direction The direction of the light reflection
  20041. * @param scene The scene the light belongs to
  20042. */
  20043. constructor(name: string, direction: Vector3, scene: Scene);
  20044. protected _buildUniformLayout(): void;
  20045. /**
  20046. * Returns the string "HemisphericLight".
  20047. * @return The class name
  20048. */
  20049. getClassName(): string;
  20050. /**
  20051. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20052. * Returns the updated direction.
  20053. * @param target The target the direction should point to
  20054. * @return The computed direction
  20055. */
  20056. setDirectionToTarget(target: Vector3): Vector3;
  20057. /**
  20058. * Returns the shadow generator associated to the light.
  20059. * @returns Always null for hemispheric lights because it does not support shadows.
  20060. */
  20061. getShadowGenerator(): Nullable<IShadowGenerator>;
  20062. /**
  20063. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20064. * @param effect The effect to update
  20065. * @param lightIndex The index of the light in the effect to update
  20066. * @returns The hemispheric light
  20067. */
  20068. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20069. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20070. /**
  20071. * Computes the world matrix of the node
  20072. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20073. * @param useWasUpdatedFlag defines a reserved property
  20074. * @returns the world matrix
  20075. */
  20076. computeWorldMatrix(): Matrix;
  20077. /**
  20078. * Returns the integer 3.
  20079. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20080. */
  20081. getTypeID(): number;
  20082. /**
  20083. * Prepares the list of defines specific to the light type.
  20084. * @param defines the list of defines
  20085. * @param lightIndex defines the index of the light for the effect
  20086. */
  20087. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20088. }
  20089. }
  20090. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20091. /** @hidden */
  20092. export var vrMultiviewToSingleviewPixelShader: {
  20093. name: string;
  20094. shader: string;
  20095. };
  20096. }
  20097. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20099. import { Scene } from "babylonjs/scene";
  20100. /**
  20101. * Renders to multiple views with a single draw call
  20102. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20103. */
  20104. export class MultiviewRenderTarget extends RenderTargetTexture {
  20105. /**
  20106. * Creates a multiview render target
  20107. * @param scene scene used with the render target
  20108. * @param size the size of the render target (used for each view)
  20109. */
  20110. constructor(scene: Scene, size?: number | {
  20111. width: number;
  20112. height: number;
  20113. } | {
  20114. ratio: number;
  20115. });
  20116. /**
  20117. * @hidden
  20118. * @param faceIndex the face index, if its a cube texture
  20119. */
  20120. _bindFrameBuffer(faceIndex?: number): void;
  20121. /**
  20122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20123. * @returns the view count
  20124. */
  20125. getViewCount(): number;
  20126. }
  20127. }
  20128. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20129. import { Camera } from "babylonjs/Cameras/camera";
  20130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20131. import { Nullable } from "babylonjs/types";
  20132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20133. import { Matrix } from "babylonjs/Maths/math.vector";
  20134. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20135. module "babylonjs/Engines/engine" {
  20136. interface Engine {
  20137. /**
  20138. * Creates a new multiview render target
  20139. * @param width defines the width of the texture
  20140. * @param height defines the height of the texture
  20141. * @returns the created multiview texture
  20142. */
  20143. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20144. /**
  20145. * Binds a multiview framebuffer to be drawn to
  20146. * @param multiviewTexture texture to bind
  20147. */
  20148. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20149. }
  20150. }
  20151. module "babylonjs/Cameras/camera" {
  20152. interface Camera {
  20153. /**
  20154. * @hidden
  20155. * 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)
  20156. */
  20157. _useMultiviewToSingleView: boolean;
  20158. /**
  20159. * @hidden
  20160. * 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)
  20161. */
  20162. _multiviewTexture: Nullable<RenderTargetTexture>;
  20163. /**
  20164. * @hidden
  20165. * ensures the multiview texture of the camera exists and has the specified width/height
  20166. * @param width height to set on the multiview texture
  20167. * @param height width to set on the multiview texture
  20168. */
  20169. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20170. }
  20171. }
  20172. module "babylonjs/scene" {
  20173. interface Scene {
  20174. /** @hidden */
  20175. _transformMatrixR: Matrix;
  20176. /** @hidden */
  20177. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20178. /** @hidden */
  20179. _createMultiviewUbo(): void;
  20180. /** @hidden */
  20181. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20182. /** @hidden */
  20183. _renderMultiviewToSingleView(camera: Camera): void;
  20184. }
  20185. }
  20186. }
  20187. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20188. import { Camera } from "babylonjs/Cameras/camera";
  20189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20190. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20191. import "babylonjs/Engines/Extensions/engine.multiview";
  20192. /**
  20193. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20194. * This will not be used for webXR as it supports displaying texture arrays directly
  20195. */
  20196. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20197. /**
  20198. * Initializes a VRMultiviewToSingleview
  20199. * @param name name of the post process
  20200. * @param camera camera to be applied to
  20201. * @param scaleFactor scaling factor to the size of the output texture
  20202. */
  20203. constructor(name: string, camera: Camera, scaleFactor: number);
  20204. }
  20205. }
  20206. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20207. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20208. import { Nullable } from "babylonjs/types";
  20209. import { Size } from "babylonjs/Maths/math.size";
  20210. import { Observable } from "babylonjs/Misc/observable";
  20211. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20212. /**
  20213. * Interface used to define additional presentation attributes
  20214. */
  20215. export interface IVRPresentationAttributes {
  20216. /**
  20217. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20218. */
  20219. highRefreshRate: boolean;
  20220. /**
  20221. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20222. */
  20223. foveationLevel: number;
  20224. }
  20225. module "babylonjs/Engines/engine" {
  20226. interface Engine {
  20227. /** @hidden */
  20228. _vrDisplay: any;
  20229. /** @hidden */
  20230. _vrSupported: boolean;
  20231. /** @hidden */
  20232. _oldSize: Size;
  20233. /** @hidden */
  20234. _oldHardwareScaleFactor: number;
  20235. /** @hidden */
  20236. _vrExclusivePointerMode: boolean;
  20237. /** @hidden */
  20238. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20239. /** @hidden */
  20240. _onVRDisplayPointerRestricted: () => void;
  20241. /** @hidden */
  20242. _onVRDisplayPointerUnrestricted: () => void;
  20243. /** @hidden */
  20244. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20245. /** @hidden */
  20246. _onVrDisplayDisconnect: Nullable<() => void>;
  20247. /** @hidden */
  20248. _onVrDisplayPresentChange: Nullable<() => void>;
  20249. /**
  20250. * Observable signaled when VR display mode changes
  20251. */
  20252. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20253. /**
  20254. * Observable signaled when VR request present is complete
  20255. */
  20256. onVRRequestPresentComplete: Observable<boolean>;
  20257. /**
  20258. * Observable signaled when VR request present starts
  20259. */
  20260. onVRRequestPresentStart: Observable<Engine>;
  20261. /**
  20262. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20263. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20264. */
  20265. isInVRExclusivePointerMode: boolean;
  20266. /**
  20267. * Gets a boolean indicating if a webVR device was detected
  20268. * @returns true if a webVR device was detected
  20269. */
  20270. isVRDevicePresent(): boolean;
  20271. /**
  20272. * Gets the current webVR device
  20273. * @returns the current webVR device (or null)
  20274. */
  20275. getVRDevice(): any;
  20276. /**
  20277. * Initializes a webVR display and starts listening to display change events
  20278. * The onVRDisplayChangedObservable will be notified upon these changes
  20279. * @returns A promise containing a VRDisplay and if vr is supported
  20280. */
  20281. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20282. /** @hidden */
  20283. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20284. /**
  20285. * Gets or sets the presentation attributes used to configure VR rendering
  20286. */
  20287. vrPresentationAttributes?: IVRPresentationAttributes;
  20288. /**
  20289. * Call this function to switch to webVR mode
  20290. * Will do nothing if webVR is not supported or if there is no webVR device
  20291. * @param options the webvr options provided to the camera. mainly used for multiview
  20292. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20293. */
  20294. enableVR(options: WebVROptions): void;
  20295. /** @hidden */
  20296. _onVRFullScreenTriggered(): void;
  20297. }
  20298. }
  20299. }
  20300. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20301. import { Nullable } from "babylonjs/types";
  20302. import { Observable } from "babylonjs/Misc/observable";
  20303. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20304. import { Scene } from "babylonjs/scene";
  20305. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20306. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20307. import { Node } from "babylonjs/node";
  20308. import { Ray } from "babylonjs/Culling/ray";
  20309. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20310. import "babylonjs/Engines/Extensions/engine.webVR";
  20311. /**
  20312. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20313. * IMPORTANT!! The data is right-hand data.
  20314. * @export
  20315. * @interface DevicePose
  20316. */
  20317. export interface DevicePose {
  20318. /**
  20319. * The position of the device, values in array are [x,y,z].
  20320. */
  20321. readonly position: Nullable<Float32Array>;
  20322. /**
  20323. * The linearVelocity of the device, values in array are [x,y,z].
  20324. */
  20325. readonly linearVelocity: Nullable<Float32Array>;
  20326. /**
  20327. * The linearAcceleration of the device, values in array are [x,y,z].
  20328. */
  20329. readonly linearAcceleration: Nullable<Float32Array>;
  20330. /**
  20331. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20332. */
  20333. readonly orientation: Nullable<Float32Array>;
  20334. /**
  20335. * The angularVelocity of the device, values in array are [x,y,z].
  20336. */
  20337. readonly angularVelocity: Nullable<Float32Array>;
  20338. /**
  20339. * The angularAcceleration of the device, values in array are [x,y,z].
  20340. */
  20341. readonly angularAcceleration: Nullable<Float32Array>;
  20342. }
  20343. /**
  20344. * Interface representing a pose controlled object in Babylon.
  20345. * A pose controlled object has both regular pose values as well as pose values
  20346. * from an external device such as a VR head mounted display
  20347. */
  20348. export interface PoseControlled {
  20349. /**
  20350. * The position of the object in babylon space.
  20351. */
  20352. position: Vector3;
  20353. /**
  20354. * The rotation quaternion of the object in babylon space.
  20355. */
  20356. rotationQuaternion: Quaternion;
  20357. /**
  20358. * The position of the device in babylon space.
  20359. */
  20360. devicePosition?: Vector3;
  20361. /**
  20362. * The rotation quaternion of the device in babylon space.
  20363. */
  20364. deviceRotationQuaternion: Quaternion;
  20365. /**
  20366. * The raw pose coming from the device.
  20367. */
  20368. rawPose: Nullable<DevicePose>;
  20369. /**
  20370. * The scale of the device to be used when translating from device space to babylon space.
  20371. */
  20372. deviceScaleFactor: number;
  20373. /**
  20374. * Updates the poseControlled values based on the input device pose.
  20375. * @param poseData the pose data to update the object with
  20376. */
  20377. updateFromDevice(poseData: DevicePose): void;
  20378. }
  20379. /**
  20380. * Set of options to customize the webVRCamera
  20381. */
  20382. export interface WebVROptions {
  20383. /**
  20384. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20385. */
  20386. trackPosition?: boolean;
  20387. /**
  20388. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20389. */
  20390. positionScale?: number;
  20391. /**
  20392. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20393. */
  20394. displayName?: string;
  20395. /**
  20396. * Should the native controller meshes be initialized. (default: true)
  20397. */
  20398. controllerMeshes?: boolean;
  20399. /**
  20400. * Creating a default HemiLight only on controllers. (default: true)
  20401. */
  20402. defaultLightingOnControllers?: boolean;
  20403. /**
  20404. * If you don't want to use the default VR button of the helper. (default: false)
  20405. */
  20406. useCustomVRButton?: boolean;
  20407. /**
  20408. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20409. */
  20410. customVRButton?: HTMLButtonElement;
  20411. /**
  20412. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20413. */
  20414. rayLength?: number;
  20415. /**
  20416. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20417. */
  20418. defaultHeight?: number;
  20419. /**
  20420. * If multiview should be used if availible (default: false)
  20421. */
  20422. useMultiview?: boolean;
  20423. }
  20424. /**
  20425. * This represents a WebVR camera.
  20426. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20427. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20428. */
  20429. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20430. private webVROptions;
  20431. /**
  20432. * @hidden
  20433. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20434. */
  20435. _vrDevice: any;
  20436. /**
  20437. * The rawPose of the vrDevice.
  20438. */
  20439. rawPose: Nullable<DevicePose>;
  20440. private _onVREnabled;
  20441. private _specsVersion;
  20442. private _attached;
  20443. private _frameData;
  20444. protected _descendants: Array<Node>;
  20445. private _deviceRoomPosition;
  20446. /** @hidden */
  20447. _deviceRoomRotationQuaternion: Quaternion;
  20448. private _standingMatrix;
  20449. /**
  20450. * Represents device position in babylon space.
  20451. */
  20452. devicePosition: Vector3;
  20453. /**
  20454. * Represents device rotation in babylon space.
  20455. */
  20456. deviceRotationQuaternion: Quaternion;
  20457. /**
  20458. * The scale of the device to be used when translating from device space to babylon space.
  20459. */
  20460. deviceScaleFactor: number;
  20461. private _deviceToWorld;
  20462. private _worldToDevice;
  20463. /**
  20464. * References to the webVR controllers for the vrDevice.
  20465. */
  20466. controllers: Array<WebVRController>;
  20467. /**
  20468. * Emits an event when a controller is attached.
  20469. */
  20470. onControllersAttachedObservable: Observable<WebVRController[]>;
  20471. /**
  20472. * Emits an event when a controller's mesh has been loaded;
  20473. */
  20474. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20475. /**
  20476. * Emits an event when the HMD's pose has been updated.
  20477. */
  20478. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20479. private _poseSet;
  20480. /**
  20481. * If the rig cameras be used as parent instead of this camera.
  20482. */
  20483. rigParenting: boolean;
  20484. private _lightOnControllers;
  20485. private _defaultHeight?;
  20486. /**
  20487. * Instantiates a WebVRFreeCamera.
  20488. * @param name The name of the WebVRFreeCamera
  20489. * @param position The starting anchor position for the camera
  20490. * @param scene The scene the camera belongs to
  20491. * @param webVROptions a set of customizable options for the webVRCamera
  20492. */
  20493. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20494. /**
  20495. * Gets the device distance from the ground in meters.
  20496. * @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.
  20497. */
  20498. deviceDistanceToRoomGround(): number;
  20499. /**
  20500. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20501. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20502. */
  20503. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20504. /**
  20505. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20506. * @returns A promise with a boolean set to if the standing matrix is supported.
  20507. */
  20508. useStandingMatrixAsync(): Promise<boolean>;
  20509. /**
  20510. * Disposes the camera
  20511. */
  20512. dispose(): void;
  20513. /**
  20514. * Gets a vrController by name.
  20515. * @param name The name of the controller to retreive
  20516. * @returns the controller matching the name specified or null if not found
  20517. */
  20518. getControllerByName(name: string): Nullable<WebVRController>;
  20519. private _leftController;
  20520. /**
  20521. * The controller corresponding to the users left hand.
  20522. */
  20523. get leftController(): Nullable<WebVRController>;
  20524. private _rightController;
  20525. /**
  20526. * The controller corresponding to the users right hand.
  20527. */
  20528. get rightController(): Nullable<WebVRController>;
  20529. /**
  20530. * Casts a ray forward from the vrCamera's gaze.
  20531. * @param length Length of the ray (default: 100)
  20532. * @returns the ray corresponding to the gaze
  20533. */
  20534. getForwardRay(length?: number): Ray;
  20535. /**
  20536. * @hidden
  20537. * Updates the camera based on device's frame data
  20538. */
  20539. _checkInputs(): void;
  20540. /**
  20541. * Updates the poseControlled values based on the input device pose.
  20542. * @param poseData Pose coming from the device
  20543. */
  20544. updateFromDevice(poseData: DevicePose): void;
  20545. private _htmlElementAttached;
  20546. private _detachIfAttached;
  20547. /**
  20548. * WebVR's attach control will start broadcasting frames to the device.
  20549. * Note that in certain browsers (chrome for example) this function must be called
  20550. * within a user-interaction callback. Example:
  20551. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20552. *
  20553. * @param element html element to attach the vrDevice to
  20554. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20555. */
  20556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20557. /**
  20558. * Detaches the camera from the html element and disables VR
  20559. *
  20560. * @param element html element to detach from
  20561. */
  20562. detachControl(element: HTMLElement): void;
  20563. /**
  20564. * @returns the name of this class
  20565. */
  20566. getClassName(): string;
  20567. /**
  20568. * Calls resetPose on the vrDisplay
  20569. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20570. */
  20571. resetToCurrentRotation(): void;
  20572. /**
  20573. * @hidden
  20574. * Updates the rig cameras (left and right eye)
  20575. */
  20576. _updateRigCameras(): void;
  20577. private _workingVector;
  20578. private _oneVector;
  20579. private _workingMatrix;
  20580. private updateCacheCalled;
  20581. private _correctPositionIfNotTrackPosition;
  20582. /**
  20583. * @hidden
  20584. * Updates the cached values of the camera
  20585. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20586. */
  20587. _updateCache(ignoreParentClass?: boolean): void;
  20588. /**
  20589. * @hidden
  20590. * Get current device position in babylon world
  20591. */
  20592. _computeDevicePosition(): void;
  20593. /**
  20594. * Updates the current device position and rotation in the babylon world
  20595. */
  20596. update(): void;
  20597. /**
  20598. * @hidden
  20599. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20600. * @returns an identity matrix
  20601. */
  20602. _getViewMatrix(): Matrix;
  20603. private _tmpMatrix;
  20604. /**
  20605. * This function is called by the two RIG cameras.
  20606. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20607. * @hidden
  20608. */
  20609. _getWebVRViewMatrix(): Matrix;
  20610. /** @hidden */
  20611. _getWebVRProjectionMatrix(): Matrix;
  20612. private _onGamepadConnectedObserver;
  20613. private _onGamepadDisconnectedObserver;
  20614. private _updateCacheWhenTrackingDisabledObserver;
  20615. /**
  20616. * Initializes the controllers and their meshes
  20617. */
  20618. initControllers(): void;
  20619. }
  20620. }
  20621. declare module "babylonjs/Materials/materialHelper" {
  20622. import { Nullable } from "babylonjs/types";
  20623. import { Scene } from "babylonjs/scene";
  20624. import { Engine } from "babylonjs/Engines/engine";
  20625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20626. import { Light } from "babylonjs/Lights/light";
  20627. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20628. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20630. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20631. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20632. /**
  20633. * "Static Class" containing the most commonly used helper while dealing with material for
  20634. * rendering purpose.
  20635. *
  20636. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20637. *
  20638. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20639. */
  20640. export class MaterialHelper {
  20641. /**
  20642. * Bind the current view position to an effect.
  20643. * @param effect The effect to be bound
  20644. * @param scene The scene the eyes position is used from
  20645. * @param variableName name of the shader variable that will hold the eye position
  20646. */
  20647. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20648. /**
  20649. * Helps preparing the defines values about the UVs in used in the effect.
  20650. * UVs are shared as much as we can accross channels in the shaders.
  20651. * @param texture The texture we are preparing the UVs for
  20652. * @param defines The defines to update
  20653. * @param key The channel key "diffuse", "specular"... used in the shader
  20654. */
  20655. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20656. /**
  20657. * Binds a texture matrix value to its corrsponding uniform
  20658. * @param texture The texture to bind the matrix for
  20659. * @param uniformBuffer The uniform buffer receivin the data
  20660. * @param key The channel key "diffuse", "specular"... used in the shader
  20661. */
  20662. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20663. /**
  20664. * Gets the current status of the fog (should it be enabled?)
  20665. * @param mesh defines the mesh to evaluate for fog support
  20666. * @param scene defines the hosting scene
  20667. * @returns true if fog must be enabled
  20668. */
  20669. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20670. /**
  20671. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20672. * @param mesh defines the current mesh
  20673. * @param scene defines the current scene
  20674. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20675. * @param pointsCloud defines if point cloud rendering has to be turned on
  20676. * @param fogEnabled defines if fog has to be turned on
  20677. * @param alphaTest defines if alpha testing has to be turned on
  20678. * @param defines defines the current list of defines
  20679. */
  20680. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20681. /**
  20682. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20683. * @param scene defines the current scene
  20684. * @param engine defines the current engine
  20685. * @param defines specifies the list of active defines
  20686. * @param useInstances defines if instances have to be turned on
  20687. * @param useClipPlane defines if clip plane have to be turned on
  20688. * @param useInstances defines if instances have to be turned on
  20689. * @param useThinInstances defines if thin instances have to be turned on
  20690. */
  20691. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20692. /**
  20693. * Prepares the defines for bones
  20694. * @param mesh The mesh containing the geometry data we will draw
  20695. * @param defines The defines to update
  20696. */
  20697. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20698. /**
  20699. * Prepares the defines for morph targets
  20700. * @param mesh The mesh containing the geometry data we will draw
  20701. * @param defines The defines to update
  20702. */
  20703. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20704. /**
  20705. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20706. * @param mesh The mesh containing the geometry data we will draw
  20707. * @param defines The defines to update
  20708. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20709. * @param useBones Precise whether bones should be used or not (override mesh info)
  20710. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20711. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20712. * @returns false if defines are considered not dirty and have not been checked
  20713. */
  20714. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20715. /**
  20716. * Prepares the defines related to multiview
  20717. * @param scene The scene we are intending to draw
  20718. * @param defines The defines to update
  20719. */
  20720. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20721. /**
  20722. * Prepares the defines related to the prepass
  20723. * @param scene The scene we are intending to draw
  20724. * @param defines The defines to update
  20725. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20726. */
  20727. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20728. /**
  20729. * Prepares the defines related to the light information passed in parameter
  20730. * @param scene The scene we are intending to draw
  20731. * @param mesh The mesh the effect is compiling for
  20732. * @param light The light the effect is compiling for
  20733. * @param lightIndex The index of the light
  20734. * @param defines The defines to update
  20735. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20736. * @param state Defines the current state regarding what is needed (normals, etc...)
  20737. */
  20738. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20739. needNormals: boolean;
  20740. needRebuild: boolean;
  20741. shadowEnabled: boolean;
  20742. specularEnabled: boolean;
  20743. lightmapMode: boolean;
  20744. }): void;
  20745. /**
  20746. * Prepares the defines related to the light information passed in parameter
  20747. * @param scene The scene we are intending to draw
  20748. * @param mesh The mesh the effect is compiling for
  20749. * @param defines The defines to update
  20750. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20751. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20752. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20753. * @returns true if normals will be required for the rest of the effect
  20754. */
  20755. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20756. /**
  20757. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20758. * @param lightIndex defines the light index
  20759. * @param uniformsList The uniform list
  20760. * @param samplersList The sampler list
  20761. * @param projectedLightTexture defines if projected texture must be used
  20762. * @param uniformBuffersList defines an optional list of uniform buffers
  20763. */
  20764. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20765. /**
  20766. * Prepares the uniforms and samplers list to be used in the effect
  20767. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20768. * @param samplersList The sampler list
  20769. * @param defines The defines helping in the list generation
  20770. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20771. */
  20772. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20773. /**
  20774. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20775. * @param defines The defines to update while falling back
  20776. * @param fallbacks The authorized effect fallbacks
  20777. * @param maxSimultaneousLights The maximum number of lights allowed
  20778. * @param rank the current rank of the Effect
  20779. * @returns The newly affected rank
  20780. */
  20781. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20782. private static _TmpMorphInfluencers;
  20783. /**
  20784. * Prepares the list of attributes required for morph targets according to the effect defines.
  20785. * @param attribs The current list of supported attribs
  20786. * @param mesh The mesh to prepare the morph targets attributes for
  20787. * @param influencers The number of influencers
  20788. */
  20789. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20790. /**
  20791. * Prepares the list of attributes required for morph targets according to the effect defines.
  20792. * @param attribs The current list of supported attribs
  20793. * @param mesh The mesh to prepare the morph targets attributes for
  20794. * @param defines The current Defines of the effect
  20795. */
  20796. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20797. /**
  20798. * Prepares the list of attributes required for bones according to the effect defines.
  20799. * @param attribs The current list of supported attribs
  20800. * @param mesh The mesh to prepare the bones attributes for
  20801. * @param defines The current Defines of the effect
  20802. * @param fallbacks The current efffect fallback strategy
  20803. */
  20804. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20805. /**
  20806. * Check and prepare the list of attributes required for instances according to the effect defines.
  20807. * @param attribs The current list of supported attribs
  20808. * @param defines The current MaterialDefines of the effect
  20809. */
  20810. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20811. /**
  20812. * Add the list of attributes required for instances to the attribs array.
  20813. * @param attribs The current list of supported attribs
  20814. */
  20815. static PushAttributesForInstances(attribs: string[]): void;
  20816. /**
  20817. * Binds the light information to the effect.
  20818. * @param light The light containing the generator
  20819. * @param effect The effect we are binding the data to
  20820. * @param lightIndex The light index in the effect used to render
  20821. */
  20822. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20823. /**
  20824. * Binds the lights information from the scene to the effect for the given mesh.
  20825. * @param light Light to bind
  20826. * @param lightIndex Light index
  20827. * @param scene The scene where the light belongs to
  20828. * @param effect The effect we are binding the data to
  20829. * @param useSpecular Defines if specular is supported
  20830. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20831. */
  20832. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20833. /**
  20834. * Binds the lights information from the scene to the effect for the given mesh.
  20835. * @param scene The scene the lights belongs to
  20836. * @param mesh The mesh we are binding the information to render
  20837. * @param effect The effect we are binding the data to
  20838. * @param defines The generated defines for the effect
  20839. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20840. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20841. */
  20842. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20843. private static _tempFogColor;
  20844. /**
  20845. * Binds the fog information from the scene to the effect for the given mesh.
  20846. * @param scene The scene the lights belongs to
  20847. * @param mesh The mesh we are binding the information to render
  20848. * @param effect The effect we are binding the data to
  20849. * @param linearSpace Defines if the fog effect is applied in linear space
  20850. */
  20851. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20852. /**
  20853. * Binds the bones information from the mesh to the effect.
  20854. * @param mesh The mesh we are binding the information to render
  20855. * @param effect The effect we are binding the data to
  20856. */
  20857. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20858. /**
  20859. * Binds the morph targets information from the mesh to the effect.
  20860. * @param abstractMesh The mesh we are binding the information to render
  20861. * @param effect The effect we are binding the data to
  20862. */
  20863. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20864. /**
  20865. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20866. * @param defines The generated defines used in the effect
  20867. * @param effect The effect we are binding the data to
  20868. * @param scene The scene we are willing to render with logarithmic scale for
  20869. */
  20870. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20871. /**
  20872. * Binds the clip plane information from the scene to the effect.
  20873. * @param scene The scene the clip plane information are extracted from
  20874. * @param effect The effect we are binding the data to
  20875. */
  20876. static BindClipPlane(effect: Effect, scene: Scene): void;
  20877. }
  20878. }
  20879. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20881. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20882. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20883. import { Nullable } from "babylonjs/types";
  20884. import { Effect } from "babylonjs/Materials/effect";
  20885. import { Matrix } from "babylonjs/Maths/math.vector";
  20886. import { Scene } from "babylonjs/scene";
  20887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20889. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20890. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20891. import { Observable } from "babylonjs/Misc/observable";
  20892. /**
  20893. * Block used to expose an input value
  20894. */
  20895. export class InputBlock extends NodeMaterialBlock {
  20896. private _mode;
  20897. private _associatedVariableName;
  20898. private _storedValue;
  20899. private _valueCallback;
  20900. private _type;
  20901. private _animationType;
  20902. /** Gets or set a value used to limit the range of float values */
  20903. min: number;
  20904. /** Gets or set a value used to limit the range of float values */
  20905. max: number;
  20906. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20907. isBoolean: boolean;
  20908. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20909. matrixMode: number;
  20910. /** @hidden */
  20911. _systemValue: Nullable<NodeMaterialSystemValues>;
  20912. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20913. visibleInInspector: boolean;
  20914. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20915. isConstant: boolean;
  20916. /** Gets or sets the group to use to display this block in the Inspector */
  20917. groupInInspector: string;
  20918. /** Gets an observable raised when the value is changed */
  20919. onValueChangedObservable: Observable<InputBlock>;
  20920. /**
  20921. * Gets or sets the connection point type (default is float)
  20922. */
  20923. get type(): NodeMaterialBlockConnectionPointTypes;
  20924. /**
  20925. * Creates a new InputBlock
  20926. * @param name defines the block name
  20927. * @param target defines the target of that block (Vertex by default)
  20928. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20929. */
  20930. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20931. /**
  20932. * Validates if a name is a reserve word.
  20933. * @param newName the new name to be given to the node.
  20934. * @returns false if the name is a reserve word, else true.
  20935. */
  20936. validateBlockName(newName: string): boolean;
  20937. /**
  20938. * Gets the output component
  20939. */
  20940. get output(): NodeMaterialConnectionPoint;
  20941. /**
  20942. * Set the source of this connection point to a vertex attribute
  20943. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20944. * @returns the current connection point
  20945. */
  20946. setAsAttribute(attributeName?: string): InputBlock;
  20947. /**
  20948. * Set the source of this connection point to a system value
  20949. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20950. * @returns the current connection point
  20951. */
  20952. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20953. /**
  20954. * Gets or sets the value of that point.
  20955. * Please note that this value will be ignored if valueCallback is defined
  20956. */
  20957. get value(): any;
  20958. set value(value: any);
  20959. /**
  20960. * Gets or sets a callback used to get the value of that point.
  20961. * Please note that setting this value will force the connection point to ignore the value property
  20962. */
  20963. get valueCallback(): () => any;
  20964. set valueCallback(value: () => any);
  20965. /**
  20966. * Gets or sets the associated variable name in the shader
  20967. */
  20968. get associatedVariableName(): string;
  20969. set associatedVariableName(value: string);
  20970. /** Gets or sets the type of animation applied to the input */
  20971. get animationType(): AnimatedInputBlockTypes;
  20972. set animationType(value: AnimatedInputBlockTypes);
  20973. /**
  20974. * Gets a boolean indicating that this connection point not defined yet
  20975. */
  20976. get isUndefined(): boolean;
  20977. /**
  20978. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20979. * In this case the connection point name must be the name of the uniform to use.
  20980. * Can only be set on inputs
  20981. */
  20982. get isUniform(): boolean;
  20983. set isUniform(value: boolean);
  20984. /**
  20985. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20986. * In this case the connection point name must be the name of the attribute to use
  20987. * Can only be set on inputs
  20988. */
  20989. get isAttribute(): boolean;
  20990. set isAttribute(value: boolean);
  20991. /**
  20992. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20993. * Can only be set on exit points
  20994. */
  20995. get isVarying(): boolean;
  20996. set isVarying(value: boolean);
  20997. /**
  20998. * Gets a boolean indicating that the current connection point is a system value
  20999. */
  21000. get isSystemValue(): boolean;
  21001. /**
  21002. * Gets or sets the current well known value or null if not defined as a system value
  21003. */
  21004. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21005. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21006. /**
  21007. * Gets the current class name
  21008. * @returns the class name
  21009. */
  21010. getClassName(): string;
  21011. /**
  21012. * Animate the input if animationType !== None
  21013. * @param scene defines the rendering scene
  21014. */
  21015. animate(scene: Scene): void;
  21016. private _emitDefine;
  21017. initialize(state: NodeMaterialBuildState): void;
  21018. /**
  21019. * Set the input block to its default value (based on its type)
  21020. */
  21021. setDefaultValue(): void;
  21022. private _emitConstant;
  21023. /** @hidden */
  21024. get _noContextSwitch(): boolean;
  21025. private _emit;
  21026. /** @hidden */
  21027. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21028. /** @hidden */
  21029. _transmit(effect: Effect, scene: Scene): void;
  21030. protected _buildBlock(state: NodeMaterialBuildState): void;
  21031. protected _dumpPropertiesCode(): string;
  21032. dispose(): void;
  21033. serialize(): any;
  21034. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21035. }
  21036. }
  21037. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21038. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21039. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21040. import { Nullable } from "babylonjs/types";
  21041. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21042. import { Observable } from "babylonjs/Misc/observable";
  21043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21044. /**
  21045. * Enum used to define the compatibility state between two connection points
  21046. */
  21047. export enum NodeMaterialConnectionPointCompatibilityStates {
  21048. /** Points are compatibles */
  21049. Compatible = 0,
  21050. /** Points are incompatible because of their types */
  21051. TypeIncompatible = 1,
  21052. /** Points are incompatible because of their targets (vertex vs fragment) */
  21053. TargetIncompatible = 2
  21054. }
  21055. /**
  21056. * Defines the direction of a connection point
  21057. */
  21058. export enum NodeMaterialConnectionPointDirection {
  21059. /** Input */
  21060. Input = 0,
  21061. /** Output */
  21062. Output = 1
  21063. }
  21064. /**
  21065. * Defines a connection point for a block
  21066. */
  21067. export class NodeMaterialConnectionPoint {
  21068. /** @hidden */
  21069. _ownerBlock: NodeMaterialBlock;
  21070. /** @hidden */
  21071. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21072. private _endpoints;
  21073. private _associatedVariableName;
  21074. private _direction;
  21075. /** @hidden */
  21076. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21077. /** @hidden */
  21078. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21079. private _type;
  21080. /** @hidden */
  21081. _enforceAssociatedVariableName: boolean;
  21082. /** Gets the direction of the point */
  21083. get direction(): NodeMaterialConnectionPointDirection;
  21084. /** Indicates that this connection point needs dual validation before being connected to another point */
  21085. needDualDirectionValidation: boolean;
  21086. /**
  21087. * Gets or sets the additional types supported by this connection point
  21088. */
  21089. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21090. /**
  21091. * Gets or sets the additional types excluded by this connection point
  21092. */
  21093. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21094. /**
  21095. * Observable triggered when this point is connected
  21096. */
  21097. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21098. /**
  21099. * Gets or sets the associated variable name in the shader
  21100. */
  21101. get associatedVariableName(): string;
  21102. set associatedVariableName(value: string);
  21103. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21104. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21105. /**
  21106. * Gets or sets the connection point type (default is float)
  21107. */
  21108. get type(): NodeMaterialBlockConnectionPointTypes;
  21109. set type(value: NodeMaterialBlockConnectionPointTypes);
  21110. /**
  21111. * Gets or sets the connection point name
  21112. */
  21113. name: string;
  21114. /**
  21115. * Gets or sets the connection point name
  21116. */
  21117. displayName: string;
  21118. /**
  21119. * Gets or sets a boolean indicating that this connection point can be omitted
  21120. */
  21121. isOptional: boolean;
  21122. /**
  21123. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21124. */
  21125. isExposedOnFrame: boolean;
  21126. /**
  21127. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21128. */
  21129. define: string;
  21130. /** @hidden */
  21131. _prioritizeVertex: boolean;
  21132. private _target;
  21133. /** Gets or sets the target of that connection point */
  21134. get target(): NodeMaterialBlockTargets;
  21135. set target(value: NodeMaterialBlockTargets);
  21136. /**
  21137. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21138. */
  21139. get isConnected(): boolean;
  21140. /**
  21141. * Gets a boolean indicating that the current point is connected to an input block
  21142. */
  21143. get isConnectedToInputBlock(): boolean;
  21144. /**
  21145. * Gets a the connected input block (if any)
  21146. */
  21147. get connectInputBlock(): Nullable<InputBlock>;
  21148. /** Get the other side of the connection (if any) */
  21149. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21150. /** Get the block that owns this connection point */
  21151. get ownerBlock(): NodeMaterialBlock;
  21152. /** Get the block connected on the other side of this connection (if any) */
  21153. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21154. /** Get the block connected on the endpoints of this connection (if any) */
  21155. get connectedBlocks(): Array<NodeMaterialBlock>;
  21156. /** Gets the list of connected endpoints */
  21157. get endpoints(): NodeMaterialConnectionPoint[];
  21158. /** Gets a boolean indicating if that output point is connected to at least one input */
  21159. get hasEndpoints(): boolean;
  21160. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21161. get isConnectedInVertexShader(): boolean;
  21162. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21163. get isConnectedInFragmentShader(): boolean;
  21164. /**
  21165. * Creates a block suitable to be used as an input for this input point.
  21166. * If null is returned, a block based on the point type will be created.
  21167. * @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
  21168. */
  21169. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21170. /**
  21171. * Creates a new connection point
  21172. * @param name defines the connection point name
  21173. * @param ownerBlock defines the block hosting this connection point
  21174. * @param direction defines the direction of the connection point
  21175. */
  21176. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21177. /**
  21178. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21179. * @returns the class name
  21180. */
  21181. getClassName(): string;
  21182. /**
  21183. * Gets a boolean indicating if the current point can be connected to another point
  21184. * @param connectionPoint defines the other connection point
  21185. * @returns a boolean
  21186. */
  21187. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21188. /**
  21189. * Gets a number indicating if the current point can be connected to another point
  21190. * @param connectionPoint defines the other connection point
  21191. * @returns a number defining the compatibility state
  21192. */
  21193. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21194. /**
  21195. * Connect this point to another connection point
  21196. * @param connectionPoint defines the other connection point
  21197. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21198. * @returns the current connection point
  21199. */
  21200. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21201. /**
  21202. * Disconnect this point from one of his endpoint
  21203. * @param endpoint defines the other connection point
  21204. * @returns the current connection point
  21205. */
  21206. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21207. /**
  21208. * Serializes this point in a JSON representation
  21209. * @param isInput defines if the connection point is an input (default is true)
  21210. * @returns the serialized point object
  21211. */
  21212. serialize(isInput?: boolean): any;
  21213. /**
  21214. * Release resources
  21215. */
  21216. dispose(): void;
  21217. }
  21218. }
  21219. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21220. /**
  21221. * Enum used to define the material modes
  21222. */
  21223. export enum NodeMaterialModes {
  21224. /** Regular material */
  21225. Material = 0,
  21226. /** For post process */
  21227. PostProcess = 1,
  21228. /** For particle system */
  21229. Particle = 2
  21230. }
  21231. }
  21232. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21235. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21238. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21239. import { Effect } from "babylonjs/Materials/effect";
  21240. import { Mesh } from "babylonjs/Meshes/mesh";
  21241. import { Nullable } from "babylonjs/types";
  21242. import { Texture } from "babylonjs/Materials/Textures/texture";
  21243. import { Scene } from "babylonjs/scene";
  21244. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21245. /**
  21246. * Block used to read a texture from a sampler
  21247. */
  21248. export class TextureBlock extends NodeMaterialBlock {
  21249. private _defineName;
  21250. private _linearDefineName;
  21251. private _gammaDefineName;
  21252. private _tempTextureRead;
  21253. private _samplerName;
  21254. private _transformedUVName;
  21255. private _textureTransformName;
  21256. private _textureInfoName;
  21257. private _mainUVName;
  21258. private _mainUVDefineName;
  21259. private _fragmentOnly;
  21260. /**
  21261. * Gets or sets the texture associated with the node
  21262. */
  21263. texture: Nullable<Texture>;
  21264. /**
  21265. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21266. */
  21267. convertToGammaSpace: boolean;
  21268. /**
  21269. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21270. */
  21271. convertToLinearSpace: boolean;
  21272. /**
  21273. * Create a new TextureBlock
  21274. * @param name defines the block name
  21275. */
  21276. constructor(name: string, fragmentOnly?: boolean);
  21277. /**
  21278. * Gets the current class name
  21279. * @returns the class name
  21280. */
  21281. getClassName(): string;
  21282. /**
  21283. * Gets the uv input component
  21284. */
  21285. get uv(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Gets the rgba output component
  21288. */
  21289. get rgba(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Gets the rgb output component
  21292. */
  21293. get rgb(): NodeMaterialConnectionPoint;
  21294. /**
  21295. * Gets the r output component
  21296. */
  21297. get r(): NodeMaterialConnectionPoint;
  21298. /**
  21299. * Gets the g output component
  21300. */
  21301. get g(): NodeMaterialConnectionPoint;
  21302. /**
  21303. * Gets the b output component
  21304. */
  21305. get b(): NodeMaterialConnectionPoint;
  21306. /**
  21307. * Gets the a output component
  21308. */
  21309. get a(): NodeMaterialConnectionPoint;
  21310. get target(): NodeMaterialBlockTargets;
  21311. autoConfigure(material: NodeMaterial): void;
  21312. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21314. isReady(): boolean;
  21315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21316. private get _isMixed();
  21317. private _injectVertexCode;
  21318. private _writeTextureRead;
  21319. private _writeOutput;
  21320. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21321. protected _dumpPropertiesCode(): string;
  21322. serialize(): any;
  21323. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21324. }
  21325. }
  21326. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21327. /** @hidden */
  21328. export var reflectionFunction: {
  21329. name: string;
  21330. shader: string;
  21331. };
  21332. }
  21333. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21337. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21339. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21340. import { Effect } from "babylonjs/Materials/effect";
  21341. import { Mesh } from "babylonjs/Meshes/mesh";
  21342. import { Nullable } from "babylonjs/types";
  21343. import { Scene } from "babylonjs/scene";
  21344. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21345. /**
  21346. * Base block used to read a reflection texture from a sampler
  21347. */
  21348. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21349. /** @hidden */
  21350. _define3DName: string;
  21351. /** @hidden */
  21352. _defineCubicName: string;
  21353. /** @hidden */
  21354. _defineExplicitName: string;
  21355. /** @hidden */
  21356. _defineProjectionName: string;
  21357. /** @hidden */
  21358. _defineLocalCubicName: string;
  21359. /** @hidden */
  21360. _defineSphericalName: string;
  21361. /** @hidden */
  21362. _definePlanarName: string;
  21363. /** @hidden */
  21364. _defineEquirectangularName: string;
  21365. /** @hidden */
  21366. _defineMirroredEquirectangularFixedName: string;
  21367. /** @hidden */
  21368. _defineEquirectangularFixedName: string;
  21369. /** @hidden */
  21370. _defineSkyboxName: string;
  21371. /** @hidden */
  21372. _defineOppositeZ: string;
  21373. /** @hidden */
  21374. _cubeSamplerName: string;
  21375. /** @hidden */
  21376. _2DSamplerName: string;
  21377. protected _positionUVWName: string;
  21378. protected _directionWName: string;
  21379. protected _reflectionVectorName: string;
  21380. /** @hidden */
  21381. _reflectionCoordsName: string;
  21382. /** @hidden */
  21383. _reflectionMatrixName: string;
  21384. protected _reflectionColorName: string;
  21385. /**
  21386. * Gets or sets the texture associated with the node
  21387. */
  21388. texture: Nullable<BaseTexture>;
  21389. /**
  21390. * Create a new ReflectionTextureBaseBlock
  21391. * @param name defines the block name
  21392. */
  21393. constructor(name: string);
  21394. /**
  21395. * Gets the current class name
  21396. * @returns the class name
  21397. */
  21398. getClassName(): string;
  21399. /**
  21400. * Gets the world position input component
  21401. */
  21402. abstract get position(): NodeMaterialConnectionPoint;
  21403. /**
  21404. * Gets the world position input component
  21405. */
  21406. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21407. /**
  21408. * Gets the world normal input component
  21409. */
  21410. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21411. /**
  21412. * Gets the world input component
  21413. */
  21414. abstract get world(): NodeMaterialConnectionPoint;
  21415. /**
  21416. * Gets the camera (or eye) position component
  21417. */
  21418. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21419. /**
  21420. * Gets the view input component
  21421. */
  21422. abstract get view(): NodeMaterialConnectionPoint;
  21423. protected _getTexture(): Nullable<BaseTexture>;
  21424. autoConfigure(material: NodeMaterial): void;
  21425. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21426. isReady(): boolean;
  21427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21428. /**
  21429. * Gets the code to inject in the vertex shader
  21430. * @param state current state of the node material building
  21431. * @returns the shader code
  21432. */
  21433. handleVertexSide(state: NodeMaterialBuildState): string;
  21434. /**
  21435. * Handles the inits for the fragment code path
  21436. * @param state node material build state
  21437. */
  21438. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21439. /**
  21440. * Generates the reflection coords code for the fragment code path
  21441. * @param worldNormalVarName name of the world normal variable
  21442. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21443. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21444. * @returns the shader code
  21445. */
  21446. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21447. /**
  21448. * Generates the reflection color code for the fragment code path
  21449. * @param lodVarName name of the lod variable
  21450. * @param swizzleLookupTexture swizzle to use for the final color variable
  21451. * @returns the shader code
  21452. */
  21453. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21454. /**
  21455. * Generates the code corresponding to the connected output points
  21456. * @param state node material build state
  21457. * @param varName name of the variable to output
  21458. * @returns the shader code
  21459. */
  21460. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21461. protected _buildBlock(state: NodeMaterialBuildState): this;
  21462. protected _dumpPropertiesCode(): string;
  21463. serialize(): any;
  21464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21465. }
  21466. }
  21467. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21469. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21470. import { Nullable } from "babylonjs/types";
  21471. /**
  21472. * Defines a connection point to be used for points with a custom object type
  21473. */
  21474. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21475. private _blockType;
  21476. private _blockName;
  21477. private _nameForCheking?;
  21478. /**
  21479. * Creates a new connection point
  21480. * @param name defines the connection point name
  21481. * @param ownerBlock defines the block hosting this connection point
  21482. * @param direction defines the direction of the connection point
  21483. */
  21484. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21485. /**
  21486. * Gets a number indicating if the current point can be connected to another point
  21487. * @param connectionPoint defines the other connection point
  21488. * @returns a number defining the compatibility state
  21489. */
  21490. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21491. /**
  21492. * Creates a block suitable to be used as an input for this input point.
  21493. * If null is returned, a block based on the point type will be created.
  21494. * @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
  21495. */
  21496. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21497. }
  21498. }
  21499. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21500. /**
  21501. * Enum defining the type of properties that can be edited in the property pages in the NME
  21502. */
  21503. export enum PropertyTypeForEdition {
  21504. /** property is a boolean */
  21505. Boolean = 0,
  21506. /** property is a float */
  21507. Float = 1,
  21508. /** property is a Vector2 */
  21509. Vector2 = 2,
  21510. /** property is a list of values */
  21511. List = 3
  21512. }
  21513. /**
  21514. * Interface that defines an option in a variable of type list
  21515. */
  21516. export interface IEditablePropertyListOption {
  21517. /** label of the option */
  21518. "label": string;
  21519. /** value of the option */
  21520. "value": number;
  21521. }
  21522. /**
  21523. * Interface that defines the options available for an editable property
  21524. */
  21525. export interface IEditablePropertyOption {
  21526. /** min value */
  21527. "min"?: number;
  21528. /** max value */
  21529. "max"?: number;
  21530. /** notifiers: indicates which actions to take when the property is changed */
  21531. "notifiers"?: {
  21532. /** the material should be rebuilt */
  21533. "rebuild"?: boolean;
  21534. /** the preview should be updated */
  21535. "update"?: boolean;
  21536. };
  21537. /** list of the options for a variable of type list */
  21538. "options"?: IEditablePropertyListOption[];
  21539. }
  21540. /**
  21541. * Interface that describes an editable property
  21542. */
  21543. export interface IPropertyDescriptionForEdition {
  21544. /** name of the property */
  21545. "propertyName": string;
  21546. /** display name of the property */
  21547. "displayName": string;
  21548. /** type of the property */
  21549. "type": PropertyTypeForEdition;
  21550. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21551. "groupName": string;
  21552. /** options for the property */
  21553. "options": IEditablePropertyOption;
  21554. }
  21555. /**
  21556. * Decorator that flags a property in a node material block as being editable
  21557. */
  21558. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21559. }
  21560. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21563. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21565. import { Nullable } from "babylonjs/types";
  21566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21567. import { Mesh } from "babylonjs/Meshes/mesh";
  21568. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21569. import { Effect } from "babylonjs/Materials/effect";
  21570. import { Scene } from "babylonjs/scene";
  21571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21572. /**
  21573. * Block used to implement the refraction part of the sub surface module of the PBR material
  21574. */
  21575. export class RefractionBlock extends NodeMaterialBlock {
  21576. /** @hidden */
  21577. _define3DName: string;
  21578. /** @hidden */
  21579. _refractionMatrixName: string;
  21580. /** @hidden */
  21581. _defineLODRefractionAlpha: string;
  21582. /** @hidden */
  21583. _defineLinearSpecularRefraction: string;
  21584. /** @hidden */
  21585. _defineOppositeZ: string;
  21586. /** @hidden */
  21587. _cubeSamplerName: string;
  21588. /** @hidden */
  21589. _2DSamplerName: string;
  21590. /** @hidden */
  21591. _vRefractionMicrosurfaceInfosName: string;
  21592. /** @hidden */
  21593. _vRefractionInfosName: string;
  21594. private _scene;
  21595. /**
  21596. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21597. * Materials half opaque for instance using refraction could benefit from this control.
  21598. */
  21599. linkRefractionWithTransparency: boolean;
  21600. /**
  21601. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21602. */
  21603. invertRefractionY: boolean;
  21604. /**
  21605. * Gets or sets the texture associated with the node
  21606. */
  21607. texture: Nullable<BaseTexture>;
  21608. /**
  21609. * Create a new RefractionBlock
  21610. * @param name defines the block name
  21611. */
  21612. constructor(name: string);
  21613. /**
  21614. * Gets the current class name
  21615. * @returns the class name
  21616. */
  21617. getClassName(): string;
  21618. /**
  21619. * Gets the intensity input component
  21620. */
  21621. get intensity(): NodeMaterialConnectionPoint;
  21622. /**
  21623. * Gets the index of refraction input component
  21624. */
  21625. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21626. /**
  21627. * Gets the tint at distance input component
  21628. */
  21629. get tintAtDistance(): NodeMaterialConnectionPoint;
  21630. /**
  21631. * Gets the view input component
  21632. */
  21633. get view(): NodeMaterialConnectionPoint;
  21634. /**
  21635. * Gets the refraction object output component
  21636. */
  21637. get refraction(): NodeMaterialConnectionPoint;
  21638. /**
  21639. * Returns true if the block has a texture
  21640. */
  21641. get hasTexture(): boolean;
  21642. protected _getTexture(): Nullable<BaseTexture>;
  21643. autoConfigure(material: NodeMaterial): void;
  21644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21645. isReady(): boolean;
  21646. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21647. /**
  21648. * Gets the main code of the block (fragment side)
  21649. * @param state current state of the node material building
  21650. * @returns the shader code
  21651. */
  21652. getCode(state: NodeMaterialBuildState): string;
  21653. protected _buildBlock(state: NodeMaterialBuildState): this;
  21654. protected _dumpPropertiesCode(): string;
  21655. serialize(): any;
  21656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21657. }
  21658. }
  21659. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21662. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21665. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21667. import { Nullable } from "babylonjs/types";
  21668. import { Scene } from "babylonjs/scene";
  21669. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21670. /**
  21671. * Base block used as input for post process
  21672. */
  21673. export class CurrentScreenBlock extends NodeMaterialBlock {
  21674. private _samplerName;
  21675. private _linearDefineName;
  21676. private _gammaDefineName;
  21677. private _mainUVName;
  21678. private _tempTextureRead;
  21679. /**
  21680. * Gets or sets the texture associated with the node
  21681. */
  21682. texture: Nullable<BaseTexture>;
  21683. /**
  21684. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21685. */
  21686. convertToGammaSpace: boolean;
  21687. /**
  21688. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21689. */
  21690. convertToLinearSpace: boolean;
  21691. /**
  21692. * Create a new CurrentScreenBlock
  21693. * @param name defines the block name
  21694. */
  21695. constructor(name: string);
  21696. /**
  21697. * Gets the current class name
  21698. * @returns the class name
  21699. */
  21700. getClassName(): string;
  21701. /**
  21702. * Gets the uv input component
  21703. */
  21704. get uv(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Gets the rgba output component
  21707. */
  21708. get rgba(): NodeMaterialConnectionPoint;
  21709. /**
  21710. * Gets the rgb output component
  21711. */
  21712. get rgb(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the r output component
  21715. */
  21716. get r(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the g output component
  21719. */
  21720. get g(): NodeMaterialConnectionPoint;
  21721. /**
  21722. * Gets the b output component
  21723. */
  21724. get b(): NodeMaterialConnectionPoint;
  21725. /**
  21726. * Gets the a output component
  21727. */
  21728. get a(): NodeMaterialConnectionPoint;
  21729. /**
  21730. * Initialize the block and prepare the context for build
  21731. * @param state defines the state that will be used for the build
  21732. */
  21733. initialize(state: NodeMaterialBuildState): void;
  21734. get target(): NodeMaterialBlockTargets;
  21735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21736. isReady(): boolean;
  21737. private _injectVertexCode;
  21738. private _writeTextureRead;
  21739. private _writeOutput;
  21740. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21741. serialize(): any;
  21742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21743. }
  21744. }
  21745. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21750. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21752. import { Nullable } from "babylonjs/types";
  21753. import { Scene } from "babylonjs/scene";
  21754. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21755. /**
  21756. * Base block used for the particle texture
  21757. */
  21758. export class ParticleTextureBlock extends NodeMaterialBlock {
  21759. private _samplerName;
  21760. private _linearDefineName;
  21761. private _gammaDefineName;
  21762. private _tempTextureRead;
  21763. /**
  21764. * Gets or sets the texture associated with the node
  21765. */
  21766. texture: Nullable<BaseTexture>;
  21767. /**
  21768. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21769. */
  21770. convertToGammaSpace: boolean;
  21771. /**
  21772. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21773. */
  21774. convertToLinearSpace: boolean;
  21775. /**
  21776. * Create a new ParticleTextureBlock
  21777. * @param name defines the block name
  21778. */
  21779. constructor(name: string);
  21780. /**
  21781. * Gets the current class name
  21782. * @returns the class name
  21783. */
  21784. getClassName(): string;
  21785. /**
  21786. * Gets the uv input component
  21787. */
  21788. get uv(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the rgba output component
  21791. */
  21792. get rgba(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the rgb output component
  21795. */
  21796. get rgb(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the r output component
  21799. */
  21800. get r(): NodeMaterialConnectionPoint;
  21801. /**
  21802. * Gets the g output component
  21803. */
  21804. get g(): NodeMaterialConnectionPoint;
  21805. /**
  21806. * Gets the b output component
  21807. */
  21808. get b(): NodeMaterialConnectionPoint;
  21809. /**
  21810. * Gets the a output component
  21811. */
  21812. get a(): NodeMaterialConnectionPoint;
  21813. /**
  21814. * Initialize the block and prepare the context for build
  21815. * @param state defines the state that will be used for the build
  21816. */
  21817. initialize(state: NodeMaterialBuildState): void;
  21818. autoConfigure(material: NodeMaterial): void;
  21819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21820. isReady(): boolean;
  21821. private _writeOutput;
  21822. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21823. serialize(): any;
  21824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21825. }
  21826. }
  21827. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21830. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21831. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21832. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21833. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21834. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21835. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21836. import { Scene } from "babylonjs/scene";
  21837. /**
  21838. * Class used to store shared data between 2 NodeMaterialBuildState
  21839. */
  21840. export class NodeMaterialBuildStateSharedData {
  21841. /**
  21842. * Gets the list of emitted varyings
  21843. */
  21844. temps: string[];
  21845. /**
  21846. * Gets the list of emitted varyings
  21847. */
  21848. varyings: string[];
  21849. /**
  21850. * Gets the varying declaration string
  21851. */
  21852. varyingDeclaration: string;
  21853. /**
  21854. * Input blocks
  21855. */
  21856. inputBlocks: InputBlock[];
  21857. /**
  21858. * Input blocks
  21859. */
  21860. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21861. /**
  21862. * Bindable blocks (Blocks that need to set data to the effect)
  21863. */
  21864. bindableBlocks: NodeMaterialBlock[];
  21865. /**
  21866. * List of blocks that can provide a compilation fallback
  21867. */
  21868. blocksWithFallbacks: NodeMaterialBlock[];
  21869. /**
  21870. * List of blocks that can provide a define update
  21871. */
  21872. blocksWithDefines: NodeMaterialBlock[];
  21873. /**
  21874. * List of blocks that can provide a repeatable content
  21875. */
  21876. repeatableContentBlocks: NodeMaterialBlock[];
  21877. /**
  21878. * List of blocks that can provide a dynamic list of uniforms
  21879. */
  21880. dynamicUniformBlocks: NodeMaterialBlock[];
  21881. /**
  21882. * List of blocks that can block the isReady function for the material
  21883. */
  21884. blockingBlocks: NodeMaterialBlock[];
  21885. /**
  21886. * Gets the list of animated inputs
  21887. */
  21888. animatedInputs: InputBlock[];
  21889. /**
  21890. * Build Id used to avoid multiple recompilations
  21891. */
  21892. buildId: number;
  21893. /** List of emitted variables */
  21894. variableNames: {
  21895. [key: string]: number;
  21896. };
  21897. /** List of emitted defines */
  21898. defineNames: {
  21899. [key: string]: number;
  21900. };
  21901. /** Should emit comments? */
  21902. emitComments: boolean;
  21903. /** Emit build activity */
  21904. verbose: boolean;
  21905. /** Gets or sets the hosting scene */
  21906. scene: Scene;
  21907. /**
  21908. * Gets the compilation hints emitted at compilation time
  21909. */
  21910. hints: {
  21911. needWorldViewMatrix: boolean;
  21912. needWorldViewProjectionMatrix: boolean;
  21913. needAlphaBlending: boolean;
  21914. needAlphaTesting: boolean;
  21915. };
  21916. /**
  21917. * List of compilation checks
  21918. */
  21919. checks: {
  21920. emitVertex: boolean;
  21921. emitFragment: boolean;
  21922. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21923. };
  21924. /**
  21925. * Is vertex program allowed to be empty?
  21926. */
  21927. allowEmptyVertexProgram: boolean;
  21928. /** Creates a new shared data */
  21929. constructor();
  21930. /**
  21931. * Emits console errors and exceptions if there is a failing check
  21932. */
  21933. emitErrors(): void;
  21934. }
  21935. }
  21936. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21937. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21938. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21939. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21940. /**
  21941. * Class used to store node based material build state
  21942. */
  21943. export class NodeMaterialBuildState {
  21944. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21945. supportUniformBuffers: boolean;
  21946. /**
  21947. * Gets the list of emitted attributes
  21948. */
  21949. attributes: string[];
  21950. /**
  21951. * Gets the list of emitted uniforms
  21952. */
  21953. uniforms: string[];
  21954. /**
  21955. * Gets the list of emitted constants
  21956. */
  21957. constants: string[];
  21958. /**
  21959. * Gets the list of emitted samplers
  21960. */
  21961. samplers: string[];
  21962. /**
  21963. * Gets the list of emitted functions
  21964. */
  21965. functions: {
  21966. [key: string]: string;
  21967. };
  21968. /**
  21969. * Gets the list of emitted extensions
  21970. */
  21971. extensions: {
  21972. [key: string]: string;
  21973. };
  21974. /**
  21975. * Gets the target of the compilation state
  21976. */
  21977. target: NodeMaterialBlockTargets;
  21978. /**
  21979. * Gets the list of emitted counters
  21980. */
  21981. counters: {
  21982. [key: string]: number;
  21983. };
  21984. /**
  21985. * Shared data between multiple NodeMaterialBuildState instances
  21986. */
  21987. sharedData: NodeMaterialBuildStateSharedData;
  21988. /** @hidden */
  21989. _vertexState: NodeMaterialBuildState;
  21990. /** @hidden */
  21991. _attributeDeclaration: string;
  21992. /** @hidden */
  21993. _uniformDeclaration: string;
  21994. /** @hidden */
  21995. _constantDeclaration: string;
  21996. /** @hidden */
  21997. _samplerDeclaration: string;
  21998. /** @hidden */
  21999. _varyingTransfer: string;
  22000. /** @hidden */
  22001. _injectAtEnd: string;
  22002. private _repeatableContentAnchorIndex;
  22003. /** @hidden */
  22004. _builtCompilationString: string;
  22005. /**
  22006. * Gets the emitted compilation strings
  22007. */
  22008. compilationString: string;
  22009. /**
  22010. * Finalize the compilation strings
  22011. * @param state defines the current compilation state
  22012. */
  22013. finalize(state: NodeMaterialBuildState): void;
  22014. /** @hidden */
  22015. get _repeatableContentAnchor(): string;
  22016. /** @hidden */
  22017. _getFreeVariableName(prefix: string): string;
  22018. /** @hidden */
  22019. _getFreeDefineName(prefix: string): string;
  22020. /** @hidden */
  22021. _excludeVariableName(name: string): void;
  22022. /** @hidden */
  22023. _emit2DSampler(name: string): void;
  22024. /** @hidden */
  22025. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22026. /** @hidden */
  22027. _emitExtension(name: string, extension: string, define?: string): void;
  22028. /** @hidden */
  22029. _emitFunction(name: string, code: string, comments: string): void;
  22030. /** @hidden */
  22031. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22032. replaceStrings?: {
  22033. search: RegExp;
  22034. replace: string;
  22035. }[];
  22036. repeatKey?: string;
  22037. }): string;
  22038. /** @hidden */
  22039. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22040. repeatKey?: string;
  22041. removeAttributes?: boolean;
  22042. removeUniforms?: boolean;
  22043. removeVaryings?: boolean;
  22044. removeIfDef?: boolean;
  22045. replaceStrings?: {
  22046. search: RegExp;
  22047. replace: string;
  22048. }[];
  22049. }, storeKey?: string): void;
  22050. /** @hidden */
  22051. _registerTempVariable(name: string): boolean;
  22052. /** @hidden */
  22053. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22054. /** @hidden */
  22055. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22056. /** @hidden */
  22057. _emitFloat(value: number): string;
  22058. }
  22059. }
  22060. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22061. /**
  22062. * Helper class used to generate session unique ID
  22063. */
  22064. export class UniqueIdGenerator {
  22065. private static _UniqueIdCounter;
  22066. /**
  22067. * Gets an unique (relatively to the current scene) Id
  22068. */
  22069. static get UniqueId(): number;
  22070. }
  22071. }
  22072. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22073. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22074. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22075. import { Nullable } from "babylonjs/types";
  22076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22077. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22078. import { Effect } from "babylonjs/Materials/effect";
  22079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22080. import { Mesh } from "babylonjs/Meshes/mesh";
  22081. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22082. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22083. import { Scene } from "babylonjs/scene";
  22084. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22085. /**
  22086. * Defines a block that can be used inside a node based material
  22087. */
  22088. export class NodeMaterialBlock {
  22089. private _buildId;
  22090. private _buildTarget;
  22091. private _target;
  22092. private _isFinalMerger;
  22093. private _isInput;
  22094. private _name;
  22095. protected _isUnique: boolean;
  22096. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22097. inputsAreExclusive: boolean;
  22098. /** @hidden */
  22099. _codeVariableName: string;
  22100. /** @hidden */
  22101. _inputs: NodeMaterialConnectionPoint[];
  22102. /** @hidden */
  22103. _outputs: NodeMaterialConnectionPoint[];
  22104. /** @hidden */
  22105. _preparationId: number;
  22106. /**
  22107. * Gets the name of the block
  22108. */
  22109. get name(): string;
  22110. /**
  22111. * Sets the name of the block. Will check if the name is valid.
  22112. */
  22113. set name(newName: string);
  22114. /**
  22115. * Gets or sets the unique id of the node
  22116. */
  22117. uniqueId: number;
  22118. /**
  22119. * Gets or sets the comments associated with this block
  22120. */
  22121. comments: string;
  22122. /**
  22123. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22124. */
  22125. get isUnique(): boolean;
  22126. /**
  22127. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22128. */
  22129. get isFinalMerger(): boolean;
  22130. /**
  22131. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22132. */
  22133. get isInput(): boolean;
  22134. /**
  22135. * Gets or sets the build Id
  22136. */
  22137. get buildId(): number;
  22138. set buildId(value: number);
  22139. /**
  22140. * Gets or sets the target of the block
  22141. */
  22142. get target(): NodeMaterialBlockTargets;
  22143. set target(value: NodeMaterialBlockTargets);
  22144. /**
  22145. * Gets the list of input points
  22146. */
  22147. get inputs(): NodeMaterialConnectionPoint[];
  22148. /** Gets the list of output points */
  22149. get outputs(): NodeMaterialConnectionPoint[];
  22150. /**
  22151. * Find an input by its name
  22152. * @param name defines the name of the input to look for
  22153. * @returns the input or null if not found
  22154. */
  22155. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22156. /**
  22157. * Find an output by its name
  22158. * @param name defines the name of the outputto look for
  22159. * @returns the output or null if not found
  22160. */
  22161. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22162. /**
  22163. * Creates a new NodeMaterialBlock
  22164. * @param name defines the block name
  22165. * @param target defines the target of that block (Vertex by default)
  22166. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22167. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22168. */
  22169. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22170. /**
  22171. * Initialize the block and prepare the context for build
  22172. * @param state defines the state that will be used for the build
  22173. */
  22174. initialize(state: NodeMaterialBuildState): void;
  22175. /**
  22176. * Bind data to effect. Will only be called for blocks with isBindable === true
  22177. * @param effect defines the effect to bind data to
  22178. * @param nodeMaterial defines the hosting NodeMaterial
  22179. * @param mesh defines the mesh that will be rendered
  22180. * @param subMesh defines the submesh that will be rendered
  22181. */
  22182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22183. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22184. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22185. protected _writeFloat(value: number): string;
  22186. /**
  22187. * Gets the current class name e.g. "NodeMaterialBlock"
  22188. * @returns the class name
  22189. */
  22190. getClassName(): string;
  22191. /**
  22192. * Register a new input. Must be called inside a block constructor
  22193. * @param name defines the connection point name
  22194. * @param type defines the connection point type
  22195. * @param isOptional defines a boolean indicating that this input can be omitted
  22196. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22197. * @param point an already created connection point. If not provided, create a new one
  22198. * @returns the current block
  22199. */
  22200. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22201. /**
  22202. * Register a new output. Must be called inside a block constructor
  22203. * @param name defines the connection point name
  22204. * @param type defines the connection point type
  22205. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22206. * @param point an already created connection point. If not provided, create a new one
  22207. * @returns the current block
  22208. */
  22209. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22210. /**
  22211. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22212. * @param forOutput defines an optional connection point to check compatibility with
  22213. * @returns the first available input or null
  22214. */
  22215. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22216. /**
  22217. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22218. * @param forBlock defines an optional block to check compatibility with
  22219. * @returns the first available input or null
  22220. */
  22221. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22222. /**
  22223. * Gets the sibling of the given output
  22224. * @param current defines the current output
  22225. * @returns the next output in the list or null
  22226. */
  22227. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22228. /**
  22229. * Connect current block with another block
  22230. * @param other defines the block to connect with
  22231. * @param options define the various options to help pick the right connections
  22232. * @returns the current block
  22233. */
  22234. connectTo(other: NodeMaterialBlock, options?: {
  22235. input?: string;
  22236. output?: string;
  22237. outputSwizzle?: string;
  22238. }): this | undefined;
  22239. protected _buildBlock(state: NodeMaterialBuildState): void;
  22240. /**
  22241. * Add uniforms, samplers and uniform buffers at compilation time
  22242. * @param state defines the state to update
  22243. * @param nodeMaterial defines the node material requesting the update
  22244. * @param defines defines the material defines to update
  22245. * @param uniformBuffers defines the list of uniform buffer names
  22246. */
  22247. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22248. /**
  22249. * Add potential fallbacks if shader compilation fails
  22250. * @param mesh defines the mesh to be rendered
  22251. * @param fallbacks defines the current prioritized list of fallbacks
  22252. */
  22253. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22254. /**
  22255. * Initialize defines for shader compilation
  22256. * @param mesh defines the mesh to be rendered
  22257. * @param nodeMaterial defines the node material requesting the update
  22258. * @param defines defines the material defines to update
  22259. * @param useInstances specifies that instances should be used
  22260. */
  22261. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22262. /**
  22263. * Update defines for shader compilation
  22264. * @param mesh defines the mesh to be rendered
  22265. * @param nodeMaterial defines the node material requesting the update
  22266. * @param defines defines the material defines to update
  22267. * @param useInstances specifies that instances should be used
  22268. * @param subMesh defines which submesh to render
  22269. */
  22270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22271. /**
  22272. * Lets the block try to connect some inputs automatically
  22273. * @param material defines the hosting NodeMaterial
  22274. */
  22275. autoConfigure(material: NodeMaterial): void;
  22276. /**
  22277. * Function called when a block is declared as repeatable content generator
  22278. * @param vertexShaderState defines the current compilation state for the vertex shader
  22279. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22280. * @param mesh defines the mesh to be rendered
  22281. * @param defines defines the material defines to update
  22282. */
  22283. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22284. /**
  22285. * Checks if the block is ready
  22286. * @param mesh defines the mesh to be rendered
  22287. * @param nodeMaterial defines the node material requesting the update
  22288. * @param defines defines the material defines to update
  22289. * @param useInstances specifies that instances should be used
  22290. * @returns true if the block is ready
  22291. */
  22292. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22293. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22294. private _processBuild;
  22295. /**
  22296. * Validates the new name for the block node.
  22297. * @param newName the new name to be given to the node.
  22298. * @returns false if the name is a reserve word, else true.
  22299. */
  22300. validateBlockName(newName: string): boolean;
  22301. /**
  22302. * Compile the current node and generate the shader code
  22303. * @param state defines the current compilation state (uniforms, samplers, current string)
  22304. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22305. * @returns true if already built
  22306. */
  22307. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22308. protected _inputRename(name: string): string;
  22309. protected _outputRename(name: string): string;
  22310. protected _dumpPropertiesCode(): string;
  22311. /** @hidden */
  22312. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22313. /** @hidden */
  22314. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22315. /**
  22316. * Clone the current block to a new identical block
  22317. * @param scene defines the hosting scene
  22318. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22319. * @returns a copy of the current block
  22320. */
  22321. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22322. /**
  22323. * Serializes this block in a JSON representation
  22324. * @returns the serialized block object
  22325. */
  22326. serialize(): any;
  22327. /** @hidden */
  22328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22329. private _deserializePortDisplayNamesAndExposedOnFrame;
  22330. /**
  22331. * Release resources
  22332. */
  22333. dispose(): void;
  22334. }
  22335. }
  22336. declare module "babylonjs/Materials/pushMaterial" {
  22337. import { Nullable } from "babylonjs/types";
  22338. import { Scene } from "babylonjs/scene";
  22339. import { Matrix } from "babylonjs/Maths/math.vector";
  22340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22341. import { Mesh } from "babylonjs/Meshes/mesh";
  22342. import { Material } from "babylonjs/Materials/material";
  22343. import { Effect } from "babylonjs/Materials/effect";
  22344. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22345. /**
  22346. * Base class of materials working in push mode in babylon JS
  22347. * @hidden
  22348. */
  22349. export class PushMaterial extends Material {
  22350. protected _activeEffect: Effect;
  22351. protected _normalMatrix: Matrix;
  22352. constructor(name: string, scene: Scene);
  22353. getEffect(): Effect;
  22354. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22355. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22356. /**
  22357. * Binds the given world matrix to the active effect
  22358. *
  22359. * @param world the matrix to bind
  22360. */
  22361. bindOnlyWorldMatrix(world: Matrix): void;
  22362. /**
  22363. * Binds the given normal matrix to the active effect
  22364. *
  22365. * @param normalMatrix the matrix to bind
  22366. */
  22367. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22368. bind(world: Matrix, mesh?: Mesh): void;
  22369. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22370. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22371. }
  22372. }
  22373. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22375. /**
  22376. * Root class for all node material optimizers
  22377. */
  22378. export class NodeMaterialOptimizer {
  22379. /**
  22380. * Function used to optimize a NodeMaterial graph
  22381. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22382. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22383. */
  22384. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22385. }
  22386. }
  22387. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22391. import { Scene } from "babylonjs/scene";
  22392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22393. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22395. /**
  22396. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22397. */
  22398. export class TransformBlock extends NodeMaterialBlock {
  22399. /**
  22400. * Defines the value to use to complement W value to transform it to a Vector4
  22401. */
  22402. complementW: number;
  22403. /**
  22404. * Defines the value to use to complement z value to transform it to a Vector4
  22405. */
  22406. complementZ: number;
  22407. /**
  22408. * Creates a new TransformBlock
  22409. * @param name defines the block name
  22410. */
  22411. constructor(name: string);
  22412. /**
  22413. * Gets the current class name
  22414. * @returns the class name
  22415. */
  22416. getClassName(): string;
  22417. /**
  22418. * Gets the vector input
  22419. */
  22420. get vector(): NodeMaterialConnectionPoint;
  22421. /**
  22422. * Gets the output component
  22423. */
  22424. get output(): NodeMaterialConnectionPoint;
  22425. /**
  22426. * Gets the xyz output component
  22427. */
  22428. get xyz(): NodeMaterialConnectionPoint;
  22429. /**
  22430. * Gets the matrix transform input
  22431. */
  22432. get transform(): NodeMaterialConnectionPoint;
  22433. protected _buildBlock(state: NodeMaterialBuildState): this;
  22434. /**
  22435. * Update defines for shader compilation
  22436. * @param mesh defines the mesh to be rendered
  22437. * @param nodeMaterial defines the node material requesting the update
  22438. * @param defines defines the material defines to update
  22439. * @param useInstances specifies that instances should be used
  22440. * @param subMesh defines which submesh to render
  22441. */
  22442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22443. serialize(): any;
  22444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22445. protected _dumpPropertiesCode(): string;
  22446. }
  22447. }
  22448. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22452. /**
  22453. * Block used to output the vertex position
  22454. */
  22455. export class VertexOutputBlock extends NodeMaterialBlock {
  22456. /**
  22457. * Creates a new VertexOutputBlock
  22458. * @param name defines the block name
  22459. */
  22460. constructor(name: string);
  22461. /**
  22462. * Gets the current class name
  22463. * @returns the class name
  22464. */
  22465. getClassName(): string;
  22466. /**
  22467. * Gets the vector input component
  22468. */
  22469. get vector(): NodeMaterialConnectionPoint;
  22470. protected _buildBlock(state: NodeMaterialBuildState): this;
  22471. }
  22472. }
  22473. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22477. /**
  22478. * Block used to output the final color
  22479. */
  22480. export class FragmentOutputBlock extends NodeMaterialBlock {
  22481. /**
  22482. * Create a new FragmentOutputBlock
  22483. * @param name defines the block name
  22484. */
  22485. constructor(name: string);
  22486. /**
  22487. * Gets the current class name
  22488. * @returns the class name
  22489. */
  22490. getClassName(): string;
  22491. /**
  22492. * Gets the rgba input component
  22493. */
  22494. get rgba(): NodeMaterialConnectionPoint;
  22495. /**
  22496. * Gets the rgb input component
  22497. */
  22498. get rgb(): NodeMaterialConnectionPoint;
  22499. /**
  22500. * Gets the a input component
  22501. */
  22502. get a(): NodeMaterialConnectionPoint;
  22503. protected _buildBlock(state: NodeMaterialBuildState): this;
  22504. }
  22505. }
  22506. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22510. /**
  22511. * Block used for the particle ramp gradient section
  22512. */
  22513. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22514. /**
  22515. * Create a new ParticleRampGradientBlock
  22516. * @param name defines the block name
  22517. */
  22518. constructor(name: string);
  22519. /**
  22520. * Gets the current class name
  22521. * @returns the class name
  22522. */
  22523. getClassName(): string;
  22524. /**
  22525. * Gets the color input component
  22526. */
  22527. get color(): NodeMaterialConnectionPoint;
  22528. /**
  22529. * Gets the rampColor output component
  22530. */
  22531. get rampColor(): NodeMaterialConnectionPoint;
  22532. /**
  22533. * Initialize the block and prepare the context for build
  22534. * @param state defines the state that will be used for the build
  22535. */
  22536. initialize(state: NodeMaterialBuildState): void;
  22537. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22538. }
  22539. }
  22540. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22544. /**
  22545. * Block used for the particle blend multiply section
  22546. */
  22547. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22548. /**
  22549. * Create a new ParticleBlendMultiplyBlock
  22550. * @param name defines the block name
  22551. */
  22552. constructor(name: string);
  22553. /**
  22554. * Gets the current class name
  22555. * @returns the class name
  22556. */
  22557. getClassName(): string;
  22558. /**
  22559. * Gets the color input component
  22560. */
  22561. get color(): NodeMaterialConnectionPoint;
  22562. /**
  22563. * Gets the alphaTexture input component
  22564. */
  22565. get alphaTexture(): NodeMaterialConnectionPoint;
  22566. /**
  22567. * Gets the alphaColor input component
  22568. */
  22569. get alphaColor(): NodeMaterialConnectionPoint;
  22570. /**
  22571. * Gets the blendColor output component
  22572. */
  22573. get blendColor(): NodeMaterialConnectionPoint;
  22574. /**
  22575. * Initialize the block and prepare the context for build
  22576. * @param state defines the state that will be used for the build
  22577. */
  22578. initialize(state: NodeMaterialBuildState): void;
  22579. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22580. }
  22581. }
  22582. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22586. /**
  22587. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22588. */
  22589. export class VectorMergerBlock extends NodeMaterialBlock {
  22590. /**
  22591. * Create a new VectorMergerBlock
  22592. * @param name defines the block name
  22593. */
  22594. constructor(name: string);
  22595. /**
  22596. * Gets the current class name
  22597. * @returns the class name
  22598. */
  22599. getClassName(): string;
  22600. /**
  22601. * Gets the xyz component (input)
  22602. */
  22603. get xyzIn(): NodeMaterialConnectionPoint;
  22604. /**
  22605. * Gets the xy component (input)
  22606. */
  22607. get xyIn(): NodeMaterialConnectionPoint;
  22608. /**
  22609. * Gets the x component (input)
  22610. */
  22611. get x(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the y component (input)
  22614. */
  22615. get y(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the z component (input)
  22618. */
  22619. get z(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the w component (input)
  22622. */
  22623. get w(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the xyzw component (output)
  22626. */
  22627. get xyzw(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the xyz component (output)
  22630. */
  22631. get xyzOut(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the xy component (output)
  22634. */
  22635. get xyOut(): NodeMaterialConnectionPoint;
  22636. /**
  22637. * Gets the xy component (output)
  22638. * @deprecated Please use xyOut instead.
  22639. */
  22640. get xy(): NodeMaterialConnectionPoint;
  22641. /**
  22642. * Gets the xyz component (output)
  22643. * @deprecated Please use xyzOut instead.
  22644. */
  22645. get xyz(): NodeMaterialConnectionPoint;
  22646. protected _buildBlock(state: NodeMaterialBuildState): this;
  22647. }
  22648. }
  22649. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22653. import { Vector2 } from "babylonjs/Maths/math.vector";
  22654. import { Scene } from "babylonjs/scene";
  22655. /**
  22656. * Block used to remap a float from a range to a new one
  22657. */
  22658. export class RemapBlock extends NodeMaterialBlock {
  22659. /**
  22660. * Gets or sets the source range
  22661. */
  22662. sourceRange: Vector2;
  22663. /**
  22664. * Gets or sets the target range
  22665. */
  22666. targetRange: Vector2;
  22667. /**
  22668. * Creates a new RemapBlock
  22669. * @param name defines the block name
  22670. */
  22671. constructor(name: string);
  22672. /**
  22673. * Gets the current class name
  22674. * @returns the class name
  22675. */
  22676. getClassName(): string;
  22677. /**
  22678. * Gets the input component
  22679. */
  22680. get input(): NodeMaterialConnectionPoint;
  22681. /**
  22682. * Gets the source min input component
  22683. */
  22684. get sourceMin(): NodeMaterialConnectionPoint;
  22685. /**
  22686. * Gets the source max input component
  22687. */
  22688. get sourceMax(): NodeMaterialConnectionPoint;
  22689. /**
  22690. * Gets the target min input component
  22691. */
  22692. get targetMin(): NodeMaterialConnectionPoint;
  22693. /**
  22694. * Gets the target max input component
  22695. */
  22696. get targetMax(): NodeMaterialConnectionPoint;
  22697. /**
  22698. * Gets the output component
  22699. */
  22700. get output(): NodeMaterialConnectionPoint;
  22701. protected _buildBlock(state: NodeMaterialBuildState): this;
  22702. protected _dumpPropertiesCode(): string;
  22703. serialize(): any;
  22704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22705. }
  22706. }
  22707. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22711. /**
  22712. * Block used to multiply 2 values
  22713. */
  22714. export class MultiplyBlock extends NodeMaterialBlock {
  22715. /**
  22716. * Creates a new MultiplyBlock
  22717. * @param name defines the block name
  22718. */
  22719. constructor(name: string);
  22720. /**
  22721. * Gets the current class name
  22722. * @returns the class name
  22723. */
  22724. getClassName(): string;
  22725. /**
  22726. * Gets the left operand input component
  22727. */
  22728. get left(): NodeMaterialConnectionPoint;
  22729. /**
  22730. * Gets the right operand input component
  22731. */
  22732. get right(): NodeMaterialConnectionPoint;
  22733. /**
  22734. * Gets the output component
  22735. */
  22736. get output(): NodeMaterialConnectionPoint;
  22737. protected _buildBlock(state: NodeMaterialBuildState): this;
  22738. }
  22739. }
  22740. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22744. /**
  22745. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22746. */
  22747. export class ColorSplitterBlock extends NodeMaterialBlock {
  22748. /**
  22749. * Create a new ColorSplitterBlock
  22750. * @param name defines the block name
  22751. */
  22752. constructor(name: string);
  22753. /**
  22754. * Gets the current class name
  22755. * @returns the class name
  22756. */
  22757. getClassName(): string;
  22758. /**
  22759. * Gets the rgba component (input)
  22760. */
  22761. get rgba(): NodeMaterialConnectionPoint;
  22762. /**
  22763. * Gets the rgb component (input)
  22764. */
  22765. get rgbIn(): NodeMaterialConnectionPoint;
  22766. /**
  22767. * Gets the rgb component (output)
  22768. */
  22769. get rgbOut(): NodeMaterialConnectionPoint;
  22770. /**
  22771. * Gets the r component (output)
  22772. */
  22773. get r(): NodeMaterialConnectionPoint;
  22774. /**
  22775. * Gets the g component (output)
  22776. */
  22777. get g(): NodeMaterialConnectionPoint;
  22778. /**
  22779. * Gets the b component (output)
  22780. */
  22781. get b(): NodeMaterialConnectionPoint;
  22782. /**
  22783. * Gets the a component (output)
  22784. */
  22785. get a(): NodeMaterialConnectionPoint;
  22786. protected _inputRename(name: string): string;
  22787. protected _outputRename(name: string): string;
  22788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22789. }
  22790. }
  22791. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22793. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22794. import { Scene } from "babylonjs/scene";
  22795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22796. import { Matrix } from "babylonjs/Maths/math.vector";
  22797. import { Mesh } from "babylonjs/Meshes/mesh";
  22798. import { Engine } from "babylonjs/Engines/engine";
  22799. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22800. import { Observable } from "babylonjs/Misc/observable";
  22801. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22802. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22803. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22804. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22805. import { Nullable } from "babylonjs/types";
  22806. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22807. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22808. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22809. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22810. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22811. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22812. import { Effect } from "babylonjs/Materials/effect";
  22813. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22814. import { Camera } from "babylonjs/Cameras/camera";
  22815. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22816. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22817. /**
  22818. * Interface used to configure the node material editor
  22819. */
  22820. export interface INodeMaterialEditorOptions {
  22821. /** Define the URl to load node editor script */
  22822. editorURL?: string;
  22823. }
  22824. /** @hidden */
  22825. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22826. NORMAL: boolean;
  22827. TANGENT: boolean;
  22828. UV1: boolean;
  22829. /** BONES */
  22830. NUM_BONE_INFLUENCERS: number;
  22831. BonesPerMesh: number;
  22832. BONETEXTURE: boolean;
  22833. /** MORPH TARGETS */
  22834. MORPHTARGETS: boolean;
  22835. MORPHTARGETS_NORMAL: boolean;
  22836. MORPHTARGETS_TANGENT: boolean;
  22837. MORPHTARGETS_UV: boolean;
  22838. NUM_MORPH_INFLUENCERS: number;
  22839. /** IMAGE PROCESSING */
  22840. IMAGEPROCESSING: boolean;
  22841. VIGNETTE: boolean;
  22842. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22843. VIGNETTEBLENDMODEOPAQUE: boolean;
  22844. TONEMAPPING: boolean;
  22845. TONEMAPPING_ACES: boolean;
  22846. CONTRAST: boolean;
  22847. EXPOSURE: boolean;
  22848. COLORCURVES: boolean;
  22849. COLORGRADING: boolean;
  22850. COLORGRADING3D: boolean;
  22851. SAMPLER3DGREENDEPTH: boolean;
  22852. SAMPLER3DBGRMAP: boolean;
  22853. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22854. /** MISC. */
  22855. BUMPDIRECTUV: number;
  22856. constructor();
  22857. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22858. }
  22859. /**
  22860. * Class used to configure NodeMaterial
  22861. */
  22862. export interface INodeMaterialOptions {
  22863. /**
  22864. * Defines if blocks should emit comments
  22865. */
  22866. emitComments: boolean;
  22867. }
  22868. /**
  22869. * Class used to create a node based material built by assembling shader blocks
  22870. */
  22871. export class NodeMaterial extends PushMaterial {
  22872. private static _BuildIdGenerator;
  22873. private _options;
  22874. private _vertexCompilationState;
  22875. private _fragmentCompilationState;
  22876. private _sharedData;
  22877. private _buildId;
  22878. private _buildWasSuccessful;
  22879. private _cachedWorldViewMatrix;
  22880. private _cachedWorldViewProjectionMatrix;
  22881. private _optimizers;
  22882. private _animationFrame;
  22883. /** Define the Url to load node editor script */
  22884. static EditorURL: string;
  22885. /** Define the Url to load snippets */
  22886. static SnippetUrl: string;
  22887. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22888. static IgnoreTexturesAtLoadTime: boolean;
  22889. private BJSNODEMATERIALEDITOR;
  22890. /** Get the inspector from bundle or global */
  22891. private _getGlobalNodeMaterialEditor;
  22892. /**
  22893. * Snippet ID if the material was created from the snippet server
  22894. */
  22895. snippetId: string;
  22896. /**
  22897. * Gets or sets data used by visual editor
  22898. * @see https://nme.babylonjs.com
  22899. */
  22900. editorData: any;
  22901. /**
  22902. * 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)
  22903. */
  22904. ignoreAlpha: boolean;
  22905. /**
  22906. * Defines the maximum number of lights that can be used in the material
  22907. */
  22908. maxSimultaneousLights: number;
  22909. /**
  22910. * Observable raised when the material is built
  22911. */
  22912. onBuildObservable: Observable<NodeMaterial>;
  22913. /**
  22914. * Gets or sets the root nodes of the material vertex shader
  22915. */
  22916. _vertexOutputNodes: NodeMaterialBlock[];
  22917. /**
  22918. * Gets or sets the root nodes of the material fragment (pixel) shader
  22919. */
  22920. _fragmentOutputNodes: NodeMaterialBlock[];
  22921. /** Gets or sets options to control the node material overall behavior */
  22922. get options(): INodeMaterialOptions;
  22923. set options(options: INodeMaterialOptions);
  22924. /**
  22925. * Default configuration related to image processing available in the standard Material.
  22926. */
  22927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22928. /**
  22929. * Gets the image processing configuration used either in this material.
  22930. */
  22931. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22932. /**
  22933. * Sets the Default image processing configuration used either in the this material.
  22934. *
  22935. * If sets to null, the scene one is in use.
  22936. */
  22937. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22938. /**
  22939. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22940. */
  22941. attachedBlocks: NodeMaterialBlock[];
  22942. /**
  22943. * Specifies the mode of the node material
  22944. * @hidden
  22945. */
  22946. _mode: NodeMaterialModes;
  22947. /**
  22948. * Gets the mode property
  22949. */
  22950. get mode(): NodeMaterialModes;
  22951. /**
  22952. * Create a new node based material
  22953. * @param name defines the material name
  22954. * @param scene defines the hosting scene
  22955. * @param options defines creation option
  22956. */
  22957. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22958. /**
  22959. * Gets the current class name of the material e.g. "NodeMaterial"
  22960. * @returns the class name
  22961. */
  22962. getClassName(): string;
  22963. /**
  22964. * Keep track of the image processing observer to allow dispose and replace.
  22965. */
  22966. private _imageProcessingObserver;
  22967. /**
  22968. * Attaches a new image processing configuration to the Standard Material.
  22969. * @param configuration
  22970. */
  22971. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22972. /**
  22973. * Get a block by its name
  22974. * @param name defines the name of the block to retrieve
  22975. * @returns the required block or null if not found
  22976. */
  22977. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22978. /**
  22979. * Get a block by its name
  22980. * @param predicate defines the predicate used to find the good candidate
  22981. * @returns the required block or null if not found
  22982. */
  22983. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22984. /**
  22985. * Get an input block by its name
  22986. * @param predicate defines the predicate used to find the good candidate
  22987. * @returns the required input block or null if not found
  22988. */
  22989. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22990. /**
  22991. * Gets the list of input blocks attached to this material
  22992. * @returns an array of InputBlocks
  22993. */
  22994. getInputBlocks(): InputBlock[];
  22995. /**
  22996. * Adds a new optimizer to the list of optimizers
  22997. * @param optimizer defines the optimizers to add
  22998. * @returns the current material
  22999. */
  23000. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23001. /**
  23002. * Remove an optimizer from the list of optimizers
  23003. * @param optimizer defines the optimizers to remove
  23004. * @returns the current material
  23005. */
  23006. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23007. /**
  23008. * Add a new block to the list of output nodes
  23009. * @param node defines the node to add
  23010. * @returns the current material
  23011. */
  23012. addOutputNode(node: NodeMaterialBlock): this;
  23013. /**
  23014. * Remove a block from the list of root nodes
  23015. * @param node defines the node to remove
  23016. * @returns the current material
  23017. */
  23018. removeOutputNode(node: NodeMaterialBlock): this;
  23019. private _addVertexOutputNode;
  23020. private _removeVertexOutputNode;
  23021. private _addFragmentOutputNode;
  23022. private _removeFragmentOutputNode;
  23023. /**
  23024. * Specifies if the material will require alpha blending
  23025. * @returns a boolean specifying if alpha blending is needed
  23026. */
  23027. needAlphaBlending(): boolean;
  23028. /**
  23029. * Specifies if this material should be rendered in alpha test mode
  23030. * @returns a boolean specifying if an alpha test is needed.
  23031. */
  23032. needAlphaTesting(): boolean;
  23033. private _initializeBlock;
  23034. private _resetDualBlocks;
  23035. /**
  23036. * Remove a block from the current node material
  23037. * @param block defines the block to remove
  23038. */
  23039. removeBlock(block: NodeMaterialBlock): void;
  23040. /**
  23041. * Build the material and generates the inner effect
  23042. * @param verbose defines if the build should log activity
  23043. */
  23044. build(verbose?: boolean): void;
  23045. /**
  23046. * Runs an otpimization phase to try to improve the shader code
  23047. */
  23048. optimize(): void;
  23049. private _prepareDefinesForAttributes;
  23050. /**
  23051. * Create a post process from the material
  23052. * @param camera The camera to apply the render pass to.
  23053. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23055. * @param engine The engine which the post process will be applied. (default: current engine)
  23056. * @param reusable If the post process can be reused on the same frame. (default: false)
  23057. * @param textureType Type of textures used when performing the post process. (default: 0)
  23058. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23059. * @returns the post process created
  23060. */
  23061. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23062. /**
  23063. * Create the post process effect from the material
  23064. * @param postProcess The post process to create the effect for
  23065. */
  23066. createEffectForPostProcess(postProcess: PostProcess): void;
  23067. private _createEffectOrPostProcess;
  23068. private _createEffectForParticles;
  23069. /**
  23070. * Create the effect to be used as the custom effect for a particle system
  23071. * @param particleSystem Particle system to create the effect for
  23072. * @param onCompiled defines a function to call when the effect creation is successful
  23073. * @param onError defines a function to call when the effect creation has failed
  23074. */
  23075. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23076. private _processDefines;
  23077. /**
  23078. * Get if the submesh is ready to be used and all its information available.
  23079. * Child classes can use it to update shaders
  23080. * @param mesh defines the mesh to check
  23081. * @param subMesh defines which submesh to check
  23082. * @param useInstances specifies that instances should be used
  23083. * @returns a boolean indicating that the submesh is ready or not
  23084. */
  23085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23086. /**
  23087. * Get a string representing the shaders built by the current node graph
  23088. */
  23089. get compiledShaders(): string;
  23090. /**
  23091. * Binds the world matrix to the material
  23092. * @param world defines the world transformation matrix
  23093. */
  23094. bindOnlyWorldMatrix(world: Matrix): void;
  23095. /**
  23096. * Binds the submesh to this material by preparing the effect and shader to draw
  23097. * @param world defines the world transformation matrix
  23098. * @param mesh defines the mesh containing the submesh
  23099. * @param subMesh defines the submesh to bind the material to
  23100. */
  23101. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23102. /**
  23103. * Gets the active textures from the material
  23104. * @returns an array of textures
  23105. */
  23106. getActiveTextures(): BaseTexture[];
  23107. /**
  23108. * Gets the list of texture blocks
  23109. * @returns an array of texture blocks
  23110. */
  23111. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23112. /**
  23113. * Specifies if the material uses a texture
  23114. * @param texture defines the texture to check against the material
  23115. * @returns a boolean specifying if the material uses the texture
  23116. */
  23117. hasTexture(texture: BaseTexture): boolean;
  23118. /**
  23119. * Disposes the material
  23120. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23121. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23122. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23123. */
  23124. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23125. /** Creates the node editor window. */
  23126. private _createNodeEditor;
  23127. /**
  23128. * Launch the node material editor
  23129. * @param config Define the configuration of the editor
  23130. * @return a promise fulfilled when the node editor is visible
  23131. */
  23132. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23133. /**
  23134. * Clear the current material
  23135. */
  23136. clear(): void;
  23137. /**
  23138. * Clear the current material and set it to a default state
  23139. */
  23140. setToDefault(): void;
  23141. /**
  23142. * Clear the current material and set it to a default state for post process
  23143. */
  23144. setToDefaultPostProcess(): void;
  23145. /**
  23146. * Clear the current material and set it to a default state for particle
  23147. */
  23148. setToDefaultParticle(): void;
  23149. /**
  23150. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23151. * @param url defines the url to load from
  23152. * @returns a promise that will fullfil when the material is fully loaded
  23153. */
  23154. loadAsync(url: string): Promise<void>;
  23155. private _gatherBlocks;
  23156. /**
  23157. * Generate a string containing the code declaration required to create an equivalent of this material
  23158. * @returns a string
  23159. */
  23160. generateCode(): string;
  23161. /**
  23162. * Serializes this material in a JSON representation
  23163. * @returns the serialized material object
  23164. */
  23165. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23166. private _restoreConnections;
  23167. /**
  23168. * Clear the current graph and load a new one from a serialization object
  23169. * @param source defines the JSON representation of the material
  23170. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23171. * @param merge defines whether or not the source must be merged or replace the current content
  23172. */
  23173. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23174. /**
  23175. * Makes a duplicate of the current material.
  23176. * @param name - name to use for the new material.
  23177. */
  23178. clone(name: string): NodeMaterial;
  23179. /**
  23180. * Creates a node material from parsed material data
  23181. * @param source defines the JSON representation of the material
  23182. * @param scene defines the hosting scene
  23183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23184. * @returns a new node material
  23185. */
  23186. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23187. /**
  23188. * Creates a node material from a snippet saved in a remote file
  23189. * @param name defines the name of the material to create
  23190. * @param url defines the url to load from
  23191. * @param scene defines the hosting scene
  23192. * @returns a promise that will resolve to the new node material
  23193. */
  23194. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23195. /**
  23196. * Creates a node material from a snippet saved by the node material editor
  23197. * @param snippetId defines the snippet to load
  23198. * @param scene defines the hosting scene
  23199. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23200. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23201. * @returns a promise that will resolve to the new node material
  23202. */
  23203. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23204. /**
  23205. * Creates a new node material set to default basic configuration
  23206. * @param name defines the name of the material
  23207. * @param scene defines the hosting scene
  23208. * @returns a new NodeMaterial
  23209. */
  23210. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23211. }
  23212. }
  23213. declare module "babylonjs/PostProcesses/postProcess" {
  23214. import { Nullable } from "babylonjs/types";
  23215. import { SmartArray } from "babylonjs/Misc/smartArray";
  23216. import { Observable } from "babylonjs/Misc/observable";
  23217. import { Vector2 } from "babylonjs/Maths/math.vector";
  23218. import { Camera } from "babylonjs/Cameras/camera";
  23219. import { Effect } from "babylonjs/Materials/effect";
  23220. import "babylonjs/Shaders/postprocess.vertex";
  23221. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23222. import { Engine } from "babylonjs/Engines/engine";
  23223. import { Color4 } from "babylonjs/Maths/math.color";
  23224. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23225. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23226. import { Scene } from "babylonjs/scene";
  23227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23228. /**
  23229. * Size options for a post process
  23230. */
  23231. export type PostProcessOptions = {
  23232. width: number;
  23233. height: number;
  23234. };
  23235. /**
  23236. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23237. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23238. */
  23239. export class PostProcess {
  23240. /** Name of the PostProcess. */
  23241. name: string;
  23242. /**
  23243. * Gets or sets the unique id of the post process
  23244. */
  23245. uniqueId: number;
  23246. /**
  23247. * Width of the texture to apply the post process on
  23248. */
  23249. width: number;
  23250. /**
  23251. * Height of the texture to apply the post process on
  23252. */
  23253. height: number;
  23254. /**
  23255. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23256. */
  23257. nodeMaterialSource: Nullable<NodeMaterial>;
  23258. /**
  23259. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23260. * @hidden
  23261. */
  23262. _outputTexture: Nullable<InternalTexture>;
  23263. /**
  23264. * Sampling mode used by the shader
  23265. * See https://doc.babylonjs.com/classes/3.1/texture
  23266. */
  23267. renderTargetSamplingMode: number;
  23268. /**
  23269. * Clear color to use when screen clearing
  23270. */
  23271. clearColor: Color4;
  23272. /**
  23273. * If the buffer needs to be cleared before applying the post process. (default: true)
  23274. * Should be set to false if shader will overwrite all previous pixels.
  23275. */
  23276. autoClear: boolean;
  23277. /**
  23278. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23279. */
  23280. alphaMode: number;
  23281. /**
  23282. * Sets the setAlphaBlendConstants of the babylon engine
  23283. */
  23284. alphaConstants: Color4;
  23285. /**
  23286. * Animations to be used for the post processing
  23287. */
  23288. animations: import("babylonjs/Animations/animation").Animation[];
  23289. /**
  23290. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23291. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23292. */
  23293. enablePixelPerfectMode: boolean;
  23294. /**
  23295. * Force the postprocess to be applied without taking in account viewport
  23296. */
  23297. forceFullscreenViewport: boolean;
  23298. /**
  23299. * List of inspectable custom properties (used by the Inspector)
  23300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23301. */
  23302. inspectableCustomProperties: IInspectable[];
  23303. /**
  23304. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23305. *
  23306. * | Value | Type | Description |
  23307. * | ----- | ----------------------------------- | ----------- |
  23308. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23309. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23310. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23311. *
  23312. */
  23313. scaleMode: number;
  23314. /**
  23315. * Force textures to be a power of two (default: false)
  23316. */
  23317. alwaysForcePOT: boolean;
  23318. private _samples;
  23319. /**
  23320. * Number of sample textures (default: 1)
  23321. */
  23322. get samples(): number;
  23323. set samples(n: number);
  23324. /**
  23325. * Modify the scale of the post process to be the same as the viewport (default: false)
  23326. */
  23327. adaptScaleToCurrentViewport: boolean;
  23328. private _camera;
  23329. protected _scene: Scene;
  23330. private _engine;
  23331. private _options;
  23332. private _reusable;
  23333. private _textureType;
  23334. private _textureFormat;
  23335. /**
  23336. * Smart array of input and output textures for the post process.
  23337. * @hidden
  23338. */
  23339. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23340. /**
  23341. * The index in _textures that corresponds to the output texture.
  23342. * @hidden
  23343. */
  23344. _currentRenderTextureInd: number;
  23345. private _effect;
  23346. private _samplers;
  23347. private _fragmentUrl;
  23348. private _vertexUrl;
  23349. private _parameters;
  23350. private _scaleRatio;
  23351. protected _indexParameters: any;
  23352. private _shareOutputWithPostProcess;
  23353. private _texelSize;
  23354. private _forcedOutputTexture;
  23355. /**
  23356. * Returns the fragment url or shader name used in the post process.
  23357. * @returns the fragment url or name in the shader store.
  23358. */
  23359. getEffectName(): string;
  23360. /**
  23361. * An event triggered when the postprocess is activated.
  23362. */
  23363. onActivateObservable: Observable<Camera>;
  23364. private _onActivateObserver;
  23365. /**
  23366. * A function that is added to the onActivateObservable
  23367. */
  23368. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23369. /**
  23370. * An event triggered when the postprocess changes its size.
  23371. */
  23372. onSizeChangedObservable: Observable<PostProcess>;
  23373. private _onSizeChangedObserver;
  23374. /**
  23375. * A function that is added to the onSizeChangedObservable
  23376. */
  23377. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23378. /**
  23379. * An event triggered when the postprocess applies its effect.
  23380. */
  23381. onApplyObservable: Observable<Effect>;
  23382. private _onApplyObserver;
  23383. /**
  23384. * A function that is added to the onApplyObservable
  23385. */
  23386. set onApply(callback: (effect: Effect) => void);
  23387. /**
  23388. * An event triggered before rendering the postprocess
  23389. */
  23390. onBeforeRenderObservable: Observable<Effect>;
  23391. private _onBeforeRenderObserver;
  23392. /**
  23393. * A function that is added to the onBeforeRenderObservable
  23394. */
  23395. set onBeforeRender(callback: (effect: Effect) => void);
  23396. /**
  23397. * An event triggered after rendering the postprocess
  23398. */
  23399. onAfterRenderObservable: Observable<Effect>;
  23400. private _onAfterRenderObserver;
  23401. /**
  23402. * A function that is added to the onAfterRenderObservable
  23403. */
  23404. set onAfterRender(callback: (efect: Effect) => void);
  23405. /**
  23406. * 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
  23407. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23408. */
  23409. get inputTexture(): InternalTexture;
  23410. set inputTexture(value: InternalTexture);
  23411. /**
  23412. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23413. * the only way to unset it is to use this function to restore its internal state
  23414. */
  23415. restoreDefaultInputTexture(): void;
  23416. /**
  23417. * Gets the camera which post process is applied to.
  23418. * @returns The camera the post process is applied to.
  23419. */
  23420. getCamera(): Camera;
  23421. /**
  23422. * Gets the texel size of the postprocess.
  23423. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23424. */
  23425. get texelSize(): Vector2;
  23426. /**
  23427. * Creates a new instance PostProcess
  23428. * @param name The name of the PostProcess.
  23429. * @param fragmentUrl The url of the fragment shader to be used.
  23430. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23431. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23432. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23433. * @param camera The camera to apply the render pass to.
  23434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23435. * @param engine The engine which the post process will be applied. (default: current engine)
  23436. * @param reusable If the post process can be reused on the same frame. (default: false)
  23437. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23438. * @param textureType Type of textures used when performing the post process. (default: 0)
  23439. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23440. * @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
  23441. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23442. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23443. */
  23444. constructor(
  23445. /** Name of the PostProcess. */
  23446. 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);
  23447. /**
  23448. * Gets a string idenfifying the name of the class
  23449. * @returns "PostProcess" string
  23450. */
  23451. getClassName(): string;
  23452. /**
  23453. * Gets the engine which this post process belongs to.
  23454. * @returns The engine the post process was enabled with.
  23455. */
  23456. getEngine(): Engine;
  23457. /**
  23458. * The effect that is created when initializing the post process.
  23459. * @returns The created effect corresponding the the postprocess.
  23460. */
  23461. getEffect(): Effect;
  23462. /**
  23463. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23464. * @param postProcess The post process to share the output with.
  23465. * @returns This post process.
  23466. */
  23467. shareOutputWith(postProcess: PostProcess): PostProcess;
  23468. /**
  23469. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23470. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23471. */
  23472. useOwnOutput(): void;
  23473. /**
  23474. * Updates the effect with the current post process compile time values and recompiles the shader.
  23475. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23476. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23477. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23478. * @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
  23479. * @param onCompiled Called when the shader has been compiled.
  23480. * @param onError Called if there is an error when compiling a shader.
  23481. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23482. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23483. */
  23484. 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;
  23485. /**
  23486. * The post process is reusable if it can be used multiple times within one frame.
  23487. * @returns If the post process is reusable
  23488. */
  23489. isReusable(): boolean;
  23490. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23491. markTextureDirty(): void;
  23492. /**
  23493. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23494. * 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.
  23495. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23496. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23497. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23498. * @returns The target texture that was bound to be written to.
  23499. */
  23500. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23501. /**
  23502. * If the post process is supported.
  23503. */
  23504. get isSupported(): boolean;
  23505. /**
  23506. * The aspect ratio of the output texture.
  23507. */
  23508. get aspectRatio(): number;
  23509. /**
  23510. * Get a value indicating if the post-process is ready to be used
  23511. * @returns true if the post-process is ready (shader is compiled)
  23512. */
  23513. isReady(): boolean;
  23514. /**
  23515. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23516. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23517. */
  23518. apply(): Nullable<Effect>;
  23519. private _disposeTextures;
  23520. /**
  23521. * Disposes the post process.
  23522. * @param camera The camera to dispose the post process on.
  23523. */
  23524. dispose(camera?: Camera): void;
  23525. }
  23526. }
  23527. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23528. /** @hidden */
  23529. export var kernelBlurVaryingDeclaration: {
  23530. name: string;
  23531. shader: string;
  23532. };
  23533. }
  23534. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23535. /** @hidden */
  23536. export var kernelBlurFragment: {
  23537. name: string;
  23538. shader: string;
  23539. };
  23540. }
  23541. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23542. /** @hidden */
  23543. export var kernelBlurFragment2: {
  23544. name: string;
  23545. shader: string;
  23546. };
  23547. }
  23548. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23549. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23550. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23551. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23552. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23553. /** @hidden */
  23554. export var kernelBlurPixelShader: {
  23555. name: string;
  23556. shader: string;
  23557. };
  23558. }
  23559. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23560. /** @hidden */
  23561. export var kernelBlurVertex: {
  23562. name: string;
  23563. shader: string;
  23564. };
  23565. }
  23566. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23567. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23568. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23569. /** @hidden */
  23570. export var kernelBlurVertexShader: {
  23571. name: string;
  23572. shader: string;
  23573. };
  23574. }
  23575. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23576. import { Vector2 } from "babylonjs/Maths/math.vector";
  23577. import { Nullable } from "babylonjs/types";
  23578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23579. import { Camera } from "babylonjs/Cameras/camera";
  23580. import { Effect } from "babylonjs/Materials/effect";
  23581. import { Engine } from "babylonjs/Engines/engine";
  23582. import "babylonjs/Shaders/kernelBlur.fragment";
  23583. import "babylonjs/Shaders/kernelBlur.vertex";
  23584. /**
  23585. * The Blur Post Process which blurs an image based on a kernel and direction.
  23586. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23587. */
  23588. export class BlurPostProcess extends PostProcess {
  23589. /** The direction in which to blur the image. */
  23590. direction: Vector2;
  23591. private blockCompilation;
  23592. protected _kernel: number;
  23593. protected _idealKernel: number;
  23594. protected _packedFloat: boolean;
  23595. private _staticDefines;
  23596. /**
  23597. * Sets the length in pixels of the blur sample region
  23598. */
  23599. set kernel(v: number);
  23600. /**
  23601. * Gets the length in pixels of the blur sample region
  23602. */
  23603. get kernel(): number;
  23604. /**
  23605. * Sets wether or not the blur needs to unpack/repack floats
  23606. */
  23607. set packedFloat(v: boolean);
  23608. /**
  23609. * Gets wether or not the blur is unpacking/repacking floats
  23610. */
  23611. get packedFloat(): boolean;
  23612. /**
  23613. * Creates a new instance BlurPostProcess
  23614. * @param name The name of the effect.
  23615. * @param direction The direction in which to blur the image.
  23616. * @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.
  23617. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23618. * @param camera The camera to apply the render pass to.
  23619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23620. * @param engine The engine which the post process will be applied. (default: current engine)
  23621. * @param reusable If the post process can be reused on the same frame. (default: false)
  23622. * @param textureType Type of textures used when performing the post process. (default: 0)
  23623. * @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)
  23624. */
  23625. constructor(name: string,
  23626. /** The direction in which to blur the image. */
  23627. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23628. /**
  23629. * Updates the effect with the current post process compile time values and recompiles the shader.
  23630. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23631. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23632. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23633. * @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
  23634. * @param onCompiled Called when the shader has been compiled.
  23635. * @param onError Called if there is an error when compiling a shader.
  23636. */
  23637. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23638. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23639. /**
  23640. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23641. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23642. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23643. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23644. * The gaps between physical kernels are compensated for in the weighting of the samples
  23645. * @param idealKernel Ideal blur kernel.
  23646. * @return Nearest best kernel.
  23647. */
  23648. protected _nearestBestKernel(idealKernel: number): number;
  23649. /**
  23650. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23651. * @param x The point on the Gaussian distribution to sample.
  23652. * @return the value of the Gaussian function at x.
  23653. */
  23654. protected _gaussianWeight(x: number): number;
  23655. /**
  23656. * Generates a string that can be used as a floating point number in GLSL.
  23657. * @param x Value to print.
  23658. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23659. * @return GLSL float string.
  23660. */
  23661. protected _glslFloat(x: number, decimalFigures?: number): string;
  23662. }
  23663. }
  23664. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23665. import { Scene } from "babylonjs/scene";
  23666. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23667. import { Plane } from "babylonjs/Maths/math.plane";
  23668. /**
  23669. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23670. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23671. * You can then easily use it as a reflectionTexture on a flat surface.
  23672. * In case the surface is not a plane, please consider relying on reflection probes.
  23673. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23674. */
  23675. export class MirrorTexture extends RenderTargetTexture {
  23676. private scene;
  23677. /**
  23678. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23679. * 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.
  23680. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23681. */
  23682. mirrorPlane: Plane;
  23683. /**
  23684. * Define the blur ratio used to blur the reflection if needed.
  23685. */
  23686. set blurRatio(value: number);
  23687. get blurRatio(): number;
  23688. /**
  23689. * Define the adaptive blur kernel used to blur the reflection if needed.
  23690. * This will autocompute the closest best match for the `blurKernel`
  23691. */
  23692. set adaptiveBlurKernel(value: number);
  23693. /**
  23694. * Define the blur kernel used to blur the reflection if needed.
  23695. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23696. */
  23697. set blurKernel(value: number);
  23698. /**
  23699. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23700. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23701. */
  23702. set blurKernelX(value: number);
  23703. get blurKernelX(): number;
  23704. /**
  23705. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23706. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23707. */
  23708. set blurKernelY(value: number);
  23709. get blurKernelY(): number;
  23710. private _autoComputeBlurKernel;
  23711. protected _onRatioRescale(): void;
  23712. private _updateGammaSpace;
  23713. private _imageProcessingConfigChangeObserver;
  23714. private _transformMatrix;
  23715. private _mirrorMatrix;
  23716. private _savedViewMatrix;
  23717. private _blurX;
  23718. private _blurY;
  23719. private _adaptiveBlurKernel;
  23720. private _blurKernelX;
  23721. private _blurKernelY;
  23722. private _blurRatio;
  23723. /**
  23724. * Instantiates a Mirror Texture.
  23725. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23726. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23727. * You can then easily use it as a reflectionTexture on a flat surface.
  23728. * In case the surface is not a plane, please consider relying on reflection probes.
  23729. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23730. * @param name
  23731. * @param size
  23732. * @param scene
  23733. * @param generateMipMaps
  23734. * @param type
  23735. * @param samplingMode
  23736. * @param generateDepthBuffer
  23737. */
  23738. constructor(name: string, size: number | {
  23739. width: number;
  23740. height: number;
  23741. } | {
  23742. ratio: number;
  23743. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23744. private _preparePostProcesses;
  23745. /**
  23746. * Clone the mirror texture.
  23747. * @returns the cloned texture
  23748. */
  23749. clone(): MirrorTexture;
  23750. /**
  23751. * Serialize the texture to a JSON representation you could use in Parse later on
  23752. * @returns the serialized JSON representation
  23753. */
  23754. serialize(): any;
  23755. /**
  23756. * Dispose the texture and release its associated resources.
  23757. */
  23758. dispose(): void;
  23759. }
  23760. }
  23761. declare module "babylonjs/Materials/Textures/texture" {
  23762. import { Observable } from "babylonjs/Misc/observable";
  23763. import { Nullable } from "babylonjs/types";
  23764. import { Matrix } from "babylonjs/Maths/math.vector";
  23765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23766. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23767. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23768. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23769. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23770. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23771. import { Scene } from "babylonjs/scene";
  23772. /**
  23773. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23774. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23775. */
  23776. export class Texture extends BaseTexture {
  23777. /**
  23778. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23779. */
  23780. static SerializeBuffers: boolean;
  23781. /** @hidden */
  23782. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23783. /** @hidden */
  23784. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23785. /** @hidden */
  23786. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23787. /** nearest is mag = nearest and min = nearest and mip = linear */
  23788. static readonly NEAREST_SAMPLINGMODE: number;
  23789. /** nearest is mag = nearest and min = nearest and mip = linear */
  23790. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23791. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23792. static readonly BILINEAR_SAMPLINGMODE: number;
  23793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23794. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23795. /** Trilinear is mag = linear and min = linear and mip = linear */
  23796. static readonly TRILINEAR_SAMPLINGMODE: number;
  23797. /** Trilinear is mag = linear and min = linear and mip = linear */
  23798. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23799. /** mag = nearest and min = nearest and mip = nearest */
  23800. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23801. /** mag = nearest and min = linear and mip = nearest */
  23802. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23803. /** mag = nearest and min = linear and mip = linear */
  23804. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23805. /** mag = nearest and min = linear and mip = none */
  23806. static readonly NEAREST_LINEAR: number;
  23807. /** mag = nearest and min = nearest and mip = none */
  23808. static readonly NEAREST_NEAREST: number;
  23809. /** mag = linear and min = nearest and mip = nearest */
  23810. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23811. /** mag = linear and min = nearest and mip = linear */
  23812. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23813. /** mag = linear and min = linear and mip = none */
  23814. static readonly LINEAR_LINEAR: number;
  23815. /** mag = linear and min = nearest and mip = none */
  23816. static readonly LINEAR_NEAREST: number;
  23817. /** Explicit coordinates mode */
  23818. static readonly EXPLICIT_MODE: number;
  23819. /** Spherical coordinates mode */
  23820. static readonly SPHERICAL_MODE: number;
  23821. /** Planar coordinates mode */
  23822. static readonly PLANAR_MODE: number;
  23823. /** Cubic coordinates mode */
  23824. static readonly CUBIC_MODE: number;
  23825. /** Projection coordinates mode */
  23826. static readonly PROJECTION_MODE: number;
  23827. /** Inverse Cubic coordinates mode */
  23828. static readonly SKYBOX_MODE: number;
  23829. /** Inverse Cubic coordinates mode */
  23830. static readonly INVCUBIC_MODE: number;
  23831. /** Equirectangular coordinates mode */
  23832. static readonly EQUIRECTANGULAR_MODE: number;
  23833. /** Equirectangular Fixed coordinates mode */
  23834. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23835. /** Equirectangular Fixed Mirrored coordinates mode */
  23836. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23837. /** Texture is not repeating outside of 0..1 UVs */
  23838. static readonly CLAMP_ADDRESSMODE: number;
  23839. /** Texture is repeating outside of 0..1 UVs */
  23840. static readonly WRAP_ADDRESSMODE: number;
  23841. /** Texture is repeating and mirrored */
  23842. static readonly MIRROR_ADDRESSMODE: number;
  23843. /**
  23844. * 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
  23845. */
  23846. static UseSerializedUrlIfAny: boolean;
  23847. /**
  23848. * Define the url of the texture.
  23849. */
  23850. url: Nullable<string>;
  23851. /**
  23852. * Define an offset on the texture to offset the u coordinates of the UVs
  23853. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23854. */
  23855. uOffset: number;
  23856. /**
  23857. * Define an offset on the texture to offset the v coordinates of the UVs
  23858. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23859. */
  23860. vOffset: number;
  23861. /**
  23862. * Define an offset on the texture to scale the u coordinates of the UVs
  23863. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23864. */
  23865. uScale: number;
  23866. /**
  23867. * Define an offset on the texture to scale the v coordinates of the UVs
  23868. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23869. */
  23870. vScale: number;
  23871. /**
  23872. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23873. * @see https://doc.babylonjs.com/how_to/more_materials
  23874. */
  23875. uAng: number;
  23876. /**
  23877. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23878. * @see https://doc.babylonjs.com/how_to/more_materials
  23879. */
  23880. vAng: number;
  23881. /**
  23882. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23883. * @see https://doc.babylonjs.com/how_to/more_materials
  23884. */
  23885. wAng: number;
  23886. /**
  23887. * Defines the center of rotation (U)
  23888. */
  23889. uRotationCenter: number;
  23890. /**
  23891. * Defines the center of rotation (V)
  23892. */
  23893. vRotationCenter: number;
  23894. /**
  23895. * Defines the center of rotation (W)
  23896. */
  23897. wRotationCenter: number;
  23898. /**
  23899. * Are mip maps generated for this texture or not.
  23900. */
  23901. get noMipmap(): boolean;
  23902. /**
  23903. * List of inspectable custom properties (used by the Inspector)
  23904. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23905. */
  23906. inspectableCustomProperties: Nullable<IInspectable[]>;
  23907. private _noMipmap;
  23908. /** @hidden */
  23909. _invertY: boolean;
  23910. private _rowGenerationMatrix;
  23911. private _cachedTextureMatrix;
  23912. private _projectionModeMatrix;
  23913. private _t0;
  23914. private _t1;
  23915. private _t2;
  23916. private _cachedUOffset;
  23917. private _cachedVOffset;
  23918. private _cachedUScale;
  23919. private _cachedVScale;
  23920. private _cachedUAng;
  23921. private _cachedVAng;
  23922. private _cachedWAng;
  23923. private _cachedProjectionMatrixId;
  23924. private _cachedCoordinatesMode;
  23925. /** @hidden */
  23926. protected _initialSamplingMode: number;
  23927. /** @hidden */
  23928. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23929. private _deleteBuffer;
  23930. protected _format: Nullable<number>;
  23931. private _delayedOnLoad;
  23932. private _delayedOnError;
  23933. private _mimeType?;
  23934. /**
  23935. * Observable triggered once the texture has been loaded.
  23936. */
  23937. onLoadObservable: Observable<Texture>;
  23938. protected _isBlocking: boolean;
  23939. /**
  23940. * Is the texture preventing material to render while loading.
  23941. * If false, a default texture will be used instead of the loading one during the preparation step.
  23942. */
  23943. set isBlocking(value: boolean);
  23944. get isBlocking(): boolean;
  23945. /**
  23946. * Get the current sampling mode associated with the texture.
  23947. */
  23948. get samplingMode(): number;
  23949. /**
  23950. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23951. */
  23952. get invertY(): boolean;
  23953. /**
  23954. * Instantiates a new texture.
  23955. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23956. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23957. * @param url defines the url of the picture to load as a texture
  23958. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23959. * @param noMipmap defines if the texture will require mip maps or not
  23960. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23961. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23962. * @param onLoad defines a callback triggered when the texture has been loaded
  23963. * @param onError defines a callback triggered when an error occurred during the loading session
  23964. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23965. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23966. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23967. * @param mimeType defines an optional mime type information
  23968. */
  23969. 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);
  23970. /**
  23971. * Update the url (and optional buffer) of this texture if url was null during construction.
  23972. * @param url the url of the texture
  23973. * @param buffer the buffer of the texture (defaults to null)
  23974. * @param onLoad callback called when the texture is loaded (defaults to null)
  23975. */
  23976. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23977. /**
  23978. * Finish the loading sequence of a texture flagged as delayed load.
  23979. * @hidden
  23980. */
  23981. delayLoad(): void;
  23982. private _prepareRowForTextureGeneration;
  23983. /**
  23984. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23985. * @returns the transform matrix of the texture.
  23986. */
  23987. getTextureMatrix(uBase?: number): Matrix;
  23988. /**
  23989. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23990. * @returns The reflection texture transform
  23991. */
  23992. getReflectionTextureMatrix(): Matrix;
  23993. /**
  23994. * Clones the texture.
  23995. * @returns the cloned texture
  23996. */
  23997. clone(): Texture;
  23998. /**
  23999. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24000. * @returns The JSON representation of the texture
  24001. */
  24002. serialize(): any;
  24003. /**
  24004. * Get the current class name of the texture useful for serialization or dynamic coding.
  24005. * @returns "Texture"
  24006. */
  24007. getClassName(): string;
  24008. /**
  24009. * Dispose the texture and release its associated resources.
  24010. */
  24011. dispose(): void;
  24012. /**
  24013. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24014. * @param parsedTexture Define the JSON representation of the texture
  24015. * @param scene Define the scene the parsed texture should be instantiated in
  24016. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24017. * @returns The parsed texture if successful
  24018. */
  24019. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24020. /**
  24021. * Creates a texture from its base 64 representation.
  24022. * @param data Define the base64 payload without the data: prefix
  24023. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24024. * @param scene Define the scene the texture should belong to
  24025. * @param noMipmap Forces the texture to not create mip map information if true
  24026. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24027. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24028. * @param onLoad define a callback triggered when the texture has been loaded
  24029. * @param onError define a callback triggered when an error occurred during the loading session
  24030. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24031. * @returns the created texture
  24032. */
  24033. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24034. /**
  24035. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24036. * @param data Define the base64 payload without the data: prefix
  24037. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24038. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24039. * @param scene Define the scene the texture should belong to
  24040. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24041. * @param noMipmap Forces the texture to not create mip map information if true
  24042. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24043. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24044. * @param onLoad define a callback triggered when the texture has been loaded
  24045. * @param onError define a callback triggered when an error occurred during the loading session
  24046. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24047. * @returns the created texture
  24048. */
  24049. 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;
  24050. }
  24051. }
  24052. declare module "babylonjs/PostProcesses/postProcessManager" {
  24053. import { Nullable } from "babylonjs/types";
  24054. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24056. import { Scene } from "babylonjs/scene";
  24057. /**
  24058. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24059. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24060. */
  24061. export class PostProcessManager {
  24062. private _scene;
  24063. private _indexBuffer;
  24064. private _vertexBuffers;
  24065. /**
  24066. * Creates a new instance PostProcess
  24067. * @param scene The scene that the post process is associated with.
  24068. */
  24069. constructor(scene: Scene);
  24070. private _prepareBuffers;
  24071. private _buildIndexBuffer;
  24072. /**
  24073. * Rebuilds the vertex buffers of the manager.
  24074. * @hidden
  24075. */
  24076. _rebuild(): void;
  24077. /**
  24078. * Prepares a frame to be run through a post process.
  24079. * @param sourceTexture The input texture to the post procesess. (default: null)
  24080. * @param postProcesses An array of post processes to be run. (default: null)
  24081. * @returns True if the post processes were able to be run.
  24082. * @hidden
  24083. */
  24084. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24085. /**
  24086. * Manually render a set of post processes to a texture.
  24087. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24088. * @param postProcesses An array of post processes to be run.
  24089. * @param targetTexture The target texture to render to.
  24090. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24091. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24092. * @param lodLevel defines which lod of the texture to render to
  24093. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24094. */
  24095. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24096. /**
  24097. * Finalize the result of the output of the postprocesses.
  24098. * @param doNotPresent If true the result will not be displayed to the screen.
  24099. * @param targetTexture The target texture to render to.
  24100. * @param faceIndex The index of the face to bind the target texture to.
  24101. * @param postProcesses The array of post processes to render.
  24102. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24103. * @hidden
  24104. */
  24105. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24106. /**
  24107. * Disposes of the post process manager.
  24108. */
  24109. dispose(): void;
  24110. }
  24111. }
  24112. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24113. import { Observable } from "babylonjs/Misc/observable";
  24114. import { SmartArray } from "babylonjs/Misc/smartArray";
  24115. import { Nullable, Immutable } from "babylonjs/types";
  24116. import { Camera } from "babylonjs/Cameras/camera";
  24117. import { Scene } from "babylonjs/scene";
  24118. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24119. import { Color4 } from "babylonjs/Maths/math.color";
  24120. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24122. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24124. import { Texture } from "babylonjs/Materials/Textures/texture";
  24125. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24126. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24127. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24128. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24129. import { Engine } from "babylonjs/Engines/engine";
  24130. /**
  24131. * This Helps creating a texture that will be created from a camera in your scene.
  24132. * It is basically a dynamic texture that could be used to create special effects for instance.
  24133. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24134. */
  24135. export class RenderTargetTexture extends Texture {
  24136. isCube: boolean;
  24137. /**
  24138. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24139. */
  24140. static readonly REFRESHRATE_RENDER_ONCE: number;
  24141. /**
  24142. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24143. */
  24144. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24145. /**
  24146. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24147. * the central point of your effect and can save a lot of performances.
  24148. */
  24149. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24150. /**
  24151. * Use this predicate to dynamically define the list of mesh you want to render.
  24152. * If set, the renderList property will be overwritten.
  24153. */
  24154. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24155. private _renderList;
  24156. /**
  24157. * Use this list to define the list of mesh you want to render.
  24158. */
  24159. get renderList(): Nullable<Array<AbstractMesh>>;
  24160. set renderList(value: Nullable<Array<AbstractMesh>>);
  24161. /**
  24162. * Use this function to overload the renderList array at rendering time.
  24163. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24164. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24165. * the cube (if the RTT is a cube, else layerOrFace=0).
  24166. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24167. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24168. * hold dummy elements!
  24169. */
  24170. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24171. private _hookArray;
  24172. /**
  24173. * Define if particles should be rendered in your texture.
  24174. */
  24175. renderParticles: boolean;
  24176. /**
  24177. * Define if sprites should be rendered in your texture.
  24178. */
  24179. renderSprites: boolean;
  24180. /**
  24181. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24182. */
  24183. coordinatesMode: number;
  24184. /**
  24185. * Define the camera used to render the texture.
  24186. */
  24187. activeCamera: Nullable<Camera>;
  24188. /**
  24189. * Override the mesh isReady function with your own one.
  24190. */
  24191. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24192. /**
  24193. * Override the render function of the texture with your own one.
  24194. */
  24195. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24196. /**
  24197. * Define if camera post processes should be use while rendering the texture.
  24198. */
  24199. useCameraPostProcesses: boolean;
  24200. /**
  24201. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24202. */
  24203. ignoreCameraViewport: boolean;
  24204. private _postProcessManager;
  24205. private _postProcesses;
  24206. private _resizeObserver;
  24207. /**
  24208. * An event triggered when the texture is unbind.
  24209. */
  24210. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24211. /**
  24212. * An event triggered when the texture is unbind.
  24213. */
  24214. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24215. private _onAfterUnbindObserver;
  24216. /**
  24217. * Set a after unbind callback in the texture.
  24218. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24219. */
  24220. set onAfterUnbind(callback: () => void);
  24221. /**
  24222. * An event triggered before rendering the texture
  24223. */
  24224. onBeforeRenderObservable: Observable<number>;
  24225. private _onBeforeRenderObserver;
  24226. /**
  24227. * Set a before render callback in the texture.
  24228. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24229. */
  24230. set onBeforeRender(callback: (faceIndex: number) => void);
  24231. /**
  24232. * An event triggered after rendering the texture
  24233. */
  24234. onAfterRenderObservable: Observable<number>;
  24235. private _onAfterRenderObserver;
  24236. /**
  24237. * Set a after render callback in the texture.
  24238. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24239. */
  24240. set onAfterRender(callback: (faceIndex: number) => void);
  24241. /**
  24242. * An event triggered after the texture clear
  24243. */
  24244. onClearObservable: Observable<Engine>;
  24245. private _onClearObserver;
  24246. /**
  24247. * Set a clear callback in the texture.
  24248. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24249. */
  24250. set onClear(callback: (Engine: Engine) => void);
  24251. /**
  24252. * An event triggered when the texture is resized.
  24253. */
  24254. onResizeObservable: Observable<RenderTargetTexture>;
  24255. /**
  24256. * Define the clear color of the Render Target if it should be different from the scene.
  24257. */
  24258. clearColor: Color4;
  24259. protected _size: number | {
  24260. width: number;
  24261. height: number;
  24262. layers?: number;
  24263. };
  24264. protected _initialSizeParameter: number | {
  24265. width: number;
  24266. height: number;
  24267. } | {
  24268. ratio: number;
  24269. };
  24270. protected _sizeRatio: Nullable<number>;
  24271. /** @hidden */
  24272. _generateMipMaps: boolean;
  24273. protected _renderingManager: RenderingManager;
  24274. /** @hidden */
  24275. _waitingRenderList: string[];
  24276. protected _doNotChangeAspectRatio: boolean;
  24277. protected _currentRefreshId: number;
  24278. protected _refreshRate: number;
  24279. protected _textureMatrix: Matrix;
  24280. protected _samples: number;
  24281. protected _renderTargetOptions: RenderTargetCreationOptions;
  24282. /**
  24283. * Gets render target creation options that were used.
  24284. */
  24285. get renderTargetOptions(): RenderTargetCreationOptions;
  24286. protected _onRatioRescale(): void;
  24287. /**
  24288. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24289. * It must define where the camera used to render the texture is set
  24290. */
  24291. boundingBoxPosition: Vector3;
  24292. private _boundingBoxSize;
  24293. /**
  24294. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24295. * When defined, the cubemap will switch to local mode
  24296. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24297. * @example https://www.babylonjs-playground.com/#RNASML
  24298. */
  24299. set boundingBoxSize(value: Vector3);
  24300. get boundingBoxSize(): Vector3;
  24301. /**
  24302. * In case the RTT has been created with a depth texture, get the associated
  24303. * depth texture.
  24304. * Otherwise, return null.
  24305. */
  24306. get depthStencilTexture(): Nullable<InternalTexture>;
  24307. /**
  24308. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24309. * or used a shadow, depth texture...
  24310. * @param name The friendly name of the texture
  24311. * @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)
  24312. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24313. * @param generateMipMaps True if mip maps need to be generated after render.
  24314. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24315. * @param type The type of the buffer in the RTT (int, half float, float...)
  24316. * @param isCube True if a cube texture needs to be created
  24317. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24318. * @param generateDepthBuffer True to generate a depth buffer
  24319. * @param generateStencilBuffer True to generate a stencil buffer
  24320. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24321. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24322. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24323. */
  24324. constructor(name: string, size: number | {
  24325. width: number;
  24326. height: number;
  24327. layers?: number;
  24328. } | {
  24329. ratio: number;
  24330. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24331. /**
  24332. * Creates a depth stencil texture.
  24333. * This is only available in WebGL 2 or with the depth texture extension available.
  24334. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24335. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24336. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24337. */
  24338. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24339. private _processSizeParameter;
  24340. /**
  24341. * Define the number of samples to use in case of MSAA.
  24342. * It defaults to one meaning no MSAA has been enabled.
  24343. */
  24344. get samples(): number;
  24345. set samples(value: number);
  24346. /**
  24347. * Resets the refresh counter of the texture and start bak from scratch.
  24348. * Could be useful to regenerate the texture if it is setup to render only once.
  24349. */
  24350. resetRefreshCounter(): void;
  24351. /**
  24352. * Define the refresh rate of the texture or the rendering frequency.
  24353. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24354. */
  24355. get refreshRate(): number;
  24356. set refreshRate(value: number);
  24357. /**
  24358. * Adds a post process to the render target rendering passes.
  24359. * @param postProcess define the post process to add
  24360. */
  24361. addPostProcess(postProcess: PostProcess): void;
  24362. /**
  24363. * Clear all the post processes attached to the render target
  24364. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24365. */
  24366. clearPostProcesses(dispose?: boolean): void;
  24367. /**
  24368. * Remove one of the post process from the list of attached post processes to the texture
  24369. * @param postProcess define the post process to remove from the list
  24370. */
  24371. removePostProcess(postProcess: PostProcess): void;
  24372. /** @hidden */
  24373. _shouldRender(): boolean;
  24374. /**
  24375. * Gets the actual render size of the texture.
  24376. * @returns the width of the render size
  24377. */
  24378. getRenderSize(): number;
  24379. /**
  24380. * Gets the actual render width of the texture.
  24381. * @returns the width of the render size
  24382. */
  24383. getRenderWidth(): number;
  24384. /**
  24385. * Gets the actual render height of the texture.
  24386. * @returns the height of the render size
  24387. */
  24388. getRenderHeight(): number;
  24389. /**
  24390. * Gets the actual number of layers of the texture.
  24391. * @returns the number of layers
  24392. */
  24393. getRenderLayers(): number;
  24394. /**
  24395. * Get if the texture can be rescaled or not.
  24396. */
  24397. get canRescale(): boolean;
  24398. /**
  24399. * Resize the texture using a ratio.
  24400. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24401. */
  24402. scale(ratio: number): void;
  24403. /**
  24404. * Get the texture reflection matrix used to rotate/transform the reflection.
  24405. * @returns the reflection matrix
  24406. */
  24407. getReflectionTextureMatrix(): Matrix;
  24408. /**
  24409. * Resize the texture to a new desired size.
  24410. * Be carrefull as it will recreate all the data in the new texture.
  24411. * @param size Define the new size. It can be:
  24412. * - a number for squared texture,
  24413. * - an object containing { width: number, height: number }
  24414. * - or an object containing a ratio { ratio: number }
  24415. */
  24416. resize(size: number | {
  24417. width: number;
  24418. height: number;
  24419. } | {
  24420. ratio: number;
  24421. }): void;
  24422. private _defaultRenderListPrepared;
  24423. /**
  24424. * Renders all the objects from the render list into the texture.
  24425. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24426. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24427. */
  24428. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24429. private _bestReflectionRenderTargetDimension;
  24430. private _prepareRenderingManager;
  24431. /**
  24432. * @hidden
  24433. * @param faceIndex face index to bind to if this is a cubetexture
  24434. * @param layer defines the index of the texture to bind in the array
  24435. */
  24436. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24437. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24438. private renderToTarget;
  24439. /**
  24440. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24441. * This allowed control for front to back rendering or reversly depending of the special needs.
  24442. *
  24443. * @param renderingGroupId The rendering group id corresponding to its index
  24444. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24445. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24446. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24447. */
  24448. 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;
  24449. /**
  24450. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24451. *
  24452. * @param renderingGroupId The rendering group id corresponding to its index
  24453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24454. */
  24455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24456. /**
  24457. * Clones the texture.
  24458. * @returns the cloned texture
  24459. */
  24460. clone(): RenderTargetTexture;
  24461. /**
  24462. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24463. * @returns The JSON representation of the texture
  24464. */
  24465. serialize(): any;
  24466. /**
  24467. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24468. */
  24469. disposeFramebufferObjects(): void;
  24470. /**
  24471. * Dispose the texture and release its associated resources.
  24472. */
  24473. dispose(): void;
  24474. /** @hidden */
  24475. _rebuild(): void;
  24476. /**
  24477. * Clear the info related to rendering groups preventing retention point in material dispose.
  24478. */
  24479. freeRenderingGroups(): void;
  24480. /**
  24481. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24482. * @returns the view count
  24483. */
  24484. getViewCount(): number;
  24485. }
  24486. }
  24487. declare module "babylonjs/Misc/guid" {
  24488. /**
  24489. * Class used to manipulate GUIDs
  24490. */
  24491. export class GUID {
  24492. /**
  24493. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24494. * Be aware Math.random() could cause collisions, but:
  24495. * "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"
  24496. * @returns a pseudo random id
  24497. */
  24498. static RandomId(): string;
  24499. }
  24500. }
  24501. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24502. import { Nullable } from "babylonjs/types";
  24503. import { Scene } from "babylonjs/scene";
  24504. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24505. import { Material } from "babylonjs/Materials/material";
  24506. import { Effect } from "babylonjs/Materials/effect";
  24507. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24508. /**
  24509. * Options to be used when creating a shadow depth material
  24510. */
  24511. export interface IIOptionShadowDepthMaterial {
  24512. /** Variables in the vertex shader code that need to have their names remapped.
  24513. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24514. * "var_name" should be either: worldPos or vNormalW
  24515. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24516. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24517. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24518. */
  24519. remappedVariables?: string[];
  24520. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24521. standalone?: boolean;
  24522. }
  24523. /**
  24524. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24525. */
  24526. export class ShadowDepthWrapper {
  24527. private _scene;
  24528. private _options?;
  24529. private _baseMaterial;
  24530. private _onEffectCreatedObserver;
  24531. private _subMeshToEffect;
  24532. private _subMeshToDepthEffect;
  24533. private _meshes;
  24534. /** @hidden */
  24535. _matriceNames: any;
  24536. /** Gets the standalone status of the wrapper */
  24537. get standalone(): boolean;
  24538. /** Gets the base material the wrapper is built upon */
  24539. get baseMaterial(): Material;
  24540. /**
  24541. * Instantiate a new shadow depth wrapper.
  24542. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24543. * generate the shadow depth map. For more information, please refer to the documentation:
  24544. * https://doc.babylonjs.com/babylon101/shadows
  24545. * @param baseMaterial Material to wrap
  24546. * @param scene Define the scene the material belongs to
  24547. * @param options Options used to create the wrapper
  24548. */
  24549. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24550. /**
  24551. * Gets the effect to use to generate the depth map
  24552. * @param subMesh subMesh to get the effect for
  24553. * @param shadowGenerator shadow generator to get the effect for
  24554. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24555. */
  24556. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24557. /**
  24558. * Specifies that the submesh is ready to be used for depth rendering
  24559. * @param subMesh submesh to check
  24560. * @param defines the list of defines to take into account when checking the effect
  24561. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24562. * @param useInstances specifies that instances should be used
  24563. * @returns a boolean indicating that the submesh is ready or not
  24564. */
  24565. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24566. /**
  24567. * Disposes the resources
  24568. */
  24569. dispose(): void;
  24570. private _makeEffect;
  24571. }
  24572. }
  24573. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24574. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24575. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24576. import { Nullable } from "babylonjs/types";
  24577. module "babylonjs/Engines/thinEngine" {
  24578. interface ThinEngine {
  24579. /**
  24580. * Unbind a list of render target textures from the webGL context
  24581. * This is used only when drawBuffer extension or webGL2 are active
  24582. * @param textures defines the render target textures to unbind
  24583. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24584. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24585. */
  24586. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24587. /**
  24588. * Create a multi render target texture
  24589. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24590. * @param size defines the size of the texture
  24591. * @param options defines the creation options
  24592. * @returns the cube texture as an InternalTexture
  24593. */
  24594. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24595. /**
  24596. * Update the sample count for a given multiple render target texture
  24597. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24598. * @param textures defines the textures to update
  24599. * @param samples defines the sample count to set
  24600. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24601. */
  24602. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24603. /**
  24604. * Select a subsets of attachments to draw to.
  24605. * @param attachments gl attachments
  24606. */
  24607. bindAttachments(attachments: number[]): void;
  24608. }
  24609. }
  24610. }
  24611. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24612. import { Scene } from "babylonjs/scene";
  24613. import { Engine } from "babylonjs/Engines/engine";
  24614. import { Texture } from "babylonjs/Materials/Textures/texture";
  24615. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24616. import "babylonjs/Engines/Extensions/engine.multiRender";
  24617. /**
  24618. * Creation options of the multi render target texture.
  24619. */
  24620. export interface IMultiRenderTargetOptions {
  24621. /**
  24622. * Define if the texture needs to create mip maps after render.
  24623. */
  24624. generateMipMaps?: boolean;
  24625. /**
  24626. * Define the types of all the draw buffers we want to create
  24627. */
  24628. types?: number[];
  24629. /**
  24630. * Define the sampling modes of all the draw buffers we want to create
  24631. */
  24632. samplingModes?: number[];
  24633. /**
  24634. * Define if a depth buffer is required
  24635. */
  24636. generateDepthBuffer?: boolean;
  24637. /**
  24638. * Define if a stencil buffer is required
  24639. */
  24640. generateStencilBuffer?: boolean;
  24641. /**
  24642. * Define if a depth texture is required instead of a depth buffer
  24643. */
  24644. generateDepthTexture?: boolean;
  24645. /**
  24646. * Define the number of desired draw buffers
  24647. */
  24648. textureCount?: number;
  24649. /**
  24650. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24651. */
  24652. doNotChangeAspectRatio?: boolean;
  24653. /**
  24654. * Define the default type of the buffers we are creating
  24655. */
  24656. defaultType?: number;
  24657. }
  24658. /**
  24659. * A multi render target, like a render target provides the ability to render to a texture.
  24660. * Unlike the render target, it can render to several draw buffers in one draw.
  24661. * This is specially interesting in deferred rendering or for any effects requiring more than
  24662. * just one color from a single pass.
  24663. */
  24664. export class MultiRenderTarget extends RenderTargetTexture {
  24665. private _internalTextures;
  24666. private _textures;
  24667. private _multiRenderTargetOptions;
  24668. private _count;
  24669. /**
  24670. * Get if draw buffers are currently supported by the used hardware and browser.
  24671. */
  24672. get isSupported(): boolean;
  24673. /**
  24674. * Get the list of textures generated by the multi render target.
  24675. */
  24676. get textures(): Texture[];
  24677. /**
  24678. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24679. */
  24680. get count(): number;
  24681. /**
  24682. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24683. */
  24684. get depthTexture(): Texture;
  24685. /**
  24686. * Set the wrapping mode on U of all the textures we are rendering to.
  24687. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24688. */
  24689. set wrapU(wrap: number);
  24690. /**
  24691. * Set the wrapping mode on V of all the textures we are rendering to.
  24692. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24693. */
  24694. set wrapV(wrap: number);
  24695. /**
  24696. * Instantiate a new multi render target texture.
  24697. * A multi render target, like a render target provides the ability to render to a texture.
  24698. * Unlike the render target, it can render to several draw buffers in one draw.
  24699. * This is specially interesting in deferred rendering or for any effects requiring more than
  24700. * just one color from a single pass.
  24701. * @param name Define the name of the texture
  24702. * @param size Define the size of the buffers to render to
  24703. * @param count Define the number of target we are rendering into
  24704. * @param scene Define the scene the texture belongs to
  24705. * @param options Define the options used to create the multi render target
  24706. */
  24707. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24708. /** @hidden */
  24709. _rebuild(): void;
  24710. private _createInternalTextures;
  24711. private _createTextures;
  24712. /**
  24713. * Define the number of samples used if MSAA is enabled.
  24714. */
  24715. get samples(): number;
  24716. set samples(value: number);
  24717. /**
  24718. * Resize all the textures in the multi render target.
  24719. * Be carrefull as it will recreate all the data in the new texture.
  24720. * @param size Define the new size
  24721. */
  24722. resize(size: any): void;
  24723. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24724. /**
  24725. * Dispose the render targets and their associated resources
  24726. */
  24727. dispose(): void;
  24728. /**
  24729. * Release all the underlying texture used as draw buffers.
  24730. */
  24731. releaseInternalTextures(): void;
  24732. }
  24733. }
  24734. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24735. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24737. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24738. /** @hidden */
  24739. export var imageProcessingPixelShader: {
  24740. name: string;
  24741. shader: string;
  24742. };
  24743. }
  24744. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24745. import { Nullable } from "babylonjs/types";
  24746. import { Color4 } from "babylonjs/Maths/math.color";
  24747. import { Camera } from "babylonjs/Cameras/camera";
  24748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24749. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24750. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24752. import { Engine } from "babylonjs/Engines/engine";
  24753. import "babylonjs/Shaders/imageProcessing.fragment";
  24754. import "babylonjs/Shaders/postprocess.vertex";
  24755. /**
  24756. * ImageProcessingPostProcess
  24757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24758. */
  24759. export class ImageProcessingPostProcess extends PostProcess {
  24760. /**
  24761. * Default configuration related to image processing available in the PBR Material.
  24762. */
  24763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24764. /**
  24765. * Gets the image processing configuration used either in this material.
  24766. */
  24767. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24768. /**
  24769. * Sets the Default image processing configuration used either in the this material.
  24770. *
  24771. * If sets to null, the scene one is in use.
  24772. */
  24773. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24774. /**
  24775. * Keep track of the image processing observer to allow dispose and replace.
  24776. */
  24777. private _imageProcessingObserver;
  24778. /**
  24779. * Attaches a new image processing configuration to the PBR Material.
  24780. * @param configuration
  24781. */
  24782. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24783. /**
  24784. * If the post process is supported.
  24785. */
  24786. get isSupported(): boolean;
  24787. /**
  24788. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24789. */
  24790. get colorCurves(): Nullable<ColorCurves>;
  24791. /**
  24792. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24793. */
  24794. set colorCurves(value: Nullable<ColorCurves>);
  24795. /**
  24796. * Gets wether the color curves effect is enabled.
  24797. */
  24798. get colorCurvesEnabled(): boolean;
  24799. /**
  24800. * Sets wether the color curves effect is enabled.
  24801. */
  24802. set colorCurvesEnabled(value: boolean);
  24803. /**
  24804. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24805. */
  24806. get colorGradingTexture(): Nullable<BaseTexture>;
  24807. /**
  24808. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24809. */
  24810. set colorGradingTexture(value: Nullable<BaseTexture>);
  24811. /**
  24812. * Gets wether the color grading effect is enabled.
  24813. */
  24814. get colorGradingEnabled(): boolean;
  24815. /**
  24816. * Gets wether the color grading effect is enabled.
  24817. */
  24818. set colorGradingEnabled(value: boolean);
  24819. /**
  24820. * Gets exposure used in the effect.
  24821. */
  24822. get exposure(): number;
  24823. /**
  24824. * Sets exposure used in the effect.
  24825. */
  24826. set exposure(value: number);
  24827. /**
  24828. * Gets wether tonemapping is enabled or not.
  24829. */
  24830. get toneMappingEnabled(): boolean;
  24831. /**
  24832. * Sets wether tonemapping is enabled or not
  24833. */
  24834. set toneMappingEnabled(value: boolean);
  24835. /**
  24836. * Gets the type of tone mapping effect.
  24837. */
  24838. get toneMappingType(): number;
  24839. /**
  24840. * Sets the type of tone mapping effect.
  24841. */
  24842. set toneMappingType(value: number);
  24843. /**
  24844. * Gets contrast used in the effect.
  24845. */
  24846. get contrast(): number;
  24847. /**
  24848. * Sets contrast used in the effect.
  24849. */
  24850. set contrast(value: number);
  24851. /**
  24852. * Gets Vignette stretch size.
  24853. */
  24854. get vignetteStretch(): number;
  24855. /**
  24856. * Sets Vignette stretch size.
  24857. */
  24858. set vignetteStretch(value: number);
  24859. /**
  24860. * Gets Vignette centre X Offset.
  24861. */
  24862. get vignetteCentreX(): number;
  24863. /**
  24864. * Sets Vignette centre X Offset.
  24865. */
  24866. set vignetteCentreX(value: number);
  24867. /**
  24868. * Gets Vignette centre Y Offset.
  24869. */
  24870. get vignetteCentreY(): number;
  24871. /**
  24872. * Sets Vignette centre Y Offset.
  24873. */
  24874. set vignetteCentreY(value: number);
  24875. /**
  24876. * Gets Vignette weight or intensity of the vignette effect.
  24877. */
  24878. get vignetteWeight(): number;
  24879. /**
  24880. * Sets Vignette weight or intensity of the vignette effect.
  24881. */
  24882. set vignetteWeight(value: number);
  24883. /**
  24884. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24885. * if vignetteEnabled is set to true.
  24886. */
  24887. get vignetteColor(): Color4;
  24888. /**
  24889. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24890. * if vignetteEnabled is set to true.
  24891. */
  24892. set vignetteColor(value: Color4);
  24893. /**
  24894. * Gets Camera field of view used by the Vignette effect.
  24895. */
  24896. get vignetteCameraFov(): number;
  24897. /**
  24898. * Sets Camera field of view used by the Vignette effect.
  24899. */
  24900. set vignetteCameraFov(value: number);
  24901. /**
  24902. * Gets the vignette blend mode allowing different kind of effect.
  24903. */
  24904. get vignetteBlendMode(): number;
  24905. /**
  24906. * Sets the vignette blend mode allowing different kind of effect.
  24907. */
  24908. set vignetteBlendMode(value: number);
  24909. /**
  24910. * Gets wether the vignette effect is enabled.
  24911. */
  24912. get vignetteEnabled(): boolean;
  24913. /**
  24914. * Sets wether the vignette effect is enabled.
  24915. */
  24916. set vignetteEnabled(value: boolean);
  24917. private _fromLinearSpace;
  24918. /**
  24919. * Gets wether the input of the processing is in Gamma or Linear Space.
  24920. */
  24921. get fromLinearSpace(): boolean;
  24922. /**
  24923. * Sets wether the input of the processing is in Gamma or Linear Space.
  24924. */
  24925. set fromLinearSpace(value: boolean);
  24926. /**
  24927. * Defines cache preventing GC.
  24928. */
  24929. private _defines;
  24930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24931. /**
  24932. * "ImageProcessingPostProcess"
  24933. * @returns "ImageProcessingPostProcess"
  24934. */
  24935. getClassName(): string;
  24936. /**
  24937. * @hidden
  24938. */
  24939. _updateParameters(): void;
  24940. dispose(camera?: Camera): void;
  24941. }
  24942. }
  24943. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  24944. /** @hidden */
  24945. export var fibonacci: {
  24946. name: string;
  24947. shader: string;
  24948. };
  24949. }
  24950. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  24951. /** @hidden */
  24952. export var subSurfaceScatteringFunctions: {
  24953. name: string;
  24954. shader: string;
  24955. };
  24956. }
  24957. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  24958. /** @hidden */
  24959. export var diffusionProfile: {
  24960. name: string;
  24961. shader: string;
  24962. };
  24963. }
  24964. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  24965. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  24966. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24967. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  24968. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  24969. /** @hidden */
  24970. export var subSurfaceScatteringPixelShader: {
  24971. name: string;
  24972. shader: string;
  24973. };
  24974. }
  24975. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  24976. import { Nullable } from "babylonjs/types";
  24977. import { Camera } from "babylonjs/Cameras/camera";
  24978. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24979. import { Engine } from "babylonjs/Engines/engine";
  24980. import { Scene } from "babylonjs/scene";
  24981. import "babylonjs/Shaders/imageProcessing.fragment";
  24982. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  24983. import "babylonjs/Shaders/postprocess.vertex";
  24984. /**
  24985. * Sub surface scattering post process
  24986. */
  24987. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24988. /** @hidden */
  24989. texelWidth: number;
  24990. /** @hidden */
  24991. texelHeight: number;
  24992. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24993. }
  24994. }
  24995. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24997. /**
  24998. * Interface for defining prepass effects in the prepass post-process pipeline
  24999. */
  25000. export interface PrePassEffectConfiguration {
  25001. /**
  25002. * Post process to attach for this effect
  25003. */
  25004. postProcess: PostProcess;
  25005. /**
  25006. * Is the effect enabled
  25007. */
  25008. enabled: boolean;
  25009. /**
  25010. * Disposes the effect configuration
  25011. */
  25012. dispose(): void;
  25013. /**
  25014. * Disposes the effect configuration
  25015. */
  25016. createPostProcess: () => PostProcess;
  25017. }
  25018. }
  25019. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25020. import { Scene } from "babylonjs/scene";
  25021. import { Color3 } from "babylonjs/Maths/math.color";
  25022. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25023. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25024. /**
  25025. * Contains all parameters needed for the prepass to perform
  25026. * screen space subsurface scattering
  25027. */
  25028. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25029. private _ssDiffusionS;
  25030. private _ssFilterRadii;
  25031. private _ssDiffusionD;
  25032. /**
  25033. * Post process to attach for screen space subsurface scattering
  25034. */
  25035. postProcess: SubSurfaceScatteringPostProcess;
  25036. /**
  25037. * Diffusion profile color for subsurface scattering
  25038. */
  25039. get ssDiffusionS(): number[];
  25040. /**
  25041. * Diffusion profile max color channel value for subsurface scattering
  25042. */
  25043. get ssDiffusionD(): number[];
  25044. /**
  25045. * Diffusion profile filter radius for subsurface scattering
  25046. */
  25047. get ssFilterRadii(): number[];
  25048. /**
  25049. * Is subsurface enabled
  25050. */
  25051. enabled: boolean;
  25052. /**
  25053. * Diffusion profile colors for subsurface scattering
  25054. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25055. * See ...
  25056. * Note that you can only store up to 5 of them
  25057. */
  25058. ssDiffusionProfileColors: Color3[];
  25059. /**
  25060. * Defines the ratio real world => scene units.
  25061. * Used for subsurface scattering
  25062. */
  25063. metersPerUnit: number;
  25064. private _scene;
  25065. /**
  25066. * Builds a subsurface configuration object
  25067. * @param scene The scene
  25068. */
  25069. constructor(scene: Scene);
  25070. /**
  25071. * Adds a new diffusion profile.
  25072. * Useful for more realistic subsurface scattering on diverse materials.
  25073. * @param color The color of the diffusion profile. Should be the average color of the material.
  25074. * @return The index of the diffusion profile for the material subsurface configuration
  25075. */
  25076. addDiffusionProfile(color: Color3): number;
  25077. /**
  25078. * Creates the sss post process
  25079. * @return The created post process
  25080. */
  25081. createPostProcess(): SubSurfaceScatteringPostProcess;
  25082. /**
  25083. * Deletes all diffusion profiles.
  25084. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25085. */
  25086. clearAllDiffusionProfiles(): void;
  25087. /**
  25088. * Disposes this object
  25089. */
  25090. dispose(): void;
  25091. /**
  25092. * @hidden
  25093. * https://zero-radiance.github.io/post/sampling-diffusion/
  25094. *
  25095. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25096. * ------------------------------------------------------------------------------------
  25097. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25098. * PDF[r, phi, s] = r * R[r, phi, s]
  25099. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25100. * ------------------------------------------------------------------------------------
  25101. * We importance sample the color channel with the widest scattering distance.
  25102. */
  25103. getDiffusionProfileParameters(color: Color3): number;
  25104. /**
  25105. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25106. * 'u' is the random number (the value of the CDF): [0, 1).
  25107. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25108. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25109. */
  25110. private _sampleBurleyDiffusionProfile;
  25111. }
  25112. }
  25113. declare module "babylonjs/Rendering/prePassRenderer" {
  25114. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25115. import { Scene } from "babylonjs/scene";
  25116. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25117. import { Effect } from "babylonjs/Materials/effect";
  25118. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25119. /**
  25120. * Renders a pre pass of the scene
  25121. * This means every mesh in the scene will be rendered to a render target texture
  25122. * And then this texture will be composited to the rendering canvas with post processes
  25123. * It is necessary for effects like subsurface scattering or deferred shading
  25124. */
  25125. export class PrePassRenderer {
  25126. /** @hidden */
  25127. static _SceneComponentInitialization: (scene: Scene) => void;
  25128. private _scene;
  25129. private _engine;
  25130. private _isDirty;
  25131. /**
  25132. * Number of textures in the multi render target texture where the scene is directly rendered
  25133. */
  25134. readonly mrtCount: number;
  25135. /**
  25136. * The render target where the scene is directly rendered
  25137. */
  25138. prePassRT: MultiRenderTarget;
  25139. private _mrtTypes;
  25140. private _multiRenderAttachments;
  25141. private _defaultAttachments;
  25142. private _clearAttachments;
  25143. private _postProcesses;
  25144. private readonly _clearColor;
  25145. /**
  25146. * Image processing post process for composition
  25147. */
  25148. imageProcessingPostProcess: ImageProcessingPostProcess;
  25149. /**
  25150. * Configuration for sub surface scattering post process
  25151. */
  25152. subSurfaceConfiguration: SubSurfaceConfiguration;
  25153. /**
  25154. * Should materials render their geometry on the MRT
  25155. */
  25156. materialsShouldRenderGeometry: boolean;
  25157. /**
  25158. * Should materials render the irradiance information on the MRT
  25159. */
  25160. materialsShouldRenderIrradiance: boolean;
  25161. private _enabled;
  25162. /**
  25163. * Indicates if the prepass is enabled
  25164. */
  25165. get enabled(): boolean;
  25166. /**
  25167. * How many samples are used for MSAA of the scene render target
  25168. */
  25169. get samples(): number;
  25170. set samples(n: number);
  25171. /**
  25172. * Instanciates a prepass renderer
  25173. * @param scene The scene
  25174. */
  25175. constructor(scene: Scene);
  25176. private _initializeAttachments;
  25177. private _createCompositionEffect;
  25178. /**
  25179. * Indicates if rendering a prepass is supported
  25180. */
  25181. get isSupported(): boolean;
  25182. /**
  25183. * Sets the proper output textures to draw in the engine.
  25184. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25185. */
  25186. bindAttachmentsForEffect(effect: Effect): void;
  25187. /**
  25188. * @hidden
  25189. */
  25190. _beforeCameraDraw(): void;
  25191. /**
  25192. * @hidden
  25193. */
  25194. _afterCameraDraw(): void;
  25195. private _checkRTSize;
  25196. private _bindFrameBuffer;
  25197. /**
  25198. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25199. */
  25200. clear(): void;
  25201. private _setState;
  25202. private _enable;
  25203. private _disable;
  25204. private _resetPostProcessChain;
  25205. private _bindPostProcessChain;
  25206. /**
  25207. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25208. */
  25209. markAsDirty(): void;
  25210. private _update;
  25211. /**
  25212. * Disposes the prepass renderer.
  25213. */
  25214. dispose(): void;
  25215. }
  25216. }
  25217. declare module "babylonjs/Materials/material" {
  25218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25219. import { SmartArray } from "babylonjs/Misc/smartArray";
  25220. import { Observable } from "babylonjs/Misc/observable";
  25221. import { Nullable } from "babylonjs/types";
  25222. import { Scene } from "babylonjs/scene";
  25223. import { Matrix } from "babylonjs/Maths/math.vector";
  25224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25226. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25227. import { Effect } from "babylonjs/Materials/effect";
  25228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25229. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25230. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25231. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25232. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25233. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25234. import { Mesh } from "babylonjs/Meshes/mesh";
  25235. import { Animation } from "babylonjs/Animations/animation";
  25236. /**
  25237. * Options for compiling materials.
  25238. */
  25239. export interface IMaterialCompilationOptions {
  25240. /**
  25241. * Defines whether clip planes are enabled.
  25242. */
  25243. clipPlane: boolean;
  25244. /**
  25245. * Defines whether instances are enabled.
  25246. */
  25247. useInstances: boolean;
  25248. }
  25249. /**
  25250. * Options passed when calling customShaderNameResolve
  25251. */
  25252. export interface ICustomShaderNameResolveOptions {
  25253. /**
  25254. * 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
  25255. */
  25256. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25257. }
  25258. /**
  25259. * Base class for the main features of a material in Babylon.js
  25260. */
  25261. export class Material implements IAnimatable {
  25262. /**
  25263. * Returns the triangle fill mode
  25264. */
  25265. static readonly TriangleFillMode: number;
  25266. /**
  25267. * Returns the wireframe mode
  25268. */
  25269. static readonly WireFrameFillMode: number;
  25270. /**
  25271. * Returns the point fill mode
  25272. */
  25273. static readonly PointFillMode: number;
  25274. /**
  25275. * Returns the point list draw mode
  25276. */
  25277. static readonly PointListDrawMode: number;
  25278. /**
  25279. * Returns the line list draw mode
  25280. */
  25281. static readonly LineListDrawMode: number;
  25282. /**
  25283. * Returns the line loop draw mode
  25284. */
  25285. static readonly LineLoopDrawMode: number;
  25286. /**
  25287. * Returns the line strip draw mode
  25288. */
  25289. static readonly LineStripDrawMode: number;
  25290. /**
  25291. * Returns the triangle strip draw mode
  25292. */
  25293. static readonly TriangleStripDrawMode: number;
  25294. /**
  25295. * Returns the triangle fan draw mode
  25296. */
  25297. static readonly TriangleFanDrawMode: number;
  25298. /**
  25299. * Stores the clock-wise side orientation
  25300. */
  25301. static readonly ClockWiseSideOrientation: number;
  25302. /**
  25303. * Stores the counter clock-wise side orientation
  25304. */
  25305. static readonly CounterClockWiseSideOrientation: number;
  25306. /**
  25307. * The dirty texture flag value
  25308. */
  25309. static readonly TextureDirtyFlag: number;
  25310. /**
  25311. * The dirty light flag value
  25312. */
  25313. static readonly LightDirtyFlag: number;
  25314. /**
  25315. * The dirty fresnel flag value
  25316. */
  25317. static readonly FresnelDirtyFlag: number;
  25318. /**
  25319. * The dirty attribute flag value
  25320. */
  25321. static readonly AttributesDirtyFlag: number;
  25322. /**
  25323. * The dirty misc flag value
  25324. */
  25325. static readonly MiscDirtyFlag: number;
  25326. /**
  25327. * The all dirty flag value
  25328. */
  25329. static readonly AllDirtyFlag: number;
  25330. /**
  25331. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25332. */
  25333. static readonly MATERIAL_OPAQUE: number;
  25334. /**
  25335. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25336. */
  25337. static readonly MATERIAL_ALPHATEST: number;
  25338. /**
  25339. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25340. */
  25341. static readonly MATERIAL_ALPHABLEND: number;
  25342. /**
  25343. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25344. * They are also discarded below the alpha cutoff threshold to improve performances.
  25345. */
  25346. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25347. /**
  25348. * The Whiteout method is used to blend normals.
  25349. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25350. */
  25351. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25352. /**
  25353. * The Reoriented Normal Mapping method is used to blend normals.
  25354. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25355. */
  25356. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25357. /**
  25358. * Custom callback helping to override the default shader used in the material.
  25359. */
  25360. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25361. /**
  25362. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25363. */
  25364. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25365. /**
  25366. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25367. * This means that the material can keep using a previous shader while a new one is being compiled.
  25368. * This is mostly used when shader parallel compilation is supported (true by default)
  25369. */
  25370. allowShaderHotSwapping: boolean;
  25371. /**
  25372. * The ID of the material
  25373. */
  25374. id: string;
  25375. /**
  25376. * Gets or sets the unique id of the material
  25377. */
  25378. uniqueId: number;
  25379. /**
  25380. * The name of the material
  25381. */
  25382. name: string;
  25383. /**
  25384. * Gets or sets user defined metadata
  25385. */
  25386. metadata: any;
  25387. /**
  25388. * For internal use only. Please do not use.
  25389. */
  25390. reservedDataStore: any;
  25391. /**
  25392. * Specifies if the ready state should be checked on each call
  25393. */
  25394. checkReadyOnEveryCall: boolean;
  25395. /**
  25396. * Specifies if the ready state should be checked once
  25397. */
  25398. checkReadyOnlyOnce: boolean;
  25399. /**
  25400. * The state of the material
  25401. */
  25402. state: string;
  25403. /**
  25404. * If the material can be rendered to several textures with MRT extension
  25405. */
  25406. get canRenderToMRT(): boolean;
  25407. /**
  25408. * The alpha value of the material
  25409. */
  25410. protected _alpha: number;
  25411. /**
  25412. * List of inspectable custom properties (used by the Inspector)
  25413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25414. */
  25415. inspectableCustomProperties: IInspectable[];
  25416. /**
  25417. * Sets the alpha value of the material
  25418. */
  25419. set alpha(value: number);
  25420. /**
  25421. * Gets the alpha value of the material
  25422. */
  25423. get alpha(): number;
  25424. /**
  25425. * Specifies if back face culling is enabled
  25426. */
  25427. protected _backFaceCulling: boolean;
  25428. /**
  25429. * Sets the back-face culling state
  25430. */
  25431. set backFaceCulling(value: boolean);
  25432. /**
  25433. * Gets the back-face culling state
  25434. */
  25435. get backFaceCulling(): boolean;
  25436. /**
  25437. * Stores the value for side orientation
  25438. */
  25439. sideOrientation: number;
  25440. /**
  25441. * Callback triggered when the material is compiled
  25442. */
  25443. onCompiled: Nullable<(effect: Effect) => void>;
  25444. /**
  25445. * Callback triggered when an error occurs
  25446. */
  25447. onError: Nullable<(effect: Effect, errors: string) => void>;
  25448. /**
  25449. * Callback triggered to get the render target textures
  25450. */
  25451. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25452. /**
  25453. * Gets a boolean indicating that current material needs to register RTT
  25454. */
  25455. get hasRenderTargetTextures(): boolean;
  25456. /**
  25457. * Specifies if the material should be serialized
  25458. */
  25459. doNotSerialize: boolean;
  25460. /**
  25461. * @hidden
  25462. */
  25463. _storeEffectOnSubMeshes: boolean;
  25464. /**
  25465. * Stores the animations for the material
  25466. */
  25467. animations: Nullable<Array<Animation>>;
  25468. /**
  25469. * An event triggered when the material is disposed
  25470. */
  25471. onDisposeObservable: Observable<Material>;
  25472. /**
  25473. * An observer which watches for dispose events
  25474. */
  25475. private _onDisposeObserver;
  25476. private _onUnBindObservable;
  25477. /**
  25478. * Called during a dispose event
  25479. */
  25480. set onDispose(callback: () => void);
  25481. private _onBindObservable;
  25482. /**
  25483. * An event triggered when the material is bound
  25484. */
  25485. get onBindObservable(): Observable<AbstractMesh>;
  25486. /**
  25487. * An observer which watches for bind events
  25488. */
  25489. private _onBindObserver;
  25490. /**
  25491. * Called during a bind event
  25492. */
  25493. set onBind(callback: (Mesh: AbstractMesh) => void);
  25494. /**
  25495. * An event triggered when the material is unbound
  25496. */
  25497. get onUnBindObservable(): Observable<Material>;
  25498. protected _onEffectCreatedObservable: Nullable<Observable<{
  25499. effect: Effect;
  25500. subMesh: Nullable<SubMesh>;
  25501. }>>;
  25502. /**
  25503. * An event triggered when the effect is (re)created
  25504. */
  25505. get onEffectCreatedObservable(): Observable<{
  25506. effect: Effect;
  25507. subMesh: Nullable<SubMesh>;
  25508. }>;
  25509. /**
  25510. * Stores the value of the alpha mode
  25511. */
  25512. private _alphaMode;
  25513. /**
  25514. * Sets the value of the alpha mode.
  25515. *
  25516. * | Value | Type | Description |
  25517. * | --- | --- | --- |
  25518. * | 0 | ALPHA_DISABLE | |
  25519. * | 1 | ALPHA_ADD | |
  25520. * | 2 | ALPHA_COMBINE | |
  25521. * | 3 | ALPHA_SUBTRACT | |
  25522. * | 4 | ALPHA_MULTIPLY | |
  25523. * | 5 | ALPHA_MAXIMIZED | |
  25524. * | 6 | ALPHA_ONEONE | |
  25525. * | 7 | ALPHA_PREMULTIPLIED | |
  25526. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25527. * | 9 | ALPHA_INTERPOLATE | |
  25528. * | 10 | ALPHA_SCREENMODE | |
  25529. *
  25530. */
  25531. set alphaMode(value: number);
  25532. /**
  25533. * Gets the value of the alpha mode
  25534. */
  25535. get alphaMode(): number;
  25536. /**
  25537. * Stores the state of the need depth pre-pass value
  25538. */
  25539. private _needDepthPrePass;
  25540. /**
  25541. * Sets the need depth pre-pass value
  25542. */
  25543. set needDepthPrePass(value: boolean);
  25544. /**
  25545. * Gets the depth pre-pass value
  25546. */
  25547. get needDepthPrePass(): boolean;
  25548. /**
  25549. * Specifies if depth writing should be disabled
  25550. */
  25551. disableDepthWrite: boolean;
  25552. /**
  25553. * Specifies if color writing should be disabled
  25554. */
  25555. disableColorWrite: boolean;
  25556. /**
  25557. * Specifies if depth writing should be forced
  25558. */
  25559. forceDepthWrite: boolean;
  25560. /**
  25561. * Specifies the depth function that should be used. 0 means the default engine function
  25562. */
  25563. depthFunction: number;
  25564. /**
  25565. * Specifies if there should be a separate pass for culling
  25566. */
  25567. separateCullingPass: boolean;
  25568. /**
  25569. * Stores the state specifing if fog should be enabled
  25570. */
  25571. private _fogEnabled;
  25572. /**
  25573. * Sets the state for enabling fog
  25574. */
  25575. set fogEnabled(value: boolean);
  25576. /**
  25577. * Gets the value of the fog enabled state
  25578. */
  25579. get fogEnabled(): boolean;
  25580. /**
  25581. * Stores the size of points
  25582. */
  25583. pointSize: number;
  25584. /**
  25585. * Stores the z offset value
  25586. */
  25587. zOffset: number;
  25588. get wireframe(): boolean;
  25589. /**
  25590. * Sets the state of wireframe mode
  25591. */
  25592. set wireframe(value: boolean);
  25593. /**
  25594. * Gets the value specifying if point clouds are enabled
  25595. */
  25596. get pointsCloud(): boolean;
  25597. /**
  25598. * Sets the state of point cloud mode
  25599. */
  25600. set pointsCloud(value: boolean);
  25601. /**
  25602. * Gets the material fill mode
  25603. */
  25604. get fillMode(): number;
  25605. /**
  25606. * Sets the material fill mode
  25607. */
  25608. set fillMode(value: number);
  25609. /**
  25610. * @hidden
  25611. * Stores the effects for the material
  25612. */
  25613. _effect: Nullable<Effect>;
  25614. /**
  25615. * Specifies if uniform buffers should be used
  25616. */
  25617. private _useUBO;
  25618. /**
  25619. * Stores a reference to the scene
  25620. */
  25621. private _scene;
  25622. /**
  25623. * Stores the fill mode state
  25624. */
  25625. private _fillMode;
  25626. /**
  25627. * Specifies if the depth write state should be cached
  25628. */
  25629. private _cachedDepthWriteState;
  25630. /**
  25631. * Specifies if the color write state should be cached
  25632. */
  25633. private _cachedColorWriteState;
  25634. /**
  25635. * Specifies if the depth function state should be cached
  25636. */
  25637. private _cachedDepthFunctionState;
  25638. /**
  25639. * Stores the uniform buffer
  25640. */
  25641. protected _uniformBuffer: UniformBuffer;
  25642. /** @hidden */
  25643. _indexInSceneMaterialArray: number;
  25644. /** @hidden */
  25645. meshMap: Nullable<{
  25646. [id: string]: AbstractMesh | undefined;
  25647. }>;
  25648. /**
  25649. * Creates a material instance
  25650. * @param name defines the name of the material
  25651. * @param scene defines the scene to reference
  25652. * @param doNotAdd specifies if the material should be added to the scene
  25653. */
  25654. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25655. /**
  25656. * Returns a string representation of the current material
  25657. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25658. * @returns a string with material information
  25659. */
  25660. toString(fullDetails?: boolean): string;
  25661. /**
  25662. * Gets the class name of the material
  25663. * @returns a string with the class name of the material
  25664. */
  25665. getClassName(): string;
  25666. /**
  25667. * Specifies if updates for the material been locked
  25668. */
  25669. get isFrozen(): boolean;
  25670. /**
  25671. * Locks updates for the material
  25672. */
  25673. freeze(): void;
  25674. /**
  25675. * Unlocks updates for the material
  25676. */
  25677. unfreeze(): void;
  25678. /**
  25679. * Specifies if the material is ready to be used
  25680. * @param mesh defines the mesh to check
  25681. * @param useInstances specifies if instances should be used
  25682. * @returns a boolean indicating if the material is ready to be used
  25683. */
  25684. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25685. /**
  25686. * Specifies that the submesh is ready to be used
  25687. * @param mesh defines the mesh to check
  25688. * @param subMesh defines which submesh to check
  25689. * @param useInstances specifies that instances should be used
  25690. * @returns a boolean indicating that the submesh is ready or not
  25691. */
  25692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25693. /**
  25694. * Returns the material effect
  25695. * @returns the effect associated with the material
  25696. */
  25697. getEffect(): Nullable<Effect>;
  25698. /**
  25699. * Returns the current scene
  25700. * @returns a Scene
  25701. */
  25702. getScene(): Scene;
  25703. /**
  25704. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25705. */
  25706. protected _forceAlphaTest: boolean;
  25707. /**
  25708. * The transparency mode of the material.
  25709. */
  25710. protected _transparencyMode: Nullable<number>;
  25711. /**
  25712. * Gets the current transparency mode.
  25713. */
  25714. get transparencyMode(): Nullable<number>;
  25715. /**
  25716. * Sets the transparency mode of the material.
  25717. *
  25718. * | Value | Type | Description |
  25719. * | ----- | ----------------------------------- | ----------- |
  25720. * | 0 | OPAQUE | |
  25721. * | 1 | ALPHATEST | |
  25722. * | 2 | ALPHABLEND | |
  25723. * | 3 | ALPHATESTANDBLEND | |
  25724. *
  25725. */
  25726. set transparencyMode(value: Nullable<number>);
  25727. /**
  25728. * Returns true if alpha blending should be disabled.
  25729. */
  25730. protected get _disableAlphaBlending(): boolean;
  25731. /**
  25732. * Specifies whether or not this material should be rendered in alpha blend mode.
  25733. * @returns a boolean specifying if alpha blending is needed
  25734. */
  25735. needAlphaBlending(): boolean;
  25736. /**
  25737. * Specifies if the mesh will require alpha blending
  25738. * @param mesh defines the mesh to check
  25739. * @returns a boolean specifying if alpha blending is needed for the mesh
  25740. */
  25741. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25742. /**
  25743. * Specifies whether or not this material should be rendered in alpha test mode.
  25744. * @returns a boolean specifying if an alpha test is needed.
  25745. */
  25746. needAlphaTesting(): boolean;
  25747. /**
  25748. * Specifies if material alpha testing should be turned on for the mesh
  25749. * @param mesh defines the mesh to check
  25750. */
  25751. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25752. /**
  25753. * Gets the texture used for the alpha test
  25754. * @returns the texture to use for alpha testing
  25755. */
  25756. getAlphaTestTexture(): Nullable<BaseTexture>;
  25757. /**
  25758. * Marks the material to indicate that it needs to be re-calculated
  25759. */
  25760. markDirty(): void;
  25761. /** @hidden */
  25762. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25763. /**
  25764. * Binds the material to the mesh
  25765. * @param world defines the world transformation matrix
  25766. * @param mesh defines the mesh to bind the material to
  25767. */
  25768. bind(world: Matrix, mesh?: Mesh): void;
  25769. /**
  25770. * Binds the submesh to the material
  25771. * @param world defines the world transformation matrix
  25772. * @param mesh defines the mesh containing the submesh
  25773. * @param subMesh defines the submesh to bind the material to
  25774. */
  25775. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25776. /**
  25777. * Binds the world matrix to the material
  25778. * @param world defines the world transformation matrix
  25779. */
  25780. bindOnlyWorldMatrix(world: Matrix): void;
  25781. /**
  25782. * Binds the scene's uniform buffer to the effect.
  25783. * @param effect defines the effect to bind to the scene uniform buffer
  25784. * @param sceneUbo defines the uniform buffer storing scene data
  25785. */
  25786. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25787. /**
  25788. * Binds the view matrix to the effect
  25789. * @param effect defines the effect to bind the view matrix to
  25790. */
  25791. bindView(effect: Effect): void;
  25792. /**
  25793. * Binds the view projection matrix to the effect
  25794. * @param effect defines the effect to bind the view projection matrix to
  25795. */
  25796. bindViewProjection(effect: Effect): void;
  25797. /**
  25798. * Processes to execute after binding the material to a mesh
  25799. * @param mesh defines the rendered mesh
  25800. */
  25801. protected _afterBind(mesh?: Mesh): void;
  25802. /**
  25803. * Unbinds the material from the mesh
  25804. */
  25805. unbind(): void;
  25806. /**
  25807. * Gets the active textures from the material
  25808. * @returns an array of textures
  25809. */
  25810. getActiveTextures(): BaseTexture[];
  25811. /**
  25812. * Specifies if the material uses a texture
  25813. * @param texture defines the texture to check against the material
  25814. * @returns a boolean specifying if the material uses the texture
  25815. */
  25816. hasTexture(texture: BaseTexture): boolean;
  25817. /**
  25818. * Makes a duplicate of the material, and gives it a new name
  25819. * @param name defines the new name for the duplicated material
  25820. * @returns the cloned material
  25821. */
  25822. clone(name: string): Nullable<Material>;
  25823. /**
  25824. * Gets the meshes bound to the material
  25825. * @returns an array of meshes bound to the material
  25826. */
  25827. getBindedMeshes(): AbstractMesh[];
  25828. /**
  25829. * Force shader compilation
  25830. * @param mesh defines the mesh associated with this material
  25831. * @param onCompiled defines a function to execute once the material is compiled
  25832. * @param options defines the options to configure the compilation
  25833. * @param onError defines a function to execute if the material fails compiling
  25834. */
  25835. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25836. /**
  25837. * Force shader compilation
  25838. * @param mesh defines the mesh that will use this material
  25839. * @param options defines additional options for compiling the shaders
  25840. * @returns a promise that resolves when the compilation completes
  25841. */
  25842. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25843. private static readonly _AllDirtyCallBack;
  25844. private static readonly _ImageProcessingDirtyCallBack;
  25845. private static readonly _TextureDirtyCallBack;
  25846. private static readonly _FresnelDirtyCallBack;
  25847. private static readonly _MiscDirtyCallBack;
  25848. private static readonly _LightsDirtyCallBack;
  25849. private static readonly _AttributeDirtyCallBack;
  25850. private static _FresnelAndMiscDirtyCallBack;
  25851. private static _TextureAndMiscDirtyCallBack;
  25852. private static readonly _DirtyCallbackArray;
  25853. private static readonly _RunDirtyCallBacks;
  25854. /**
  25855. * Marks a define in the material to indicate that it needs to be re-computed
  25856. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25857. */
  25858. markAsDirty(flag: number): void;
  25859. /**
  25860. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25861. * @param func defines a function which checks material defines against the submeshes
  25862. */
  25863. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25864. /**
  25865. * Indicates that the scene should check if the rendering now needs a prepass
  25866. */
  25867. protected _markScenePrePassDirty(): void;
  25868. /**
  25869. * Indicates that we need to re-calculated for all submeshes
  25870. */
  25871. protected _markAllSubMeshesAsAllDirty(): void;
  25872. /**
  25873. * Indicates that image processing needs to be re-calculated for all submeshes
  25874. */
  25875. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25876. /**
  25877. * Indicates that textures need to be re-calculated for all submeshes
  25878. */
  25879. protected _markAllSubMeshesAsTexturesDirty(): void;
  25880. /**
  25881. * Indicates that fresnel needs to be re-calculated for all submeshes
  25882. */
  25883. protected _markAllSubMeshesAsFresnelDirty(): void;
  25884. /**
  25885. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25886. */
  25887. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25888. /**
  25889. * Indicates that lights need to be re-calculated for all submeshes
  25890. */
  25891. protected _markAllSubMeshesAsLightsDirty(): void;
  25892. /**
  25893. * Indicates that attributes need to be re-calculated for all submeshes
  25894. */
  25895. protected _markAllSubMeshesAsAttributesDirty(): void;
  25896. /**
  25897. * Indicates that misc needs to be re-calculated for all submeshes
  25898. */
  25899. protected _markAllSubMeshesAsMiscDirty(): void;
  25900. /**
  25901. * Indicates that textures and misc need to be re-calculated for all submeshes
  25902. */
  25903. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25904. /**
  25905. * Sets the required values to the prepass renderer.
  25906. * @param prePassRenderer defines the prepass renderer to setup.
  25907. * @returns true if the pre pass is needed.
  25908. */
  25909. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25910. /**
  25911. * Disposes the material
  25912. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25913. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25914. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25915. */
  25916. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25917. /** @hidden */
  25918. private releaseVertexArrayObject;
  25919. /**
  25920. * Serializes this material
  25921. * @returns the serialized material object
  25922. */
  25923. serialize(): any;
  25924. /**
  25925. * Creates a material from parsed material data
  25926. * @param parsedMaterial defines parsed material data
  25927. * @param scene defines the hosting scene
  25928. * @param rootUrl defines the root URL to use to load textures
  25929. * @returns a new material
  25930. */
  25931. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25932. }
  25933. }
  25934. declare module "babylonjs/Materials/multiMaterial" {
  25935. import { Nullable } from "babylonjs/types";
  25936. import { Scene } from "babylonjs/scene";
  25937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25940. import { Material } from "babylonjs/Materials/material";
  25941. /**
  25942. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25943. * separate meshes. This can be use to improve performances.
  25944. * @see https://doc.babylonjs.com/how_to/multi_materials
  25945. */
  25946. export class MultiMaterial extends Material {
  25947. private _subMaterials;
  25948. /**
  25949. * Gets or Sets the list of Materials used within the multi material.
  25950. * They need to be ordered according to the submeshes order in the associated mesh
  25951. */
  25952. get subMaterials(): Nullable<Material>[];
  25953. set subMaterials(value: Nullable<Material>[]);
  25954. /**
  25955. * Function used to align with Node.getChildren()
  25956. * @returns the list of Materials used within the multi material
  25957. */
  25958. getChildren(): Nullable<Material>[];
  25959. /**
  25960. * Instantiates a new Multi Material
  25961. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25962. * separate meshes. This can be use to improve performances.
  25963. * @see https://doc.babylonjs.com/how_to/multi_materials
  25964. * @param name Define the name in the scene
  25965. * @param scene Define the scene the material belongs to
  25966. */
  25967. constructor(name: string, scene: Scene);
  25968. private _hookArray;
  25969. /**
  25970. * Get one of the submaterial by its index in the submaterials array
  25971. * @param index The index to look the sub material at
  25972. * @returns The Material if the index has been defined
  25973. */
  25974. getSubMaterial(index: number): Nullable<Material>;
  25975. /**
  25976. * Get the list of active textures for the whole sub materials list.
  25977. * @returns All the textures that will be used during the rendering
  25978. */
  25979. getActiveTextures(): BaseTexture[];
  25980. /**
  25981. * Gets the current class name of the material e.g. "MultiMaterial"
  25982. * Mainly use in serialization.
  25983. * @returns the class name
  25984. */
  25985. getClassName(): string;
  25986. /**
  25987. * Checks if the material is ready to render the requested sub mesh
  25988. * @param mesh Define the mesh the submesh belongs to
  25989. * @param subMesh Define the sub mesh to look readyness for
  25990. * @param useInstances Define whether or not the material is used with instances
  25991. * @returns true if ready, otherwise false
  25992. */
  25993. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25994. /**
  25995. * Clones the current material and its related sub materials
  25996. * @param name Define the name of the newly cloned material
  25997. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25998. * @returns the cloned material
  25999. */
  26000. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26001. /**
  26002. * Serializes the materials into a JSON representation.
  26003. * @returns the JSON representation
  26004. */
  26005. serialize(): any;
  26006. /**
  26007. * Dispose the material and release its associated resources
  26008. * @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)
  26009. * @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)
  26010. * @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)
  26011. */
  26012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26013. /**
  26014. * Creates a MultiMaterial from parsed MultiMaterial data.
  26015. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26016. * @param scene defines the hosting scene
  26017. * @returns a new MultiMaterial
  26018. */
  26019. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26020. }
  26021. }
  26022. declare module "babylonjs/Meshes/subMesh" {
  26023. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26024. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26025. import { Engine } from "babylonjs/Engines/engine";
  26026. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26027. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26028. import { Effect } from "babylonjs/Materials/effect";
  26029. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26030. import { Plane } from "babylonjs/Maths/math.plane";
  26031. import { Collider } from "babylonjs/Collisions/collider";
  26032. import { Material } from "babylonjs/Materials/material";
  26033. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26035. import { Mesh } from "babylonjs/Meshes/mesh";
  26036. import { Ray } from "babylonjs/Culling/ray";
  26037. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26038. /**
  26039. * Defines a subdivision inside a mesh
  26040. */
  26041. export class SubMesh implements ICullable {
  26042. /** the material index to use */
  26043. materialIndex: number;
  26044. /** vertex index start */
  26045. verticesStart: number;
  26046. /** vertices count */
  26047. verticesCount: number;
  26048. /** index start */
  26049. indexStart: number;
  26050. /** indices count */
  26051. indexCount: number;
  26052. /** @hidden */
  26053. _materialDefines: Nullable<MaterialDefines>;
  26054. /** @hidden */
  26055. _materialEffect: Nullable<Effect>;
  26056. /** @hidden */
  26057. _effectOverride: Nullable<Effect>;
  26058. /**
  26059. * Gets material defines used by the effect associated to the sub mesh
  26060. */
  26061. get materialDefines(): Nullable<MaterialDefines>;
  26062. /**
  26063. * Sets material defines used by the effect associated to the sub mesh
  26064. */
  26065. set materialDefines(defines: Nullable<MaterialDefines>);
  26066. /**
  26067. * Gets associated effect
  26068. */
  26069. get effect(): Nullable<Effect>;
  26070. /**
  26071. * Sets associated effect (effect used to render this submesh)
  26072. * @param effect defines the effect to associate with
  26073. * @param defines defines the set of defines used to compile this effect
  26074. */
  26075. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26076. /** @hidden */
  26077. _linesIndexCount: number;
  26078. private _mesh;
  26079. private _renderingMesh;
  26080. private _boundingInfo;
  26081. private _linesIndexBuffer;
  26082. /** @hidden */
  26083. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26084. /** @hidden */
  26085. _trianglePlanes: Plane[];
  26086. /** @hidden */
  26087. _lastColliderTransformMatrix: Nullable<Matrix>;
  26088. /** @hidden */
  26089. _renderId: number;
  26090. /** @hidden */
  26091. _alphaIndex: number;
  26092. /** @hidden */
  26093. _distanceToCamera: number;
  26094. /** @hidden */
  26095. _id: number;
  26096. private _currentMaterial;
  26097. /**
  26098. * Add a new submesh to a mesh
  26099. * @param materialIndex defines the material index to use
  26100. * @param verticesStart defines vertex index start
  26101. * @param verticesCount defines vertices count
  26102. * @param indexStart defines index start
  26103. * @param indexCount defines indices count
  26104. * @param mesh defines the parent mesh
  26105. * @param renderingMesh defines an optional rendering mesh
  26106. * @param createBoundingBox defines if bounding box should be created for this submesh
  26107. * @returns the new submesh
  26108. */
  26109. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26110. /**
  26111. * Creates a new submesh
  26112. * @param materialIndex defines the material index to use
  26113. * @param verticesStart defines vertex index start
  26114. * @param verticesCount defines vertices count
  26115. * @param indexStart defines index start
  26116. * @param indexCount defines indices count
  26117. * @param mesh defines the parent mesh
  26118. * @param renderingMesh defines an optional rendering mesh
  26119. * @param createBoundingBox defines if bounding box should be created for this submesh
  26120. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26121. */
  26122. constructor(
  26123. /** the material index to use */
  26124. materialIndex: number,
  26125. /** vertex index start */
  26126. verticesStart: number,
  26127. /** vertices count */
  26128. verticesCount: number,
  26129. /** index start */
  26130. indexStart: number,
  26131. /** indices count */
  26132. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26133. /**
  26134. * Returns true if this submesh covers the entire parent mesh
  26135. * @ignorenaming
  26136. */
  26137. get IsGlobal(): boolean;
  26138. /**
  26139. * Returns the submesh BoudingInfo object
  26140. * @returns current bounding info (or mesh's one if the submesh is global)
  26141. */
  26142. getBoundingInfo(): BoundingInfo;
  26143. /**
  26144. * Sets the submesh BoundingInfo
  26145. * @param boundingInfo defines the new bounding info to use
  26146. * @returns the SubMesh
  26147. */
  26148. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26149. /**
  26150. * Returns the mesh of the current submesh
  26151. * @return the parent mesh
  26152. */
  26153. getMesh(): AbstractMesh;
  26154. /**
  26155. * Returns the rendering mesh of the submesh
  26156. * @returns the rendering mesh (could be different from parent mesh)
  26157. */
  26158. getRenderingMesh(): Mesh;
  26159. /**
  26160. * Returns the replacement mesh of the submesh
  26161. * @returns the replacement mesh (could be different from parent mesh)
  26162. */
  26163. getReplacementMesh(): Nullable<AbstractMesh>;
  26164. /**
  26165. * Returns the effective mesh of the submesh
  26166. * @returns the effective mesh (could be different from parent mesh)
  26167. */
  26168. getEffectiveMesh(): AbstractMesh;
  26169. /**
  26170. * Returns the submesh material
  26171. * @returns null or the current material
  26172. */
  26173. getMaterial(): Nullable<Material>;
  26174. private _IsMultiMaterial;
  26175. /**
  26176. * Sets a new updated BoundingInfo object to the submesh
  26177. * @param data defines an optional position array to use to determine the bounding info
  26178. * @returns the SubMesh
  26179. */
  26180. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26181. /** @hidden */
  26182. _checkCollision(collider: Collider): boolean;
  26183. /**
  26184. * Updates the submesh BoundingInfo
  26185. * @param world defines the world matrix to use to update the bounding info
  26186. * @returns the submesh
  26187. */
  26188. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26189. /**
  26190. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26191. * @param frustumPlanes defines the frustum planes
  26192. * @returns true if the submesh is intersecting with the frustum
  26193. */
  26194. isInFrustum(frustumPlanes: Plane[]): boolean;
  26195. /**
  26196. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26197. * @param frustumPlanes defines the frustum planes
  26198. * @returns true if the submesh is inside the frustum
  26199. */
  26200. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26201. /**
  26202. * Renders the submesh
  26203. * @param enableAlphaMode defines if alpha needs to be used
  26204. * @returns the submesh
  26205. */
  26206. render(enableAlphaMode: boolean): SubMesh;
  26207. /**
  26208. * @hidden
  26209. */
  26210. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26211. /**
  26212. * Checks if the submesh intersects with a ray
  26213. * @param ray defines the ray to test
  26214. * @returns true is the passed ray intersects the submesh bounding box
  26215. */
  26216. canIntersects(ray: Ray): boolean;
  26217. /**
  26218. * Intersects current submesh with a ray
  26219. * @param ray defines the ray to test
  26220. * @param positions defines mesh's positions array
  26221. * @param indices defines mesh's indices array
  26222. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26224. * @returns intersection info or null if no intersection
  26225. */
  26226. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26227. /** @hidden */
  26228. private _intersectLines;
  26229. /** @hidden */
  26230. private _intersectUnIndexedLines;
  26231. /** @hidden */
  26232. private _intersectTriangles;
  26233. /** @hidden */
  26234. private _intersectUnIndexedTriangles;
  26235. /** @hidden */
  26236. _rebuild(): void;
  26237. /**
  26238. * Creates a new submesh from the passed mesh
  26239. * @param newMesh defines the new hosting mesh
  26240. * @param newRenderingMesh defines an optional rendering mesh
  26241. * @returns the new submesh
  26242. */
  26243. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26244. /**
  26245. * Release associated resources
  26246. */
  26247. dispose(): void;
  26248. /**
  26249. * Gets the class name
  26250. * @returns the string "SubMesh".
  26251. */
  26252. getClassName(): string;
  26253. /**
  26254. * Creates a new submesh from indices data
  26255. * @param materialIndex the index of the main mesh material
  26256. * @param startIndex the index where to start the copy in the mesh indices array
  26257. * @param indexCount the number of indices to copy then from the startIndex
  26258. * @param mesh the main mesh to create the submesh from
  26259. * @param renderingMesh the optional rendering mesh
  26260. * @returns a new submesh
  26261. */
  26262. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26263. }
  26264. }
  26265. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26266. /**
  26267. * Class used to represent data loading progression
  26268. */
  26269. export class SceneLoaderFlags {
  26270. private static _ForceFullSceneLoadingForIncremental;
  26271. private static _ShowLoadingScreen;
  26272. private static _CleanBoneMatrixWeights;
  26273. private static _loggingLevel;
  26274. /**
  26275. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26276. */
  26277. static get ForceFullSceneLoadingForIncremental(): boolean;
  26278. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26279. /**
  26280. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26281. */
  26282. static get ShowLoadingScreen(): boolean;
  26283. static set ShowLoadingScreen(value: boolean);
  26284. /**
  26285. * Defines the current logging level (while loading the scene)
  26286. * @ignorenaming
  26287. */
  26288. static get loggingLevel(): number;
  26289. static set loggingLevel(value: number);
  26290. /**
  26291. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26292. */
  26293. static get CleanBoneMatrixWeights(): boolean;
  26294. static set CleanBoneMatrixWeights(value: boolean);
  26295. }
  26296. }
  26297. declare module "babylonjs/Meshes/geometry" {
  26298. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26299. import { Scene } from "babylonjs/scene";
  26300. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26301. import { Engine } from "babylonjs/Engines/engine";
  26302. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26303. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26304. import { Effect } from "babylonjs/Materials/effect";
  26305. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26307. import { Mesh } from "babylonjs/Meshes/mesh";
  26308. /**
  26309. * Class used to store geometry data (vertex buffers + index buffer)
  26310. */
  26311. export class Geometry implements IGetSetVerticesData {
  26312. /**
  26313. * Gets or sets the ID of the geometry
  26314. */
  26315. id: string;
  26316. /**
  26317. * Gets or sets the unique ID of the geometry
  26318. */
  26319. uniqueId: number;
  26320. /**
  26321. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26322. */
  26323. delayLoadState: number;
  26324. /**
  26325. * Gets the file containing the data to load when running in delay load state
  26326. */
  26327. delayLoadingFile: Nullable<string>;
  26328. /**
  26329. * Callback called when the geometry is updated
  26330. */
  26331. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26332. private _scene;
  26333. private _engine;
  26334. private _meshes;
  26335. private _totalVertices;
  26336. /** @hidden */
  26337. _indices: IndicesArray;
  26338. /** @hidden */
  26339. _vertexBuffers: {
  26340. [key: string]: VertexBuffer;
  26341. };
  26342. private _isDisposed;
  26343. private _extend;
  26344. private _boundingBias;
  26345. /** @hidden */
  26346. _delayInfo: Array<string>;
  26347. private _indexBuffer;
  26348. private _indexBufferIsUpdatable;
  26349. /** @hidden */
  26350. _boundingInfo: Nullable<BoundingInfo>;
  26351. /** @hidden */
  26352. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26353. /** @hidden */
  26354. _softwareSkinningFrameId: number;
  26355. private _vertexArrayObjects;
  26356. private _updatable;
  26357. /** @hidden */
  26358. _positions: Nullable<Vector3[]>;
  26359. /**
  26360. * 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
  26361. */
  26362. get boundingBias(): Vector2;
  26363. /**
  26364. * 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
  26365. */
  26366. set boundingBias(value: Vector2);
  26367. /**
  26368. * Static function used to attach a new empty geometry to a mesh
  26369. * @param mesh defines the mesh to attach the geometry to
  26370. * @returns the new Geometry
  26371. */
  26372. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26373. /** Get the list of meshes using this geometry */
  26374. get meshes(): Mesh[];
  26375. /**
  26376. * 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
  26377. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26378. */
  26379. useBoundingInfoFromGeometry: boolean;
  26380. /**
  26381. * Creates a new geometry
  26382. * @param id defines the unique ID
  26383. * @param scene defines the hosting scene
  26384. * @param vertexData defines the VertexData used to get geometry data
  26385. * @param updatable defines if geometry must be updatable (false by default)
  26386. * @param mesh defines the mesh that will be associated with the geometry
  26387. */
  26388. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26389. /**
  26390. * Gets the current extend of the geometry
  26391. */
  26392. get extend(): {
  26393. minimum: Vector3;
  26394. maximum: Vector3;
  26395. };
  26396. /**
  26397. * Gets the hosting scene
  26398. * @returns the hosting Scene
  26399. */
  26400. getScene(): Scene;
  26401. /**
  26402. * Gets the hosting engine
  26403. * @returns the hosting Engine
  26404. */
  26405. getEngine(): Engine;
  26406. /**
  26407. * Defines if the geometry is ready to use
  26408. * @returns true if the geometry is ready to be used
  26409. */
  26410. isReady(): boolean;
  26411. /**
  26412. * Gets a value indicating that the geometry should not be serialized
  26413. */
  26414. get doNotSerialize(): boolean;
  26415. /** @hidden */
  26416. _rebuild(): void;
  26417. /**
  26418. * Affects all geometry data in one call
  26419. * @param vertexData defines the geometry data
  26420. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26421. */
  26422. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26423. /**
  26424. * Set specific vertex data
  26425. * @param kind defines the data kind (Position, normal, etc...)
  26426. * @param data defines the vertex data to use
  26427. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26428. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26429. */
  26430. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26431. /**
  26432. * Removes a specific vertex data
  26433. * @param kind defines the data kind (Position, normal, etc...)
  26434. */
  26435. removeVerticesData(kind: string): void;
  26436. /**
  26437. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26438. * @param buffer defines the vertex buffer to use
  26439. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26440. */
  26441. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26442. /**
  26443. * Update a specific vertex buffer
  26444. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26445. * It will do nothing if the buffer is not updatable
  26446. * @param kind defines the data kind (Position, normal, etc...)
  26447. * @param data defines the data to use
  26448. * @param offset defines the offset in the target buffer where to store the data
  26449. * @param useBytes set to true if the offset is in bytes
  26450. */
  26451. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26452. /**
  26453. * Update a specific vertex buffer
  26454. * This function will create a new buffer if the current one is not updatable
  26455. * @param kind defines the data kind (Position, normal, etc...)
  26456. * @param data defines the data to use
  26457. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26458. */
  26459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26460. private _updateBoundingInfo;
  26461. /** @hidden */
  26462. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26463. /**
  26464. * Gets total number of vertices
  26465. * @returns the total number of vertices
  26466. */
  26467. getTotalVertices(): number;
  26468. /**
  26469. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26470. * @param kind defines the data kind (Position, normal, etc...)
  26471. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26472. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26473. * @returns a float array containing vertex data
  26474. */
  26475. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26476. /**
  26477. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26478. * @param kind defines the data kind (Position, normal, etc...)
  26479. * @returns true if the vertex buffer with the specified kind is updatable
  26480. */
  26481. isVertexBufferUpdatable(kind: string): boolean;
  26482. /**
  26483. * Gets a specific vertex buffer
  26484. * @param kind defines the data kind (Position, normal, etc...)
  26485. * @returns a VertexBuffer
  26486. */
  26487. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26488. /**
  26489. * Returns all vertex buffers
  26490. * @return an object holding all vertex buffers indexed by kind
  26491. */
  26492. getVertexBuffers(): Nullable<{
  26493. [key: string]: VertexBuffer;
  26494. }>;
  26495. /**
  26496. * Gets a boolean indicating if specific vertex buffer is present
  26497. * @param kind defines the data kind (Position, normal, etc...)
  26498. * @returns true if data is present
  26499. */
  26500. isVerticesDataPresent(kind: string): boolean;
  26501. /**
  26502. * Gets a list of all attached data kinds (Position, normal, etc...)
  26503. * @returns a list of string containing all kinds
  26504. */
  26505. getVerticesDataKinds(): string[];
  26506. /**
  26507. * Update index buffer
  26508. * @param indices defines the indices to store in the index buffer
  26509. * @param offset defines the offset in the target buffer where to store the data
  26510. * @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)
  26511. */
  26512. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26513. /**
  26514. * Creates a new index buffer
  26515. * @param indices defines the indices to store in the index buffer
  26516. * @param totalVertices defines the total number of vertices (could be null)
  26517. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26518. */
  26519. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26520. /**
  26521. * Return the total number of indices
  26522. * @returns the total number of indices
  26523. */
  26524. getTotalIndices(): number;
  26525. /**
  26526. * Gets the index buffer array
  26527. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26528. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26529. * @returns the index buffer array
  26530. */
  26531. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26532. /**
  26533. * Gets the index buffer
  26534. * @return the index buffer
  26535. */
  26536. getIndexBuffer(): Nullable<DataBuffer>;
  26537. /** @hidden */
  26538. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26539. /**
  26540. * Release the associated resources for a specific mesh
  26541. * @param mesh defines the source mesh
  26542. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26543. */
  26544. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26545. /**
  26546. * Apply current geometry to a given mesh
  26547. * @param mesh defines the mesh to apply geometry to
  26548. */
  26549. applyToMesh(mesh: Mesh): void;
  26550. private _updateExtend;
  26551. private _applyToMesh;
  26552. private notifyUpdate;
  26553. /**
  26554. * Load the geometry if it was flagged as delay loaded
  26555. * @param scene defines the hosting scene
  26556. * @param onLoaded defines a callback called when the geometry is loaded
  26557. */
  26558. load(scene: Scene, onLoaded?: () => void): void;
  26559. private _queueLoad;
  26560. /**
  26561. * Invert the geometry to move from a right handed system to a left handed one.
  26562. */
  26563. toLeftHanded(): void;
  26564. /** @hidden */
  26565. _resetPointsArrayCache(): void;
  26566. /** @hidden */
  26567. _generatePointsArray(): boolean;
  26568. /**
  26569. * Gets a value indicating if the geometry is disposed
  26570. * @returns true if the geometry was disposed
  26571. */
  26572. isDisposed(): boolean;
  26573. private _disposeVertexArrayObjects;
  26574. /**
  26575. * Free all associated resources
  26576. */
  26577. dispose(): void;
  26578. /**
  26579. * Clone the current geometry into a new geometry
  26580. * @param id defines the unique ID of the new geometry
  26581. * @returns a new geometry object
  26582. */
  26583. copy(id: string): Geometry;
  26584. /**
  26585. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26586. * @return a JSON representation of the current geometry data (without the vertices data)
  26587. */
  26588. serialize(): any;
  26589. private toNumberArray;
  26590. /**
  26591. * Serialize all vertices data into a JSON oject
  26592. * @returns a JSON representation of the current geometry data
  26593. */
  26594. serializeVerticeData(): any;
  26595. /**
  26596. * Extracts a clone of a mesh geometry
  26597. * @param mesh defines the source mesh
  26598. * @param id defines the unique ID of the new geometry object
  26599. * @returns the new geometry object
  26600. */
  26601. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26602. /**
  26603. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26604. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26605. * Be aware Math.random() could cause collisions, but:
  26606. * "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"
  26607. * @returns a string containing a new GUID
  26608. */
  26609. static RandomId(): string;
  26610. /** @hidden */
  26611. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26612. private static _CleanMatricesWeights;
  26613. /**
  26614. * Create a new geometry from persisted data (Using .babylon file format)
  26615. * @param parsedVertexData defines the persisted data
  26616. * @param scene defines the hosting scene
  26617. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26618. * @returns the new geometry object
  26619. */
  26620. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26621. }
  26622. }
  26623. declare module "babylonjs/Meshes/mesh.vertexData" {
  26624. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26625. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26626. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26627. import { Geometry } from "babylonjs/Meshes/geometry";
  26628. import { Mesh } from "babylonjs/Meshes/mesh";
  26629. /**
  26630. * Define an interface for all classes that will get and set the data on vertices
  26631. */
  26632. export interface IGetSetVerticesData {
  26633. /**
  26634. * Gets a boolean indicating if specific vertex data is present
  26635. * @param kind defines the vertex data kind to use
  26636. * @returns true is data kind is present
  26637. */
  26638. isVerticesDataPresent(kind: string): boolean;
  26639. /**
  26640. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26641. * @param kind defines the data kind (Position, normal, etc...)
  26642. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26643. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26644. * @returns a float array containing vertex data
  26645. */
  26646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26647. /**
  26648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26649. * @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.
  26650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26651. * @returns the indices array or an empty array if the mesh has no geometry
  26652. */
  26653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26654. /**
  26655. * Set specific vertex data
  26656. * @param kind defines the data kind (Position, normal, etc...)
  26657. * @param data defines the vertex data to use
  26658. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26659. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26660. */
  26661. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26662. /**
  26663. * Update a specific associated vertex buffer
  26664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26665. * - VertexBuffer.PositionKind
  26666. * - VertexBuffer.UVKind
  26667. * - VertexBuffer.UV2Kind
  26668. * - VertexBuffer.UV3Kind
  26669. * - VertexBuffer.UV4Kind
  26670. * - VertexBuffer.UV5Kind
  26671. * - VertexBuffer.UV6Kind
  26672. * - VertexBuffer.ColorKind
  26673. * - VertexBuffer.MatricesIndicesKind
  26674. * - VertexBuffer.MatricesIndicesExtraKind
  26675. * - VertexBuffer.MatricesWeightsKind
  26676. * - VertexBuffer.MatricesWeightsExtraKind
  26677. * @param data defines the data source
  26678. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26679. * @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)
  26680. */
  26681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26682. /**
  26683. * Creates a new index buffer
  26684. * @param indices defines the indices to store in the index buffer
  26685. * @param totalVertices defines the total number of vertices (could be null)
  26686. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26687. */
  26688. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26689. }
  26690. /**
  26691. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26692. */
  26693. export class VertexData {
  26694. /**
  26695. * Mesh side orientation : usually the external or front surface
  26696. */
  26697. static readonly FRONTSIDE: number;
  26698. /**
  26699. * Mesh side orientation : usually the internal or back surface
  26700. */
  26701. static readonly BACKSIDE: number;
  26702. /**
  26703. * Mesh side orientation : both internal and external or front and back surfaces
  26704. */
  26705. static readonly DOUBLESIDE: number;
  26706. /**
  26707. * Mesh side orientation : by default, `FRONTSIDE`
  26708. */
  26709. static readonly DEFAULTSIDE: number;
  26710. /**
  26711. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26712. */
  26713. positions: Nullable<FloatArray>;
  26714. /**
  26715. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26716. */
  26717. normals: Nullable<FloatArray>;
  26718. /**
  26719. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26720. */
  26721. tangents: Nullable<FloatArray>;
  26722. /**
  26723. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26724. */
  26725. uvs: Nullable<FloatArray>;
  26726. /**
  26727. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26728. */
  26729. uvs2: Nullable<FloatArray>;
  26730. /**
  26731. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26732. */
  26733. uvs3: Nullable<FloatArray>;
  26734. /**
  26735. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26736. */
  26737. uvs4: Nullable<FloatArray>;
  26738. /**
  26739. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26740. */
  26741. uvs5: Nullable<FloatArray>;
  26742. /**
  26743. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26744. */
  26745. uvs6: Nullable<FloatArray>;
  26746. /**
  26747. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26748. */
  26749. colors: Nullable<FloatArray>;
  26750. /**
  26751. * 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).
  26752. */
  26753. matricesIndices: Nullable<FloatArray>;
  26754. /**
  26755. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26756. */
  26757. matricesWeights: Nullable<FloatArray>;
  26758. /**
  26759. * An array extending the number of possible indices
  26760. */
  26761. matricesIndicesExtra: Nullable<FloatArray>;
  26762. /**
  26763. * An array extending the number of possible weights when the number of indices is extended
  26764. */
  26765. matricesWeightsExtra: Nullable<FloatArray>;
  26766. /**
  26767. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26768. */
  26769. indices: Nullable<IndicesArray>;
  26770. /**
  26771. * Uses the passed data array to set the set the values for the specified kind of data
  26772. * @param data a linear array of floating numbers
  26773. * @param kind the type of data that is being set, eg positions, colors etc
  26774. */
  26775. set(data: FloatArray, kind: string): void;
  26776. /**
  26777. * Associates the vertexData to the passed Mesh.
  26778. * Sets it as updatable or not (default `false`)
  26779. * @param mesh the mesh the vertexData is applied to
  26780. * @param updatable when used and having the value true allows new data to update the vertexData
  26781. * @returns the VertexData
  26782. */
  26783. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26784. /**
  26785. * Associates the vertexData to the passed Geometry.
  26786. * Sets it as updatable or not (default `false`)
  26787. * @param geometry the geometry the vertexData is applied to
  26788. * @param updatable when used and having the value true allows new data to update the vertexData
  26789. * @returns VertexData
  26790. */
  26791. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26792. /**
  26793. * Updates the associated mesh
  26794. * @param mesh the mesh to be updated
  26795. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26796. * @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
  26797. * @returns VertexData
  26798. */
  26799. updateMesh(mesh: Mesh): VertexData;
  26800. /**
  26801. * Updates the associated geometry
  26802. * @param geometry the geometry to be updated
  26803. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26804. * @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
  26805. * @returns VertexData.
  26806. */
  26807. updateGeometry(geometry: Geometry): VertexData;
  26808. private _applyTo;
  26809. private _update;
  26810. /**
  26811. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26812. * @param matrix the transforming matrix
  26813. * @returns the VertexData
  26814. */
  26815. transform(matrix: Matrix): VertexData;
  26816. /**
  26817. * Merges the passed VertexData into the current one
  26818. * @param other the VertexData to be merged into the current one
  26819. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26820. * @returns the modified VertexData
  26821. */
  26822. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26823. private _mergeElement;
  26824. private _validate;
  26825. /**
  26826. * Serializes the VertexData
  26827. * @returns a serialized object
  26828. */
  26829. serialize(): any;
  26830. /**
  26831. * Extracts the vertexData from a mesh
  26832. * @param mesh the mesh from which to extract the VertexData
  26833. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26834. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26835. * @returns the object VertexData associated to the passed mesh
  26836. */
  26837. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26838. /**
  26839. * Extracts the vertexData from the geometry
  26840. * @param geometry the geometry from which to extract the VertexData
  26841. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26842. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26843. * @returns the object VertexData associated to the passed mesh
  26844. */
  26845. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26846. private static _ExtractFrom;
  26847. /**
  26848. * Creates the VertexData for a Ribbon
  26849. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26850. * * pathArray array of paths, each of which an array of successive Vector3
  26851. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26852. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26853. * * 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
  26854. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26855. * * 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)
  26856. * * 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)
  26857. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26858. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26859. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26860. * @returns the VertexData of the ribbon
  26861. */
  26862. static CreateRibbon(options: {
  26863. pathArray: Vector3[][];
  26864. closeArray?: boolean;
  26865. closePath?: boolean;
  26866. offset?: number;
  26867. sideOrientation?: number;
  26868. frontUVs?: Vector4;
  26869. backUVs?: Vector4;
  26870. invertUV?: boolean;
  26871. uvs?: Vector2[];
  26872. colors?: Color4[];
  26873. }): VertexData;
  26874. /**
  26875. * Creates the VertexData for a box
  26876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26877. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26878. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26879. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26880. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26881. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26882. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26883. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26884. * * 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)
  26885. * * 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)
  26886. * @returns the VertexData of the box
  26887. */
  26888. static CreateBox(options: {
  26889. size?: number;
  26890. width?: number;
  26891. height?: number;
  26892. depth?: number;
  26893. faceUV?: Vector4[];
  26894. faceColors?: Color4[];
  26895. sideOrientation?: number;
  26896. frontUVs?: Vector4;
  26897. backUVs?: Vector4;
  26898. }): VertexData;
  26899. /**
  26900. * Creates the VertexData for a tiled box
  26901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26902. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26903. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26904. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26906. * @returns the VertexData of the box
  26907. */
  26908. static CreateTiledBox(options: {
  26909. pattern?: number;
  26910. width?: number;
  26911. height?: number;
  26912. depth?: number;
  26913. tileSize?: number;
  26914. tileWidth?: number;
  26915. tileHeight?: number;
  26916. alignHorizontal?: number;
  26917. alignVertical?: number;
  26918. faceUV?: Vector4[];
  26919. faceColors?: Color4[];
  26920. sideOrientation?: number;
  26921. }): VertexData;
  26922. /**
  26923. * Creates the VertexData for a tiled plane
  26924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26925. * * pattern a limited pattern arrangement depending on the number
  26926. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26927. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26928. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26930. * * 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)
  26931. * * 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)
  26932. * @returns the VertexData of the tiled plane
  26933. */
  26934. static CreateTiledPlane(options: {
  26935. pattern?: number;
  26936. tileSize?: number;
  26937. tileWidth?: number;
  26938. tileHeight?: number;
  26939. size?: number;
  26940. width?: number;
  26941. height?: number;
  26942. alignHorizontal?: number;
  26943. alignVertical?: number;
  26944. sideOrientation?: number;
  26945. frontUVs?: Vector4;
  26946. backUVs?: Vector4;
  26947. }): VertexData;
  26948. /**
  26949. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26951. * * segments sets the number of horizontal strips optional, default 32
  26952. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26953. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26954. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26955. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26956. * * 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
  26957. * * 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
  26958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26959. * * 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)
  26960. * * 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)
  26961. * @returns the VertexData of the ellipsoid
  26962. */
  26963. static CreateSphere(options: {
  26964. segments?: number;
  26965. diameter?: number;
  26966. diameterX?: number;
  26967. diameterY?: number;
  26968. diameterZ?: number;
  26969. arc?: number;
  26970. slice?: number;
  26971. sideOrientation?: number;
  26972. frontUVs?: Vector4;
  26973. backUVs?: Vector4;
  26974. }): VertexData;
  26975. /**
  26976. * Creates the VertexData for a cylinder, cone or prism
  26977. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26978. * * height sets the height (y direction) of the cylinder, optional, default 2
  26979. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26980. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26981. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26982. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26983. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26984. * * 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
  26985. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26986. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26987. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26988. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26990. * * 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)
  26991. * * 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)
  26992. * @returns the VertexData of the cylinder, cone or prism
  26993. */
  26994. static CreateCylinder(options: {
  26995. height?: number;
  26996. diameterTop?: number;
  26997. diameterBottom?: number;
  26998. diameter?: number;
  26999. tessellation?: number;
  27000. subdivisions?: number;
  27001. arc?: number;
  27002. faceColors?: Color4[];
  27003. faceUV?: Vector4[];
  27004. hasRings?: boolean;
  27005. enclose?: boolean;
  27006. sideOrientation?: number;
  27007. frontUVs?: Vector4;
  27008. backUVs?: Vector4;
  27009. }): VertexData;
  27010. /**
  27011. * Creates the VertexData for a torus
  27012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27013. * * diameter the diameter of the torus, optional default 1
  27014. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27015. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27017. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27018. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27019. * @returns the VertexData of the torus
  27020. */
  27021. static CreateTorus(options: {
  27022. diameter?: number;
  27023. thickness?: number;
  27024. tessellation?: number;
  27025. sideOrientation?: number;
  27026. frontUVs?: Vector4;
  27027. backUVs?: Vector4;
  27028. }): VertexData;
  27029. /**
  27030. * Creates the VertexData of the LineSystem
  27031. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27032. * - lines an array of lines, each line being an array of successive Vector3
  27033. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27034. * @returns the VertexData of the LineSystem
  27035. */
  27036. static CreateLineSystem(options: {
  27037. lines: Vector3[][];
  27038. colors?: Nullable<Color4[][]>;
  27039. }): VertexData;
  27040. /**
  27041. * Create the VertexData for a DashedLines
  27042. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27043. * - points an array successive Vector3
  27044. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27045. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27046. * - dashNb the intended total number of dashes, optional, default 200
  27047. * @returns the VertexData for the DashedLines
  27048. */
  27049. static CreateDashedLines(options: {
  27050. points: Vector3[];
  27051. dashSize?: number;
  27052. gapSize?: number;
  27053. dashNb?: number;
  27054. }): VertexData;
  27055. /**
  27056. * Creates the VertexData for a Ground
  27057. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27058. * - width the width (x direction) of the ground, optional, default 1
  27059. * - height the height (z direction) of the ground, optional, default 1
  27060. * - subdivisions the number of subdivisions per side, optional, default 1
  27061. * @returns the VertexData of the Ground
  27062. */
  27063. static CreateGround(options: {
  27064. width?: number;
  27065. height?: number;
  27066. subdivisions?: number;
  27067. subdivisionsX?: number;
  27068. subdivisionsY?: number;
  27069. }): VertexData;
  27070. /**
  27071. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27072. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27073. * * xmin the ground minimum X coordinate, optional, default -1
  27074. * * zmin the ground minimum Z coordinate, optional, default -1
  27075. * * xmax the ground maximum X coordinate, optional, default 1
  27076. * * zmax the ground maximum Z coordinate, optional, default 1
  27077. * * 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}
  27078. * * 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}
  27079. * @returns the VertexData of the TiledGround
  27080. */
  27081. static CreateTiledGround(options: {
  27082. xmin: number;
  27083. zmin: number;
  27084. xmax: number;
  27085. zmax: number;
  27086. subdivisions?: {
  27087. w: number;
  27088. h: number;
  27089. };
  27090. precision?: {
  27091. w: number;
  27092. h: number;
  27093. };
  27094. }): VertexData;
  27095. /**
  27096. * Creates the VertexData of the Ground designed from a heightmap
  27097. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27098. * * width the width (x direction) of the ground
  27099. * * height the height (z direction) of the ground
  27100. * * subdivisions the number of subdivisions per side
  27101. * * minHeight the minimum altitude on the ground, optional, default 0
  27102. * * maxHeight the maximum altitude on the ground, optional default 1
  27103. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27104. * * buffer the array holding the image color data
  27105. * * bufferWidth the width of image
  27106. * * bufferHeight the height of image
  27107. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27108. * @returns the VertexData of the Ground designed from a heightmap
  27109. */
  27110. static CreateGroundFromHeightMap(options: {
  27111. width: number;
  27112. height: number;
  27113. subdivisions: number;
  27114. minHeight: number;
  27115. maxHeight: number;
  27116. colorFilter: Color3;
  27117. buffer: Uint8Array;
  27118. bufferWidth: number;
  27119. bufferHeight: number;
  27120. alphaFilter: number;
  27121. }): VertexData;
  27122. /**
  27123. * Creates the VertexData for a Plane
  27124. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27125. * * size sets the width and height of the plane to the value of size, optional default 1
  27126. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27127. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27129. * * 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)
  27130. * * 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)
  27131. * @returns the VertexData of the box
  27132. */
  27133. static CreatePlane(options: {
  27134. size?: number;
  27135. width?: number;
  27136. height?: number;
  27137. sideOrientation?: number;
  27138. frontUVs?: Vector4;
  27139. backUVs?: Vector4;
  27140. }): VertexData;
  27141. /**
  27142. * Creates the VertexData of the Disc or regular Polygon
  27143. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27144. * * radius the radius of the disc, optional default 0.5
  27145. * * tessellation the number of polygon sides, optional, default 64
  27146. * * 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
  27147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27148. * * 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)
  27149. * * 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)
  27150. * @returns the VertexData of the box
  27151. */
  27152. static CreateDisc(options: {
  27153. radius?: number;
  27154. tessellation?: number;
  27155. arc?: number;
  27156. sideOrientation?: number;
  27157. frontUVs?: Vector4;
  27158. backUVs?: Vector4;
  27159. }): VertexData;
  27160. /**
  27161. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27162. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27163. * @param polygon a mesh built from polygonTriangulation.build()
  27164. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27165. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27166. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27167. * @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)
  27168. * @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)
  27169. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27170. * @returns the VertexData of the Polygon
  27171. */
  27172. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27173. /**
  27174. * Creates the VertexData of the IcoSphere
  27175. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27176. * * radius the radius of the IcoSphere, optional default 1
  27177. * * radiusX allows stretching in the x direction, optional, default radius
  27178. * * radiusY allows stretching in the y direction, optional, default radius
  27179. * * radiusZ allows stretching in the z direction, optional, default radius
  27180. * * flat when true creates a flat shaded mesh, optional, default true
  27181. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27183. * * 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)
  27184. * * 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)
  27185. * @returns the VertexData of the IcoSphere
  27186. */
  27187. static CreateIcoSphere(options: {
  27188. radius?: number;
  27189. radiusX?: number;
  27190. radiusY?: number;
  27191. radiusZ?: number;
  27192. flat?: boolean;
  27193. subdivisions?: number;
  27194. sideOrientation?: number;
  27195. frontUVs?: Vector4;
  27196. backUVs?: Vector4;
  27197. }): VertexData;
  27198. /**
  27199. * Creates the VertexData for a Polyhedron
  27200. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27201. * * type provided types are:
  27202. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27203. * * 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)
  27204. * * size the size of the IcoSphere, optional default 1
  27205. * * sizeX allows stretching in the x direction, optional, default size
  27206. * * sizeY allows stretching in the y direction, optional, default size
  27207. * * sizeZ allows stretching in the z direction, optional, default size
  27208. * * 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
  27209. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27210. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27211. * * flat when true creates a flat shaded mesh, optional, default true
  27212. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27214. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27215. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27216. * @returns the VertexData of the Polyhedron
  27217. */
  27218. static CreatePolyhedron(options: {
  27219. type?: number;
  27220. size?: number;
  27221. sizeX?: number;
  27222. sizeY?: number;
  27223. sizeZ?: number;
  27224. custom?: any;
  27225. faceUV?: Vector4[];
  27226. faceColors?: Color4[];
  27227. flat?: boolean;
  27228. sideOrientation?: number;
  27229. frontUVs?: Vector4;
  27230. backUVs?: Vector4;
  27231. }): VertexData;
  27232. /**
  27233. * Creates the VertexData for a TorusKnot
  27234. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27235. * * radius the radius of the torus knot, optional, default 2
  27236. * * tube the thickness of the tube, optional, default 0.5
  27237. * * radialSegments the number of sides on each tube segments, optional, default 32
  27238. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27239. * * p the number of windings around the z axis, optional, default 2
  27240. * * q the number of windings around the x axis, optional, default 3
  27241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27242. * * 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)
  27243. * * 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)
  27244. * @returns the VertexData of the Torus Knot
  27245. */
  27246. static CreateTorusKnot(options: {
  27247. radius?: number;
  27248. tube?: number;
  27249. radialSegments?: number;
  27250. tubularSegments?: number;
  27251. p?: number;
  27252. q?: number;
  27253. sideOrientation?: number;
  27254. frontUVs?: Vector4;
  27255. backUVs?: Vector4;
  27256. }): VertexData;
  27257. /**
  27258. * Compute normals for given positions and indices
  27259. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27260. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27261. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27262. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27263. * * facetNormals : optional array of facet normals (vector3)
  27264. * * facetPositions : optional array of facet positions (vector3)
  27265. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27266. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27267. * * bInfo : optional bounding info, required for facetPartitioning computation
  27268. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27269. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27270. * * useRightHandedSystem: optional boolean to for right handed system computation
  27271. * * depthSort : optional boolean to enable the facet depth sort computation
  27272. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27273. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27274. */
  27275. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27276. facetNormals?: any;
  27277. facetPositions?: any;
  27278. facetPartitioning?: any;
  27279. ratio?: number;
  27280. bInfo?: any;
  27281. bbSize?: Vector3;
  27282. subDiv?: any;
  27283. useRightHandedSystem?: boolean;
  27284. depthSort?: boolean;
  27285. distanceTo?: Vector3;
  27286. depthSortedFacets?: any;
  27287. }): void;
  27288. /** @hidden */
  27289. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27290. /**
  27291. * Applies VertexData created from the imported parameters to the geometry
  27292. * @param parsedVertexData the parsed data from an imported file
  27293. * @param geometry the geometry to apply the VertexData to
  27294. */
  27295. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27296. }
  27297. }
  27298. declare module "babylonjs/Morph/morphTarget" {
  27299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27300. import { Observable } from "babylonjs/Misc/observable";
  27301. import { Nullable, FloatArray } from "babylonjs/types";
  27302. import { Scene } from "babylonjs/scene";
  27303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27304. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27305. /**
  27306. * Defines a target to use with MorphTargetManager
  27307. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27308. */
  27309. export class MorphTarget implements IAnimatable {
  27310. /** defines the name of the target */
  27311. name: string;
  27312. /**
  27313. * Gets or sets the list of animations
  27314. */
  27315. animations: import("babylonjs/Animations/animation").Animation[];
  27316. private _scene;
  27317. private _positions;
  27318. private _normals;
  27319. private _tangents;
  27320. private _uvs;
  27321. private _influence;
  27322. private _uniqueId;
  27323. /**
  27324. * Observable raised when the influence changes
  27325. */
  27326. onInfluenceChanged: Observable<boolean>;
  27327. /** @hidden */
  27328. _onDataLayoutChanged: Observable<void>;
  27329. /**
  27330. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27331. */
  27332. get influence(): number;
  27333. set influence(influence: number);
  27334. /**
  27335. * Gets or sets the id of the morph Target
  27336. */
  27337. id: string;
  27338. private _animationPropertiesOverride;
  27339. /**
  27340. * Gets or sets the animation properties override
  27341. */
  27342. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27343. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27344. /**
  27345. * Creates a new MorphTarget
  27346. * @param name defines the name of the target
  27347. * @param influence defines the influence to use
  27348. * @param scene defines the scene the morphtarget belongs to
  27349. */
  27350. constructor(
  27351. /** defines the name of the target */
  27352. name: string, influence?: number, scene?: Nullable<Scene>);
  27353. /**
  27354. * Gets the unique ID of this manager
  27355. */
  27356. get uniqueId(): number;
  27357. /**
  27358. * Gets a boolean defining if the target contains position data
  27359. */
  27360. get hasPositions(): boolean;
  27361. /**
  27362. * Gets a boolean defining if the target contains normal data
  27363. */
  27364. get hasNormals(): boolean;
  27365. /**
  27366. * Gets a boolean defining if the target contains tangent data
  27367. */
  27368. get hasTangents(): boolean;
  27369. /**
  27370. * Gets a boolean defining if the target contains texture coordinates data
  27371. */
  27372. get hasUVs(): boolean;
  27373. /**
  27374. * Affects position data to this target
  27375. * @param data defines the position data to use
  27376. */
  27377. setPositions(data: Nullable<FloatArray>): void;
  27378. /**
  27379. * Gets the position data stored in this target
  27380. * @returns a FloatArray containing the position data (or null if not present)
  27381. */
  27382. getPositions(): Nullable<FloatArray>;
  27383. /**
  27384. * Affects normal data to this target
  27385. * @param data defines the normal data to use
  27386. */
  27387. setNormals(data: Nullable<FloatArray>): void;
  27388. /**
  27389. * Gets the normal data stored in this target
  27390. * @returns a FloatArray containing the normal data (or null if not present)
  27391. */
  27392. getNormals(): Nullable<FloatArray>;
  27393. /**
  27394. * Affects tangent data to this target
  27395. * @param data defines the tangent data to use
  27396. */
  27397. setTangents(data: Nullable<FloatArray>): void;
  27398. /**
  27399. * Gets the tangent data stored in this target
  27400. * @returns a FloatArray containing the tangent data (or null if not present)
  27401. */
  27402. getTangents(): Nullable<FloatArray>;
  27403. /**
  27404. * Affects texture coordinates data to this target
  27405. * @param data defines the texture coordinates data to use
  27406. */
  27407. setUVs(data: Nullable<FloatArray>): void;
  27408. /**
  27409. * Gets the texture coordinates data stored in this target
  27410. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27411. */
  27412. getUVs(): Nullable<FloatArray>;
  27413. /**
  27414. * Clone the current target
  27415. * @returns a new MorphTarget
  27416. */
  27417. clone(): MorphTarget;
  27418. /**
  27419. * Serializes the current target into a Serialization object
  27420. * @returns the serialized object
  27421. */
  27422. serialize(): any;
  27423. /**
  27424. * Returns the string "MorphTarget"
  27425. * @returns "MorphTarget"
  27426. */
  27427. getClassName(): string;
  27428. /**
  27429. * Creates a new target from serialized data
  27430. * @param serializationObject defines the serialized data to use
  27431. * @returns a new MorphTarget
  27432. */
  27433. static Parse(serializationObject: any): MorphTarget;
  27434. /**
  27435. * Creates a MorphTarget from mesh data
  27436. * @param mesh defines the source mesh
  27437. * @param name defines the name to use for the new target
  27438. * @param influence defines the influence to attach to the target
  27439. * @returns a new MorphTarget
  27440. */
  27441. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27442. }
  27443. }
  27444. declare module "babylonjs/Morph/morphTargetManager" {
  27445. import { Nullable } from "babylonjs/types";
  27446. import { Scene } from "babylonjs/scene";
  27447. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27448. /**
  27449. * This class is used to deform meshes using morphing between different targets
  27450. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27451. */
  27452. export class MorphTargetManager {
  27453. private _targets;
  27454. private _targetInfluenceChangedObservers;
  27455. private _targetDataLayoutChangedObservers;
  27456. private _activeTargets;
  27457. private _scene;
  27458. private _influences;
  27459. private _supportsNormals;
  27460. private _supportsTangents;
  27461. private _supportsUVs;
  27462. private _vertexCount;
  27463. private _uniqueId;
  27464. private _tempInfluences;
  27465. /**
  27466. * Gets or sets a boolean indicating if normals must be morphed
  27467. */
  27468. enableNormalMorphing: boolean;
  27469. /**
  27470. * Gets or sets a boolean indicating if tangents must be morphed
  27471. */
  27472. enableTangentMorphing: boolean;
  27473. /**
  27474. * Gets or sets a boolean indicating if UV must be morphed
  27475. */
  27476. enableUVMorphing: boolean;
  27477. /**
  27478. * Creates a new MorphTargetManager
  27479. * @param scene defines the current scene
  27480. */
  27481. constructor(scene?: Nullable<Scene>);
  27482. /**
  27483. * Gets the unique ID of this manager
  27484. */
  27485. get uniqueId(): number;
  27486. /**
  27487. * Gets the number of vertices handled by this manager
  27488. */
  27489. get vertexCount(): number;
  27490. /**
  27491. * Gets a boolean indicating if this manager supports morphing of normals
  27492. */
  27493. get supportsNormals(): boolean;
  27494. /**
  27495. * Gets a boolean indicating if this manager supports morphing of tangents
  27496. */
  27497. get supportsTangents(): boolean;
  27498. /**
  27499. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27500. */
  27501. get supportsUVs(): boolean;
  27502. /**
  27503. * Gets the number of targets stored in this manager
  27504. */
  27505. get numTargets(): number;
  27506. /**
  27507. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27508. */
  27509. get numInfluencers(): number;
  27510. /**
  27511. * Gets the list of influences (one per target)
  27512. */
  27513. get influences(): Float32Array;
  27514. /**
  27515. * Gets the active target at specified index. An active target is a target with an influence > 0
  27516. * @param index defines the index to check
  27517. * @returns the requested target
  27518. */
  27519. getActiveTarget(index: number): MorphTarget;
  27520. /**
  27521. * Gets the target at specified index
  27522. * @param index defines the index to check
  27523. * @returns the requested target
  27524. */
  27525. getTarget(index: number): MorphTarget;
  27526. /**
  27527. * Add a new target to this manager
  27528. * @param target defines the target to add
  27529. */
  27530. addTarget(target: MorphTarget): void;
  27531. /**
  27532. * Removes a target from the manager
  27533. * @param target defines the target to remove
  27534. */
  27535. removeTarget(target: MorphTarget): void;
  27536. /**
  27537. * Clone the current manager
  27538. * @returns a new MorphTargetManager
  27539. */
  27540. clone(): MorphTargetManager;
  27541. /**
  27542. * Serializes the current manager into a Serialization object
  27543. * @returns the serialized object
  27544. */
  27545. serialize(): any;
  27546. private _syncActiveTargets;
  27547. /**
  27548. * Syncrhonize the targets with all the meshes using this morph target manager
  27549. */
  27550. synchronize(): void;
  27551. /**
  27552. * Creates a new MorphTargetManager from serialized data
  27553. * @param serializationObject defines the serialized data
  27554. * @param scene defines the hosting scene
  27555. * @returns the new MorphTargetManager
  27556. */
  27557. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27558. }
  27559. }
  27560. declare module "babylonjs/Meshes/meshLODLevel" {
  27561. import { Mesh } from "babylonjs/Meshes/mesh";
  27562. import { Nullable } from "babylonjs/types";
  27563. /**
  27564. * Class used to represent a specific level of detail of a mesh
  27565. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27566. */
  27567. export class MeshLODLevel {
  27568. /** Defines the distance where this level should start being displayed */
  27569. distance: number;
  27570. /** Defines the mesh to use to render this level */
  27571. mesh: Nullable<Mesh>;
  27572. /**
  27573. * Creates a new LOD level
  27574. * @param distance defines the distance where this level should star being displayed
  27575. * @param mesh defines the mesh to use to render this level
  27576. */
  27577. constructor(
  27578. /** Defines the distance where this level should start being displayed */
  27579. distance: number,
  27580. /** Defines the mesh to use to render this level */
  27581. mesh: Nullable<Mesh>);
  27582. }
  27583. }
  27584. declare module "babylonjs/Misc/canvasGenerator" {
  27585. /**
  27586. * Helper class used to generate a canvas to manipulate images
  27587. */
  27588. export class CanvasGenerator {
  27589. /**
  27590. * Create a new canvas (or offscreen canvas depending on the context)
  27591. * @param width defines the expected width
  27592. * @param height defines the expected height
  27593. * @return a new canvas or offscreen canvas
  27594. */
  27595. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27596. }
  27597. }
  27598. declare module "babylonjs/Meshes/groundMesh" {
  27599. import { Scene } from "babylonjs/scene";
  27600. import { Vector3 } from "babylonjs/Maths/math.vector";
  27601. import { Mesh } from "babylonjs/Meshes/mesh";
  27602. /**
  27603. * Mesh representing the gorund
  27604. */
  27605. export class GroundMesh extends Mesh {
  27606. /** If octree should be generated */
  27607. generateOctree: boolean;
  27608. private _heightQuads;
  27609. /** @hidden */
  27610. _subdivisionsX: number;
  27611. /** @hidden */
  27612. _subdivisionsY: number;
  27613. /** @hidden */
  27614. _width: number;
  27615. /** @hidden */
  27616. _height: number;
  27617. /** @hidden */
  27618. _minX: number;
  27619. /** @hidden */
  27620. _maxX: number;
  27621. /** @hidden */
  27622. _minZ: number;
  27623. /** @hidden */
  27624. _maxZ: number;
  27625. constructor(name: string, scene: Scene);
  27626. /**
  27627. * "GroundMesh"
  27628. * @returns "GroundMesh"
  27629. */
  27630. getClassName(): string;
  27631. /**
  27632. * The minimum of x and y subdivisions
  27633. */
  27634. get subdivisions(): number;
  27635. /**
  27636. * X subdivisions
  27637. */
  27638. get subdivisionsX(): number;
  27639. /**
  27640. * Y subdivisions
  27641. */
  27642. get subdivisionsY(): number;
  27643. /**
  27644. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27645. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27646. * @param chunksCount the number of subdivisions for x and y
  27647. * @param octreeBlocksSize (Default: 32)
  27648. */
  27649. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27650. /**
  27651. * Returns a height (y) value in the Worl system :
  27652. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27653. * @param x x coordinate
  27654. * @param z z coordinate
  27655. * @returns the ground y position if (x, z) are outside the ground surface.
  27656. */
  27657. getHeightAtCoordinates(x: number, z: number): number;
  27658. /**
  27659. * Returns a normalized vector (Vector3) orthogonal to the ground
  27660. * at the ground coordinates (x, z) expressed in the World system.
  27661. * @param x x coordinate
  27662. * @param z z coordinate
  27663. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27664. */
  27665. getNormalAtCoordinates(x: number, z: number): Vector3;
  27666. /**
  27667. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27668. * at the ground coordinates (x, z) expressed in the World system.
  27669. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27670. * @param x x coordinate
  27671. * @param z z coordinate
  27672. * @param ref vector to store the result
  27673. * @returns the GroundMesh.
  27674. */
  27675. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27676. /**
  27677. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27678. * if the ground has been updated.
  27679. * This can be used in the render loop.
  27680. * @returns the GroundMesh.
  27681. */
  27682. updateCoordinateHeights(): GroundMesh;
  27683. private _getFacetAt;
  27684. private _initHeightQuads;
  27685. private _computeHeightQuads;
  27686. /**
  27687. * Serializes this ground mesh
  27688. * @param serializationObject object to write serialization to
  27689. */
  27690. serialize(serializationObject: any): void;
  27691. /**
  27692. * Parses a serialized ground mesh
  27693. * @param parsedMesh the serialized mesh
  27694. * @param scene the scene to create the ground mesh in
  27695. * @returns the created ground mesh
  27696. */
  27697. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27698. }
  27699. }
  27700. declare module "babylonjs/Physics/physicsJoint" {
  27701. import { Vector3 } from "babylonjs/Maths/math.vector";
  27702. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27703. /**
  27704. * Interface for Physics-Joint data
  27705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27706. */
  27707. export interface PhysicsJointData {
  27708. /**
  27709. * The main pivot of the joint
  27710. */
  27711. mainPivot?: Vector3;
  27712. /**
  27713. * The connected pivot of the joint
  27714. */
  27715. connectedPivot?: Vector3;
  27716. /**
  27717. * The main axis of the joint
  27718. */
  27719. mainAxis?: Vector3;
  27720. /**
  27721. * The connected axis of the joint
  27722. */
  27723. connectedAxis?: Vector3;
  27724. /**
  27725. * The collision of the joint
  27726. */
  27727. collision?: boolean;
  27728. /**
  27729. * Native Oimo/Cannon/Energy data
  27730. */
  27731. nativeParams?: any;
  27732. }
  27733. /**
  27734. * This is a holder class for the physics joint created by the physics plugin
  27735. * It holds a set of functions to control the underlying joint
  27736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27737. */
  27738. export class PhysicsJoint {
  27739. /**
  27740. * The type of the physics joint
  27741. */
  27742. type: number;
  27743. /**
  27744. * The data for the physics joint
  27745. */
  27746. jointData: PhysicsJointData;
  27747. private _physicsJoint;
  27748. protected _physicsPlugin: IPhysicsEnginePlugin;
  27749. /**
  27750. * Initializes the physics joint
  27751. * @param type The type of the physics joint
  27752. * @param jointData The data for the physics joint
  27753. */
  27754. constructor(
  27755. /**
  27756. * The type of the physics joint
  27757. */
  27758. type: number,
  27759. /**
  27760. * The data for the physics joint
  27761. */
  27762. jointData: PhysicsJointData);
  27763. /**
  27764. * Gets the physics joint
  27765. */
  27766. get physicsJoint(): any;
  27767. /**
  27768. * Sets the physics joint
  27769. */
  27770. set physicsJoint(newJoint: any);
  27771. /**
  27772. * Sets the physics plugin
  27773. */
  27774. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27775. /**
  27776. * Execute a function that is physics-plugin specific.
  27777. * @param {Function} func the function that will be executed.
  27778. * It accepts two parameters: the physics world and the physics joint
  27779. */
  27780. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27781. /**
  27782. * Distance-Joint type
  27783. */
  27784. static DistanceJoint: number;
  27785. /**
  27786. * Hinge-Joint type
  27787. */
  27788. static HingeJoint: number;
  27789. /**
  27790. * Ball-and-Socket joint type
  27791. */
  27792. static BallAndSocketJoint: number;
  27793. /**
  27794. * Wheel-Joint type
  27795. */
  27796. static WheelJoint: number;
  27797. /**
  27798. * Slider-Joint type
  27799. */
  27800. static SliderJoint: number;
  27801. /**
  27802. * Prismatic-Joint type
  27803. */
  27804. static PrismaticJoint: number;
  27805. /**
  27806. * Universal-Joint type
  27807. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27808. */
  27809. static UniversalJoint: number;
  27810. /**
  27811. * Hinge-Joint 2 type
  27812. */
  27813. static Hinge2Joint: number;
  27814. /**
  27815. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27816. */
  27817. static PointToPointJoint: number;
  27818. /**
  27819. * Spring-Joint type
  27820. */
  27821. static SpringJoint: number;
  27822. /**
  27823. * Lock-Joint type
  27824. */
  27825. static LockJoint: number;
  27826. }
  27827. /**
  27828. * A class representing a physics distance joint
  27829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27830. */
  27831. export class DistanceJoint extends PhysicsJoint {
  27832. /**
  27833. *
  27834. * @param jointData The data for the Distance-Joint
  27835. */
  27836. constructor(jointData: DistanceJointData);
  27837. /**
  27838. * Update the predefined distance.
  27839. * @param maxDistance The maximum preferred distance
  27840. * @param minDistance The minimum preferred distance
  27841. */
  27842. updateDistance(maxDistance: number, minDistance?: number): void;
  27843. }
  27844. /**
  27845. * Represents a Motor-Enabled Joint
  27846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27847. */
  27848. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27849. /**
  27850. * Initializes the Motor-Enabled Joint
  27851. * @param type The type of the joint
  27852. * @param jointData The physica joint data for the joint
  27853. */
  27854. constructor(type: number, jointData: PhysicsJointData);
  27855. /**
  27856. * Set the motor values.
  27857. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27858. * @param force the force to apply
  27859. * @param maxForce max force for this motor.
  27860. */
  27861. setMotor(force?: number, maxForce?: number): void;
  27862. /**
  27863. * Set the motor's limits.
  27864. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27865. * @param upperLimit The upper limit of the motor
  27866. * @param lowerLimit The lower limit of the motor
  27867. */
  27868. setLimit(upperLimit: number, lowerLimit?: number): void;
  27869. }
  27870. /**
  27871. * This class represents a single physics Hinge-Joint
  27872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27873. */
  27874. export class HingeJoint extends MotorEnabledJoint {
  27875. /**
  27876. * Initializes the Hinge-Joint
  27877. * @param jointData The joint data for the Hinge-Joint
  27878. */
  27879. constructor(jointData: PhysicsJointData);
  27880. /**
  27881. * Set the motor values.
  27882. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27883. * @param {number} force the force to apply
  27884. * @param {number} maxForce max force for this motor.
  27885. */
  27886. setMotor(force?: number, maxForce?: number): void;
  27887. /**
  27888. * Set the motor's limits.
  27889. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27890. * @param upperLimit The upper limit of the motor
  27891. * @param lowerLimit The lower limit of the motor
  27892. */
  27893. setLimit(upperLimit: number, lowerLimit?: number): void;
  27894. }
  27895. /**
  27896. * This class represents a dual hinge physics joint (same as wheel joint)
  27897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27898. */
  27899. export class Hinge2Joint extends MotorEnabledJoint {
  27900. /**
  27901. * Initializes the Hinge2-Joint
  27902. * @param jointData The joint data for the Hinge2-Joint
  27903. */
  27904. constructor(jointData: PhysicsJointData);
  27905. /**
  27906. * Set the motor values.
  27907. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27908. * @param {number} targetSpeed the speed the motor is to reach
  27909. * @param {number} maxForce max force for this motor.
  27910. * @param {motorIndex} the motor's index, 0 or 1.
  27911. */
  27912. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27913. /**
  27914. * Set the motor limits.
  27915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27916. * @param {number} upperLimit the upper limit
  27917. * @param {number} lowerLimit lower limit
  27918. * @param {motorIndex} the motor's index, 0 or 1.
  27919. */
  27920. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27921. }
  27922. /**
  27923. * Interface for a motor enabled joint
  27924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27925. */
  27926. export interface IMotorEnabledJoint {
  27927. /**
  27928. * Physics joint
  27929. */
  27930. physicsJoint: any;
  27931. /**
  27932. * Sets the motor of the motor-enabled joint
  27933. * @param force The force of the motor
  27934. * @param maxForce The maximum force of the motor
  27935. * @param motorIndex The index of the motor
  27936. */
  27937. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27938. /**
  27939. * Sets the limit of the motor
  27940. * @param upperLimit The upper limit of the motor
  27941. * @param lowerLimit The lower limit of the motor
  27942. * @param motorIndex The index of the motor
  27943. */
  27944. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27945. }
  27946. /**
  27947. * Joint data for a Distance-Joint
  27948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27949. */
  27950. export interface DistanceJointData extends PhysicsJointData {
  27951. /**
  27952. * Max distance the 2 joint objects can be apart
  27953. */
  27954. maxDistance: number;
  27955. }
  27956. /**
  27957. * Joint data from a spring joint
  27958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27959. */
  27960. export interface SpringJointData extends PhysicsJointData {
  27961. /**
  27962. * Length of the spring
  27963. */
  27964. length: number;
  27965. /**
  27966. * Stiffness of the spring
  27967. */
  27968. stiffness: number;
  27969. /**
  27970. * Damping of the spring
  27971. */
  27972. damping: number;
  27973. /** this callback will be called when applying the force to the impostors. */
  27974. forceApplicationCallback: () => void;
  27975. }
  27976. }
  27977. declare module "babylonjs/Physics/physicsRaycastResult" {
  27978. import { Vector3 } from "babylonjs/Maths/math.vector";
  27979. /**
  27980. * Holds the data for the raycast result
  27981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27982. */
  27983. export class PhysicsRaycastResult {
  27984. private _hasHit;
  27985. private _hitDistance;
  27986. private _hitNormalWorld;
  27987. private _hitPointWorld;
  27988. private _rayFromWorld;
  27989. private _rayToWorld;
  27990. /**
  27991. * Gets if there was a hit
  27992. */
  27993. get hasHit(): boolean;
  27994. /**
  27995. * Gets the distance from the hit
  27996. */
  27997. get hitDistance(): number;
  27998. /**
  27999. * Gets the hit normal/direction in the world
  28000. */
  28001. get hitNormalWorld(): Vector3;
  28002. /**
  28003. * Gets the hit point in the world
  28004. */
  28005. get hitPointWorld(): Vector3;
  28006. /**
  28007. * Gets the ray "start point" of the ray in the world
  28008. */
  28009. get rayFromWorld(): Vector3;
  28010. /**
  28011. * Gets the ray "end point" of the ray in the world
  28012. */
  28013. get rayToWorld(): Vector3;
  28014. /**
  28015. * Sets the hit data (normal & point in world space)
  28016. * @param hitNormalWorld defines the normal in world space
  28017. * @param hitPointWorld defines the point in world space
  28018. */
  28019. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28020. /**
  28021. * Sets the distance from the start point to the hit point
  28022. * @param distance
  28023. */
  28024. setHitDistance(distance: number): void;
  28025. /**
  28026. * Calculates the distance manually
  28027. */
  28028. calculateHitDistance(): void;
  28029. /**
  28030. * Resets all the values to default
  28031. * @param from The from point on world space
  28032. * @param to The to point on world space
  28033. */
  28034. reset(from?: Vector3, to?: Vector3): void;
  28035. }
  28036. /**
  28037. * Interface for the size containing width and height
  28038. */
  28039. interface IXYZ {
  28040. /**
  28041. * X
  28042. */
  28043. x: number;
  28044. /**
  28045. * Y
  28046. */
  28047. y: number;
  28048. /**
  28049. * Z
  28050. */
  28051. z: number;
  28052. }
  28053. }
  28054. declare module "babylonjs/Physics/IPhysicsEngine" {
  28055. import { Nullable } from "babylonjs/types";
  28056. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28058. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28059. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28060. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28061. /**
  28062. * Interface used to describe a physics joint
  28063. */
  28064. export interface PhysicsImpostorJoint {
  28065. /** Defines the main impostor to which the joint is linked */
  28066. mainImpostor: PhysicsImpostor;
  28067. /** Defines the impostor that is connected to the main impostor using this joint */
  28068. connectedImpostor: PhysicsImpostor;
  28069. /** Defines the joint itself */
  28070. joint: PhysicsJoint;
  28071. }
  28072. /** @hidden */
  28073. export interface IPhysicsEnginePlugin {
  28074. world: any;
  28075. name: string;
  28076. setGravity(gravity: Vector3): void;
  28077. setTimeStep(timeStep: number): void;
  28078. getTimeStep(): number;
  28079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28080. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28081. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28082. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28083. removePhysicsBody(impostor: PhysicsImpostor): void;
  28084. generateJoint(joint: PhysicsImpostorJoint): void;
  28085. removeJoint(joint: PhysicsImpostorJoint): void;
  28086. isSupported(): boolean;
  28087. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28088. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28089. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28090. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28091. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28092. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28093. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28094. getBodyMass(impostor: PhysicsImpostor): number;
  28095. getBodyFriction(impostor: PhysicsImpostor): number;
  28096. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28097. getBodyRestitution(impostor: PhysicsImpostor): number;
  28098. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28099. getBodyPressure?(impostor: PhysicsImpostor): number;
  28100. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28101. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28102. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28103. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28104. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28105. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28106. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28107. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28108. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28109. sleepBody(impostor: PhysicsImpostor): void;
  28110. wakeUpBody(impostor: PhysicsImpostor): void;
  28111. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28112. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28113. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28114. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28115. getRadius(impostor: PhysicsImpostor): number;
  28116. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28117. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28118. dispose(): void;
  28119. }
  28120. /**
  28121. * Interface used to define a physics engine
  28122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28123. */
  28124. export interface IPhysicsEngine {
  28125. /**
  28126. * Gets the gravity vector used by the simulation
  28127. */
  28128. gravity: Vector3;
  28129. /**
  28130. * Sets the gravity vector used by the simulation
  28131. * @param gravity defines the gravity vector to use
  28132. */
  28133. setGravity(gravity: Vector3): void;
  28134. /**
  28135. * Set the time step of the physics engine.
  28136. * Default is 1/60.
  28137. * To slow it down, enter 1/600 for example.
  28138. * To speed it up, 1/30
  28139. * @param newTimeStep the new timestep to apply to this world.
  28140. */
  28141. setTimeStep(newTimeStep: number): void;
  28142. /**
  28143. * Get the time step of the physics engine.
  28144. * @returns the current time step
  28145. */
  28146. getTimeStep(): number;
  28147. /**
  28148. * Set the sub time step of the physics engine.
  28149. * Default is 0 meaning there is no sub steps
  28150. * To increase physics resolution precision, set a small value (like 1 ms)
  28151. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28152. */
  28153. setSubTimeStep(subTimeStep: number): void;
  28154. /**
  28155. * Get the sub time step of the physics engine.
  28156. * @returns the current sub time step
  28157. */
  28158. getSubTimeStep(): number;
  28159. /**
  28160. * Release all resources
  28161. */
  28162. dispose(): void;
  28163. /**
  28164. * Gets the name of the current physics plugin
  28165. * @returns the name of the plugin
  28166. */
  28167. getPhysicsPluginName(): string;
  28168. /**
  28169. * Adding a new impostor for the impostor tracking.
  28170. * This will be done by the impostor itself.
  28171. * @param impostor the impostor to add
  28172. */
  28173. addImpostor(impostor: PhysicsImpostor): void;
  28174. /**
  28175. * Remove an impostor from the engine.
  28176. * This impostor and its mesh will not longer be updated by the physics engine.
  28177. * @param impostor the impostor to remove
  28178. */
  28179. removeImpostor(impostor: PhysicsImpostor): void;
  28180. /**
  28181. * Add a joint to the physics engine
  28182. * @param mainImpostor defines the main impostor to which the joint is added.
  28183. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28184. * @param joint defines the joint that will connect both impostors.
  28185. */
  28186. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28187. /**
  28188. * Removes a joint from the simulation
  28189. * @param mainImpostor defines the impostor used with the joint
  28190. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28191. * @param joint defines the joint to remove
  28192. */
  28193. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28194. /**
  28195. * Gets the current plugin used to run the simulation
  28196. * @returns current plugin
  28197. */
  28198. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28199. /**
  28200. * Gets the list of physic impostors
  28201. * @returns an array of PhysicsImpostor
  28202. */
  28203. getImpostors(): Array<PhysicsImpostor>;
  28204. /**
  28205. * Gets the impostor for a physics enabled object
  28206. * @param object defines the object impersonated by the impostor
  28207. * @returns the PhysicsImpostor or null if not found
  28208. */
  28209. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28210. /**
  28211. * Gets the impostor for a physics body object
  28212. * @param body defines physics body used by the impostor
  28213. * @returns the PhysicsImpostor or null if not found
  28214. */
  28215. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28216. /**
  28217. * Does a raycast in the physics world
  28218. * @param from when should the ray start?
  28219. * @param to when should the ray end?
  28220. * @returns PhysicsRaycastResult
  28221. */
  28222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28223. /**
  28224. * Called by the scene. No need to call it.
  28225. * @param delta defines the timespam between frames
  28226. */
  28227. _step(delta: number): void;
  28228. }
  28229. }
  28230. declare module "babylonjs/Physics/physicsImpostor" {
  28231. import { Nullable, IndicesArray } from "babylonjs/types";
  28232. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28233. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28235. import { Scene } from "babylonjs/scene";
  28236. import { Bone } from "babylonjs/Bones/bone";
  28237. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28238. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28239. import { Space } from "babylonjs/Maths/math.axis";
  28240. /**
  28241. * The interface for the physics imposter parameters
  28242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28243. */
  28244. export interface PhysicsImpostorParameters {
  28245. /**
  28246. * The mass of the physics imposter
  28247. */
  28248. mass: number;
  28249. /**
  28250. * The friction of the physics imposter
  28251. */
  28252. friction?: number;
  28253. /**
  28254. * The coefficient of restitution of the physics imposter
  28255. */
  28256. restitution?: number;
  28257. /**
  28258. * The native options of the physics imposter
  28259. */
  28260. nativeOptions?: any;
  28261. /**
  28262. * Specifies if the parent should be ignored
  28263. */
  28264. ignoreParent?: boolean;
  28265. /**
  28266. * Specifies if bi-directional transformations should be disabled
  28267. */
  28268. disableBidirectionalTransformation?: boolean;
  28269. /**
  28270. * The pressure inside the physics imposter, soft object only
  28271. */
  28272. pressure?: number;
  28273. /**
  28274. * The stiffness the physics imposter, soft object only
  28275. */
  28276. stiffness?: number;
  28277. /**
  28278. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28279. */
  28280. velocityIterations?: number;
  28281. /**
  28282. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28283. */
  28284. positionIterations?: number;
  28285. /**
  28286. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28287. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28288. * Add to fix multiple points
  28289. */
  28290. fixedPoints?: number;
  28291. /**
  28292. * The collision margin around a soft object
  28293. */
  28294. margin?: number;
  28295. /**
  28296. * The collision margin around a soft object
  28297. */
  28298. damping?: number;
  28299. /**
  28300. * The path for a rope based on an extrusion
  28301. */
  28302. path?: any;
  28303. /**
  28304. * The shape of an extrusion used for a rope based on an extrusion
  28305. */
  28306. shape?: any;
  28307. }
  28308. /**
  28309. * Interface for a physics-enabled object
  28310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28311. */
  28312. export interface IPhysicsEnabledObject {
  28313. /**
  28314. * The position of the physics-enabled object
  28315. */
  28316. position: Vector3;
  28317. /**
  28318. * The rotation of the physics-enabled object
  28319. */
  28320. rotationQuaternion: Nullable<Quaternion>;
  28321. /**
  28322. * The scale of the physics-enabled object
  28323. */
  28324. scaling: Vector3;
  28325. /**
  28326. * The rotation of the physics-enabled object
  28327. */
  28328. rotation?: Vector3;
  28329. /**
  28330. * The parent of the physics-enabled object
  28331. */
  28332. parent?: any;
  28333. /**
  28334. * The bounding info of the physics-enabled object
  28335. * @returns The bounding info of the physics-enabled object
  28336. */
  28337. getBoundingInfo(): BoundingInfo;
  28338. /**
  28339. * Computes the world matrix
  28340. * @param force Specifies if the world matrix should be computed by force
  28341. * @returns A world matrix
  28342. */
  28343. computeWorldMatrix(force: boolean): Matrix;
  28344. /**
  28345. * Gets the world matrix
  28346. * @returns A world matrix
  28347. */
  28348. getWorldMatrix?(): Matrix;
  28349. /**
  28350. * Gets the child meshes
  28351. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28352. * @returns An array of abstract meshes
  28353. */
  28354. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28355. /**
  28356. * Gets the vertex data
  28357. * @param kind The type of vertex data
  28358. * @returns A nullable array of numbers, or a float32 array
  28359. */
  28360. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28361. /**
  28362. * Gets the indices from the mesh
  28363. * @returns A nullable array of index arrays
  28364. */
  28365. getIndices?(): Nullable<IndicesArray>;
  28366. /**
  28367. * Gets the scene from the mesh
  28368. * @returns the indices array or null
  28369. */
  28370. getScene?(): Scene;
  28371. /**
  28372. * Gets the absolute position from the mesh
  28373. * @returns the absolute position
  28374. */
  28375. getAbsolutePosition(): Vector3;
  28376. /**
  28377. * Gets the absolute pivot point from the mesh
  28378. * @returns the absolute pivot point
  28379. */
  28380. getAbsolutePivotPoint(): Vector3;
  28381. /**
  28382. * Rotates the mesh
  28383. * @param axis The axis of rotation
  28384. * @param amount The amount of rotation
  28385. * @param space The space of the rotation
  28386. * @returns The rotation transform node
  28387. */
  28388. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28389. /**
  28390. * Translates the mesh
  28391. * @param axis The axis of translation
  28392. * @param distance The distance of translation
  28393. * @param space The space of the translation
  28394. * @returns The transform node
  28395. */
  28396. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28397. /**
  28398. * Sets the absolute position of the mesh
  28399. * @param absolutePosition The absolute position of the mesh
  28400. * @returns The transform node
  28401. */
  28402. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28403. /**
  28404. * Gets the class name of the mesh
  28405. * @returns The class name
  28406. */
  28407. getClassName(): string;
  28408. }
  28409. /**
  28410. * Represents a physics imposter
  28411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28412. */
  28413. export class PhysicsImpostor {
  28414. /**
  28415. * The physics-enabled object used as the physics imposter
  28416. */
  28417. object: IPhysicsEnabledObject;
  28418. /**
  28419. * The type of the physics imposter
  28420. */
  28421. type: number;
  28422. private _options;
  28423. private _scene?;
  28424. /**
  28425. * The default object size of the imposter
  28426. */
  28427. static DEFAULT_OBJECT_SIZE: Vector3;
  28428. /**
  28429. * The identity quaternion of the imposter
  28430. */
  28431. static IDENTITY_QUATERNION: Quaternion;
  28432. /** @hidden */
  28433. _pluginData: any;
  28434. private _physicsEngine;
  28435. private _physicsBody;
  28436. private _bodyUpdateRequired;
  28437. private _onBeforePhysicsStepCallbacks;
  28438. private _onAfterPhysicsStepCallbacks;
  28439. /** @hidden */
  28440. _onPhysicsCollideCallbacks: Array<{
  28441. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28442. otherImpostors: Array<PhysicsImpostor>;
  28443. }>;
  28444. private _deltaPosition;
  28445. private _deltaRotation;
  28446. private _deltaRotationConjugated;
  28447. /** @hidden */
  28448. _isFromLine: boolean;
  28449. private _parent;
  28450. private _isDisposed;
  28451. private static _tmpVecs;
  28452. private static _tmpQuat;
  28453. /**
  28454. * Specifies if the physics imposter is disposed
  28455. */
  28456. get isDisposed(): boolean;
  28457. /**
  28458. * Gets the mass of the physics imposter
  28459. */
  28460. get mass(): number;
  28461. set mass(value: number);
  28462. /**
  28463. * Gets the coefficient of friction
  28464. */
  28465. get friction(): number;
  28466. /**
  28467. * Sets the coefficient of friction
  28468. */
  28469. set friction(value: number);
  28470. /**
  28471. * Gets the coefficient of restitution
  28472. */
  28473. get restitution(): number;
  28474. /**
  28475. * Sets the coefficient of restitution
  28476. */
  28477. set restitution(value: number);
  28478. /**
  28479. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28480. */
  28481. get pressure(): number;
  28482. /**
  28483. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28484. */
  28485. set pressure(value: number);
  28486. /**
  28487. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28488. */
  28489. get stiffness(): number;
  28490. /**
  28491. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28492. */
  28493. set stiffness(value: number);
  28494. /**
  28495. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28496. */
  28497. get velocityIterations(): number;
  28498. /**
  28499. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28500. */
  28501. set velocityIterations(value: number);
  28502. /**
  28503. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28504. */
  28505. get positionIterations(): number;
  28506. /**
  28507. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28508. */
  28509. set positionIterations(value: number);
  28510. /**
  28511. * The unique id of the physics imposter
  28512. * set by the physics engine when adding this impostor to the array
  28513. */
  28514. uniqueId: number;
  28515. /**
  28516. * @hidden
  28517. */
  28518. soft: boolean;
  28519. /**
  28520. * @hidden
  28521. */
  28522. segments: number;
  28523. private _joints;
  28524. /**
  28525. * Initializes the physics imposter
  28526. * @param object The physics-enabled object used as the physics imposter
  28527. * @param type The type of the physics imposter
  28528. * @param _options The options for the physics imposter
  28529. * @param _scene The Babylon scene
  28530. */
  28531. constructor(
  28532. /**
  28533. * The physics-enabled object used as the physics imposter
  28534. */
  28535. object: IPhysicsEnabledObject,
  28536. /**
  28537. * The type of the physics imposter
  28538. */
  28539. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28540. /**
  28541. * This function will completly initialize this impostor.
  28542. * It will create a new body - but only if this mesh has no parent.
  28543. * If it has, this impostor will not be used other than to define the impostor
  28544. * of the child mesh.
  28545. * @hidden
  28546. */
  28547. _init(): void;
  28548. private _getPhysicsParent;
  28549. /**
  28550. * Should a new body be generated.
  28551. * @returns boolean specifying if body initialization is required
  28552. */
  28553. isBodyInitRequired(): boolean;
  28554. /**
  28555. * Sets the updated scaling
  28556. * @param updated Specifies if the scaling is updated
  28557. */
  28558. setScalingUpdated(): void;
  28559. /**
  28560. * Force a regeneration of this or the parent's impostor's body.
  28561. * Use under cautious - This will remove all joints already implemented.
  28562. */
  28563. forceUpdate(): void;
  28564. /**
  28565. * Gets the body that holds this impostor. Either its own, or its parent.
  28566. */
  28567. get physicsBody(): any;
  28568. /**
  28569. * Get the parent of the physics imposter
  28570. * @returns Physics imposter or null
  28571. */
  28572. get parent(): Nullable<PhysicsImpostor>;
  28573. /**
  28574. * Sets the parent of the physics imposter
  28575. */
  28576. set parent(value: Nullable<PhysicsImpostor>);
  28577. /**
  28578. * Set the physics body. Used mainly by the physics engine/plugin
  28579. */
  28580. set physicsBody(physicsBody: any);
  28581. /**
  28582. * Resets the update flags
  28583. */
  28584. resetUpdateFlags(): void;
  28585. /**
  28586. * Gets the object extend size
  28587. * @returns the object extend size
  28588. */
  28589. getObjectExtendSize(): Vector3;
  28590. /**
  28591. * Gets the object center
  28592. * @returns The object center
  28593. */
  28594. getObjectCenter(): Vector3;
  28595. /**
  28596. * Get a specific parameter from the options parameters
  28597. * @param paramName The object parameter name
  28598. * @returns The object parameter
  28599. */
  28600. getParam(paramName: string): any;
  28601. /**
  28602. * Sets a specific parameter in the options given to the physics plugin
  28603. * @param paramName The parameter name
  28604. * @param value The value of the parameter
  28605. */
  28606. setParam(paramName: string, value: number): void;
  28607. /**
  28608. * Specifically change the body's mass option. Won't recreate the physics body object
  28609. * @param mass The mass of the physics imposter
  28610. */
  28611. setMass(mass: number): void;
  28612. /**
  28613. * Gets the linear velocity
  28614. * @returns linear velocity or null
  28615. */
  28616. getLinearVelocity(): Nullable<Vector3>;
  28617. /**
  28618. * Sets the linear velocity
  28619. * @param velocity linear velocity or null
  28620. */
  28621. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28622. /**
  28623. * Gets the angular velocity
  28624. * @returns angular velocity or null
  28625. */
  28626. getAngularVelocity(): Nullable<Vector3>;
  28627. /**
  28628. * Sets the angular velocity
  28629. * @param velocity The velocity or null
  28630. */
  28631. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28632. /**
  28633. * Execute a function with the physics plugin native code
  28634. * Provide a function the will have two variables - the world object and the physics body object
  28635. * @param func The function to execute with the physics plugin native code
  28636. */
  28637. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28638. /**
  28639. * Register a function that will be executed before the physics world is stepping forward
  28640. * @param func The function to execute before the physics world is stepped forward
  28641. */
  28642. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28643. /**
  28644. * Unregister a function that will be executed before the physics world is stepping forward
  28645. * @param func The function to execute before the physics world is stepped forward
  28646. */
  28647. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28648. /**
  28649. * Register a function that will be executed after the physics step
  28650. * @param func The function to execute after physics step
  28651. */
  28652. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28653. /**
  28654. * Unregisters a function that will be executed after the physics step
  28655. * @param func The function to execute after physics step
  28656. */
  28657. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28658. /**
  28659. * register a function that will be executed when this impostor collides against a different body
  28660. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28661. * @param func Callback that is executed on collision
  28662. */
  28663. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28664. /**
  28665. * Unregisters the physics imposter on contact
  28666. * @param collideAgainst The physics object to collide against
  28667. * @param func Callback to execute on collision
  28668. */
  28669. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28670. private _tmpQuat;
  28671. private _tmpQuat2;
  28672. /**
  28673. * Get the parent rotation
  28674. * @returns The parent rotation
  28675. */
  28676. getParentsRotation(): Quaternion;
  28677. /**
  28678. * this function is executed by the physics engine.
  28679. */
  28680. beforeStep: () => void;
  28681. /**
  28682. * this function is executed by the physics engine
  28683. */
  28684. afterStep: () => void;
  28685. /**
  28686. * Legacy collision detection event support
  28687. */
  28688. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28689. /**
  28690. * event and body object due to cannon's event-based architecture.
  28691. */
  28692. onCollide: (e: {
  28693. body: any;
  28694. }) => void;
  28695. /**
  28696. * Apply a force
  28697. * @param force The force to apply
  28698. * @param contactPoint The contact point for the force
  28699. * @returns The physics imposter
  28700. */
  28701. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28702. /**
  28703. * Apply an impulse
  28704. * @param force The impulse force
  28705. * @param contactPoint The contact point for the impulse force
  28706. * @returns The physics imposter
  28707. */
  28708. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28709. /**
  28710. * A help function to create a joint
  28711. * @param otherImpostor A physics imposter used to create a joint
  28712. * @param jointType The type of joint
  28713. * @param jointData The data for the joint
  28714. * @returns The physics imposter
  28715. */
  28716. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28717. /**
  28718. * Add a joint to this impostor with a different impostor
  28719. * @param otherImpostor A physics imposter used to add a joint
  28720. * @param joint The joint to add
  28721. * @returns The physics imposter
  28722. */
  28723. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28724. /**
  28725. * Add an anchor to a cloth impostor
  28726. * @param otherImpostor rigid impostor to anchor to
  28727. * @param width ratio across width from 0 to 1
  28728. * @param height ratio up height from 0 to 1
  28729. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28730. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28731. * @returns impostor the soft imposter
  28732. */
  28733. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28734. /**
  28735. * Add a hook to a rope impostor
  28736. * @param otherImpostor rigid impostor to anchor to
  28737. * @param length ratio across rope from 0 to 1
  28738. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28739. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28740. * @returns impostor the rope imposter
  28741. */
  28742. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28743. /**
  28744. * Will keep this body still, in a sleep mode.
  28745. * @returns the physics imposter
  28746. */
  28747. sleep(): PhysicsImpostor;
  28748. /**
  28749. * Wake the body up.
  28750. * @returns The physics imposter
  28751. */
  28752. wakeUp(): PhysicsImpostor;
  28753. /**
  28754. * Clones the physics imposter
  28755. * @param newObject The physics imposter clones to this physics-enabled object
  28756. * @returns A nullable physics imposter
  28757. */
  28758. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28759. /**
  28760. * Disposes the physics imposter
  28761. */
  28762. dispose(): void;
  28763. /**
  28764. * Sets the delta position
  28765. * @param position The delta position amount
  28766. */
  28767. setDeltaPosition(position: Vector3): void;
  28768. /**
  28769. * Sets the delta rotation
  28770. * @param rotation The delta rotation amount
  28771. */
  28772. setDeltaRotation(rotation: Quaternion): void;
  28773. /**
  28774. * Gets the box size of the physics imposter and stores the result in the input parameter
  28775. * @param result Stores the box size
  28776. * @returns The physics imposter
  28777. */
  28778. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28779. /**
  28780. * Gets the radius of the physics imposter
  28781. * @returns Radius of the physics imposter
  28782. */
  28783. getRadius(): number;
  28784. /**
  28785. * Sync a bone with this impostor
  28786. * @param bone The bone to sync to the impostor.
  28787. * @param boneMesh The mesh that the bone is influencing.
  28788. * @param jointPivot The pivot of the joint / bone in local space.
  28789. * @param distToJoint Optional distance from the impostor to the joint.
  28790. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28791. */
  28792. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28793. /**
  28794. * Sync impostor to a bone
  28795. * @param bone The bone that the impostor will be synced to.
  28796. * @param boneMesh The mesh that the bone is influencing.
  28797. * @param jointPivot The pivot of the joint / bone in local space.
  28798. * @param distToJoint Optional distance from the impostor to the joint.
  28799. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28800. * @param boneAxis Optional vector3 axis the bone is aligned with
  28801. */
  28802. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28803. /**
  28804. * No-Imposter type
  28805. */
  28806. static NoImpostor: number;
  28807. /**
  28808. * Sphere-Imposter type
  28809. */
  28810. static SphereImpostor: number;
  28811. /**
  28812. * Box-Imposter type
  28813. */
  28814. static BoxImpostor: number;
  28815. /**
  28816. * Plane-Imposter type
  28817. */
  28818. static PlaneImpostor: number;
  28819. /**
  28820. * Mesh-imposter type
  28821. */
  28822. static MeshImpostor: number;
  28823. /**
  28824. * Capsule-Impostor type (Ammo.js plugin only)
  28825. */
  28826. static CapsuleImpostor: number;
  28827. /**
  28828. * Cylinder-Imposter type
  28829. */
  28830. static CylinderImpostor: number;
  28831. /**
  28832. * Particle-Imposter type
  28833. */
  28834. static ParticleImpostor: number;
  28835. /**
  28836. * Heightmap-Imposter type
  28837. */
  28838. static HeightmapImpostor: number;
  28839. /**
  28840. * ConvexHull-Impostor type (Ammo.js plugin only)
  28841. */
  28842. static ConvexHullImpostor: number;
  28843. /**
  28844. * Custom-Imposter type (Ammo.js plugin only)
  28845. */
  28846. static CustomImpostor: number;
  28847. /**
  28848. * Rope-Imposter type
  28849. */
  28850. static RopeImpostor: number;
  28851. /**
  28852. * Cloth-Imposter type
  28853. */
  28854. static ClothImpostor: number;
  28855. /**
  28856. * Softbody-Imposter type
  28857. */
  28858. static SoftbodyImpostor: number;
  28859. }
  28860. }
  28861. declare module "babylonjs/Meshes/mesh" {
  28862. import { Observable } from "babylonjs/Misc/observable";
  28863. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28864. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28865. import { Camera } from "babylonjs/Cameras/camera";
  28866. import { Scene } from "babylonjs/scene";
  28867. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28868. import { Color4 } from "babylonjs/Maths/math.color";
  28869. import { Engine } from "babylonjs/Engines/engine";
  28870. import { Node } from "babylonjs/node";
  28871. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28872. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28873. import { Buffer } from "babylonjs/Meshes/buffer";
  28874. import { Geometry } from "babylonjs/Meshes/geometry";
  28875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28877. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28878. import { Effect } from "babylonjs/Materials/effect";
  28879. import { Material } from "babylonjs/Materials/material";
  28880. import { Skeleton } from "babylonjs/Bones/skeleton";
  28881. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28882. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28883. import { Path3D } from "babylonjs/Maths/math.path";
  28884. import { Plane } from "babylonjs/Maths/math.plane";
  28885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28886. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28887. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28888. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28889. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28890. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28891. /**
  28892. * @hidden
  28893. **/
  28894. export class _CreationDataStorage {
  28895. closePath?: boolean;
  28896. closeArray?: boolean;
  28897. idx: number[];
  28898. dashSize: number;
  28899. gapSize: number;
  28900. path3D: Path3D;
  28901. pathArray: Vector3[][];
  28902. arc: number;
  28903. radius: number;
  28904. cap: number;
  28905. tessellation: number;
  28906. }
  28907. /**
  28908. * @hidden
  28909. **/
  28910. class _InstanceDataStorage {
  28911. visibleInstances: any;
  28912. batchCache: _InstancesBatch;
  28913. instancesBufferSize: number;
  28914. instancesBuffer: Nullable<Buffer>;
  28915. instancesData: Float32Array;
  28916. overridenInstanceCount: number;
  28917. isFrozen: boolean;
  28918. previousBatch: Nullable<_InstancesBatch>;
  28919. hardwareInstancedRendering: boolean;
  28920. sideOrientation: number;
  28921. manualUpdate: boolean;
  28922. }
  28923. /**
  28924. * @hidden
  28925. **/
  28926. export class _InstancesBatch {
  28927. mustReturn: boolean;
  28928. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28929. renderSelf: boolean[];
  28930. hardwareInstancedRendering: boolean[];
  28931. }
  28932. /**
  28933. * @hidden
  28934. **/
  28935. class _ThinInstanceDataStorage {
  28936. instancesCount: number;
  28937. matrixBuffer: Nullable<Buffer>;
  28938. matrixBufferSize: number;
  28939. matrixData: Nullable<Float32Array>;
  28940. boundingVectors: Array<Vector3>;
  28941. worldMatrices: Nullable<Matrix[]>;
  28942. }
  28943. /**
  28944. * Class used to represent renderable models
  28945. */
  28946. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28947. /**
  28948. * Mesh side orientation : usually the external or front surface
  28949. */
  28950. static readonly FRONTSIDE: number;
  28951. /**
  28952. * Mesh side orientation : usually the internal or back surface
  28953. */
  28954. static readonly BACKSIDE: number;
  28955. /**
  28956. * Mesh side orientation : both internal and external or front and back surfaces
  28957. */
  28958. static readonly DOUBLESIDE: number;
  28959. /**
  28960. * Mesh side orientation : by default, `FRONTSIDE`
  28961. */
  28962. static readonly DEFAULTSIDE: number;
  28963. /**
  28964. * Mesh cap setting : no cap
  28965. */
  28966. static readonly NO_CAP: number;
  28967. /**
  28968. * Mesh cap setting : one cap at the beginning of the mesh
  28969. */
  28970. static readonly CAP_START: number;
  28971. /**
  28972. * Mesh cap setting : one cap at the end of the mesh
  28973. */
  28974. static readonly CAP_END: number;
  28975. /**
  28976. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28977. */
  28978. static readonly CAP_ALL: number;
  28979. /**
  28980. * Mesh pattern setting : no flip or rotate
  28981. */
  28982. static readonly NO_FLIP: number;
  28983. /**
  28984. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28985. */
  28986. static readonly FLIP_TILE: number;
  28987. /**
  28988. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28989. */
  28990. static readonly ROTATE_TILE: number;
  28991. /**
  28992. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28993. */
  28994. static readonly FLIP_ROW: number;
  28995. /**
  28996. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28997. */
  28998. static readonly ROTATE_ROW: number;
  28999. /**
  29000. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29001. */
  29002. static readonly FLIP_N_ROTATE_TILE: number;
  29003. /**
  29004. * Mesh pattern setting : rotate pattern and rotate
  29005. */
  29006. static readonly FLIP_N_ROTATE_ROW: number;
  29007. /**
  29008. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29009. */
  29010. static readonly CENTER: number;
  29011. /**
  29012. * Mesh tile positioning : part tiles on left
  29013. */
  29014. static readonly LEFT: number;
  29015. /**
  29016. * Mesh tile positioning : part tiles on right
  29017. */
  29018. static readonly RIGHT: number;
  29019. /**
  29020. * Mesh tile positioning : part tiles on top
  29021. */
  29022. static readonly TOP: number;
  29023. /**
  29024. * Mesh tile positioning : part tiles on bottom
  29025. */
  29026. static readonly BOTTOM: number;
  29027. /**
  29028. * Gets the default side orientation.
  29029. * @param orientation the orientation to value to attempt to get
  29030. * @returns the default orientation
  29031. * @hidden
  29032. */
  29033. static _GetDefaultSideOrientation(orientation?: number): number;
  29034. private _internalMeshDataInfo;
  29035. get computeBonesUsingShaders(): boolean;
  29036. set computeBonesUsingShaders(value: boolean);
  29037. /**
  29038. * An event triggered before rendering the mesh
  29039. */
  29040. get onBeforeRenderObservable(): Observable<Mesh>;
  29041. /**
  29042. * An event triggered before binding the mesh
  29043. */
  29044. get onBeforeBindObservable(): Observable<Mesh>;
  29045. /**
  29046. * An event triggered after rendering the mesh
  29047. */
  29048. get onAfterRenderObservable(): Observable<Mesh>;
  29049. /**
  29050. * An event triggered before drawing the mesh
  29051. */
  29052. get onBeforeDrawObservable(): Observable<Mesh>;
  29053. private _onBeforeDrawObserver;
  29054. /**
  29055. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29056. */
  29057. set onBeforeDraw(callback: () => void);
  29058. get hasInstances(): boolean;
  29059. get hasThinInstances(): boolean;
  29060. /**
  29061. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29062. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29063. */
  29064. delayLoadState: number;
  29065. /**
  29066. * Gets the list of instances created from this mesh
  29067. * it is not supposed to be modified manually.
  29068. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29069. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29070. */
  29071. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29072. /**
  29073. * Gets the file containing delay loading data for this mesh
  29074. */
  29075. delayLoadingFile: string;
  29076. /** @hidden */
  29077. _binaryInfo: any;
  29078. /**
  29079. * User defined function used to change how LOD level selection is done
  29080. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29081. */
  29082. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29083. /**
  29084. * Gets or sets the morph target manager
  29085. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29086. */
  29087. get morphTargetManager(): Nullable<MorphTargetManager>;
  29088. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29089. /** @hidden */
  29090. _creationDataStorage: Nullable<_CreationDataStorage>;
  29091. /** @hidden */
  29092. _geometry: Nullable<Geometry>;
  29093. /** @hidden */
  29094. _delayInfo: Array<string>;
  29095. /** @hidden */
  29096. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29097. /** @hidden */
  29098. _instanceDataStorage: _InstanceDataStorage;
  29099. /** @hidden */
  29100. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29101. private _effectiveMaterial;
  29102. /** @hidden */
  29103. _shouldGenerateFlatShading: boolean;
  29104. /** @hidden */
  29105. _originalBuilderSideOrientation: number;
  29106. /**
  29107. * Use this property to change the original side orientation defined at construction time
  29108. */
  29109. overrideMaterialSideOrientation: Nullable<number>;
  29110. /**
  29111. * Gets the source mesh (the one used to clone this one from)
  29112. */
  29113. get source(): Nullable<Mesh>;
  29114. /**
  29115. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29116. */
  29117. get isUnIndexed(): boolean;
  29118. set isUnIndexed(value: boolean);
  29119. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29120. get worldMatrixInstancedBuffer(): Float32Array;
  29121. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29122. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29123. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29124. /**
  29125. * @constructor
  29126. * @param name The value used by scene.getMeshByName() to do a lookup.
  29127. * @param scene The scene to add this mesh to.
  29128. * @param parent The parent of this mesh, if it has one
  29129. * @param source An optional Mesh from which geometry is shared, cloned.
  29130. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29131. * When false, achieved by calling a clone(), also passing False.
  29132. * This will make creation of children, recursive.
  29133. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29134. */
  29135. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29136. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29137. doNotInstantiate: boolean;
  29138. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29139. /**
  29140. * Gets the class name
  29141. * @returns the string "Mesh".
  29142. */
  29143. getClassName(): string;
  29144. /** @hidden */
  29145. get _isMesh(): boolean;
  29146. /**
  29147. * Returns a description of this mesh
  29148. * @param fullDetails define if full details about this mesh must be used
  29149. * @returns a descriptive string representing this mesh
  29150. */
  29151. toString(fullDetails?: boolean): string;
  29152. /** @hidden */
  29153. _unBindEffect(): void;
  29154. /**
  29155. * Gets a boolean indicating if this mesh has LOD
  29156. */
  29157. get hasLODLevels(): boolean;
  29158. /**
  29159. * Gets the list of MeshLODLevel associated with the current mesh
  29160. * @returns an array of MeshLODLevel
  29161. */
  29162. getLODLevels(): MeshLODLevel[];
  29163. private _sortLODLevels;
  29164. /**
  29165. * Add a mesh as LOD level triggered at the given distance.
  29166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29167. * @param distance The distance from the center of the object to show this level
  29168. * @param mesh The mesh to be added as LOD level (can be null)
  29169. * @return This mesh (for chaining)
  29170. */
  29171. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29172. /**
  29173. * Returns the LOD level mesh at the passed distance or null if not found.
  29174. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29175. * @param distance The distance from the center of the object to show this level
  29176. * @returns a Mesh or `null`
  29177. */
  29178. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29179. /**
  29180. * Remove a mesh from the LOD array
  29181. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29182. * @param mesh defines the mesh to be removed
  29183. * @return This mesh (for chaining)
  29184. */
  29185. removeLODLevel(mesh: Mesh): Mesh;
  29186. /**
  29187. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29188. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29189. * @param camera defines the camera to use to compute distance
  29190. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29191. * @return This mesh (for chaining)
  29192. */
  29193. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29194. /**
  29195. * Gets the mesh internal Geometry object
  29196. */
  29197. get geometry(): Nullable<Geometry>;
  29198. /**
  29199. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29200. * @returns the total number of vertices
  29201. */
  29202. getTotalVertices(): number;
  29203. /**
  29204. * Returns the content of an associated vertex buffer
  29205. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29206. * - VertexBuffer.PositionKind
  29207. * - VertexBuffer.UVKind
  29208. * - VertexBuffer.UV2Kind
  29209. * - VertexBuffer.UV3Kind
  29210. * - VertexBuffer.UV4Kind
  29211. * - VertexBuffer.UV5Kind
  29212. * - VertexBuffer.UV6Kind
  29213. * - VertexBuffer.ColorKind
  29214. * - VertexBuffer.MatricesIndicesKind
  29215. * - VertexBuffer.MatricesIndicesExtraKind
  29216. * - VertexBuffer.MatricesWeightsKind
  29217. * - VertexBuffer.MatricesWeightsExtraKind
  29218. * @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
  29219. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29220. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29221. */
  29222. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29223. /**
  29224. * Returns the mesh VertexBuffer object from the requested `kind`
  29225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29226. * - VertexBuffer.PositionKind
  29227. * - VertexBuffer.NormalKind
  29228. * - VertexBuffer.UVKind
  29229. * - VertexBuffer.UV2Kind
  29230. * - VertexBuffer.UV3Kind
  29231. * - VertexBuffer.UV4Kind
  29232. * - VertexBuffer.UV5Kind
  29233. * - VertexBuffer.UV6Kind
  29234. * - VertexBuffer.ColorKind
  29235. * - VertexBuffer.MatricesIndicesKind
  29236. * - VertexBuffer.MatricesIndicesExtraKind
  29237. * - VertexBuffer.MatricesWeightsKind
  29238. * - VertexBuffer.MatricesWeightsExtraKind
  29239. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29240. */
  29241. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29242. /**
  29243. * Tests if a specific vertex buffer is associated with this mesh
  29244. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29245. * - VertexBuffer.PositionKind
  29246. * - VertexBuffer.NormalKind
  29247. * - VertexBuffer.UVKind
  29248. * - VertexBuffer.UV2Kind
  29249. * - VertexBuffer.UV3Kind
  29250. * - VertexBuffer.UV4Kind
  29251. * - VertexBuffer.UV5Kind
  29252. * - VertexBuffer.UV6Kind
  29253. * - VertexBuffer.ColorKind
  29254. * - VertexBuffer.MatricesIndicesKind
  29255. * - VertexBuffer.MatricesIndicesExtraKind
  29256. * - VertexBuffer.MatricesWeightsKind
  29257. * - VertexBuffer.MatricesWeightsExtraKind
  29258. * @returns a boolean
  29259. */
  29260. isVerticesDataPresent(kind: string): boolean;
  29261. /**
  29262. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29263. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29264. * - VertexBuffer.PositionKind
  29265. * - VertexBuffer.UVKind
  29266. * - VertexBuffer.UV2Kind
  29267. * - VertexBuffer.UV3Kind
  29268. * - VertexBuffer.UV4Kind
  29269. * - VertexBuffer.UV5Kind
  29270. * - VertexBuffer.UV6Kind
  29271. * - VertexBuffer.ColorKind
  29272. * - VertexBuffer.MatricesIndicesKind
  29273. * - VertexBuffer.MatricesIndicesExtraKind
  29274. * - VertexBuffer.MatricesWeightsKind
  29275. * - VertexBuffer.MatricesWeightsExtraKind
  29276. * @returns a boolean
  29277. */
  29278. isVertexBufferUpdatable(kind: string): boolean;
  29279. /**
  29280. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29281. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29282. * - VertexBuffer.PositionKind
  29283. * - VertexBuffer.NormalKind
  29284. * - VertexBuffer.UVKind
  29285. * - VertexBuffer.UV2Kind
  29286. * - VertexBuffer.UV3Kind
  29287. * - VertexBuffer.UV4Kind
  29288. * - VertexBuffer.UV5Kind
  29289. * - VertexBuffer.UV6Kind
  29290. * - VertexBuffer.ColorKind
  29291. * - VertexBuffer.MatricesIndicesKind
  29292. * - VertexBuffer.MatricesIndicesExtraKind
  29293. * - VertexBuffer.MatricesWeightsKind
  29294. * - VertexBuffer.MatricesWeightsExtraKind
  29295. * @returns an array of strings
  29296. */
  29297. getVerticesDataKinds(): string[];
  29298. /**
  29299. * Returns a positive integer : the total number of indices in this mesh geometry.
  29300. * @returns the numner of indices or zero if the mesh has no geometry.
  29301. */
  29302. getTotalIndices(): number;
  29303. /**
  29304. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29305. * @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.
  29306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29307. * @returns the indices array or an empty array if the mesh has no geometry
  29308. */
  29309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29310. get isBlocked(): boolean;
  29311. /**
  29312. * Determine if the current mesh is ready to be rendered
  29313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29314. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29315. * @returns true if all associated assets are ready (material, textures, shaders)
  29316. */
  29317. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29318. /**
  29319. * 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.
  29320. */
  29321. get areNormalsFrozen(): boolean;
  29322. /**
  29323. * 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.
  29324. * @returns the current mesh
  29325. */
  29326. freezeNormals(): Mesh;
  29327. /**
  29328. * 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
  29329. * @returns the current mesh
  29330. */
  29331. unfreezeNormals(): Mesh;
  29332. /**
  29333. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29334. */
  29335. set overridenInstanceCount(count: number);
  29336. /** @hidden */
  29337. _preActivate(): Mesh;
  29338. /** @hidden */
  29339. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29340. /** @hidden */
  29341. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29342. protected _afterComputeWorldMatrix(): void;
  29343. /** @hidden */
  29344. _postActivate(): void;
  29345. /**
  29346. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29347. * This means the mesh underlying bounding box and sphere are recomputed.
  29348. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29349. * @returns the current mesh
  29350. */
  29351. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29352. /** @hidden */
  29353. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29354. /**
  29355. * This function will subdivide the mesh into multiple submeshes
  29356. * @param count defines the expected number of submeshes
  29357. */
  29358. subdivide(count: number): void;
  29359. /**
  29360. * Copy a FloatArray into a specific associated vertex buffer
  29361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29362. * - VertexBuffer.PositionKind
  29363. * - VertexBuffer.UVKind
  29364. * - VertexBuffer.UV2Kind
  29365. * - VertexBuffer.UV3Kind
  29366. * - VertexBuffer.UV4Kind
  29367. * - VertexBuffer.UV5Kind
  29368. * - VertexBuffer.UV6Kind
  29369. * - VertexBuffer.ColorKind
  29370. * - VertexBuffer.MatricesIndicesKind
  29371. * - VertexBuffer.MatricesIndicesExtraKind
  29372. * - VertexBuffer.MatricesWeightsKind
  29373. * - VertexBuffer.MatricesWeightsExtraKind
  29374. * @param data defines the data source
  29375. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29376. * @param stride defines the data stride size (can be null)
  29377. * @returns the current mesh
  29378. */
  29379. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29380. /**
  29381. * Delete a vertex buffer associated with this mesh
  29382. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29383. * - VertexBuffer.PositionKind
  29384. * - VertexBuffer.UVKind
  29385. * - VertexBuffer.UV2Kind
  29386. * - VertexBuffer.UV3Kind
  29387. * - VertexBuffer.UV4Kind
  29388. * - VertexBuffer.UV5Kind
  29389. * - VertexBuffer.UV6Kind
  29390. * - VertexBuffer.ColorKind
  29391. * - VertexBuffer.MatricesIndicesKind
  29392. * - VertexBuffer.MatricesIndicesExtraKind
  29393. * - VertexBuffer.MatricesWeightsKind
  29394. * - VertexBuffer.MatricesWeightsExtraKind
  29395. */
  29396. removeVerticesData(kind: string): void;
  29397. /**
  29398. * Flags an associated vertex buffer as updatable
  29399. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29400. * - VertexBuffer.PositionKind
  29401. * - VertexBuffer.UVKind
  29402. * - VertexBuffer.UV2Kind
  29403. * - VertexBuffer.UV3Kind
  29404. * - VertexBuffer.UV4Kind
  29405. * - VertexBuffer.UV5Kind
  29406. * - VertexBuffer.UV6Kind
  29407. * - VertexBuffer.ColorKind
  29408. * - VertexBuffer.MatricesIndicesKind
  29409. * - VertexBuffer.MatricesIndicesExtraKind
  29410. * - VertexBuffer.MatricesWeightsKind
  29411. * - VertexBuffer.MatricesWeightsExtraKind
  29412. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29413. */
  29414. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29415. /**
  29416. * Sets the mesh global Vertex Buffer
  29417. * @param buffer defines the buffer to use
  29418. * @returns the current mesh
  29419. */
  29420. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29421. /**
  29422. * Update a specific associated vertex buffer
  29423. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29424. * - VertexBuffer.PositionKind
  29425. * - VertexBuffer.UVKind
  29426. * - VertexBuffer.UV2Kind
  29427. * - VertexBuffer.UV3Kind
  29428. * - VertexBuffer.UV4Kind
  29429. * - VertexBuffer.UV5Kind
  29430. * - VertexBuffer.UV6Kind
  29431. * - VertexBuffer.ColorKind
  29432. * - VertexBuffer.MatricesIndicesKind
  29433. * - VertexBuffer.MatricesIndicesExtraKind
  29434. * - VertexBuffer.MatricesWeightsKind
  29435. * - VertexBuffer.MatricesWeightsExtraKind
  29436. * @param data defines the data source
  29437. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29438. * @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)
  29439. * @returns the current mesh
  29440. */
  29441. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29442. /**
  29443. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29444. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29445. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29446. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29447. * @returns the current mesh
  29448. */
  29449. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29450. /**
  29451. * Creates a un-shared specific occurence of the geometry for the mesh.
  29452. * @returns the current mesh
  29453. */
  29454. makeGeometryUnique(): Mesh;
  29455. /**
  29456. * Set the index buffer of this mesh
  29457. * @param indices defines the source data
  29458. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29459. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29460. * @returns the current mesh
  29461. */
  29462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29463. /**
  29464. * Update the current index buffer
  29465. * @param indices defines the source data
  29466. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29467. * @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)
  29468. * @returns the current mesh
  29469. */
  29470. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29471. /**
  29472. * Invert the geometry to move from a right handed system to a left handed one.
  29473. * @returns the current mesh
  29474. */
  29475. toLeftHanded(): Mesh;
  29476. /** @hidden */
  29477. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29478. /** @hidden */
  29479. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29480. /**
  29481. * Registers for this mesh a javascript function called just before the rendering process
  29482. * @param func defines the function to call before rendering this mesh
  29483. * @returns the current mesh
  29484. */
  29485. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29486. /**
  29487. * Disposes a previously registered javascript function called before the rendering
  29488. * @param func defines the function to remove
  29489. * @returns the current mesh
  29490. */
  29491. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29492. /**
  29493. * Registers for this mesh a javascript function called just after the rendering is complete
  29494. * @param func defines the function to call after rendering this mesh
  29495. * @returns the current mesh
  29496. */
  29497. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29498. /**
  29499. * Disposes a previously registered javascript function called after the rendering.
  29500. * @param func defines the function to remove
  29501. * @returns the current mesh
  29502. */
  29503. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29504. /** @hidden */
  29505. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29506. /** @hidden */
  29507. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29508. /** @hidden */
  29509. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29510. /** @hidden */
  29511. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29512. /** @hidden */
  29513. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29514. /** @hidden */
  29515. _rebuild(): void;
  29516. /** @hidden */
  29517. _freeze(): void;
  29518. /** @hidden */
  29519. _unFreeze(): void;
  29520. /**
  29521. * 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
  29522. * @param subMesh defines the subMesh to render
  29523. * @param enableAlphaMode defines if alpha mode can be changed
  29524. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29525. * @returns the current mesh
  29526. */
  29527. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29528. private _onBeforeDraw;
  29529. /**
  29530. * Renormalize the mesh and patch it up if there are no weights
  29531. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29532. * However in the case of zero weights then we set just a single influence to 1.
  29533. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29534. */
  29535. cleanMatrixWeights(): void;
  29536. private normalizeSkinFourWeights;
  29537. private normalizeSkinWeightsAndExtra;
  29538. /**
  29539. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29540. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29541. * the user know there was an issue with importing the mesh
  29542. * @returns a validation object with skinned, valid and report string
  29543. */
  29544. validateSkinning(): {
  29545. skinned: boolean;
  29546. valid: boolean;
  29547. report: string;
  29548. };
  29549. /** @hidden */
  29550. _checkDelayState(): Mesh;
  29551. private _queueLoad;
  29552. /**
  29553. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29554. * A mesh is in the frustum if its bounding box intersects the frustum
  29555. * @param frustumPlanes defines the frustum to test
  29556. * @returns true if the mesh is in the frustum planes
  29557. */
  29558. isInFrustum(frustumPlanes: Plane[]): boolean;
  29559. /**
  29560. * Sets the mesh material by the material or multiMaterial `id` property
  29561. * @param id is a string identifying the material or the multiMaterial
  29562. * @returns the current mesh
  29563. */
  29564. setMaterialByID(id: string): Mesh;
  29565. /**
  29566. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29567. * @returns an array of IAnimatable
  29568. */
  29569. getAnimatables(): IAnimatable[];
  29570. /**
  29571. * Modifies the mesh geometry according to the passed transformation matrix.
  29572. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29573. * The mesh normals are modified using the same transformation.
  29574. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29575. * @param transform defines the transform matrix to use
  29576. * @see https://doc.babylonjs.com/resources/baking_transformations
  29577. * @returns the current mesh
  29578. */
  29579. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29580. /**
  29581. * Modifies the mesh geometry according to its own current World Matrix.
  29582. * The mesh World Matrix is then reset.
  29583. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29584. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29585. * @see https://doc.babylonjs.com/resources/baking_transformations
  29586. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29587. * @returns the current mesh
  29588. */
  29589. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29590. /** @hidden */
  29591. get _positions(): Nullable<Vector3[]>;
  29592. /** @hidden */
  29593. _resetPointsArrayCache(): Mesh;
  29594. /** @hidden */
  29595. _generatePointsArray(): boolean;
  29596. /**
  29597. * Returns a new Mesh object generated from the current mesh properties.
  29598. * This method must not get confused with createInstance()
  29599. * @param name is a string, the name given to the new mesh
  29600. * @param newParent can be any Node object (default `null`)
  29601. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29602. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29603. * @returns a new mesh
  29604. */
  29605. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29606. /**
  29607. * Releases resources associated with this mesh.
  29608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29610. */
  29611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29612. /** @hidden */
  29613. _disposeInstanceSpecificData(): void;
  29614. /** @hidden */
  29615. _disposeThinInstanceSpecificData(): void;
  29616. /**
  29617. * Modifies the mesh geometry according to a displacement map.
  29618. * 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.
  29619. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29620. * @param url is a string, the URL from the image file is to be downloaded.
  29621. * @param minHeight is the lower limit of the displacement.
  29622. * @param maxHeight is the upper limit of the displacement.
  29623. * @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.
  29624. * @param uvOffset is an optional vector2 used to offset UV.
  29625. * @param uvScale is an optional vector2 used to scale UV.
  29626. * @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.
  29627. * @returns the Mesh.
  29628. */
  29629. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29630. /**
  29631. * Modifies the mesh geometry according to a displacementMap buffer.
  29632. * 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.
  29633. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29634. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29635. * @param heightMapWidth is the width of the buffer image.
  29636. * @param heightMapHeight is the height of the buffer image.
  29637. * @param minHeight is the lower limit of the displacement.
  29638. * @param maxHeight is the upper limit of the displacement.
  29639. * @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.
  29640. * @param uvOffset is an optional vector2 used to offset UV.
  29641. * @param uvScale is an optional vector2 used to scale UV.
  29642. * @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.
  29643. * @returns the Mesh.
  29644. */
  29645. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29646. /**
  29647. * Modify the mesh to get a flat shading rendering.
  29648. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29649. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29650. * @returns current mesh
  29651. */
  29652. convertToFlatShadedMesh(): Mesh;
  29653. /**
  29654. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29655. * In other words, more vertices, no more indices and a single bigger VBO.
  29656. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29657. * @returns current mesh
  29658. */
  29659. convertToUnIndexedMesh(): Mesh;
  29660. /**
  29661. * Inverses facet orientations.
  29662. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29663. * @param flipNormals will also inverts the normals
  29664. * @returns current mesh
  29665. */
  29666. flipFaces(flipNormals?: boolean): Mesh;
  29667. /**
  29668. * Increase the number of facets and hence vertices in a mesh
  29669. * Vertex normals are interpolated from existing vertex normals
  29670. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29671. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29672. */
  29673. increaseVertices(numberPerEdge: number): void;
  29674. /**
  29675. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29676. * This will undo any application of covertToFlatShadedMesh
  29677. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29678. */
  29679. forceSharedVertices(): void;
  29680. /** @hidden */
  29681. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29682. /** @hidden */
  29683. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29684. /**
  29685. * Creates a new InstancedMesh object from the mesh model.
  29686. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29687. * @param name defines the name of the new instance
  29688. * @returns a new InstancedMesh
  29689. */
  29690. createInstance(name: string): InstancedMesh;
  29691. /**
  29692. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29693. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29694. * @returns the current mesh
  29695. */
  29696. synchronizeInstances(): Mesh;
  29697. /**
  29698. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29699. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29700. * This should be used together with the simplification to avoid disappearing triangles.
  29701. * @param successCallback an optional success callback to be called after the optimization finished.
  29702. * @returns the current mesh
  29703. */
  29704. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29705. /**
  29706. * Serialize current mesh
  29707. * @param serializationObject defines the object which will receive the serialization data
  29708. */
  29709. serialize(serializationObject: any): void;
  29710. /** @hidden */
  29711. _syncGeometryWithMorphTargetManager(): void;
  29712. /** @hidden */
  29713. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29714. /**
  29715. * Returns a new Mesh object parsed from the source provided.
  29716. * @param parsedMesh is the source
  29717. * @param scene defines the hosting scene
  29718. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29719. * @returns a new Mesh
  29720. */
  29721. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29722. /**
  29723. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29725. * @param name defines the name of the mesh to create
  29726. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29727. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29728. * @param closePath creates a seam between the first and the last points of each path of the path array
  29729. * @param offset is taken in account only if the `pathArray` is containing a single path
  29730. * @param scene defines the hosting scene
  29731. * @param updatable defines if the mesh must be flagged as updatable
  29732. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29733. * @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)
  29734. * @returns a new Mesh
  29735. */
  29736. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29737. /**
  29738. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29739. * @param name defines the name of the mesh to create
  29740. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29741. * @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
  29742. * @param scene defines the hosting scene
  29743. * @param updatable defines if the mesh must be flagged as updatable
  29744. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29745. * @returns a new Mesh
  29746. */
  29747. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29748. /**
  29749. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29750. * @param name defines the name of the mesh to create
  29751. * @param size sets the size (float) of each box side (default 1)
  29752. * @param scene defines the hosting scene
  29753. * @param updatable defines if the mesh must be flagged as updatable
  29754. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29755. * @returns a new Mesh
  29756. */
  29757. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29758. /**
  29759. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29760. * @param name defines the name of the mesh to create
  29761. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29762. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29763. * @param scene defines the hosting scene
  29764. * @param updatable defines if the mesh must be flagged as updatable
  29765. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29766. * @returns a new Mesh
  29767. */
  29768. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29769. /**
  29770. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29771. * @param name defines the name of the mesh to create
  29772. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29773. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29774. * @param scene defines the hosting scene
  29775. * @returns a new Mesh
  29776. */
  29777. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29778. /**
  29779. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29780. * @param name defines the name of the mesh to create
  29781. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29782. * @param diameterTop set the top cap diameter (floats, default 1)
  29783. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29784. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29785. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29786. * @param scene defines the hosting scene
  29787. * @param updatable defines if the mesh must be flagged as updatable
  29788. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29789. * @returns a new Mesh
  29790. */
  29791. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29792. /**
  29793. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29794. * @param name defines the name of the mesh to create
  29795. * @param diameter sets the diameter size (float) of the torus (default 1)
  29796. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29797. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29798. * @param scene defines the hosting scene
  29799. * @param updatable defines if the mesh must be flagged as updatable
  29800. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29801. * @returns a new Mesh
  29802. */
  29803. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29804. /**
  29805. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29806. * @param name defines the name of the mesh to create
  29807. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29808. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29809. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29810. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29811. * @param p the number of windings on X axis (positive integers, default 2)
  29812. * @param q the number of windings on Y axis (positive integers, default 3)
  29813. * @param scene defines the hosting scene
  29814. * @param updatable defines if the mesh must be flagged as updatable
  29815. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29816. * @returns a new Mesh
  29817. */
  29818. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29819. /**
  29820. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29821. * @param name defines the name of the mesh to create
  29822. * @param points is an array successive Vector3
  29823. * @param scene defines the hosting scene
  29824. * @param updatable defines if the mesh must be flagged as updatable
  29825. * @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).
  29826. * @returns a new Mesh
  29827. */
  29828. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29829. /**
  29830. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29831. * @param name defines the name of the mesh to create
  29832. * @param points is an array successive Vector3
  29833. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29834. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29835. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29836. * @param scene defines the hosting scene
  29837. * @param updatable defines if the mesh must be flagged as updatable
  29838. * @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)
  29839. * @returns a new Mesh
  29840. */
  29841. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29842. /**
  29843. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29844. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29845. * 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.
  29846. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29847. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29848. * Remember you can only change the shape positions, not their number when updating a polygon.
  29849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29850. * @param name defines the name of the mesh to create
  29851. * @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
  29852. * @param scene defines the hosting scene
  29853. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29854. * @param updatable defines if the mesh must be flagged as updatable
  29855. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29856. * @param earcutInjection can be used to inject your own earcut reference
  29857. * @returns a new Mesh
  29858. */
  29859. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29860. /**
  29861. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29863. * @param name defines the name of the mesh to create
  29864. * @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
  29865. * @param depth defines the height of extrusion
  29866. * @param scene defines the hosting scene
  29867. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29868. * @param updatable defines if the mesh must be flagged as updatable
  29869. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29870. * @param earcutInjection can be used to inject your own earcut reference
  29871. * @returns a new Mesh
  29872. */
  29873. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29874. /**
  29875. * Creates an extruded shape mesh.
  29876. * 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
  29877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29879. * @param name defines the name of the mesh to create
  29880. * @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
  29881. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29882. * @param scale is the value to scale the shape
  29883. * @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
  29884. * @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
  29885. * @param scene defines the hosting scene
  29886. * @param updatable defines if the mesh must be flagged as updatable
  29887. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29888. * @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)
  29889. * @returns a new Mesh
  29890. */
  29891. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29892. /**
  29893. * Creates an custom extruded shape mesh.
  29894. * The custom extrusion is a parametric shape.
  29895. * It has no predefined shape. Its final shape will depend on the input parameters.
  29896. * Please consider using the same method from the MeshBuilder class instead
  29897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29898. * @param name defines the name of the mesh to create
  29899. * @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
  29900. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29901. * @param scaleFunction is a custom Javascript function called on each path point
  29902. * @param rotationFunction is a custom Javascript function called on each path point
  29903. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29904. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29905. * @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
  29906. * @param scene defines the hosting scene
  29907. * @param updatable defines if the mesh must be flagged as updatable
  29908. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29909. * @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)
  29910. * @returns a new Mesh
  29911. */
  29912. 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;
  29913. /**
  29914. * Creates lathe mesh.
  29915. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29916. * Please consider using the same method from the MeshBuilder class instead
  29917. * @param name defines the name of the mesh to create
  29918. * @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
  29919. * @param radius is the radius value of the lathe
  29920. * @param tessellation is the side number of the lathe.
  29921. * @param scene defines the hosting scene
  29922. * @param updatable defines if the mesh must be flagged as updatable
  29923. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29924. * @returns a new Mesh
  29925. */
  29926. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29927. /**
  29928. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29929. * @param name defines the name of the mesh to create
  29930. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29931. * @param scene defines the hosting scene
  29932. * @param updatable defines if the mesh must be flagged as updatable
  29933. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29934. * @returns a new Mesh
  29935. */
  29936. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29937. /**
  29938. * Creates a ground mesh.
  29939. * Please consider using the same method from the MeshBuilder class instead
  29940. * @param name defines the name of the mesh to create
  29941. * @param width set the width of the ground
  29942. * @param height set the height of the ground
  29943. * @param subdivisions sets the number of subdivisions per side
  29944. * @param scene defines the hosting scene
  29945. * @param updatable defines if the mesh must be flagged as updatable
  29946. * @returns a new Mesh
  29947. */
  29948. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29949. /**
  29950. * Creates a tiled ground mesh.
  29951. * Please consider using the same method from the MeshBuilder class instead
  29952. * @param name defines the name of the mesh to create
  29953. * @param xmin set the ground minimum X coordinate
  29954. * @param zmin set the ground minimum Y coordinate
  29955. * @param xmax set the ground maximum X coordinate
  29956. * @param zmax set the ground maximum Z coordinate
  29957. * @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
  29958. * @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
  29959. * @param scene defines the hosting scene
  29960. * @param updatable defines if the mesh must be flagged as updatable
  29961. * @returns a new Mesh
  29962. */
  29963. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29964. w: number;
  29965. h: number;
  29966. }, precision: {
  29967. w: number;
  29968. h: number;
  29969. }, scene: Scene, updatable?: boolean): Mesh;
  29970. /**
  29971. * Creates a ground mesh from a height map.
  29972. * Please consider using the same method from the MeshBuilder class instead
  29973. * @see https://doc.babylonjs.com/babylon101/height_map
  29974. * @param name defines the name of the mesh to create
  29975. * @param url sets the URL of the height map image resource
  29976. * @param width set the ground width size
  29977. * @param height set the ground height size
  29978. * @param subdivisions sets the number of subdivision per side
  29979. * @param minHeight is the minimum altitude on the ground
  29980. * @param maxHeight is the maximum altitude on the ground
  29981. * @param scene defines the hosting scene
  29982. * @param updatable defines if the mesh must be flagged as updatable
  29983. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29984. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29985. * @returns a new Mesh
  29986. */
  29987. 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;
  29988. /**
  29989. * Creates a tube mesh.
  29990. * The tube is a parametric shape.
  29991. * It has no predefined shape. Its final shape will depend on the input parameters.
  29992. * Please consider using the same method from the MeshBuilder class instead
  29993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29994. * @param name defines the name of the mesh to create
  29995. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29996. * @param radius sets the tube radius size
  29997. * @param tessellation is the number of sides on the tubular surface
  29998. * @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
  29999. * @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
  30000. * @param scene defines the hosting scene
  30001. * @param updatable defines if the mesh must be flagged as updatable
  30002. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30003. * @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)
  30004. * @returns a new Mesh
  30005. */
  30006. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30007. (i: number, distance: number): number;
  30008. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30009. /**
  30010. * Creates a polyhedron mesh.
  30011. * Please consider using the same method from the MeshBuilder class instead.
  30012. * * 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
  30013. * * The parameter `size` (positive float, default 1) sets the polygon size
  30014. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30015. * * 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`
  30016. * * 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
  30017. * * 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)`)
  30018. * * 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
  30019. * * 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
  30020. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30023. * @param name defines the name of the mesh to create
  30024. * @param options defines the options used to create the mesh
  30025. * @param scene defines the hosting scene
  30026. * @returns a new Mesh
  30027. */
  30028. static CreatePolyhedron(name: string, options: {
  30029. type?: number;
  30030. size?: number;
  30031. sizeX?: number;
  30032. sizeY?: number;
  30033. sizeZ?: number;
  30034. custom?: any;
  30035. faceUV?: Vector4[];
  30036. faceColors?: Color4[];
  30037. updatable?: boolean;
  30038. sideOrientation?: number;
  30039. }, scene: Scene): Mesh;
  30040. /**
  30041. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30042. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30043. * * 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`)
  30044. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30045. * * 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
  30046. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30049. * @param name defines the name of the mesh
  30050. * @param options defines the options used to create the mesh
  30051. * @param scene defines the hosting scene
  30052. * @returns a new Mesh
  30053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30054. */
  30055. static CreateIcoSphere(name: string, options: {
  30056. radius?: number;
  30057. flat?: boolean;
  30058. subdivisions?: number;
  30059. sideOrientation?: number;
  30060. updatable?: boolean;
  30061. }, scene: Scene): Mesh;
  30062. /**
  30063. * Creates a decal mesh.
  30064. * Please consider using the same method from the MeshBuilder class instead.
  30065. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30066. * @param name defines the name of the mesh
  30067. * @param sourceMesh defines the mesh receiving the decal
  30068. * @param position sets the position of the decal in world coordinates
  30069. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30070. * @param size sets the decal scaling
  30071. * @param angle sets the angle to rotate the decal
  30072. * @returns a new Mesh
  30073. */
  30074. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30075. /**
  30076. * Prepare internal position array for software CPU skinning
  30077. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30078. */
  30079. setPositionsForCPUSkinning(): Float32Array;
  30080. /**
  30081. * Prepare internal normal array for software CPU skinning
  30082. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30083. */
  30084. setNormalsForCPUSkinning(): Float32Array;
  30085. /**
  30086. * Updates the vertex buffer by applying transformation from the bones
  30087. * @param skeleton defines the skeleton to apply to current mesh
  30088. * @returns the current mesh
  30089. */
  30090. applySkeleton(skeleton: Skeleton): Mesh;
  30091. /**
  30092. * 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
  30093. * @param meshes defines the list of meshes to scan
  30094. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30095. */
  30096. static MinMax(meshes: AbstractMesh[]): {
  30097. min: Vector3;
  30098. max: Vector3;
  30099. };
  30100. /**
  30101. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30102. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30103. * @returns a vector3
  30104. */
  30105. static Center(meshesOrMinMaxVector: {
  30106. min: Vector3;
  30107. max: Vector3;
  30108. } | AbstractMesh[]): Vector3;
  30109. /**
  30110. * Merge the array of meshes into a single mesh for performance reasons.
  30111. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30112. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30113. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30114. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30115. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30116. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30117. * @returns a new mesh
  30118. */
  30119. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30120. /** @hidden */
  30121. addInstance(instance: InstancedMesh): void;
  30122. /** @hidden */
  30123. removeInstance(instance: InstancedMesh): void;
  30124. }
  30125. }
  30126. declare module "babylonjs/Cameras/camera" {
  30127. import { SmartArray } from "babylonjs/Misc/smartArray";
  30128. import { Observable } from "babylonjs/Misc/observable";
  30129. import { Nullable } from "babylonjs/types";
  30130. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30131. import { Scene } from "babylonjs/scene";
  30132. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30133. import { Node } from "babylonjs/node";
  30134. import { Mesh } from "babylonjs/Meshes/mesh";
  30135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30136. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30137. import { Viewport } from "babylonjs/Maths/math.viewport";
  30138. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30139. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30140. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30141. import { Ray } from "babylonjs/Culling/ray";
  30142. /**
  30143. * This is the base class of all the camera used in the application.
  30144. * @see https://doc.babylonjs.com/features/cameras
  30145. */
  30146. export class Camera extends Node {
  30147. /** @hidden */
  30148. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30149. /**
  30150. * This is the default projection mode used by the cameras.
  30151. * It helps recreating a feeling of perspective and better appreciate depth.
  30152. * This is the best way to simulate real life cameras.
  30153. */
  30154. static readonly PERSPECTIVE_CAMERA: number;
  30155. /**
  30156. * This helps creating camera with an orthographic mode.
  30157. * 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.
  30158. */
  30159. static readonly ORTHOGRAPHIC_CAMERA: number;
  30160. /**
  30161. * This is the default FOV mode for perspective cameras.
  30162. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30163. */
  30164. static readonly FOVMODE_VERTICAL_FIXED: number;
  30165. /**
  30166. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30167. */
  30168. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30169. /**
  30170. * This specifies ther is no need for a camera rig.
  30171. * Basically only one eye is rendered corresponding to the camera.
  30172. */
  30173. static readonly RIG_MODE_NONE: number;
  30174. /**
  30175. * Simulates a camera Rig with one blue eye and one red eye.
  30176. * This can be use with 3d blue and red glasses.
  30177. */
  30178. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30179. /**
  30180. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30181. */
  30182. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30183. /**
  30184. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30185. */
  30186. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30187. /**
  30188. * Defines that both eyes of the camera will be rendered over under each other.
  30189. */
  30190. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30191. /**
  30192. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30193. */
  30194. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30195. /**
  30196. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30197. */
  30198. static readonly RIG_MODE_VR: number;
  30199. /**
  30200. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30201. */
  30202. static readonly RIG_MODE_WEBVR: number;
  30203. /**
  30204. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30205. */
  30206. static readonly RIG_MODE_CUSTOM: number;
  30207. /**
  30208. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30209. */
  30210. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30211. /**
  30212. * Define the input manager associated with the camera.
  30213. */
  30214. inputs: CameraInputsManager<Camera>;
  30215. /** @hidden */
  30216. _position: Vector3;
  30217. /**
  30218. * Define the current local position of the camera in the scene
  30219. */
  30220. get position(): Vector3;
  30221. set position(newPosition: Vector3);
  30222. /**
  30223. * The vector the camera should consider as up.
  30224. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30225. */
  30226. upVector: Vector3;
  30227. /**
  30228. * Define the current limit on the left side for an orthographic camera
  30229. * In scene unit
  30230. */
  30231. orthoLeft: Nullable<number>;
  30232. /**
  30233. * Define the current limit on the right side for an orthographic camera
  30234. * In scene unit
  30235. */
  30236. orthoRight: Nullable<number>;
  30237. /**
  30238. * Define the current limit on the bottom side for an orthographic camera
  30239. * In scene unit
  30240. */
  30241. orthoBottom: Nullable<number>;
  30242. /**
  30243. * Define the current limit on the top side for an orthographic camera
  30244. * In scene unit
  30245. */
  30246. orthoTop: Nullable<number>;
  30247. /**
  30248. * Field Of View is set in Radians. (default is 0.8)
  30249. */
  30250. fov: number;
  30251. /**
  30252. * Define the minimum distance the camera can see from.
  30253. * This is important to note that the depth buffer are not infinite and the closer it starts
  30254. * the more your scene might encounter depth fighting issue.
  30255. */
  30256. minZ: number;
  30257. /**
  30258. * Define the maximum distance the camera can see to.
  30259. * This is important to note that the depth buffer are not infinite and the further it end
  30260. * the more your scene might encounter depth fighting issue.
  30261. */
  30262. maxZ: number;
  30263. /**
  30264. * Define the default inertia of the camera.
  30265. * This helps giving a smooth feeling to the camera movement.
  30266. */
  30267. inertia: number;
  30268. /**
  30269. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30270. */
  30271. mode: number;
  30272. /**
  30273. * Define whether the camera is intermediate.
  30274. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30275. */
  30276. isIntermediate: boolean;
  30277. /**
  30278. * Define the viewport of the camera.
  30279. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30280. */
  30281. viewport: Viewport;
  30282. /**
  30283. * Restricts the camera to viewing objects with the same layerMask.
  30284. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30285. */
  30286. layerMask: number;
  30287. /**
  30288. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30289. */
  30290. fovMode: number;
  30291. /**
  30292. * Rig mode of the camera.
  30293. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30294. * This is normally controlled byt the camera themselves as internal use.
  30295. */
  30296. cameraRigMode: number;
  30297. /**
  30298. * Defines the distance between both "eyes" in case of a RIG
  30299. */
  30300. interaxialDistance: number;
  30301. /**
  30302. * Defines if stereoscopic rendering is done side by side or over under.
  30303. */
  30304. isStereoscopicSideBySide: boolean;
  30305. /**
  30306. * 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
  30307. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30308. * else in the scene. (Eg. security camera)
  30309. *
  30310. * 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)
  30311. */
  30312. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30313. /**
  30314. * When set, the camera will render to this render target instead of the default canvas
  30315. *
  30316. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30317. */
  30318. outputRenderTarget: Nullable<RenderTargetTexture>;
  30319. /**
  30320. * Observable triggered when the camera view matrix has changed.
  30321. */
  30322. onViewMatrixChangedObservable: Observable<Camera>;
  30323. /**
  30324. * Observable triggered when the camera Projection matrix has changed.
  30325. */
  30326. onProjectionMatrixChangedObservable: Observable<Camera>;
  30327. /**
  30328. * Observable triggered when the inputs have been processed.
  30329. */
  30330. onAfterCheckInputsObservable: Observable<Camera>;
  30331. /**
  30332. * Observable triggered when reset has been called and applied to the camera.
  30333. */
  30334. onRestoreStateObservable: Observable<Camera>;
  30335. /**
  30336. * Is this camera a part of a rig system?
  30337. */
  30338. isRigCamera: boolean;
  30339. /**
  30340. * If isRigCamera set to true this will be set with the parent camera.
  30341. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30342. */
  30343. rigParent?: Camera;
  30344. /** @hidden */
  30345. _cameraRigParams: any;
  30346. /** @hidden */
  30347. _rigCameras: Camera[];
  30348. /** @hidden */
  30349. _rigPostProcess: Nullable<PostProcess>;
  30350. protected _webvrViewMatrix: Matrix;
  30351. /** @hidden */
  30352. _skipRendering: boolean;
  30353. /** @hidden */
  30354. _projectionMatrix: Matrix;
  30355. /** @hidden */
  30356. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30357. /** @hidden */
  30358. _activeMeshes: SmartArray<AbstractMesh>;
  30359. protected _globalPosition: Vector3;
  30360. /** @hidden */
  30361. _computedViewMatrix: Matrix;
  30362. private _doNotComputeProjectionMatrix;
  30363. private _transformMatrix;
  30364. private _frustumPlanes;
  30365. private _refreshFrustumPlanes;
  30366. private _storedFov;
  30367. private _stateStored;
  30368. /**
  30369. * Instantiates a new camera object.
  30370. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30371. * @see https://doc.babylonjs.com/features/cameras
  30372. * @param name Defines the name of the camera in the scene
  30373. * @param position Defines the position of the camera
  30374. * @param scene Defines the scene the camera belongs too
  30375. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30376. */
  30377. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30378. /**
  30379. * Store current camera state (fov, position, etc..)
  30380. * @returns the camera
  30381. */
  30382. storeState(): Camera;
  30383. /**
  30384. * Restores the camera state values if it has been stored. You must call storeState() first
  30385. */
  30386. protected _restoreStateValues(): boolean;
  30387. /**
  30388. * Restored camera state. You must call storeState() first.
  30389. * @returns true if restored and false otherwise
  30390. */
  30391. restoreState(): boolean;
  30392. /**
  30393. * Gets the class name of the camera.
  30394. * @returns the class name
  30395. */
  30396. getClassName(): string;
  30397. /** @hidden */
  30398. readonly _isCamera: boolean;
  30399. /**
  30400. * Gets a string representation of the camera useful for debug purpose.
  30401. * @param fullDetails Defines that a more verboe level of logging is required
  30402. * @returns the string representation
  30403. */
  30404. toString(fullDetails?: boolean): string;
  30405. /**
  30406. * Gets the current world space position of the camera.
  30407. */
  30408. get globalPosition(): Vector3;
  30409. /**
  30410. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30411. * @returns the active meshe list
  30412. */
  30413. getActiveMeshes(): SmartArray<AbstractMesh>;
  30414. /**
  30415. * Check whether a mesh is part of the current active mesh list of the camera
  30416. * @param mesh Defines the mesh to check
  30417. * @returns true if active, false otherwise
  30418. */
  30419. isActiveMesh(mesh: Mesh): boolean;
  30420. /**
  30421. * Is this camera ready to be used/rendered
  30422. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30423. * @return true if the camera is ready
  30424. */
  30425. isReady(completeCheck?: boolean): boolean;
  30426. /** @hidden */
  30427. _initCache(): void;
  30428. /** @hidden */
  30429. _updateCache(ignoreParentClass?: boolean): void;
  30430. /** @hidden */
  30431. _isSynchronized(): boolean;
  30432. /** @hidden */
  30433. _isSynchronizedViewMatrix(): boolean;
  30434. /** @hidden */
  30435. _isSynchronizedProjectionMatrix(): boolean;
  30436. /**
  30437. * Attach the input controls to a specific dom element to get the input from.
  30438. * @param element Defines the element the controls should be listened from
  30439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30440. */
  30441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30442. /**
  30443. * Detach the current controls from the specified dom element.
  30444. * @param element Defines the element to stop listening the inputs from
  30445. */
  30446. detachControl(element: HTMLElement): void;
  30447. /**
  30448. * Update the camera state according to the different inputs gathered during the frame.
  30449. */
  30450. update(): void;
  30451. /** @hidden */
  30452. _checkInputs(): void;
  30453. /** @hidden */
  30454. get rigCameras(): Camera[];
  30455. /**
  30456. * Gets the post process used by the rig cameras
  30457. */
  30458. get rigPostProcess(): Nullable<PostProcess>;
  30459. /**
  30460. * Internal, gets the first post proces.
  30461. * @returns the first post process to be run on this camera.
  30462. */
  30463. _getFirstPostProcess(): Nullable<PostProcess>;
  30464. private _cascadePostProcessesToRigCams;
  30465. /**
  30466. * Attach a post process to the camera.
  30467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30468. * @param postProcess The post process to attach to the camera
  30469. * @param insertAt The position of the post process in case several of them are in use in the scene
  30470. * @returns the position the post process has been inserted at
  30471. */
  30472. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30473. /**
  30474. * Detach a post process to the camera.
  30475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30476. * @param postProcess The post process to detach from the camera
  30477. */
  30478. detachPostProcess(postProcess: PostProcess): void;
  30479. /**
  30480. * Gets the current world matrix of the camera
  30481. */
  30482. getWorldMatrix(): Matrix;
  30483. /** @hidden */
  30484. _getViewMatrix(): Matrix;
  30485. /**
  30486. * Gets the current view matrix of the camera.
  30487. * @param force forces the camera to recompute the matrix without looking at the cached state
  30488. * @returns the view matrix
  30489. */
  30490. getViewMatrix(force?: boolean): Matrix;
  30491. /**
  30492. * Freeze the projection matrix.
  30493. * It will prevent the cache check of the camera projection compute and can speed up perf
  30494. * if no parameter of the camera are meant to change
  30495. * @param projection Defines manually a projection if necessary
  30496. */
  30497. freezeProjectionMatrix(projection?: Matrix): void;
  30498. /**
  30499. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30500. */
  30501. unfreezeProjectionMatrix(): void;
  30502. /**
  30503. * Gets the current projection matrix of the camera.
  30504. * @param force forces the camera to recompute the matrix without looking at the cached state
  30505. * @returns the projection matrix
  30506. */
  30507. getProjectionMatrix(force?: boolean): Matrix;
  30508. /**
  30509. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30510. * @returns a Matrix
  30511. */
  30512. getTransformationMatrix(): Matrix;
  30513. private _updateFrustumPlanes;
  30514. /**
  30515. * Checks if a cullable object (mesh...) is in the camera frustum
  30516. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30517. * @param target The object to check
  30518. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30519. * @returns true if the object is in frustum otherwise false
  30520. */
  30521. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30522. /**
  30523. * Checks if a cullable object (mesh...) is in the camera frustum
  30524. * Unlike isInFrustum this cheks the full bounding box
  30525. * @param target The object to check
  30526. * @returns true if the object is in frustum otherwise false
  30527. */
  30528. isCompletelyInFrustum(target: ICullable): boolean;
  30529. /**
  30530. * Gets a ray in the forward direction from the camera.
  30531. * @param length Defines the length of the ray to create
  30532. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30533. * @param origin Defines the start point of the ray which defaults to the camera position
  30534. * @returns the forward ray
  30535. */
  30536. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30537. /**
  30538. * Gets a ray in the forward direction from the camera.
  30539. * @param refRay the ray to (re)use when setting the values
  30540. * @param length Defines the length of the ray to create
  30541. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30542. * @param origin Defines the start point of the ray which defaults to the camera position
  30543. * @returns the forward ray
  30544. */
  30545. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30546. /**
  30547. * Releases resources associated with this node.
  30548. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30549. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30550. */
  30551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30552. /** @hidden */
  30553. _isLeftCamera: boolean;
  30554. /**
  30555. * Gets the left camera of a rig setup in case of Rigged Camera
  30556. */
  30557. get isLeftCamera(): boolean;
  30558. /** @hidden */
  30559. _isRightCamera: boolean;
  30560. /**
  30561. * Gets the right camera of a rig setup in case of Rigged Camera
  30562. */
  30563. get isRightCamera(): boolean;
  30564. /**
  30565. * Gets the left camera of a rig setup in case of Rigged Camera
  30566. */
  30567. get leftCamera(): Nullable<FreeCamera>;
  30568. /**
  30569. * Gets the right camera of a rig setup in case of Rigged Camera
  30570. */
  30571. get rightCamera(): Nullable<FreeCamera>;
  30572. /**
  30573. * Gets the left camera target of a rig setup in case of Rigged Camera
  30574. * @returns the target position
  30575. */
  30576. getLeftTarget(): Nullable<Vector3>;
  30577. /**
  30578. * Gets the right camera target of a rig setup in case of Rigged Camera
  30579. * @returns the target position
  30580. */
  30581. getRightTarget(): Nullable<Vector3>;
  30582. /**
  30583. * @hidden
  30584. */
  30585. setCameraRigMode(mode: number, rigParams: any): void;
  30586. /** @hidden */
  30587. static _setStereoscopicRigMode(camera: Camera): void;
  30588. /** @hidden */
  30589. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30590. /** @hidden */
  30591. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30592. /** @hidden */
  30593. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30594. /** @hidden */
  30595. _getVRProjectionMatrix(): Matrix;
  30596. protected _updateCameraRotationMatrix(): void;
  30597. protected _updateWebVRCameraRotationMatrix(): void;
  30598. /**
  30599. * This function MUST be overwritten by the different WebVR cameras available.
  30600. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30601. * @hidden
  30602. */
  30603. _getWebVRProjectionMatrix(): Matrix;
  30604. /**
  30605. * This function MUST be overwritten by the different WebVR cameras available.
  30606. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30607. * @hidden
  30608. */
  30609. _getWebVRViewMatrix(): Matrix;
  30610. /** @hidden */
  30611. setCameraRigParameter(name: string, value: any): void;
  30612. /**
  30613. * needs to be overridden by children so sub has required properties to be copied
  30614. * @hidden
  30615. */
  30616. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30617. /**
  30618. * May need to be overridden by children
  30619. * @hidden
  30620. */
  30621. _updateRigCameras(): void;
  30622. /** @hidden */
  30623. _setupInputs(): void;
  30624. /**
  30625. * Serialiaze the camera setup to a json represention
  30626. * @returns the JSON representation
  30627. */
  30628. serialize(): any;
  30629. /**
  30630. * Clones the current camera.
  30631. * @param name The cloned camera name
  30632. * @returns the cloned camera
  30633. */
  30634. clone(name: string): Camera;
  30635. /**
  30636. * Gets the direction of the camera relative to a given local axis.
  30637. * @param localAxis Defines the reference axis to provide a relative direction.
  30638. * @return the direction
  30639. */
  30640. getDirection(localAxis: Vector3): Vector3;
  30641. /**
  30642. * Returns the current camera absolute rotation
  30643. */
  30644. get absoluteRotation(): Quaternion;
  30645. /**
  30646. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30647. * @param localAxis Defines the reference axis to provide a relative direction.
  30648. * @param result Defines the vector to store the result in
  30649. */
  30650. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30651. /**
  30652. * Gets a camera constructor for a given camera type
  30653. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30654. * @param name The name of the camera the result will be able to instantiate
  30655. * @param scene The scene the result will construct the camera in
  30656. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30657. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30658. * @returns a factory method to construc the camera
  30659. */
  30660. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30661. /**
  30662. * Compute the world matrix of the camera.
  30663. * @returns the camera world matrix
  30664. */
  30665. computeWorldMatrix(): Matrix;
  30666. /**
  30667. * Parse a JSON and creates the camera from the parsed information
  30668. * @param parsedCamera The JSON to parse
  30669. * @param scene The scene to instantiate the camera in
  30670. * @returns the newly constructed camera
  30671. */
  30672. static Parse(parsedCamera: any, scene: Scene): Camera;
  30673. }
  30674. }
  30675. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30676. import { Nullable } from "babylonjs/types";
  30677. import { Scene } from "babylonjs/scene";
  30678. import { Vector4 } from "babylonjs/Maths/math.vector";
  30679. import { Mesh } from "babylonjs/Meshes/mesh";
  30680. /**
  30681. * Class containing static functions to help procedurally build meshes
  30682. */
  30683. export class DiscBuilder {
  30684. /**
  30685. * Creates a plane polygonal mesh. By default, this is a disc
  30686. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30687. * * 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
  30688. * * 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
  30689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30692. * @param name defines the name of the mesh
  30693. * @param options defines the options used to create the mesh
  30694. * @param scene defines the hosting scene
  30695. * @returns the plane polygonal mesh
  30696. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30697. */
  30698. static CreateDisc(name: string, options: {
  30699. radius?: number;
  30700. tessellation?: number;
  30701. arc?: number;
  30702. updatable?: boolean;
  30703. sideOrientation?: number;
  30704. frontUVs?: Vector4;
  30705. backUVs?: Vector4;
  30706. }, scene?: Nullable<Scene>): Mesh;
  30707. }
  30708. }
  30709. declare module "babylonjs/Materials/fresnelParameters" {
  30710. import { DeepImmutable } from "babylonjs/types";
  30711. import { Color3 } from "babylonjs/Maths/math.color";
  30712. /**
  30713. * Options to be used when creating a FresnelParameters.
  30714. */
  30715. export type IFresnelParametersCreationOptions = {
  30716. /**
  30717. * Define the color used on edges (grazing angle)
  30718. */
  30719. leftColor?: Color3;
  30720. /**
  30721. * Define the color used on center
  30722. */
  30723. rightColor?: Color3;
  30724. /**
  30725. * Define bias applied to computed fresnel term
  30726. */
  30727. bias?: number;
  30728. /**
  30729. * Defined the power exponent applied to fresnel term
  30730. */
  30731. power?: number;
  30732. /**
  30733. * Define if the fresnel effect is enable or not.
  30734. */
  30735. isEnabled?: boolean;
  30736. };
  30737. /**
  30738. * Serialized format for FresnelParameters.
  30739. */
  30740. export type IFresnelParametersSerialized = {
  30741. /**
  30742. * Define the color used on edges (grazing angle) [as an array]
  30743. */
  30744. leftColor: number[];
  30745. /**
  30746. * Define the color used on center [as an array]
  30747. */
  30748. rightColor: number[];
  30749. /**
  30750. * Define bias applied to computed fresnel term
  30751. */
  30752. bias: number;
  30753. /**
  30754. * Defined the power exponent applied to fresnel term
  30755. */
  30756. power?: number;
  30757. /**
  30758. * Define if the fresnel effect is enable or not.
  30759. */
  30760. isEnabled: boolean;
  30761. };
  30762. /**
  30763. * This represents all the required information to add a fresnel effect on a material:
  30764. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30765. */
  30766. export class FresnelParameters {
  30767. private _isEnabled;
  30768. /**
  30769. * Define if the fresnel effect is enable or not.
  30770. */
  30771. get isEnabled(): boolean;
  30772. set isEnabled(value: boolean);
  30773. /**
  30774. * Define the color used on edges (grazing angle)
  30775. */
  30776. leftColor: Color3;
  30777. /**
  30778. * Define the color used on center
  30779. */
  30780. rightColor: Color3;
  30781. /**
  30782. * Define bias applied to computed fresnel term
  30783. */
  30784. bias: number;
  30785. /**
  30786. * Defined the power exponent applied to fresnel term
  30787. */
  30788. power: number;
  30789. /**
  30790. * Creates a new FresnelParameters object.
  30791. *
  30792. * @param options provide your own settings to optionally to override defaults
  30793. */
  30794. constructor(options?: IFresnelParametersCreationOptions);
  30795. /**
  30796. * Clones the current fresnel and its valuues
  30797. * @returns a clone fresnel configuration
  30798. */
  30799. clone(): FresnelParameters;
  30800. /**
  30801. * Determines equality between FresnelParameters objects
  30802. * @param otherFresnelParameters defines the second operand
  30803. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30804. */
  30805. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30806. /**
  30807. * Serializes the current fresnel parameters to a JSON representation.
  30808. * @return the JSON serialization
  30809. */
  30810. serialize(): IFresnelParametersSerialized;
  30811. /**
  30812. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30813. * @param parsedFresnelParameters Define the JSON representation
  30814. * @returns the parsed parameters
  30815. */
  30816. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30817. }
  30818. }
  30819. declare module "babylonjs/Materials/materialFlags" {
  30820. /**
  30821. * This groups all the flags used to control the materials channel.
  30822. */
  30823. export class MaterialFlags {
  30824. private static _DiffuseTextureEnabled;
  30825. /**
  30826. * Are diffuse textures enabled in the application.
  30827. */
  30828. static get DiffuseTextureEnabled(): boolean;
  30829. static set DiffuseTextureEnabled(value: boolean);
  30830. private static _DetailTextureEnabled;
  30831. /**
  30832. * Are detail textures enabled in the application.
  30833. */
  30834. static get DetailTextureEnabled(): boolean;
  30835. static set DetailTextureEnabled(value: boolean);
  30836. private static _AmbientTextureEnabled;
  30837. /**
  30838. * Are ambient textures enabled in the application.
  30839. */
  30840. static get AmbientTextureEnabled(): boolean;
  30841. static set AmbientTextureEnabled(value: boolean);
  30842. private static _OpacityTextureEnabled;
  30843. /**
  30844. * Are opacity textures enabled in the application.
  30845. */
  30846. static get OpacityTextureEnabled(): boolean;
  30847. static set OpacityTextureEnabled(value: boolean);
  30848. private static _ReflectionTextureEnabled;
  30849. /**
  30850. * Are reflection textures enabled in the application.
  30851. */
  30852. static get ReflectionTextureEnabled(): boolean;
  30853. static set ReflectionTextureEnabled(value: boolean);
  30854. private static _EmissiveTextureEnabled;
  30855. /**
  30856. * Are emissive textures enabled in the application.
  30857. */
  30858. static get EmissiveTextureEnabled(): boolean;
  30859. static set EmissiveTextureEnabled(value: boolean);
  30860. private static _SpecularTextureEnabled;
  30861. /**
  30862. * Are specular textures enabled in the application.
  30863. */
  30864. static get SpecularTextureEnabled(): boolean;
  30865. static set SpecularTextureEnabled(value: boolean);
  30866. private static _BumpTextureEnabled;
  30867. /**
  30868. * Are bump textures enabled in the application.
  30869. */
  30870. static get BumpTextureEnabled(): boolean;
  30871. static set BumpTextureEnabled(value: boolean);
  30872. private static _LightmapTextureEnabled;
  30873. /**
  30874. * Are lightmap textures enabled in the application.
  30875. */
  30876. static get LightmapTextureEnabled(): boolean;
  30877. static set LightmapTextureEnabled(value: boolean);
  30878. private static _RefractionTextureEnabled;
  30879. /**
  30880. * Are refraction textures enabled in the application.
  30881. */
  30882. static get RefractionTextureEnabled(): boolean;
  30883. static set RefractionTextureEnabled(value: boolean);
  30884. private static _ColorGradingTextureEnabled;
  30885. /**
  30886. * Are color grading textures enabled in the application.
  30887. */
  30888. static get ColorGradingTextureEnabled(): boolean;
  30889. static set ColorGradingTextureEnabled(value: boolean);
  30890. private static _FresnelEnabled;
  30891. /**
  30892. * Are fresnels enabled in the application.
  30893. */
  30894. static get FresnelEnabled(): boolean;
  30895. static set FresnelEnabled(value: boolean);
  30896. private static _ClearCoatTextureEnabled;
  30897. /**
  30898. * Are clear coat textures enabled in the application.
  30899. */
  30900. static get ClearCoatTextureEnabled(): boolean;
  30901. static set ClearCoatTextureEnabled(value: boolean);
  30902. private static _ClearCoatBumpTextureEnabled;
  30903. /**
  30904. * Are clear coat bump textures enabled in the application.
  30905. */
  30906. static get ClearCoatBumpTextureEnabled(): boolean;
  30907. static set ClearCoatBumpTextureEnabled(value: boolean);
  30908. private static _ClearCoatTintTextureEnabled;
  30909. /**
  30910. * Are clear coat tint textures enabled in the application.
  30911. */
  30912. static get ClearCoatTintTextureEnabled(): boolean;
  30913. static set ClearCoatTintTextureEnabled(value: boolean);
  30914. private static _SheenTextureEnabled;
  30915. /**
  30916. * Are sheen textures enabled in the application.
  30917. */
  30918. static get SheenTextureEnabled(): boolean;
  30919. static set SheenTextureEnabled(value: boolean);
  30920. private static _AnisotropicTextureEnabled;
  30921. /**
  30922. * Are anisotropic textures enabled in the application.
  30923. */
  30924. static get AnisotropicTextureEnabled(): boolean;
  30925. static set AnisotropicTextureEnabled(value: boolean);
  30926. private static _ThicknessTextureEnabled;
  30927. /**
  30928. * Are thickness textures enabled in the application.
  30929. */
  30930. static get ThicknessTextureEnabled(): boolean;
  30931. static set ThicknessTextureEnabled(value: boolean);
  30932. }
  30933. }
  30934. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30935. /** @hidden */
  30936. export var defaultFragmentDeclaration: {
  30937. name: string;
  30938. shader: string;
  30939. };
  30940. }
  30941. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30942. /** @hidden */
  30943. export var defaultUboDeclaration: {
  30944. name: string;
  30945. shader: string;
  30946. };
  30947. }
  30948. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30949. /** @hidden */
  30950. export var prePassDeclaration: {
  30951. name: string;
  30952. shader: string;
  30953. };
  30954. }
  30955. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30956. /** @hidden */
  30957. export var lightFragmentDeclaration: {
  30958. name: string;
  30959. shader: string;
  30960. };
  30961. }
  30962. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30963. /** @hidden */
  30964. export var lightUboDeclaration: {
  30965. name: string;
  30966. shader: string;
  30967. };
  30968. }
  30969. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30970. /** @hidden */
  30971. export var lightsFragmentFunctions: {
  30972. name: string;
  30973. shader: string;
  30974. };
  30975. }
  30976. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30977. /** @hidden */
  30978. export var shadowsFragmentFunctions: {
  30979. name: string;
  30980. shader: string;
  30981. };
  30982. }
  30983. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30984. /** @hidden */
  30985. export var fresnelFunction: {
  30986. name: string;
  30987. shader: string;
  30988. };
  30989. }
  30990. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30991. /** @hidden */
  30992. export var bumpFragmentMainFunctions: {
  30993. name: string;
  30994. shader: string;
  30995. };
  30996. }
  30997. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30998. /** @hidden */
  30999. export var bumpFragmentFunctions: {
  31000. name: string;
  31001. shader: string;
  31002. };
  31003. }
  31004. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31005. /** @hidden */
  31006. export var logDepthDeclaration: {
  31007. name: string;
  31008. shader: string;
  31009. };
  31010. }
  31011. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31012. /** @hidden */
  31013. export var bumpFragment: {
  31014. name: string;
  31015. shader: string;
  31016. };
  31017. }
  31018. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31019. /** @hidden */
  31020. export var depthPrePass: {
  31021. name: string;
  31022. shader: string;
  31023. };
  31024. }
  31025. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31026. /** @hidden */
  31027. export var lightFragment: {
  31028. name: string;
  31029. shader: string;
  31030. };
  31031. }
  31032. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31033. /** @hidden */
  31034. export var logDepthFragment: {
  31035. name: string;
  31036. shader: string;
  31037. };
  31038. }
  31039. declare module "babylonjs/Shaders/default.fragment" {
  31040. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31041. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31042. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31043. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31044. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31045. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31046. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31047. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31048. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31049. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31050. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31051. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31052. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31053. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31054. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31055. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31056. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31057. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31058. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31059. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31060. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31061. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31062. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31063. /** @hidden */
  31064. export var defaultPixelShader: {
  31065. name: string;
  31066. shader: string;
  31067. };
  31068. }
  31069. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31070. /** @hidden */
  31071. export var defaultVertexDeclaration: {
  31072. name: string;
  31073. shader: string;
  31074. };
  31075. }
  31076. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31077. /** @hidden */
  31078. export var bumpVertexDeclaration: {
  31079. name: string;
  31080. shader: string;
  31081. };
  31082. }
  31083. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31084. /** @hidden */
  31085. export var bumpVertex: {
  31086. name: string;
  31087. shader: string;
  31088. };
  31089. }
  31090. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31091. /** @hidden */
  31092. export var fogVertex: {
  31093. name: string;
  31094. shader: string;
  31095. };
  31096. }
  31097. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31098. /** @hidden */
  31099. export var shadowsVertex: {
  31100. name: string;
  31101. shader: string;
  31102. };
  31103. }
  31104. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31105. /** @hidden */
  31106. export var pointCloudVertex: {
  31107. name: string;
  31108. shader: string;
  31109. };
  31110. }
  31111. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31112. /** @hidden */
  31113. export var logDepthVertex: {
  31114. name: string;
  31115. shader: string;
  31116. };
  31117. }
  31118. declare module "babylonjs/Shaders/default.vertex" {
  31119. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31120. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31121. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31122. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31123. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31124. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31125. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31126. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31127. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31128. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31129. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31131. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31133. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31134. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31135. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31136. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31137. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31138. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31139. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31140. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31141. /** @hidden */
  31142. export var defaultVertexShader: {
  31143. name: string;
  31144. shader: string;
  31145. };
  31146. }
  31147. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31148. import { Nullable } from "babylonjs/types";
  31149. import { Scene } from "babylonjs/scene";
  31150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31151. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31152. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31153. /**
  31154. * @hidden
  31155. */
  31156. export interface IMaterialDetailMapDefines {
  31157. DETAIL: boolean;
  31158. DETAILDIRECTUV: number;
  31159. DETAIL_NORMALBLENDMETHOD: number;
  31160. /** @hidden */
  31161. _areTexturesDirty: boolean;
  31162. }
  31163. /**
  31164. * Define the code related to the detail map parameters of a material
  31165. *
  31166. * Inspired from:
  31167. * 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
  31168. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31169. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31170. */
  31171. export class DetailMapConfiguration {
  31172. private _texture;
  31173. /**
  31174. * The detail texture of the material.
  31175. */
  31176. texture: Nullable<BaseTexture>;
  31177. /**
  31178. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31179. * Bigger values mean stronger blending
  31180. */
  31181. diffuseBlendLevel: number;
  31182. /**
  31183. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31184. * Bigger values mean stronger blending. Only used with PBR materials
  31185. */
  31186. roughnessBlendLevel: number;
  31187. /**
  31188. * Defines how strong the bump effect from the detail map is
  31189. * Bigger values mean stronger effect
  31190. */
  31191. bumpLevel: number;
  31192. private _normalBlendMethod;
  31193. /**
  31194. * The method used to blend the bump and detail normals together
  31195. */
  31196. normalBlendMethod: number;
  31197. private _isEnabled;
  31198. /**
  31199. * Enable or disable the detail map on this material
  31200. */
  31201. isEnabled: boolean;
  31202. /** @hidden */
  31203. private _internalMarkAllSubMeshesAsTexturesDirty;
  31204. /** @hidden */
  31205. _markAllSubMeshesAsTexturesDirty(): void;
  31206. /**
  31207. * Instantiate a new detail map
  31208. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31209. */
  31210. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31211. /**
  31212. * Gets whether the submesh is ready to be used or not.
  31213. * @param defines the list of "defines" to update.
  31214. * @param scene defines the scene the material belongs to.
  31215. * @returns - boolean indicating that the submesh is ready or not.
  31216. */
  31217. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31218. /**
  31219. * Update the defines for detail map usage
  31220. * @param defines the list of "defines" to update.
  31221. * @param scene defines the scene the material belongs to.
  31222. */
  31223. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31224. /**
  31225. * Binds the material data.
  31226. * @param uniformBuffer defines the Uniform buffer to fill in.
  31227. * @param scene defines the scene the material belongs to.
  31228. * @param isFrozen defines whether the material is frozen or not.
  31229. */
  31230. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31231. /**
  31232. * Checks to see if a texture is used in the material.
  31233. * @param texture - Base texture to use.
  31234. * @returns - Boolean specifying if a texture is used in the material.
  31235. */
  31236. hasTexture(texture: BaseTexture): boolean;
  31237. /**
  31238. * Returns an array of the actively used textures.
  31239. * @param activeTextures Array of BaseTextures
  31240. */
  31241. getActiveTextures(activeTextures: BaseTexture[]): void;
  31242. /**
  31243. * Returns the animatable textures.
  31244. * @param animatables Array of animatable textures.
  31245. */
  31246. getAnimatables(animatables: IAnimatable[]): void;
  31247. /**
  31248. * Disposes the resources of the material.
  31249. * @param forceDisposeTextures - Forces the disposal of all textures.
  31250. */
  31251. dispose(forceDisposeTextures?: boolean): void;
  31252. /**
  31253. * Get the current class name useful for serialization or dynamic coding.
  31254. * @returns "DetailMap"
  31255. */
  31256. getClassName(): string;
  31257. /**
  31258. * Add the required uniforms to the current list.
  31259. * @param uniforms defines the current uniform list.
  31260. */
  31261. static AddUniforms(uniforms: string[]): void;
  31262. /**
  31263. * Add the required samplers to the current list.
  31264. * @param samplers defines the current sampler list.
  31265. */
  31266. static AddSamplers(samplers: string[]): void;
  31267. /**
  31268. * Add the required uniforms to the current buffer.
  31269. * @param uniformBuffer defines the current uniform buffer.
  31270. */
  31271. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31272. /**
  31273. * Makes a duplicate of the current instance into another one.
  31274. * @param detailMap define the instance where to copy the info
  31275. */
  31276. copyTo(detailMap: DetailMapConfiguration): void;
  31277. /**
  31278. * Serializes this detail map instance
  31279. * @returns - An object with the serialized instance.
  31280. */
  31281. serialize(): any;
  31282. /**
  31283. * Parses a detail map setting from a serialized object.
  31284. * @param source - Serialized object.
  31285. * @param scene Defines the scene we are parsing for
  31286. * @param rootUrl Defines the rootUrl to load from
  31287. */
  31288. parse(source: any, scene: Scene, rootUrl: string): void;
  31289. }
  31290. }
  31291. declare module "babylonjs/Materials/standardMaterial" {
  31292. import { SmartArray } from "babylonjs/Misc/smartArray";
  31293. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31294. import { Nullable } from "babylonjs/types";
  31295. import { Scene } from "babylonjs/scene";
  31296. import { Matrix } from "babylonjs/Maths/math.vector";
  31297. import { Color3 } from "babylonjs/Maths/math.color";
  31298. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31300. import { Mesh } from "babylonjs/Meshes/mesh";
  31301. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31302. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31303. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31304. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31305. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31308. import "babylonjs/Shaders/default.fragment";
  31309. import "babylonjs/Shaders/default.vertex";
  31310. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31311. /** @hidden */
  31312. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31313. MAINUV1: boolean;
  31314. MAINUV2: boolean;
  31315. DIFFUSE: boolean;
  31316. DIFFUSEDIRECTUV: number;
  31317. DETAIL: boolean;
  31318. DETAILDIRECTUV: number;
  31319. DETAIL_NORMALBLENDMETHOD: number;
  31320. AMBIENT: boolean;
  31321. AMBIENTDIRECTUV: number;
  31322. OPACITY: boolean;
  31323. OPACITYDIRECTUV: number;
  31324. OPACITYRGB: boolean;
  31325. REFLECTION: boolean;
  31326. EMISSIVE: boolean;
  31327. EMISSIVEDIRECTUV: number;
  31328. SPECULAR: boolean;
  31329. SPECULARDIRECTUV: number;
  31330. BUMP: boolean;
  31331. BUMPDIRECTUV: number;
  31332. PARALLAX: boolean;
  31333. PARALLAXOCCLUSION: boolean;
  31334. SPECULAROVERALPHA: boolean;
  31335. CLIPPLANE: boolean;
  31336. CLIPPLANE2: boolean;
  31337. CLIPPLANE3: boolean;
  31338. CLIPPLANE4: boolean;
  31339. CLIPPLANE5: boolean;
  31340. CLIPPLANE6: boolean;
  31341. ALPHATEST: boolean;
  31342. DEPTHPREPASS: boolean;
  31343. ALPHAFROMDIFFUSE: boolean;
  31344. POINTSIZE: boolean;
  31345. FOG: boolean;
  31346. SPECULARTERM: boolean;
  31347. DIFFUSEFRESNEL: boolean;
  31348. OPACITYFRESNEL: boolean;
  31349. REFLECTIONFRESNEL: boolean;
  31350. REFRACTIONFRESNEL: boolean;
  31351. EMISSIVEFRESNEL: boolean;
  31352. FRESNEL: boolean;
  31353. NORMAL: boolean;
  31354. UV1: boolean;
  31355. UV2: boolean;
  31356. VERTEXCOLOR: boolean;
  31357. VERTEXALPHA: boolean;
  31358. NUM_BONE_INFLUENCERS: number;
  31359. BonesPerMesh: number;
  31360. BONETEXTURE: boolean;
  31361. INSTANCES: boolean;
  31362. THIN_INSTANCES: boolean;
  31363. GLOSSINESS: boolean;
  31364. ROUGHNESS: boolean;
  31365. EMISSIVEASILLUMINATION: boolean;
  31366. LINKEMISSIVEWITHDIFFUSE: boolean;
  31367. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31368. LIGHTMAP: boolean;
  31369. LIGHTMAPDIRECTUV: number;
  31370. OBJECTSPACE_NORMALMAP: boolean;
  31371. USELIGHTMAPASSHADOWMAP: boolean;
  31372. REFLECTIONMAP_3D: boolean;
  31373. REFLECTIONMAP_SPHERICAL: boolean;
  31374. REFLECTIONMAP_PLANAR: boolean;
  31375. REFLECTIONMAP_CUBIC: boolean;
  31376. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31377. REFLECTIONMAP_PROJECTION: boolean;
  31378. REFLECTIONMAP_SKYBOX: boolean;
  31379. REFLECTIONMAP_EXPLICIT: boolean;
  31380. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31381. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31382. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31383. INVERTCUBICMAP: boolean;
  31384. LOGARITHMICDEPTH: boolean;
  31385. REFRACTION: boolean;
  31386. REFRACTIONMAP_3D: boolean;
  31387. REFLECTIONOVERALPHA: boolean;
  31388. TWOSIDEDLIGHTING: boolean;
  31389. SHADOWFLOAT: boolean;
  31390. MORPHTARGETS: boolean;
  31391. MORPHTARGETS_NORMAL: boolean;
  31392. MORPHTARGETS_TANGENT: boolean;
  31393. MORPHTARGETS_UV: boolean;
  31394. NUM_MORPH_INFLUENCERS: number;
  31395. NONUNIFORMSCALING: boolean;
  31396. PREMULTIPLYALPHA: boolean;
  31397. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31398. ALPHABLEND: boolean;
  31399. PREPASS: boolean;
  31400. SCENE_MRT_COUNT: number;
  31401. RGBDLIGHTMAP: boolean;
  31402. RGBDREFLECTION: boolean;
  31403. RGBDREFRACTION: boolean;
  31404. IMAGEPROCESSING: boolean;
  31405. VIGNETTE: boolean;
  31406. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31407. VIGNETTEBLENDMODEOPAQUE: boolean;
  31408. TONEMAPPING: boolean;
  31409. TONEMAPPING_ACES: boolean;
  31410. CONTRAST: boolean;
  31411. COLORCURVES: boolean;
  31412. COLORGRADING: boolean;
  31413. COLORGRADING3D: boolean;
  31414. SAMPLER3DGREENDEPTH: boolean;
  31415. SAMPLER3DBGRMAP: boolean;
  31416. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31417. MULTIVIEW: boolean;
  31418. /**
  31419. * If the reflection texture on this material is in linear color space
  31420. * @hidden
  31421. */
  31422. IS_REFLECTION_LINEAR: boolean;
  31423. /**
  31424. * If the refraction texture on this material is in linear color space
  31425. * @hidden
  31426. */
  31427. IS_REFRACTION_LINEAR: boolean;
  31428. EXPOSURE: boolean;
  31429. constructor();
  31430. setReflectionMode(modeToEnable: string): void;
  31431. }
  31432. /**
  31433. * This is the default material used in Babylon. It is the best trade off between quality
  31434. * and performances.
  31435. * @see https://doc.babylonjs.com/babylon101/materials
  31436. */
  31437. export class StandardMaterial extends PushMaterial {
  31438. private _diffuseTexture;
  31439. /**
  31440. * The basic texture of the material as viewed under a light.
  31441. */
  31442. diffuseTexture: Nullable<BaseTexture>;
  31443. private _ambientTexture;
  31444. /**
  31445. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31446. */
  31447. ambientTexture: Nullable<BaseTexture>;
  31448. private _opacityTexture;
  31449. /**
  31450. * Define the transparency of the material from a texture.
  31451. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31452. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31453. */
  31454. opacityTexture: Nullable<BaseTexture>;
  31455. private _reflectionTexture;
  31456. /**
  31457. * Define the texture used to display the reflection.
  31458. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31459. */
  31460. reflectionTexture: Nullable<BaseTexture>;
  31461. private _emissiveTexture;
  31462. /**
  31463. * Define texture of the material as if self lit.
  31464. * This will be mixed in the final result even in the absence of light.
  31465. */
  31466. emissiveTexture: Nullable<BaseTexture>;
  31467. private _specularTexture;
  31468. /**
  31469. * Define how the color and intensity of the highlight given by the light in the material.
  31470. */
  31471. specularTexture: Nullable<BaseTexture>;
  31472. private _bumpTexture;
  31473. /**
  31474. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31475. * 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.
  31476. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31477. */
  31478. bumpTexture: Nullable<BaseTexture>;
  31479. private _lightmapTexture;
  31480. /**
  31481. * Complex lighting can be computationally expensive to compute at runtime.
  31482. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31483. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31484. */
  31485. lightmapTexture: Nullable<BaseTexture>;
  31486. private _refractionTexture;
  31487. /**
  31488. * Define the texture used to display the refraction.
  31489. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31490. */
  31491. refractionTexture: Nullable<BaseTexture>;
  31492. /**
  31493. * The color of the material lit by the environmental background lighting.
  31494. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31495. */
  31496. ambientColor: Color3;
  31497. /**
  31498. * The basic color of the material as viewed under a light.
  31499. */
  31500. diffuseColor: Color3;
  31501. /**
  31502. * Define how the color and intensity of the highlight given by the light in the material.
  31503. */
  31504. specularColor: Color3;
  31505. /**
  31506. * Define the color of the material as if self lit.
  31507. * This will be mixed in the final result even in the absence of light.
  31508. */
  31509. emissiveColor: Color3;
  31510. /**
  31511. * Defines how sharp are the highlights in the material.
  31512. * The bigger the value the sharper giving a more glossy feeling to the result.
  31513. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31514. */
  31515. specularPower: number;
  31516. private _useAlphaFromDiffuseTexture;
  31517. /**
  31518. * Does the transparency come from the diffuse texture alpha channel.
  31519. */
  31520. useAlphaFromDiffuseTexture: boolean;
  31521. private _useEmissiveAsIllumination;
  31522. /**
  31523. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31524. */
  31525. useEmissiveAsIllumination: boolean;
  31526. private _linkEmissiveWithDiffuse;
  31527. /**
  31528. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31529. * the emissive level when the final color is close to one.
  31530. */
  31531. linkEmissiveWithDiffuse: boolean;
  31532. private _useSpecularOverAlpha;
  31533. /**
  31534. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31535. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31536. */
  31537. useSpecularOverAlpha: boolean;
  31538. private _useReflectionOverAlpha;
  31539. /**
  31540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31542. */
  31543. useReflectionOverAlpha: boolean;
  31544. private _disableLighting;
  31545. /**
  31546. * Does lights from the scene impacts this material.
  31547. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31548. */
  31549. disableLighting: boolean;
  31550. private _useObjectSpaceNormalMap;
  31551. /**
  31552. * Allows using an object space normal map (instead of tangent space).
  31553. */
  31554. useObjectSpaceNormalMap: boolean;
  31555. private _useParallax;
  31556. /**
  31557. * Is parallax enabled or not.
  31558. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31559. */
  31560. useParallax: boolean;
  31561. private _useParallaxOcclusion;
  31562. /**
  31563. * Is parallax occlusion enabled or not.
  31564. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31565. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31566. */
  31567. useParallaxOcclusion: boolean;
  31568. /**
  31569. * 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.
  31570. */
  31571. parallaxScaleBias: number;
  31572. private _roughness;
  31573. /**
  31574. * Helps to define how blurry the reflections should appears in the material.
  31575. */
  31576. roughness: number;
  31577. /**
  31578. * In case of refraction, define the value of the index of refraction.
  31579. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31580. */
  31581. indexOfRefraction: number;
  31582. /**
  31583. * Invert the refraction texture alongside the y axis.
  31584. * It can be useful with procedural textures or probe for instance.
  31585. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31586. */
  31587. invertRefractionY: boolean;
  31588. /**
  31589. * Defines the alpha limits in alpha test mode.
  31590. */
  31591. alphaCutOff: number;
  31592. private _useLightmapAsShadowmap;
  31593. /**
  31594. * In case of light mapping, define whether the map contains light or shadow informations.
  31595. */
  31596. useLightmapAsShadowmap: boolean;
  31597. private _diffuseFresnelParameters;
  31598. /**
  31599. * Define the diffuse fresnel parameters of the material.
  31600. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31601. */
  31602. diffuseFresnelParameters: FresnelParameters;
  31603. private _opacityFresnelParameters;
  31604. /**
  31605. * Define the opacity fresnel parameters of the material.
  31606. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31607. */
  31608. opacityFresnelParameters: FresnelParameters;
  31609. private _reflectionFresnelParameters;
  31610. /**
  31611. * Define the reflection fresnel parameters of the material.
  31612. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31613. */
  31614. reflectionFresnelParameters: FresnelParameters;
  31615. private _refractionFresnelParameters;
  31616. /**
  31617. * Define the refraction fresnel parameters of the material.
  31618. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31619. */
  31620. refractionFresnelParameters: FresnelParameters;
  31621. private _emissiveFresnelParameters;
  31622. /**
  31623. * Define the emissive fresnel parameters of the material.
  31624. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31625. */
  31626. emissiveFresnelParameters: FresnelParameters;
  31627. private _useReflectionFresnelFromSpecular;
  31628. /**
  31629. * If true automatically deducts the fresnels values from the material specularity.
  31630. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31631. */
  31632. useReflectionFresnelFromSpecular: boolean;
  31633. private _useGlossinessFromSpecularMapAlpha;
  31634. /**
  31635. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31636. */
  31637. useGlossinessFromSpecularMapAlpha: boolean;
  31638. private _maxSimultaneousLights;
  31639. /**
  31640. * Defines the maximum number of lights that can be used in the material
  31641. */
  31642. maxSimultaneousLights: number;
  31643. private _invertNormalMapX;
  31644. /**
  31645. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31646. */
  31647. invertNormalMapX: boolean;
  31648. private _invertNormalMapY;
  31649. /**
  31650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31651. */
  31652. invertNormalMapY: boolean;
  31653. private _twoSidedLighting;
  31654. /**
  31655. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31656. */
  31657. twoSidedLighting: boolean;
  31658. /**
  31659. * Default configuration related to image processing available in the standard Material.
  31660. */
  31661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31662. /**
  31663. * Gets the image processing configuration used either in this material.
  31664. */
  31665. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31666. /**
  31667. * Sets the Default image processing configuration used either in the this material.
  31668. *
  31669. * If sets to null, the scene one is in use.
  31670. */
  31671. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31672. /**
  31673. * Keep track of the image processing observer to allow dispose and replace.
  31674. */
  31675. private _imageProcessingObserver;
  31676. /**
  31677. * Attaches a new image processing configuration to the Standard Material.
  31678. * @param configuration
  31679. */
  31680. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31681. /**
  31682. * Gets wether the color curves effect is enabled.
  31683. */
  31684. get cameraColorCurvesEnabled(): boolean;
  31685. /**
  31686. * Sets wether the color curves effect is enabled.
  31687. */
  31688. set cameraColorCurvesEnabled(value: boolean);
  31689. /**
  31690. * Gets wether the color grading effect is enabled.
  31691. */
  31692. get cameraColorGradingEnabled(): boolean;
  31693. /**
  31694. * Gets wether the color grading effect is enabled.
  31695. */
  31696. set cameraColorGradingEnabled(value: boolean);
  31697. /**
  31698. * Gets wether tonemapping is enabled or not.
  31699. */
  31700. get cameraToneMappingEnabled(): boolean;
  31701. /**
  31702. * Sets wether tonemapping is enabled or not
  31703. */
  31704. set cameraToneMappingEnabled(value: boolean);
  31705. /**
  31706. * The camera exposure used on this material.
  31707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31708. * This corresponds to a photographic exposure.
  31709. */
  31710. get cameraExposure(): number;
  31711. /**
  31712. * The camera exposure used on this material.
  31713. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31714. * This corresponds to a photographic exposure.
  31715. */
  31716. set cameraExposure(value: number);
  31717. /**
  31718. * Gets The camera contrast used on this material.
  31719. */
  31720. get cameraContrast(): number;
  31721. /**
  31722. * Sets The camera contrast used on this material.
  31723. */
  31724. set cameraContrast(value: number);
  31725. /**
  31726. * Gets the Color Grading 2D Lookup Texture.
  31727. */
  31728. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31729. /**
  31730. * Sets the Color Grading 2D Lookup Texture.
  31731. */
  31732. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31733. /**
  31734. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31735. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31736. * 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;
  31737. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31738. */
  31739. get cameraColorCurves(): Nullable<ColorCurves>;
  31740. /**
  31741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31743. * 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;
  31744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31745. */
  31746. set cameraColorCurves(value: Nullable<ColorCurves>);
  31747. /**
  31748. * Can this material render to several textures at once
  31749. */
  31750. get canRenderToMRT(): boolean;
  31751. /**
  31752. * Defines the detail map parameters for the material.
  31753. */
  31754. readonly detailMap: DetailMapConfiguration;
  31755. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31756. protected _worldViewProjectionMatrix: Matrix;
  31757. protected _globalAmbientColor: Color3;
  31758. protected _useLogarithmicDepth: boolean;
  31759. protected _rebuildInParallel: boolean;
  31760. /**
  31761. * Instantiates a new standard material.
  31762. * This is the default material used in Babylon. It is the best trade off between quality
  31763. * and performances.
  31764. * @see https://doc.babylonjs.com/babylon101/materials
  31765. * @param name Define the name of the material in the scene
  31766. * @param scene Define the scene the material belong to
  31767. */
  31768. constructor(name: string, scene: Scene);
  31769. /**
  31770. * Gets a boolean indicating that current material needs to register RTT
  31771. */
  31772. get hasRenderTargetTextures(): boolean;
  31773. /**
  31774. * Gets the current class name of the material e.g. "StandardMaterial"
  31775. * Mainly use in serialization.
  31776. * @returns the class name
  31777. */
  31778. getClassName(): string;
  31779. /**
  31780. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31781. * You can try switching to logarithmic depth.
  31782. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31783. */
  31784. get useLogarithmicDepth(): boolean;
  31785. set useLogarithmicDepth(value: boolean);
  31786. /**
  31787. * Specifies if the material will require alpha blending
  31788. * @returns a boolean specifying if alpha blending is needed
  31789. */
  31790. needAlphaBlending(): boolean;
  31791. /**
  31792. * Specifies if this material should be rendered in alpha test mode
  31793. * @returns a boolean specifying if an alpha test is needed.
  31794. */
  31795. needAlphaTesting(): boolean;
  31796. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31797. /**
  31798. * Get the texture used for alpha test purpose.
  31799. * @returns the diffuse texture in case of the standard material.
  31800. */
  31801. getAlphaTestTexture(): Nullable<BaseTexture>;
  31802. /**
  31803. * Get if the submesh is ready to be used and all its information available.
  31804. * Child classes can use it to update shaders
  31805. * @param mesh defines the mesh to check
  31806. * @param subMesh defines which submesh to check
  31807. * @param useInstances specifies that instances should be used
  31808. * @returns a boolean indicating that the submesh is ready or not
  31809. */
  31810. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31811. /**
  31812. * Builds the material UBO layouts.
  31813. * Used internally during the effect preparation.
  31814. */
  31815. buildUniformLayout(): void;
  31816. /**
  31817. * Unbinds the material from the mesh
  31818. */
  31819. unbind(): void;
  31820. /**
  31821. * Binds the submesh to this material by preparing the effect and shader to draw
  31822. * @param world defines the world transformation matrix
  31823. * @param mesh defines the mesh containing the submesh
  31824. * @param subMesh defines the submesh to bind the material to
  31825. */
  31826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31827. /**
  31828. * Get the list of animatables in the material.
  31829. * @returns the list of animatables object used in the material
  31830. */
  31831. getAnimatables(): IAnimatable[];
  31832. /**
  31833. * Gets the active textures from the material
  31834. * @returns an array of textures
  31835. */
  31836. getActiveTextures(): BaseTexture[];
  31837. /**
  31838. * Specifies if the material uses a texture
  31839. * @param texture defines the texture to check against the material
  31840. * @returns a boolean specifying if the material uses the texture
  31841. */
  31842. hasTexture(texture: BaseTexture): boolean;
  31843. /**
  31844. * Disposes the material
  31845. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31846. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31847. */
  31848. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31849. /**
  31850. * Makes a duplicate of the material, and gives it a new name
  31851. * @param name defines the new name for the duplicated material
  31852. * @returns the cloned material
  31853. */
  31854. clone(name: string): StandardMaterial;
  31855. /**
  31856. * Serializes this material in a JSON representation
  31857. * @returns the serialized material object
  31858. */
  31859. serialize(): any;
  31860. /**
  31861. * Creates a standard material from parsed material data
  31862. * @param source defines the JSON representation of the material
  31863. * @param scene defines the hosting scene
  31864. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31865. * @returns a new standard material
  31866. */
  31867. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31868. /**
  31869. * Are diffuse textures enabled in the application.
  31870. */
  31871. static get DiffuseTextureEnabled(): boolean;
  31872. static set DiffuseTextureEnabled(value: boolean);
  31873. /**
  31874. * Are detail textures enabled in the application.
  31875. */
  31876. static get DetailTextureEnabled(): boolean;
  31877. static set DetailTextureEnabled(value: boolean);
  31878. /**
  31879. * Are ambient textures enabled in the application.
  31880. */
  31881. static get AmbientTextureEnabled(): boolean;
  31882. static set AmbientTextureEnabled(value: boolean);
  31883. /**
  31884. * Are opacity textures enabled in the application.
  31885. */
  31886. static get OpacityTextureEnabled(): boolean;
  31887. static set OpacityTextureEnabled(value: boolean);
  31888. /**
  31889. * Are reflection textures enabled in the application.
  31890. */
  31891. static get ReflectionTextureEnabled(): boolean;
  31892. static set ReflectionTextureEnabled(value: boolean);
  31893. /**
  31894. * Are emissive textures enabled in the application.
  31895. */
  31896. static get EmissiveTextureEnabled(): boolean;
  31897. static set EmissiveTextureEnabled(value: boolean);
  31898. /**
  31899. * Are specular textures enabled in the application.
  31900. */
  31901. static get SpecularTextureEnabled(): boolean;
  31902. static set SpecularTextureEnabled(value: boolean);
  31903. /**
  31904. * Are bump textures enabled in the application.
  31905. */
  31906. static get BumpTextureEnabled(): boolean;
  31907. static set BumpTextureEnabled(value: boolean);
  31908. /**
  31909. * Are lightmap textures enabled in the application.
  31910. */
  31911. static get LightmapTextureEnabled(): boolean;
  31912. static set LightmapTextureEnabled(value: boolean);
  31913. /**
  31914. * Are refraction textures enabled in the application.
  31915. */
  31916. static get RefractionTextureEnabled(): boolean;
  31917. static set RefractionTextureEnabled(value: boolean);
  31918. /**
  31919. * Are color grading textures enabled in the application.
  31920. */
  31921. static get ColorGradingTextureEnabled(): boolean;
  31922. static set ColorGradingTextureEnabled(value: boolean);
  31923. /**
  31924. * Are fresnels enabled in the application.
  31925. */
  31926. static get FresnelEnabled(): boolean;
  31927. static set FresnelEnabled(value: boolean);
  31928. }
  31929. }
  31930. declare module "babylonjs/Particles/solidParticleSystem" {
  31931. import { Nullable } from "babylonjs/types";
  31932. import { Mesh } from "babylonjs/Meshes/mesh";
  31933. import { Scene, IDisposable } from "babylonjs/scene";
  31934. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31935. import { Material } from "babylonjs/Materials/material";
  31936. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31937. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31938. /**
  31939. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31940. *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.
  31941. * The SPS is also a particle system. It provides some methods to manage the particles.
  31942. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31943. *
  31944. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31945. */
  31946. export class SolidParticleSystem implements IDisposable {
  31947. /**
  31948. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31949. * Example : var p = SPS.particles[i];
  31950. */
  31951. particles: SolidParticle[];
  31952. /**
  31953. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31954. */
  31955. nbParticles: number;
  31956. /**
  31957. * If the particles must ever face the camera (default false). Useful for planar particles.
  31958. */
  31959. billboard: boolean;
  31960. /**
  31961. * Recompute normals when adding a shape
  31962. */
  31963. recomputeNormals: boolean;
  31964. /**
  31965. * This a counter ofr your own usage. It's not set by any SPS functions.
  31966. */
  31967. counter: number;
  31968. /**
  31969. * The SPS name. This name is also given to the underlying mesh.
  31970. */
  31971. name: string;
  31972. /**
  31973. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31974. */
  31975. mesh: Mesh;
  31976. /**
  31977. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31978. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31979. */
  31980. vars: any;
  31981. /**
  31982. * This array is populated when the SPS is set as 'pickable'.
  31983. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31984. * Each element of this array is an object `{idx: int, faceId: int}`.
  31985. * `idx` is the picked particle index in the `SPS.particles` array
  31986. * `faceId` is the picked face index counted within this particle.
  31987. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31988. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31989. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31990. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31991. */
  31992. pickedParticles: {
  31993. idx: number;
  31994. faceId: number;
  31995. }[];
  31996. /**
  31997. * This array is populated when the SPS is set as 'pickable'
  31998. * Each key of this array is a submesh index.
  31999. * Each element of this array is a second array defined like this :
  32000. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32001. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32002. * `idx` is the picked particle index in the `SPS.particles` array
  32003. * `faceId` is the picked face index counted within this particle.
  32004. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32005. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32006. */
  32007. pickedBySubMesh: {
  32008. idx: number;
  32009. faceId: number;
  32010. }[][];
  32011. /**
  32012. * This array is populated when `enableDepthSort` is set to true.
  32013. * Each element of this array is an instance of the class DepthSortedParticle.
  32014. */
  32015. depthSortedParticles: DepthSortedParticle[];
  32016. /**
  32017. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32018. * @hidden
  32019. */
  32020. _bSphereOnly: boolean;
  32021. /**
  32022. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32023. * @hidden
  32024. */
  32025. _bSphereRadiusFactor: number;
  32026. private _scene;
  32027. private _positions;
  32028. private _indices;
  32029. private _normals;
  32030. private _colors;
  32031. private _uvs;
  32032. private _indices32;
  32033. private _positions32;
  32034. private _normals32;
  32035. private _fixedNormal32;
  32036. private _colors32;
  32037. private _uvs32;
  32038. private _index;
  32039. private _updatable;
  32040. private _pickable;
  32041. private _isVisibilityBoxLocked;
  32042. private _alwaysVisible;
  32043. private _depthSort;
  32044. private _expandable;
  32045. private _shapeCounter;
  32046. private _copy;
  32047. private _color;
  32048. private _computeParticleColor;
  32049. private _computeParticleTexture;
  32050. private _computeParticleRotation;
  32051. private _computeParticleVertex;
  32052. private _computeBoundingBox;
  32053. private _depthSortParticles;
  32054. private _camera;
  32055. private _mustUnrotateFixedNormals;
  32056. private _particlesIntersect;
  32057. private _needs32Bits;
  32058. private _isNotBuilt;
  32059. private _lastParticleId;
  32060. private _idxOfId;
  32061. private _multimaterialEnabled;
  32062. private _useModelMaterial;
  32063. private _indicesByMaterial;
  32064. private _materialIndexes;
  32065. private _depthSortFunction;
  32066. private _materialSortFunction;
  32067. private _materials;
  32068. private _multimaterial;
  32069. private _materialIndexesById;
  32070. private _defaultMaterial;
  32071. private _autoUpdateSubMeshes;
  32072. private _tmpVertex;
  32073. /**
  32074. * Creates a SPS (Solid Particle System) object.
  32075. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32076. * @param scene (Scene) is the scene in which the SPS is added.
  32077. * @param options defines the options of the sps e.g.
  32078. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32079. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32080. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32081. * * 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.
  32082. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32083. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32084. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32085. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32086. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32087. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32088. */
  32089. constructor(name: string, scene: Scene, options?: {
  32090. updatable?: boolean;
  32091. isPickable?: boolean;
  32092. enableDepthSort?: boolean;
  32093. particleIntersection?: boolean;
  32094. boundingSphereOnly?: boolean;
  32095. bSphereRadiusFactor?: number;
  32096. expandable?: boolean;
  32097. useModelMaterial?: boolean;
  32098. enableMultiMaterial?: boolean;
  32099. });
  32100. /**
  32101. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32102. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32103. * @returns the created mesh
  32104. */
  32105. buildMesh(): Mesh;
  32106. /**
  32107. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32108. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32109. * Thus the particles generated from `digest()` have their property `position` set yet.
  32110. * @param mesh ( Mesh ) is the mesh to be digested
  32111. * @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
  32112. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32113. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32114. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32115. * @returns the current SPS
  32116. */
  32117. digest(mesh: Mesh, options?: {
  32118. facetNb?: number;
  32119. number?: number;
  32120. delta?: number;
  32121. storage?: [];
  32122. }): SolidParticleSystem;
  32123. /**
  32124. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32125. * @hidden
  32126. */
  32127. private _unrotateFixedNormals;
  32128. /**
  32129. * Resets the temporary working copy particle
  32130. * @hidden
  32131. */
  32132. private _resetCopy;
  32133. /**
  32134. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32135. * @param p the current index in the positions array to be updated
  32136. * @param ind the current index in the indices array
  32137. * @param shape a Vector3 array, the shape geometry
  32138. * @param positions the positions array to be updated
  32139. * @param meshInd the shape indices array
  32140. * @param indices the indices array to be updated
  32141. * @param meshUV the shape uv array
  32142. * @param uvs the uv array to be updated
  32143. * @param meshCol the shape color array
  32144. * @param colors the color array to be updated
  32145. * @param meshNor the shape normals array
  32146. * @param normals the normals array to be updated
  32147. * @param idx the particle index
  32148. * @param idxInShape the particle index in its shape
  32149. * @param options the addShape() method passed options
  32150. * @model the particle model
  32151. * @hidden
  32152. */
  32153. private _meshBuilder;
  32154. /**
  32155. * Returns a shape Vector3 array from positions float array
  32156. * @param positions float array
  32157. * @returns a vector3 array
  32158. * @hidden
  32159. */
  32160. private _posToShape;
  32161. /**
  32162. * Returns a shapeUV array from a float uvs (array deep copy)
  32163. * @param uvs as a float array
  32164. * @returns a shapeUV array
  32165. * @hidden
  32166. */
  32167. private _uvsToShapeUV;
  32168. /**
  32169. * Adds a new particle object in the particles array
  32170. * @param idx particle index in particles array
  32171. * @param id particle id
  32172. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32173. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32174. * @param model particle ModelShape object
  32175. * @param shapeId model shape identifier
  32176. * @param idxInShape index of the particle in the current model
  32177. * @param bInfo model bounding info object
  32178. * @param storage target storage array, if any
  32179. * @hidden
  32180. */
  32181. private _addParticle;
  32182. /**
  32183. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32184. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32185. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32186. * @param nb (positive integer) the number of particles to be created from this model
  32187. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32188. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32189. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32190. * @returns the number of shapes in the system
  32191. */
  32192. addShape(mesh: Mesh, nb: number, options?: {
  32193. positionFunction?: any;
  32194. vertexFunction?: any;
  32195. storage?: [];
  32196. }): number;
  32197. /**
  32198. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32199. * @hidden
  32200. */
  32201. private _rebuildParticle;
  32202. /**
  32203. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32204. * @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.
  32205. * @returns the SPS.
  32206. */
  32207. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32208. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32209. * Returns an array with the removed particles.
  32210. * 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.
  32211. * The SPS can't be empty so at least one particle needs to remain in place.
  32212. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32213. * @param start index of the first particle to remove
  32214. * @param end index of the last particle to remove (included)
  32215. * @returns an array populated with the removed particles
  32216. */
  32217. removeParticles(start: number, end: number): SolidParticle[];
  32218. /**
  32219. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32220. * @param solidParticleArray an array populated with Solid Particles objects
  32221. * @returns the SPS
  32222. */
  32223. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32224. /**
  32225. * Creates a new particle and modifies the SPS mesh geometry :
  32226. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32227. * - calls _addParticle() to populate the particle array
  32228. * factorized code from addShape() and insertParticlesFromArray()
  32229. * @param idx particle index in the particles array
  32230. * @param i particle index in its shape
  32231. * @param modelShape particle ModelShape object
  32232. * @param shape shape vertex array
  32233. * @param meshInd shape indices array
  32234. * @param meshUV shape uv array
  32235. * @param meshCol shape color array
  32236. * @param meshNor shape normals array
  32237. * @param bbInfo shape bounding info
  32238. * @param storage target particle storage
  32239. * @options addShape() passed options
  32240. * @hidden
  32241. */
  32242. private _insertNewParticle;
  32243. /**
  32244. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32245. * This method calls `updateParticle()` for each particle of the SPS.
  32246. * For an animated SPS, it is usually called within the render loop.
  32247. * 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.
  32248. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32249. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32250. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32251. * @returns the SPS.
  32252. */
  32253. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32254. /**
  32255. * Disposes the SPS.
  32256. */
  32257. dispose(): void;
  32258. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32259. * idx is the particle index in the SPS
  32260. * faceId is the picked face index counted within this particle.
  32261. * Returns null if the pickInfo can't identify a picked particle.
  32262. * @param pickingInfo (PickingInfo object)
  32263. * @returns {idx: number, faceId: number} or null
  32264. */
  32265. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32266. idx: number;
  32267. faceId: number;
  32268. }>;
  32269. /**
  32270. * Returns a SolidParticle object from its identifier : particle.id
  32271. * @param id (integer) the particle Id
  32272. * @returns the searched particle or null if not found in the SPS.
  32273. */
  32274. getParticleById(id: number): Nullable<SolidParticle>;
  32275. /**
  32276. * Returns a new array populated with the particles having the passed shapeId.
  32277. * @param shapeId (integer) the shape identifier
  32278. * @returns a new solid particle array
  32279. */
  32280. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32281. /**
  32282. * Populates the passed array "ref" with the particles having the passed shapeId.
  32283. * @param shapeId the shape identifier
  32284. * @returns the SPS
  32285. * @param ref
  32286. */
  32287. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32288. /**
  32289. * Computes the required SubMeshes according the materials assigned to the particles.
  32290. * @returns the solid particle system.
  32291. * Does nothing if called before the SPS mesh is built.
  32292. */
  32293. computeSubMeshes(): SolidParticleSystem;
  32294. /**
  32295. * Sorts the solid particles by material when MultiMaterial is enabled.
  32296. * Updates the indices32 array.
  32297. * Updates the indicesByMaterial array.
  32298. * Updates the mesh indices array.
  32299. * @returns the SPS
  32300. * @hidden
  32301. */
  32302. private _sortParticlesByMaterial;
  32303. /**
  32304. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32305. * @hidden
  32306. */
  32307. private _setMaterialIndexesById;
  32308. /**
  32309. * Returns an array with unique values of Materials from the passed array
  32310. * @param array the material array to be checked and filtered
  32311. * @hidden
  32312. */
  32313. private _filterUniqueMaterialId;
  32314. /**
  32315. * Sets a new Standard Material as _defaultMaterial if not already set.
  32316. * @hidden
  32317. */
  32318. private _setDefaultMaterial;
  32319. /**
  32320. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32321. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32322. * @returns the SPS.
  32323. */
  32324. refreshVisibleSize(): SolidParticleSystem;
  32325. /**
  32326. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32327. * @param size the size (float) of the visibility box
  32328. * note : this doesn't lock the SPS mesh bounding box.
  32329. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32330. */
  32331. setVisibilityBox(size: number): void;
  32332. /**
  32333. * Gets whether the SPS as always visible or not
  32334. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32335. */
  32336. get isAlwaysVisible(): boolean;
  32337. /**
  32338. * Sets the SPS as always visible or not
  32339. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32340. */
  32341. set isAlwaysVisible(val: boolean);
  32342. /**
  32343. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32344. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32345. */
  32346. set isVisibilityBoxLocked(val: boolean);
  32347. /**
  32348. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32349. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32350. */
  32351. get isVisibilityBoxLocked(): boolean;
  32352. /**
  32353. * Tells to `setParticles()` to compute the particle rotations or not.
  32354. * Default value : true. The SPS is faster when it's set to false.
  32355. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32356. */
  32357. set computeParticleRotation(val: boolean);
  32358. /**
  32359. * Tells to `setParticles()` to compute the particle colors or not.
  32360. * Default value : true. The SPS is faster when it's set to false.
  32361. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32362. */
  32363. set computeParticleColor(val: boolean);
  32364. set computeParticleTexture(val: boolean);
  32365. /**
  32366. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32367. * Default value : false. The SPS is faster when it's set to false.
  32368. * Note : the particle custom vertex positions aren't stored values.
  32369. */
  32370. set computeParticleVertex(val: boolean);
  32371. /**
  32372. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32373. */
  32374. set computeBoundingBox(val: boolean);
  32375. /**
  32376. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32377. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32378. * Default : `true`
  32379. */
  32380. set depthSortParticles(val: boolean);
  32381. /**
  32382. * Gets if `setParticles()` computes the particle rotations or not.
  32383. * Default value : true. The SPS is faster when it's set to false.
  32384. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32385. */
  32386. get computeParticleRotation(): boolean;
  32387. /**
  32388. * Gets if `setParticles()` computes the particle colors or not.
  32389. * Default value : true. The SPS is faster when it's set to false.
  32390. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32391. */
  32392. get computeParticleColor(): boolean;
  32393. /**
  32394. * Gets if `setParticles()` computes the particle textures or not.
  32395. * Default value : true. The SPS is faster when it's set to false.
  32396. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32397. */
  32398. get computeParticleTexture(): boolean;
  32399. /**
  32400. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32401. * Default value : false. The SPS is faster when it's set to false.
  32402. * Note : the particle custom vertex positions aren't stored values.
  32403. */
  32404. get computeParticleVertex(): boolean;
  32405. /**
  32406. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32407. */
  32408. get computeBoundingBox(): boolean;
  32409. /**
  32410. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32411. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32412. * Default : `true`
  32413. */
  32414. get depthSortParticles(): boolean;
  32415. /**
  32416. * Gets if the SPS is created as expandable at construction time.
  32417. * Default : `false`
  32418. */
  32419. get expandable(): boolean;
  32420. /**
  32421. * Gets if the SPS supports the Multi Materials
  32422. */
  32423. get multimaterialEnabled(): boolean;
  32424. /**
  32425. * Gets if the SPS uses the model materials for its own multimaterial.
  32426. */
  32427. get useModelMaterial(): boolean;
  32428. /**
  32429. * The SPS used material array.
  32430. */
  32431. get materials(): Material[];
  32432. /**
  32433. * Sets the SPS MultiMaterial from the passed materials.
  32434. * Note : the passed array is internally copied and not used then by reference.
  32435. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32436. */
  32437. setMultiMaterial(materials: Material[]): void;
  32438. /**
  32439. * The SPS computed multimaterial object
  32440. */
  32441. get multimaterial(): MultiMaterial;
  32442. set multimaterial(mm: MultiMaterial);
  32443. /**
  32444. * If the subMeshes must be updated on the next call to setParticles()
  32445. */
  32446. get autoUpdateSubMeshes(): boolean;
  32447. set autoUpdateSubMeshes(val: boolean);
  32448. /**
  32449. * This function does nothing. It may be overwritten to set all the particle first values.
  32450. * The SPS doesn't call this function, you may have to call it by your own.
  32451. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32452. */
  32453. initParticles(): void;
  32454. /**
  32455. * This function does nothing. It may be overwritten to recycle a particle.
  32456. * The SPS doesn't call this function, you may have to call it by your own.
  32457. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32458. * @param particle The particle to recycle
  32459. * @returns the recycled particle
  32460. */
  32461. recycleParticle(particle: SolidParticle): SolidParticle;
  32462. /**
  32463. * Updates a particle : this function should be overwritten by the user.
  32464. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32465. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32466. * @example : just set a particle position or velocity and recycle conditions
  32467. * @param particle The particle to update
  32468. * @returns the updated particle
  32469. */
  32470. updateParticle(particle: SolidParticle): SolidParticle;
  32471. /**
  32472. * Updates a vertex of a particle : it can be overwritten by the user.
  32473. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32474. * @param particle the current particle
  32475. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32476. * @param pt the index of the current vertex in the particle shape
  32477. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32478. * @example : just set a vertex particle position or color
  32479. * @returns the sps
  32480. */
  32481. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32482. /**
  32483. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32484. * This does nothing and may be overwritten by the user.
  32485. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32486. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32487. * @param update the boolean update value actually passed to setParticles()
  32488. */
  32489. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32490. /**
  32491. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32492. * This will be passed three parameters.
  32493. * This does nothing and may be overwritten by the user.
  32494. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32495. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32496. * @param update the boolean update value actually passed to setParticles()
  32497. */
  32498. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32499. }
  32500. }
  32501. declare module "babylonjs/Particles/solidParticle" {
  32502. import { Nullable } from "babylonjs/types";
  32503. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32504. import { Color4 } from "babylonjs/Maths/math.color";
  32505. import { Mesh } from "babylonjs/Meshes/mesh";
  32506. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32507. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32508. import { Plane } from "babylonjs/Maths/math.plane";
  32509. import { Material } from "babylonjs/Materials/material";
  32510. /**
  32511. * Represents one particle of a solid particle system.
  32512. */
  32513. export class SolidParticle {
  32514. /**
  32515. * particle global index
  32516. */
  32517. idx: number;
  32518. /**
  32519. * particle identifier
  32520. */
  32521. id: number;
  32522. /**
  32523. * The color of the particle
  32524. */
  32525. color: Nullable<Color4>;
  32526. /**
  32527. * The world space position of the particle.
  32528. */
  32529. position: Vector3;
  32530. /**
  32531. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32532. */
  32533. rotation: Vector3;
  32534. /**
  32535. * The world space rotation quaternion of the particle.
  32536. */
  32537. rotationQuaternion: Nullable<Quaternion>;
  32538. /**
  32539. * The scaling of the particle.
  32540. */
  32541. scaling: Vector3;
  32542. /**
  32543. * The uvs of the particle.
  32544. */
  32545. uvs: Vector4;
  32546. /**
  32547. * The current speed of the particle.
  32548. */
  32549. velocity: Vector3;
  32550. /**
  32551. * The pivot point in the particle local space.
  32552. */
  32553. pivot: Vector3;
  32554. /**
  32555. * Must the particle be translated from its pivot point in its local space ?
  32556. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32557. * Default : false
  32558. */
  32559. translateFromPivot: boolean;
  32560. /**
  32561. * Is the particle active or not ?
  32562. */
  32563. alive: boolean;
  32564. /**
  32565. * Is the particle visible or not ?
  32566. */
  32567. isVisible: boolean;
  32568. /**
  32569. * Index of this particle in the global "positions" array (Internal use)
  32570. * @hidden
  32571. */
  32572. _pos: number;
  32573. /**
  32574. * @hidden Index of this particle in the global "indices" array (Internal use)
  32575. */
  32576. _ind: number;
  32577. /**
  32578. * @hidden ModelShape of this particle (Internal use)
  32579. */
  32580. _model: ModelShape;
  32581. /**
  32582. * ModelShape id of this particle
  32583. */
  32584. shapeId: number;
  32585. /**
  32586. * Index of the particle in its shape id
  32587. */
  32588. idxInShape: number;
  32589. /**
  32590. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32591. */
  32592. _modelBoundingInfo: BoundingInfo;
  32593. /**
  32594. * @hidden Particle BoundingInfo object (Internal use)
  32595. */
  32596. _boundingInfo: BoundingInfo;
  32597. /**
  32598. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32599. */
  32600. _sps: SolidParticleSystem;
  32601. /**
  32602. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32603. */
  32604. _stillInvisible: boolean;
  32605. /**
  32606. * @hidden Last computed particle rotation matrix
  32607. */
  32608. _rotationMatrix: number[];
  32609. /**
  32610. * Parent particle Id, if any.
  32611. * Default null.
  32612. */
  32613. parentId: Nullable<number>;
  32614. /**
  32615. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32616. */
  32617. materialIndex: Nullable<number>;
  32618. /**
  32619. * Custom object or properties.
  32620. */
  32621. props: Nullable<any>;
  32622. /**
  32623. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32624. * The possible values are :
  32625. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32626. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32627. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32628. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32629. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32630. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32631. * */
  32632. cullingStrategy: number;
  32633. /**
  32634. * @hidden Internal global position in the SPS.
  32635. */
  32636. _globalPosition: Vector3;
  32637. /**
  32638. * Creates a Solid Particle object.
  32639. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32640. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32641. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32642. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32643. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32644. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32645. * @param shapeId (integer) is the model shape identifier in the SPS.
  32646. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32647. * @param sps defines the sps it is associated to
  32648. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32649. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32650. */
  32651. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32652. /**
  32653. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32654. * @param target the particle target
  32655. * @returns the current particle
  32656. */
  32657. copyToRef(target: SolidParticle): SolidParticle;
  32658. /**
  32659. * Legacy support, changed scale to scaling
  32660. */
  32661. get scale(): Vector3;
  32662. /**
  32663. * Legacy support, changed scale to scaling
  32664. */
  32665. set scale(scale: Vector3);
  32666. /**
  32667. * Legacy support, changed quaternion to rotationQuaternion
  32668. */
  32669. get quaternion(): Nullable<Quaternion>;
  32670. /**
  32671. * Legacy support, changed quaternion to rotationQuaternion
  32672. */
  32673. set quaternion(q: Nullable<Quaternion>);
  32674. /**
  32675. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32676. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32677. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32678. * @returns true if it intersects
  32679. */
  32680. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32681. /**
  32682. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32683. * A particle is in the frustum if its bounding box intersects the frustum
  32684. * @param frustumPlanes defines the frustum to test
  32685. * @returns true if the particle is in the frustum planes
  32686. */
  32687. isInFrustum(frustumPlanes: Plane[]): boolean;
  32688. /**
  32689. * get the rotation matrix of the particle
  32690. * @hidden
  32691. */
  32692. getRotationMatrix(m: Matrix): void;
  32693. }
  32694. /**
  32695. * Represents the shape of the model used by one particle of a solid particle system.
  32696. * SPS internal tool, don't use it manually.
  32697. */
  32698. export class ModelShape {
  32699. /**
  32700. * The shape id
  32701. * @hidden
  32702. */
  32703. shapeID: number;
  32704. /**
  32705. * flat array of model positions (internal use)
  32706. * @hidden
  32707. */
  32708. _shape: Vector3[];
  32709. /**
  32710. * flat array of model UVs (internal use)
  32711. * @hidden
  32712. */
  32713. _shapeUV: number[];
  32714. /**
  32715. * color array of the model
  32716. * @hidden
  32717. */
  32718. _shapeColors: number[];
  32719. /**
  32720. * indices array of the model
  32721. * @hidden
  32722. */
  32723. _indices: number[];
  32724. /**
  32725. * normals array of the model
  32726. * @hidden
  32727. */
  32728. _normals: number[];
  32729. /**
  32730. * length of the shape in the model indices array (internal use)
  32731. * @hidden
  32732. */
  32733. _indicesLength: number;
  32734. /**
  32735. * Custom position function (internal use)
  32736. * @hidden
  32737. */
  32738. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32739. /**
  32740. * Custom vertex function (internal use)
  32741. * @hidden
  32742. */
  32743. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32744. /**
  32745. * Model material (internal use)
  32746. * @hidden
  32747. */
  32748. _material: Nullable<Material>;
  32749. /**
  32750. * 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.
  32751. * SPS internal tool, don't use it manually.
  32752. * @hidden
  32753. */
  32754. 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>);
  32755. }
  32756. /**
  32757. * Represents a Depth Sorted Particle in the solid particle system.
  32758. * @hidden
  32759. */
  32760. export class DepthSortedParticle {
  32761. /**
  32762. * Particle index
  32763. */
  32764. idx: number;
  32765. /**
  32766. * Index of the particle in the "indices" array
  32767. */
  32768. ind: number;
  32769. /**
  32770. * Length of the particle shape in the "indices" array
  32771. */
  32772. indicesLength: number;
  32773. /**
  32774. * Squared distance from the particle to the camera
  32775. */
  32776. sqDistance: number;
  32777. /**
  32778. * Material index when used with MultiMaterials
  32779. */
  32780. materialIndex: number;
  32781. /**
  32782. * Creates a new sorted particle
  32783. * @param materialIndex
  32784. */
  32785. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32786. }
  32787. /**
  32788. * Represents a solid particle vertex
  32789. */
  32790. export class SolidParticleVertex {
  32791. /**
  32792. * Vertex position
  32793. */
  32794. position: Vector3;
  32795. /**
  32796. * Vertex color
  32797. */
  32798. color: Color4;
  32799. /**
  32800. * Vertex UV
  32801. */
  32802. uv: Vector2;
  32803. /**
  32804. * Creates a new solid particle vertex
  32805. */
  32806. constructor();
  32807. /** Vertex x coordinate */
  32808. get x(): number;
  32809. set x(val: number);
  32810. /** Vertex y coordinate */
  32811. get y(): number;
  32812. set y(val: number);
  32813. /** Vertex z coordinate */
  32814. get z(): number;
  32815. set z(val: number);
  32816. }
  32817. }
  32818. declare module "babylonjs/Collisions/meshCollisionData" {
  32819. import { Collider } from "babylonjs/Collisions/collider";
  32820. import { Vector3 } from "babylonjs/Maths/math.vector";
  32821. import { Nullable } from "babylonjs/types";
  32822. import { Observer } from "babylonjs/Misc/observable";
  32823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32824. /**
  32825. * @hidden
  32826. */
  32827. export class _MeshCollisionData {
  32828. _checkCollisions: boolean;
  32829. _collisionMask: number;
  32830. _collisionGroup: number;
  32831. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32832. _collider: Nullable<Collider>;
  32833. _oldPositionForCollisions: Vector3;
  32834. _diffPositionForCollisions: Vector3;
  32835. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32836. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32837. }
  32838. }
  32839. declare module "babylonjs/Meshes/abstractMesh" {
  32840. import { Observable } from "babylonjs/Misc/observable";
  32841. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32842. import { Camera } from "babylonjs/Cameras/camera";
  32843. import { Scene, IDisposable } from "babylonjs/scene";
  32844. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32845. import { Node } from "babylonjs/node";
  32846. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32849. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32850. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32851. import { Material } from "babylonjs/Materials/material";
  32852. import { Light } from "babylonjs/Lights/light";
  32853. import { Skeleton } from "babylonjs/Bones/skeleton";
  32854. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32855. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32856. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32857. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32858. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32859. import { Plane } from "babylonjs/Maths/math.plane";
  32860. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32861. import { Ray } from "babylonjs/Culling/ray";
  32862. import { Collider } from "babylonjs/Collisions/collider";
  32863. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32864. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32865. /** @hidden */
  32866. class _FacetDataStorage {
  32867. facetPositions: Vector3[];
  32868. facetNormals: Vector3[];
  32869. facetPartitioning: number[][];
  32870. facetNb: number;
  32871. partitioningSubdivisions: number;
  32872. partitioningBBoxRatio: number;
  32873. facetDataEnabled: boolean;
  32874. facetParameters: any;
  32875. bbSize: Vector3;
  32876. subDiv: {
  32877. max: number;
  32878. X: number;
  32879. Y: number;
  32880. Z: number;
  32881. };
  32882. facetDepthSort: boolean;
  32883. facetDepthSortEnabled: boolean;
  32884. depthSortedIndices: IndicesArray;
  32885. depthSortedFacets: {
  32886. ind: number;
  32887. sqDistance: number;
  32888. }[];
  32889. facetDepthSortFunction: (f1: {
  32890. ind: number;
  32891. sqDistance: number;
  32892. }, f2: {
  32893. ind: number;
  32894. sqDistance: number;
  32895. }) => number;
  32896. facetDepthSortFrom: Vector3;
  32897. facetDepthSortOrigin: Vector3;
  32898. invertedMatrix: Matrix;
  32899. }
  32900. /**
  32901. * @hidden
  32902. **/
  32903. class _InternalAbstractMeshDataInfo {
  32904. _hasVertexAlpha: boolean;
  32905. _useVertexColors: boolean;
  32906. _numBoneInfluencers: number;
  32907. _applyFog: boolean;
  32908. _receiveShadows: boolean;
  32909. _facetData: _FacetDataStorage;
  32910. _visibility: number;
  32911. _skeleton: Nullable<Skeleton>;
  32912. _layerMask: number;
  32913. _computeBonesUsingShaders: boolean;
  32914. _isActive: boolean;
  32915. _onlyForInstances: boolean;
  32916. _isActiveIntermediate: boolean;
  32917. _onlyForInstancesIntermediate: boolean;
  32918. _actAsRegularMesh: boolean;
  32919. }
  32920. /**
  32921. * Class used to store all common mesh properties
  32922. */
  32923. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32924. /** No occlusion */
  32925. static OCCLUSION_TYPE_NONE: number;
  32926. /** Occlusion set to optimisitic */
  32927. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32928. /** Occlusion set to strict */
  32929. static OCCLUSION_TYPE_STRICT: number;
  32930. /** Use an accurante occlusion algorithm */
  32931. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32932. /** Use a conservative occlusion algorithm */
  32933. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32934. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32935. * Test order :
  32936. * Is the bounding sphere outside the frustum ?
  32937. * If not, are the bounding box vertices outside the frustum ?
  32938. * It not, then the cullable object is in the frustum.
  32939. */
  32940. static readonly CULLINGSTRATEGY_STANDARD: number;
  32941. /** Culling strategy : Bounding Sphere Only.
  32942. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32943. * It's also less accurate than the standard because some not visible objects can still be selected.
  32944. * Test : is the bounding sphere outside the frustum ?
  32945. * If not, then the cullable object is in the frustum.
  32946. */
  32947. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32948. /** Culling strategy : Optimistic Inclusion.
  32949. * This in an inclusion test first, then the standard exclusion test.
  32950. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32951. * 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.
  32952. * Anyway, it's as accurate as the standard strategy.
  32953. * Test :
  32954. * Is the cullable object bounding sphere center in the frustum ?
  32955. * If not, apply the default culling strategy.
  32956. */
  32957. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32958. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32959. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32960. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32961. * 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.
  32962. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32963. * Test :
  32964. * Is the cullable object bounding sphere center in the frustum ?
  32965. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32966. */
  32967. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32968. /**
  32969. * No billboard
  32970. */
  32971. static get BILLBOARDMODE_NONE(): number;
  32972. /** Billboard on X axis */
  32973. static get BILLBOARDMODE_X(): number;
  32974. /** Billboard on Y axis */
  32975. static get BILLBOARDMODE_Y(): number;
  32976. /** Billboard on Z axis */
  32977. static get BILLBOARDMODE_Z(): number;
  32978. /** Billboard on all axes */
  32979. static get BILLBOARDMODE_ALL(): number;
  32980. /** Billboard on using position instead of orientation */
  32981. static get BILLBOARDMODE_USE_POSITION(): number;
  32982. /** @hidden */
  32983. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32984. /**
  32985. * The culling strategy to use to check whether the mesh must be rendered or not.
  32986. * This value can be changed at any time and will be used on the next render mesh selection.
  32987. * The possible values are :
  32988. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32989. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32990. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32992. * Please read each static variable documentation to get details about the culling process.
  32993. * */
  32994. cullingStrategy: number;
  32995. /**
  32996. * Gets the number of facets in the mesh
  32997. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32998. */
  32999. get facetNb(): number;
  33000. /**
  33001. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33002. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33003. */
  33004. get partitioningSubdivisions(): number;
  33005. set partitioningSubdivisions(nb: number);
  33006. /**
  33007. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33008. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33009. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33010. */
  33011. get partitioningBBoxRatio(): number;
  33012. set partitioningBBoxRatio(ratio: number);
  33013. /**
  33014. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33015. * Works only for updatable meshes.
  33016. * Doesn't work with multi-materials
  33017. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33018. */
  33019. get mustDepthSortFacets(): boolean;
  33020. set mustDepthSortFacets(sort: boolean);
  33021. /**
  33022. * The location (Vector3) where the facet depth sort must be computed from.
  33023. * By default, the active camera position.
  33024. * Used only when facet depth sort is enabled
  33025. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33026. */
  33027. get facetDepthSortFrom(): Vector3;
  33028. set facetDepthSortFrom(location: Vector3);
  33029. /**
  33030. * gets a boolean indicating if facetData is enabled
  33031. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33032. */
  33033. get isFacetDataEnabled(): boolean;
  33034. /** @hidden */
  33035. _updateNonUniformScalingState(value: boolean): boolean;
  33036. /**
  33037. * An event triggered when this mesh collides with another one
  33038. */
  33039. onCollideObservable: Observable<AbstractMesh>;
  33040. /** Set a function to call when this mesh collides with another one */
  33041. set onCollide(callback: () => void);
  33042. /**
  33043. * An event triggered when the collision's position changes
  33044. */
  33045. onCollisionPositionChangeObservable: Observable<Vector3>;
  33046. /** Set a function to call when the collision's position changes */
  33047. set onCollisionPositionChange(callback: () => void);
  33048. /**
  33049. * An event triggered when material is changed
  33050. */
  33051. onMaterialChangedObservable: Observable<AbstractMesh>;
  33052. /**
  33053. * Gets or sets the orientation for POV movement & rotation
  33054. */
  33055. definedFacingForward: boolean;
  33056. /** @hidden */
  33057. _occlusionQuery: Nullable<WebGLQuery>;
  33058. /** @hidden */
  33059. _renderingGroup: Nullable<RenderingGroup>;
  33060. /**
  33061. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33062. */
  33063. get visibility(): number;
  33064. /**
  33065. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33066. */
  33067. set visibility(value: number);
  33068. /** Gets or sets the alpha index used to sort transparent meshes
  33069. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33070. */
  33071. alphaIndex: number;
  33072. /**
  33073. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33074. */
  33075. isVisible: boolean;
  33076. /**
  33077. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33078. */
  33079. isPickable: boolean;
  33080. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33081. showSubMeshesBoundingBox: boolean;
  33082. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33083. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33084. */
  33085. isBlocker: boolean;
  33086. /**
  33087. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33088. */
  33089. enablePointerMoveEvents: boolean;
  33090. /**
  33091. * Specifies the rendering group id for this mesh (0 by default)
  33092. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33093. */
  33094. renderingGroupId: number;
  33095. private _material;
  33096. /** Gets or sets current material */
  33097. get material(): Nullable<Material>;
  33098. set material(value: Nullable<Material>);
  33099. /**
  33100. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33101. * @see https://doc.babylonjs.com/babylon101/shadows
  33102. */
  33103. get receiveShadows(): boolean;
  33104. set receiveShadows(value: boolean);
  33105. /** Defines color to use when rendering outline */
  33106. outlineColor: Color3;
  33107. /** Define width to use when rendering outline */
  33108. outlineWidth: number;
  33109. /** Defines color to use when rendering overlay */
  33110. overlayColor: Color3;
  33111. /** Defines alpha to use when rendering overlay */
  33112. overlayAlpha: number;
  33113. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33114. get hasVertexAlpha(): boolean;
  33115. set hasVertexAlpha(value: boolean);
  33116. /** 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) */
  33117. get useVertexColors(): boolean;
  33118. set useVertexColors(value: boolean);
  33119. /**
  33120. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33121. */
  33122. get computeBonesUsingShaders(): boolean;
  33123. set computeBonesUsingShaders(value: boolean);
  33124. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33125. get numBoneInfluencers(): number;
  33126. set numBoneInfluencers(value: number);
  33127. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33128. get applyFog(): boolean;
  33129. set applyFog(value: boolean);
  33130. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33131. useOctreeForRenderingSelection: boolean;
  33132. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33133. useOctreeForPicking: boolean;
  33134. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33135. useOctreeForCollisions: boolean;
  33136. /**
  33137. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33138. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33139. */
  33140. get layerMask(): number;
  33141. set layerMask(value: number);
  33142. /**
  33143. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33144. */
  33145. alwaysSelectAsActiveMesh: boolean;
  33146. /**
  33147. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33148. */
  33149. doNotSyncBoundingInfo: boolean;
  33150. /**
  33151. * Gets or sets the current action manager
  33152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33153. */
  33154. actionManager: Nullable<AbstractActionManager>;
  33155. private _meshCollisionData;
  33156. /**
  33157. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33158. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33159. */
  33160. ellipsoid: Vector3;
  33161. /**
  33162. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33163. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33164. */
  33165. ellipsoidOffset: Vector3;
  33166. /**
  33167. * Gets or sets a collision mask used to mask collisions (default is -1).
  33168. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33169. */
  33170. get collisionMask(): number;
  33171. set collisionMask(mask: number);
  33172. /**
  33173. * Gets or sets the current collision group mask (-1 by default).
  33174. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33175. */
  33176. get collisionGroup(): number;
  33177. set collisionGroup(mask: number);
  33178. /**
  33179. * Gets or sets current surrounding meshes (null by default).
  33180. *
  33181. * By default collision detection is tested against every mesh in the scene.
  33182. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33183. * meshes will be tested for the collision.
  33184. *
  33185. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33186. */
  33187. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33188. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33189. /**
  33190. * Defines edge width used when edgesRenderer is enabled
  33191. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33192. */
  33193. edgesWidth: number;
  33194. /**
  33195. * Defines edge color used when edgesRenderer is enabled
  33196. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33197. */
  33198. edgesColor: Color4;
  33199. /** @hidden */
  33200. _edgesRenderer: Nullable<IEdgesRenderer>;
  33201. /** @hidden */
  33202. _masterMesh: Nullable<AbstractMesh>;
  33203. /** @hidden */
  33204. _boundingInfo: Nullable<BoundingInfo>;
  33205. /** @hidden */
  33206. _renderId: number;
  33207. /**
  33208. * Gets or sets the list of subMeshes
  33209. * @see https://doc.babylonjs.com/how_to/multi_materials
  33210. */
  33211. subMeshes: SubMesh[];
  33212. /** @hidden */
  33213. _intersectionsInProgress: AbstractMesh[];
  33214. /** @hidden */
  33215. _unIndexed: boolean;
  33216. /** @hidden */
  33217. _lightSources: Light[];
  33218. /** Gets the list of lights affecting that mesh */
  33219. get lightSources(): Light[];
  33220. /** @hidden */
  33221. get _positions(): Nullable<Vector3[]>;
  33222. /** @hidden */
  33223. _waitingData: {
  33224. lods: Nullable<any>;
  33225. actions: Nullable<any>;
  33226. freezeWorldMatrix: Nullable<boolean>;
  33227. };
  33228. /** @hidden */
  33229. _bonesTransformMatrices: Nullable<Float32Array>;
  33230. /** @hidden */
  33231. _transformMatrixTexture: Nullable<RawTexture>;
  33232. /**
  33233. * Gets or sets a skeleton to apply skining transformations
  33234. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33235. */
  33236. set skeleton(value: Nullable<Skeleton>);
  33237. get skeleton(): Nullable<Skeleton>;
  33238. /**
  33239. * An event triggered when the mesh is rebuilt.
  33240. */
  33241. onRebuildObservable: Observable<AbstractMesh>;
  33242. /**
  33243. * Creates a new AbstractMesh
  33244. * @param name defines the name of the mesh
  33245. * @param scene defines the hosting scene
  33246. */
  33247. constructor(name: string, scene?: Nullable<Scene>);
  33248. /**
  33249. * Returns the string "AbstractMesh"
  33250. * @returns "AbstractMesh"
  33251. */
  33252. getClassName(): string;
  33253. /**
  33254. * Gets a string representation of the current mesh
  33255. * @param fullDetails defines a boolean indicating if full details must be included
  33256. * @returns a string representation of the current mesh
  33257. */
  33258. toString(fullDetails?: boolean): string;
  33259. /**
  33260. * @hidden
  33261. */
  33262. protected _getEffectiveParent(): Nullable<Node>;
  33263. /** @hidden */
  33264. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33265. /** @hidden */
  33266. _rebuild(): void;
  33267. /** @hidden */
  33268. _resyncLightSources(): void;
  33269. /** @hidden */
  33270. _resyncLightSource(light: Light): void;
  33271. /** @hidden */
  33272. _unBindEffect(): void;
  33273. /** @hidden */
  33274. _removeLightSource(light: Light, dispose: boolean): void;
  33275. private _markSubMeshesAsDirty;
  33276. /** @hidden */
  33277. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33278. /** @hidden */
  33279. _markSubMeshesAsAttributesDirty(): void;
  33280. /** @hidden */
  33281. _markSubMeshesAsMiscDirty(): void;
  33282. /**
  33283. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33284. */
  33285. get scaling(): Vector3;
  33286. set scaling(newScaling: Vector3);
  33287. /**
  33288. * Returns true if the mesh is blocked. Implemented by child classes
  33289. */
  33290. get isBlocked(): boolean;
  33291. /**
  33292. * Returns the mesh itself by default. Implemented by child classes
  33293. * @param camera defines the camera to use to pick the right LOD level
  33294. * @returns the currentAbstractMesh
  33295. */
  33296. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33297. /**
  33298. * Returns 0 by default. Implemented by child classes
  33299. * @returns an integer
  33300. */
  33301. getTotalVertices(): number;
  33302. /**
  33303. * Returns a positive integer : the total number of indices in this mesh geometry.
  33304. * @returns the numner of indices or zero if the mesh has no geometry.
  33305. */
  33306. getTotalIndices(): number;
  33307. /**
  33308. * Returns null by default. Implemented by child classes
  33309. * @returns null
  33310. */
  33311. getIndices(): Nullable<IndicesArray>;
  33312. /**
  33313. * Returns the array of the requested vertex data kind. Implemented by child classes
  33314. * @param kind defines the vertex data kind to use
  33315. * @returns null
  33316. */
  33317. getVerticesData(kind: string): Nullable<FloatArray>;
  33318. /**
  33319. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33320. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33321. * Note that a new underlying VertexBuffer object is created each call.
  33322. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33323. * @param kind defines vertex data kind:
  33324. * * VertexBuffer.PositionKind
  33325. * * VertexBuffer.UVKind
  33326. * * VertexBuffer.UV2Kind
  33327. * * VertexBuffer.UV3Kind
  33328. * * VertexBuffer.UV4Kind
  33329. * * VertexBuffer.UV5Kind
  33330. * * VertexBuffer.UV6Kind
  33331. * * VertexBuffer.ColorKind
  33332. * * VertexBuffer.MatricesIndicesKind
  33333. * * VertexBuffer.MatricesIndicesExtraKind
  33334. * * VertexBuffer.MatricesWeightsKind
  33335. * * VertexBuffer.MatricesWeightsExtraKind
  33336. * @param data defines the data source
  33337. * @param updatable defines if the data must be flagged as updatable (or static)
  33338. * @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
  33339. * @returns the current mesh
  33340. */
  33341. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33342. /**
  33343. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33344. * If the mesh has no geometry, it is simply returned as it is.
  33345. * @param kind defines vertex data kind:
  33346. * * VertexBuffer.PositionKind
  33347. * * VertexBuffer.UVKind
  33348. * * VertexBuffer.UV2Kind
  33349. * * VertexBuffer.UV3Kind
  33350. * * VertexBuffer.UV4Kind
  33351. * * VertexBuffer.UV5Kind
  33352. * * VertexBuffer.UV6Kind
  33353. * * VertexBuffer.ColorKind
  33354. * * VertexBuffer.MatricesIndicesKind
  33355. * * VertexBuffer.MatricesIndicesExtraKind
  33356. * * VertexBuffer.MatricesWeightsKind
  33357. * * VertexBuffer.MatricesWeightsExtraKind
  33358. * @param data defines the data source
  33359. * @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
  33360. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33361. * @returns the current mesh
  33362. */
  33363. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33364. /**
  33365. * Sets the mesh indices,
  33366. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33367. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33368. * @param totalVertices Defines the total number of vertices
  33369. * @returns the current mesh
  33370. */
  33371. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33372. /**
  33373. * Gets a boolean indicating if specific vertex data is present
  33374. * @param kind defines the vertex data kind to use
  33375. * @returns true is data kind is present
  33376. */
  33377. isVerticesDataPresent(kind: string): boolean;
  33378. /**
  33379. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33380. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33381. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33382. * @returns a BoundingInfo
  33383. */
  33384. getBoundingInfo(): BoundingInfo;
  33385. /**
  33386. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33387. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33388. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33389. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33390. * @returns the current mesh
  33391. */
  33392. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33393. /**
  33394. * Overwrite the current bounding info
  33395. * @param boundingInfo defines the new bounding info
  33396. * @returns the current mesh
  33397. */
  33398. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33399. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33400. get useBones(): boolean;
  33401. /** @hidden */
  33402. _preActivate(): void;
  33403. /** @hidden */
  33404. _preActivateForIntermediateRendering(renderId: number): void;
  33405. /** @hidden */
  33406. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33407. /** @hidden */
  33408. _postActivate(): void;
  33409. /** @hidden */
  33410. _freeze(): void;
  33411. /** @hidden */
  33412. _unFreeze(): void;
  33413. /**
  33414. * Gets the current world matrix
  33415. * @returns a Matrix
  33416. */
  33417. getWorldMatrix(): Matrix;
  33418. /** @hidden */
  33419. _getWorldMatrixDeterminant(): number;
  33420. /**
  33421. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33422. */
  33423. get isAnInstance(): boolean;
  33424. /**
  33425. * Gets a boolean indicating if this mesh has instances
  33426. */
  33427. get hasInstances(): boolean;
  33428. /**
  33429. * Gets a boolean indicating if this mesh has thin instances
  33430. */
  33431. get hasThinInstances(): boolean;
  33432. /**
  33433. * Perform relative position change from the point of view of behind the front of the mesh.
  33434. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33435. * Supports definition of mesh facing forward or backward
  33436. * @param amountRight defines the distance on the right axis
  33437. * @param amountUp defines the distance on the up axis
  33438. * @param amountForward defines the distance on the forward axis
  33439. * @returns the current mesh
  33440. */
  33441. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33442. /**
  33443. * Calculate relative position change from the point of view of behind the front of the mesh.
  33444. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33445. * Supports definition of mesh facing forward or backward
  33446. * @param amountRight defines the distance on the right axis
  33447. * @param amountUp defines the distance on the up axis
  33448. * @param amountForward defines the distance on the forward axis
  33449. * @returns the new displacement vector
  33450. */
  33451. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33452. /**
  33453. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33454. * Supports definition of mesh facing forward or backward
  33455. * @param flipBack defines the flip
  33456. * @param twirlClockwise defines the twirl
  33457. * @param tiltRight defines the tilt
  33458. * @returns the current mesh
  33459. */
  33460. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33461. /**
  33462. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33463. * Supports definition of mesh facing forward or backward.
  33464. * @param flipBack defines the flip
  33465. * @param twirlClockwise defines the twirl
  33466. * @param tiltRight defines the tilt
  33467. * @returns the new rotation vector
  33468. */
  33469. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33470. /**
  33471. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33472. * This means the mesh underlying bounding box and sphere are recomputed.
  33473. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33474. * @returns the current mesh
  33475. */
  33476. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33477. /** @hidden */
  33478. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33479. /** @hidden */
  33480. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33481. /** @hidden */
  33482. _updateBoundingInfo(): AbstractMesh;
  33483. /** @hidden */
  33484. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33485. /** @hidden */
  33486. protected _afterComputeWorldMatrix(): void;
  33487. /** @hidden */
  33488. get _effectiveMesh(): AbstractMesh;
  33489. /**
  33490. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33491. * A mesh is in the frustum if its bounding box intersects the frustum
  33492. * @param frustumPlanes defines the frustum to test
  33493. * @returns true if the mesh is in the frustum planes
  33494. */
  33495. isInFrustum(frustumPlanes: Plane[]): boolean;
  33496. /**
  33497. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33498. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33499. * @param frustumPlanes defines the frustum to test
  33500. * @returns true if the mesh is completely in the frustum planes
  33501. */
  33502. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33503. /**
  33504. * True if the mesh intersects another mesh or a SolidParticle object
  33505. * @param mesh defines a target mesh or SolidParticle to test
  33506. * @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)
  33507. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33508. * @returns true if there is an intersection
  33509. */
  33510. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33511. /**
  33512. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33513. * @param point defines the point to test
  33514. * @returns true if there is an intersection
  33515. */
  33516. intersectsPoint(point: Vector3): boolean;
  33517. /**
  33518. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33519. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33520. */
  33521. get checkCollisions(): boolean;
  33522. set checkCollisions(collisionEnabled: boolean);
  33523. /**
  33524. * Gets Collider object used to compute collisions (not physics)
  33525. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33526. */
  33527. get collider(): Nullable<Collider>;
  33528. /**
  33529. * Move the mesh using collision engine
  33530. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33531. * @param displacement defines the requested displacement vector
  33532. * @returns the current mesh
  33533. */
  33534. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33535. private _onCollisionPositionChange;
  33536. /** @hidden */
  33537. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33538. /** @hidden */
  33539. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33540. /** @hidden */
  33541. _checkCollision(collider: Collider): AbstractMesh;
  33542. /** @hidden */
  33543. _generatePointsArray(): boolean;
  33544. /**
  33545. * Checks if the passed Ray intersects with the mesh
  33546. * @param ray defines the ray to use
  33547. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33548. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33549. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33550. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33551. * @returns the picking info
  33552. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33553. */
  33554. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33555. /**
  33556. * Clones the current mesh
  33557. * @param name defines the mesh name
  33558. * @param newParent defines the new mesh parent
  33559. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33560. * @returns the new mesh
  33561. */
  33562. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33563. /**
  33564. * Disposes all the submeshes of the current meshnp
  33565. * @returns the current mesh
  33566. */
  33567. releaseSubMeshes(): AbstractMesh;
  33568. /**
  33569. * Releases resources associated with this abstract mesh.
  33570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33572. */
  33573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33574. /**
  33575. * Adds the passed mesh as a child to the current mesh
  33576. * @param mesh defines the child mesh
  33577. * @returns the current mesh
  33578. */
  33579. addChild(mesh: AbstractMesh): AbstractMesh;
  33580. /**
  33581. * Removes the passed mesh from the current mesh children list
  33582. * @param mesh defines the child mesh
  33583. * @returns the current mesh
  33584. */
  33585. removeChild(mesh: AbstractMesh): AbstractMesh;
  33586. /** @hidden */
  33587. private _initFacetData;
  33588. /**
  33589. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33590. * This method can be called within the render loop.
  33591. * 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
  33592. * @returns the current mesh
  33593. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33594. */
  33595. updateFacetData(): AbstractMesh;
  33596. /**
  33597. * Returns the facetLocalNormals array.
  33598. * The normals are expressed in the mesh local spac
  33599. * @returns an array of Vector3
  33600. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33601. */
  33602. getFacetLocalNormals(): Vector3[];
  33603. /**
  33604. * Returns the facetLocalPositions array.
  33605. * The facet positions are expressed in the mesh local space
  33606. * @returns an array of Vector3
  33607. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33608. */
  33609. getFacetLocalPositions(): Vector3[];
  33610. /**
  33611. * Returns the facetLocalPartioning array
  33612. * @returns an array of array of numbers
  33613. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33614. */
  33615. getFacetLocalPartitioning(): number[][];
  33616. /**
  33617. * Returns the i-th facet position in the world system.
  33618. * This method allocates a new Vector3 per call
  33619. * @param i defines the facet index
  33620. * @returns a new Vector3
  33621. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33622. */
  33623. getFacetPosition(i: number): Vector3;
  33624. /**
  33625. * Sets the reference Vector3 with the i-th facet position in the world system
  33626. * @param i defines the facet index
  33627. * @param ref defines the target vector
  33628. * @returns the current mesh
  33629. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33630. */
  33631. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33632. /**
  33633. * Returns the i-th facet normal in the world system.
  33634. * This method allocates a new Vector3 per call
  33635. * @param i defines the facet index
  33636. * @returns a new Vector3
  33637. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33638. */
  33639. getFacetNormal(i: number): Vector3;
  33640. /**
  33641. * Sets the reference Vector3 with the i-th facet normal in the world system
  33642. * @param i defines the facet index
  33643. * @param ref defines the target vector
  33644. * @returns the current mesh
  33645. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33646. */
  33647. getFacetNormalToRef(i: number, ref: Vector3): this;
  33648. /**
  33649. * 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)
  33650. * @param x defines x coordinate
  33651. * @param y defines y coordinate
  33652. * @param z defines z coordinate
  33653. * @returns the array of facet indexes
  33654. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33655. */
  33656. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33657. /**
  33658. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33659. * @param projected sets as the (x,y,z) world projection on the facet
  33660. * @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
  33661. * @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
  33662. * @param x defines x coordinate
  33663. * @param y defines y coordinate
  33664. * @param z defines z coordinate
  33665. * @returns the face index if found (or null instead)
  33666. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33667. */
  33668. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33669. /**
  33670. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33671. * @param projected sets as the (x,y,z) local projection on the facet
  33672. * @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
  33673. * @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
  33674. * @param x defines x coordinate
  33675. * @param y defines y coordinate
  33676. * @param z defines z coordinate
  33677. * @returns the face index if found (or null instead)
  33678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33679. */
  33680. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33681. /**
  33682. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33683. * @returns the parameters
  33684. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33685. */
  33686. getFacetDataParameters(): any;
  33687. /**
  33688. * Disables the feature FacetData and frees the related memory
  33689. * @returns the current mesh
  33690. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33691. */
  33692. disableFacetData(): AbstractMesh;
  33693. /**
  33694. * Updates the AbstractMesh indices array
  33695. * @param indices defines the data source
  33696. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33697. * @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)
  33698. * @returns the current mesh
  33699. */
  33700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33701. /**
  33702. * Creates new normals data for the mesh
  33703. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33704. * @returns the current mesh
  33705. */
  33706. createNormals(updatable: boolean): AbstractMesh;
  33707. /**
  33708. * Align the mesh with a normal
  33709. * @param normal defines the normal to use
  33710. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33711. * @returns the current mesh
  33712. */
  33713. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33714. /** @hidden */
  33715. _checkOcclusionQuery(): boolean;
  33716. /**
  33717. * Disables the mesh edge rendering mode
  33718. * @returns the currentAbstractMesh
  33719. */
  33720. disableEdgesRendering(): AbstractMesh;
  33721. /**
  33722. * Enables the edge rendering mode on the mesh.
  33723. * This mode makes the mesh edges visible
  33724. * @param epsilon defines the maximal distance between two angles to detect a face
  33725. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33726. * @returns the currentAbstractMesh
  33727. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33728. */
  33729. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33730. /**
  33731. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33732. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33733. */
  33734. getConnectedParticleSystems(): IParticleSystem[];
  33735. }
  33736. }
  33737. declare module "babylonjs/Actions/actionEvent" {
  33738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33739. import { Nullable } from "babylonjs/types";
  33740. import { Sprite } from "babylonjs/Sprites/sprite";
  33741. import { Scene } from "babylonjs/scene";
  33742. import { Vector2 } from "babylonjs/Maths/math.vector";
  33743. /**
  33744. * Interface used to define ActionEvent
  33745. */
  33746. export interface IActionEvent {
  33747. /** The mesh or sprite that triggered the action */
  33748. source: any;
  33749. /** The X mouse cursor position at the time of the event */
  33750. pointerX: number;
  33751. /** The Y mouse cursor position at the time of the event */
  33752. pointerY: number;
  33753. /** The mesh that is currently pointed at (can be null) */
  33754. meshUnderPointer: Nullable<AbstractMesh>;
  33755. /** the original (browser) event that triggered the ActionEvent */
  33756. sourceEvent?: any;
  33757. /** additional data for the event */
  33758. additionalData?: any;
  33759. }
  33760. /**
  33761. * ActionEvent is the event being sent when an action is triggered.
  33762. */
  33763. export class ActionEvent implements IActionEvent {
  33764. /** The mesh or sprite that triggered the action */
  33765. source: any;
  33766. /** The X mouse cursor position at the time of the event */
  33767. pointerX: number;
  33768. /** The Y mouse cursor position at the time of the event */
  33769. pointerY: number;
  33770. /** The mesh that is currently pointed at (can be null) */
  33771. meshUnderPointer: Nullable<AbstractMesh>;
  33772. /** the original (browser) event that triggered the ActionEvent */
  33773. sourceEvent?: any;
  33774. /** additional data for the event */
  33775. additionalData?: any;
  33776. /**
  33777. * Creates a new ActionEvent
  33778. * @param source The mesh or sprite that triggered the action
  33779. * @param pointerX The X mouse cursor position at the time of the event
  33780. * @param pointerY The Y mouse cursor position at the time of the event
  33781. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33782. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33783. * @param additionalData additional data for the event
  33784. */
  33785. constructor(
  33786. /** The mesh or sprite that triggered the action */
  33787. source: any,
  33788. /** The X mouse cursor position at the time of the event */
  33789. pointerX: number,
  33790. /** The Y mouse cursor position at the time of the event */
  33791. pointerY: number,
  33792. /** The mesh that is currently pointed at (can be null) */
  33793. meshUnderPointer: Nullable<AbstractMesh>,
  33794. /** the original (browser) event that triggered the ActionEvent */
  33795. sourceEvent?: any,
  33796. /** additional data for the event */
  33797. additionalData?: any);
  33798. /**
  33799. * Helper function to auto-create an ActionEvent from a source mesh.
  33800. * @param source The source mesh that triggered the event
  33801. * @param evt The original (browser) event
  33802. * @param additionalData additional data for the event
  33803. * @returns the new ActionEvent
  33804. */
  33805. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33806. /**
  33807. * Helper function to auto-create an ActionEvent from a source sprite
  33808. * @param source The source sprite that triggered the event
  33809. * @param scene Scene associated with the sprite
  33810. * @param evt The original (browser) event
  33811. * @param additionalData additional data for the event
  33812. * @returns the new ActionEvent
  33813. */
  33814. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33815. /**
  33816. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33817. * @param scene the scene where the event occurred
  33818. * @param evt The original (browser) event
  33819. * @returns the new ActionEvent
  33820. */
  33821. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33822. /**
  33823. * Helper function to auto-create an ActionEvent from a primitive
  33824. * @param prim defines the target primitive
  33825. * @param pointerPos defines the pointer position
  33826. * @param evt The original (browser) event
  33827. * @param additionalData additional data for the event
  33828. * @returns the new ActionEvent
  33829. */
  33830. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33831. }
  33832. }
  33833. declare module "babylonjs/Actions/abstractActionManager" {
  33834. import { IDisposable } from "babylonjs/scene";
  33835. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33836. import { IAction } from "babylonjs/Actions/action";
  33837. import { Nullable } from "babylonjs/types";
  33838. /**
  33839. * Abstract class used to decouple action Manager from scene and meshes.
  33840. * Do not instantiate.
  33841. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33842. */
  33843. export abstract class AbstractActionManager implements IDisposable {
  33844. /** Gets the list of active triggers */
  33845. static Triggers: {
  33846. [key: string]: number;
  33847. };
  33848. /** Gets the cursor to use when hovering items */
  33849. hoverCursor: string;
  33850. /** Gets the list of actions */
  33851. actions: IAction[];
  33852. /**
  33853. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33854. */
  33855. isRecursive: boolean;
  33856. /**
  33857. * Releases all associated resources
  33858. */
  33859. abstract dispose(): void;
  33860. /**
  33861. * Does this action manager has pointer triggers
  33862. */
  33863. abstract get hasPointerTriggers(): boolean;
  33864. /**
  33865. * Does this action manager has pick triggers
  33866. */
  33867. abstract get hasPickTriggers(): boolean;
  33868. /**
  33869. * Process a specific trigger
  33870. * @param trigger defines the trigger to process
  33871. * @param evt defines the event details to be processed
  33872. */
  33873. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33874. /**
  33875. * Does this action manager handles actions of any of the given triggers
  33876. * @param triggers defines the triggers to be tested
  33877. * @return a boolean indicating whether one (or more) of the triggers is handled
  33878. */
  33879. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33880. /**
  33881. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33882. * speed.
  33883. * @param triggerA defines the trigger to be tested
  33884. * @param triggerB defines the trigger to be tested
  33885. * @return a boolean indicating whether one (or more) of the triggers is handled
  33886. */
  33887. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33888. /**
  33889. * Does this action manager handles actions of a given trigger
  33890. * @param trigger defines the trigger to be tested
  33891. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33892. * @return whether the trigger is handled
  33893. */
  33894. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33895. /**
  33896. * Serialize this manager to a JSON object
  33897. * @param name defines the property name to store this manager
  33898. * @returns a JSON representation of this manager
  33899. */
  33900. abstract serialize(name: string): any;
  33901. /**
  33902. * Registers an action to this action manager
  33903. * @param action defines the action to be registered
  33904. * @return the action amended (prepared) after registration
  33905. */
  33906. abstract registerAction(action: IAction): Nullable<IAction>;
  33907. /**
  33908. * Unregisters an action to this action manager
  33909. * @param action defines the action to be unregistered
  33910. * @return a boolean indicating whether the action has been unregistered
  33911. */
  33912. abstract unregisterAction(action: IAction): Boolean;
  33913. /**
  33914. * Does exist one action manager with at least one trigger
  33915. **/
  33916. static get HasTriggers(): boolean;
  33917. /**
  33918. * Does exist one action manager with at least one pick trigger
  33919. **/
  33920. static get HasPickTriggers(): boolean;
  33921. /**
  33922. * Does exist one action manager that handles actions of a given trigger
  33923. * @param trigger defines the trigger to be tested
  33924. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33925. **/
  33926. static HasSpecificTrigger(trigger: number): boolean;
  33927. }
  33928. }
  33929. declare module "babylonjs/node" {
  33930. import { Scene } from "babylonjs/scene";
  33931. import { Nullable } from "babylonjs/types";
  33932. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33933. import { Engine } from "babylonjs/Engines/engine";
  33934. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33935. import { Observable } from "babylonjs/Misc/observable";
  33936. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33937. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33938. import { Animatable } from "babylonjs/Animations/animatable";
  33939. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33940. import { Animation } from "babylonjs/Animations/animation";
  33941. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33943. /**
  33944. * Defines how a node can be built from a string name.
  33945. */
  33946. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33947. /**
  33948. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33949. */
  33950. export class Node implements IBehaviorAware<Node> {
  33951. /** @hidden */
  33952. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33953. private static _NodeConstructors;
  33954. /**
  33955. * Add a new node constructor
  33956. * @param type defines the type name of the node to construct
  33957. * @param constructorFunc defines the constructor function
  33958. */
  33959. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33960. /**
  33961. * Returns a node constructor based on type name
  33962. * @param type defines the type name
  33963. * @param name defines the new node name
  33964. * @param scene defines the hosting scene
  33965. * @param options defines optional options to transmit to constructors
  33966. * @returns the new constructor or null
  33967. */
  33968. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33969. /**
  33970. * Gets or sets the name of the node
  33971. */
  33972. name: string;
  33973. /**
  33974. * Gets or sets the id of the node
  33975. */
  33976. id: string;
  33977. /**
  33978. * Gets or sets the unique id of the node
  33979. */
  33980. uniqueId: number;
  33981. /**
  33982. * Gets or sets a string used to store user defined state for the node
  33983. */
  33984. state: string;
  33985. /**
  33986. * Gets or sets an object used to store user defined information for the node
  33987. */
  33988. metadata: any;
  33989. /**
  33990. * For internal use only. Please do not use.
  33991. */
  33992. reservedDataStore: any;
  33993. /**
  33994. * List of inspectable custom properties (used by the Inspector)
  33995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33996. */
  33997. inspectableCustomProperties: IInspectable[];
  33998. private _doNotSerialize;
  33999. /**
  34000. * Gets or sets a boolean used to define if the node must be serialized
  34001. */
  34002. get doNotSerialize(): boolean;
  34003. set doNotSerialize(value: boolean);
  34004. /** @hidden */
  34005. _isDisposed: boolean;
  34006. /**
  34007. * Gets a list of Animations associated with the node
  34008. */
  34009. animations: import("babylonjs/Animations/animation").Animation[];
  34010. protected _ranges: {
  34011. [name: string]: Nullable<AnimationRange>;
  34012. };
  34013. /**
  34014. * Callback raised when the node is ready to be used
  34015. */
  34016. onReady: Nullable<(node: Node) => void>;
  34017. private _isEnabled;
  34018. private _isParentEnabled;
  34019. private _isReady;
  34020. /** @hidden */
  34021. _currentRenderId: number;
  34022. private _parentUpdateId;
  34023. /** @hidden */
  34024. _childUpdateId: number;
  34025. /** @hidden */
  34026. _waitingParentId: Nullable<string>;
  34027. /** @hidden */
  34028. _scene: Scene;
  34029. /** @hidden */
  34030. _cache: any;
  34031. private _parentNode;
  34032. private _children;
  34033. /** @hidden */
  34034. _worldMatrix: Matrix;
  34035. /** @hidden */
  34036. _worldMatrixDeterminant: number;
  34037. /** @hidden */
  34038. _worldMatrixDeterminantIsDirty: boolean;
  34039. /** @hidden */
  34040. private _sceneRootNodesIndex;
  34041. /**
  34042. * Gets a boolean indicating if the node has been disposed
  34043. * @returns true if the node was disposed
  34044. */
  34045. isDisposed(): boolean;
  34046. /**
  34047. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34048. * @see https://doc.babylonjs.com/how_to/parenting
  34049. */
  34050. set parent(parent: Nullable<Node>);
  34051. get parent(): Nullable<Node>;
  34052. /** @hidden */
  34053. _addToSceneRootNodes(): void;
  34054. /** @hidden */
  34055. _removeFromSceneRootNodes(): void;
  34056. private _animationPropertiesOverride;
  34057. /**
  34058. * Gets or sets the animation properties override
  34059. */
  34060. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34061. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34062. /**
  34063. * Gets a string idenfifying the name of the class
  34064. * @returns "Node" string
  34065. */
  34066. getClassName(): string;
  34067. /** @hidden */
  34068. readonly _isNode: boolean;
  34069. /**
  34070. * An event triggered when the mesh is disposed
  34071. */
  34072. onDisposeObservable: Observable<Node>;
  34073. private _onDisposeObserver;
  34074. /**
  34075. * Sets a callback that will be raised when the node will be disposed
  34076. */
  34077. set onDispose(callback: () => void);
  34078. /**
  34079. * Creates a new Node
  34080. * @param name the name and id to be given to this node
  34081. * @param scene the scene this node will be added to
  34082. */
  34083. constructor(name: string, scene?: Nullable<Scene>);
  34084. /**
  34085. * Gets the scene of the node
  34086. * @returns a scene
  34087. */
  34088. getScene(): Scene;
  34089. /**
  34090. * Gets the engine of the node
  34091. * @returns a Engine
  34092. */
  34093. getEngine(): Engine;
  34094. private _behaviors;
  34095. /**
  34096. * Attach a behavior to the node
  34097. * @see https://doc.babylonjs.com/features/behaviour
  34098. * @param behavior defines the behavior to attach
  34099. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34100. * @returns the current Node
  34101. */
  34102. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34103. /**
  34104. * Remove an attached behavior
  34105. * @see https://doc.babylonjs.com/features/behaviour
  34106. * @param behavior defines the behavior to attach
  34107. * @returns the current Node
  34108. */
  34109. removeBehavior(behavior: Behavior<Node>): Node;
  34110. /**
  34111. * Gets the list of attached behaviors
  34112. * @see https://doc.babylonjs.com/features/behaviour
  34113. */
  34114. get behaviors(): Behavior<Node>[];
  34115. /**
  34116. * Gets an attached behavior by name
  34117. * @param name defines the name of the behavior to look for
  34118. * @see https://doc.babylonjs.com/features/behaviour
  34119. * @returns null if behavior was not found else the requested behavior
  34120. */
  34121. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34122. /**
  34123. * Returns the latest update of the World matrix
  34124. * @returns a Matrix
  34125. */
  34126. getWorldMatrix(): Matrix;
  34127. /** @hidden */
  34128. _getWorldMatrixDeterminant(): number;
  34129. /**
  34130. * Returns directly the latest state of the mesh World matrix.
  34131. * A Matrix is returned.
  34132. */
  34133. get worldMatrixFromCache(): Matrix;
  34134. /** @hidden */
  34135. _initCache(): void;
  34136. /** @hidden */
  34137. updateCache(force?: boolean): void;
  34138. /** @hidden */
  34139. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34140. /** @hidden */
  34141. _updateCache(ignoreParentClass?: boolean): void;
  34142. /** @hidden */
  34143. _isSynchronized(): boolean;
  34144. /** @hidden */
  34145. _markSyncedWithParent(): void;
  34146. /** @hidden */
  34147. isSynchronizedWithParent(): boolean;
  34148. /** @hidden */
  34149. isSynchronized(): boolean;
  34150. /**
  34151. * Is this node ready to be used/rendered
  34152. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34153. * @return true if the node is ready
  34154. */
  34155. isReady(completeCheck?: boolean): boolean;
  34156. /**
  34157. * Is this node enabled?
  34158. * 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
  34159. * @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
  34160. * @return whether this node (and its parent) is enabled
  34161. */
  34162. isEnabled(checkAncestors?: boolean): boolean;
  34163. /** @hidden */
  34164. protected _syncParentEnabledState(): void;
  34165. /**
  34166. * Set the enabled state of this node
  34167. * @param value defines the new enabled state
  34168. */
  34169. setEnabled(value: boolean): void;
  34170. /**
  34171. * Is this node a descendant of the given node?
  34172. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34173. * @param ancestor defines the parent node to inspect
  34174. * @returns a boolean indicating if this node is a descendant of the given node
  34175. */
  34176. isDescendantOf(ancestor: Node): boolean;
  34177. /** @hidden */
  34178. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34179. /**
  34180. * Will return all nodes that have this node as ascendant
  34181. * @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
  34182. * @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
  34183. * @return all children nodes of all types
  34184. */
  34185. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34186. /**
  34187. * Get all child-meshes of this node
  34188. * @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)
  34189. * @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
  34190. * @returns an array of AbstractMesh
  34191. */
  34192. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34193. /**
  34194. * Get all direct children of this node
  34195. * @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
  34196. * @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)
  34197. * @returns an array of Node
  34198. */
  34199. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34200. /** @hidden */
  34201. _setReady(state: boolean): void;
  34202. /**
  34203. * Get an animation by name
  34204. * @param name defines the name of the animation to look for
  34205. * @returns null if not found else the requested animation
  34206. */
  34207. getAnimationByName(name: string): Nullable<Animation>;
  34208. /**
  34209. * Creates an animation range for this node
  34210. * @param name defines the name of the range
  34211. * @param from defines the starting key
  34212. * @param to defines the end key
  34213. */
  34214. createAnimationRange(name: string, from: number, to: number): void;
  34215. /**
  34216. * Delete a specific animation range
  34217. * @param name defines the name of the range to delete
  34218. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34219. */
  34220. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34221. /**
  34222. * Get an animation range by name
  34223. * @param name defines the name of the animation range to look for
  34224. * @returns null if not found else the requested animation range
  34225. */
  34226. getAnimationRange(name: string): Nullable<AnimationRange>;
  34227. /**
  34228. * Gets the list of all animation ranges defined on this node
  34229. * @returns an array
  34230. */
  34231. getAnimationRanges(): Nullable<AnimationRange>[];
  34232. /**
  34233. * Will start the animation sequence
  34234. * @param name defines the range frames for animation sequence
  34235. * @param loop defines if the animation should loop (false by default)
  34236. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34237. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34238. * @returns the object created for this animation. If range does not exist, it will return null
  34239. */
  34240. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34241. /**
  34242. * Serialize animation ranges into a JSON compatible object
  34243. * @returns serialization object
  34244. */
  34245. serializeAnimationRanges(): any;
  34246. /**
  34247. * Computes the world matrix of the node
  34248. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34249. * @returns the world matrix
  34250. */
  34251. computeWorldMatrix(force?: boolean): Matrix;
  34252. /**
  34253. * Releases resources associated with this node.
  34254. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34255. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34256. */
  34257. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34258. /**
  34259. * Parse animation range data from a serialization object and store them into a given node
  34260. * @param node defines where to store the animation ranges
  34261. * @param parsedNode defines the serialization object to read data from
  34262. * @param scene defines the hosting scene
  34263. */
  34264. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34265. /**
  34266. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34267. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34268. * @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
  34269. * @returns the new bounding vectors
  34270. */
  34271. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34272. min: Vector3;
  34273. max: Vector3;
  34274. };
  34275. }
  34276. }
  34277. declare module "babylonjs/Animations/animation" {
  34278. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34279. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34280. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34281. import { Nullable } from "babylonjs/types";
  34282. import { Scene } from "babylonjs/scene";
  34283. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34284. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34285. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34286. import { Node } from "babylonjs/node";
  34287. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34288. import { Size } from "babylonjs/Maths/math.size";
  34289. import { Animatable } from "babylonjs/Animations/animatable";
  34290. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34291. /**
  34292. * @hidden
  34293. */
  34294. export class _IAnimationState {
  34295. key: number;
  34296. repeatCount: number;
  34297. workValue?: any;
  34298. loopMode?: number;
  34299. offsetValue?: any;
  34300. highLimitValue?: any;
  34301. }
  34302. /**
  34303. * Class used to store any kind of animation
  34304. */
  34305. export class Animation {
  34306. /**Name of the animation */
  34307. name: string;
  34308. /**Property to animate */
  34309. targetProperty: string;
  34310. /**The frames per second of the animation */
  34311. framePerSecond: number;
  34312. /**The data type of the animation */
  34313. dataType: number;
  34314. /**The loop mode of the animation */
  34315. loopMode?: number | undefined;
  34316. /**Specifies if blending should be enabled */
  34317. enableBlending?: boolean | undefined;
  34318. /**
  34319. * Use matrix interpolation instead of using direct key value when animating matrices
  34320. */
  34321. static AllowMatricesInterpolation: boolean;
  34322. /**
  34323. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34324. */
  34325. static AllowMatrixDecomposeForInterpolation: boolean;
  34326. /** Define the Url to load snippets */
  34327. static SnippetUrl: string;
  34328. /** Snippet ID if the animation was created from the snippet server */
  34329. snippetId: string;
  34330. /**
  34331. * Stores the key frames of the animation
  34332. */
  34333. private _keys;
  34334. /**
  34335. * Stores the easing function of the animation
  34336. */
  34337. private _easingFunction;
  34338. /**
  34339. * @hidden Internal use only
  34340. */
  34341. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34342. /**
  34343. * The set of event that will be linked to this animation
  34344. */
  34345. private _events;
  34346. /**
  34347. * Stores an array of target property paths
  34348. */
  34349. targetPropertyPath: string[];
  34350. /**
  34351. * Stores the blending speed of the animation
  34352. */
  34353. blendingSpeed: number;
  34354. /**
  34355. * Stores the animation ranges for the animation
  34356. */
  34357. private _ranges;
  34358. /**
  34359. * @hidden Internal use
  34360. */
  34361. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34362. /**
  34363. * Sets up an animation
  34364. * @param property The property to animate
  34365. * @param animationType The animation type to apply
  34366. * @param framePerSecond The frames per second of the animation
  34367. * @param easingFunction The easing function used in the animation
  34368. * @returns The created animation
  34369. */
  34370. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34371. /**
  34372. * Create and start an animation on a node
  34373. * @param name defines the name of the global animation that will be run on all nodes
  34374. * @param node defines the root node where the animation will take place
  34375. * @param targetProperty defines property to animate
  34376. * @param framePerSecond defines the number of frame per second yo use
  34377. * @param totalFrame defines the number of frames in total
  34378. * @param from defines the initial value
  34379. * @param to defines the final value
  34380. * @param loopMode defines which loop mode you want to use (off by default)
  34381. * @param easingFunction defines the easing function to use (linear by default)
  34382. * @param onAnimationEnd defines the callback to call when animation end
  34383. * @returns the animatable created for this animation
  34384. */
  34385. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34386. /**
  34387. * Create and start an animation on a node and its descendants
  34388. * @param name defines the name of the global animation that will be run on all nodes
  34389. * @param node defines the root node where the animation will take place
  34390. * @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
  34391. * @param targetProperty defines property to animate
  34392. * @param framePerSecond defines the number of frame per second to use
  34393. * @param totalFrame defines the number of frames in total
  34394. * @param from defines the initial value
  34395. * @param to defines the final value
  34396. * @param loopMode defines which loop mode you want to use (off by default)
  34397. * @param easingFunction defines the easing function to use (linear by default)
  34398. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34399. * @returns the list of animatables created for all nodes
  34400. * @example https://www.babylonjs-playground.com/#MH0VLI
  34401. */
  34402. 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[]>;
  34403. /**
  34404. * Creates a new animation, merges it with the existing animations and starts it
  34405. * @param name Name of the animation
  34406. * @param node Node which contains the scene that begins the animations
  34407. * @param targetProperty Specifies which property to animate
  34408. * @param framePerSecond The frames per second of the animation
  34409. * @param totalFrame The total number of frames
  34410. * @param from The frame at the beginning of the animation
  34411. * @param to The frame at the end of the animation
  34412. * @param loopMode Specifies the loop mode of the animation
  34413. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34414. * @param onAnimationEnd Callback to run once the animation is complete
  34415. * @returns Nullable animation
  34416. */
  34417. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34418. /**
  34419. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34420. * @param sourceAnimation defines the Animation containing keyframes to convert
  34421. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34422. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34423. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34424. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34425. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34426. */
  34427. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34428. /**
  34429. * Transition property of an host to the target Value
  34430. * @param property The property to transition
  34431. * @param targetValue The target Value of the property
  34432. * @param host The object where the property to animate belongs
  34433. * @param scene Scene used to run the animation
  34434. * @param frameRate Framerate (in frame/s) to use
  34435. * @param transition The transition type we want to use
  34436. * @param duration The duration of the animation, in milliseconds
  34437. * @param onAnimationEnd Callback trigger at the end of the animation
  34438. * @returns Nullable animation
  34439. */
  34440. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34441. /**
  34442. * Return the array of runtime animations currently using this animation
  34443. */
  34444. get runtimeAnimations(): RuntimeAnimation[];
  34445. /**
  34446. * Specifies if any of the runtime animations are currently running
  34447. */
  34448. get hasRunningRuntimeAnimations(): boolean;
  34449. /**
  34450. * Initializes the animation
  34451. * @param name Name of the animation
  34452. * @param targetProperty Property to animate
  34453. * @param framePerSecond The frames per second of the animation
  34454. * @param dataType The data type of the animation
  34455. * @param loopMode The loop mode of the animation
  34456. * @param enableBlending Specifies if blending should be enabled
  34457. */
  34458. constructor(
  34459. /**Name of the animation */
  34460. name: string,
  34461. /**Property to animate */
  34462. targetProperty: string,
  34463. /**The frames per second of the animation */
  34464. framePerSecond: number,
  34465. /**The data type of the animation */
  34466. dataType: number,
  34467. /**The loop mode of the animation */
  34468. loopMode?: number | undefined,
  34469. /**Specifies if blending should be enabled */
  34470. enableBlending?: boolean | undefined);
  34471. /**
  34472. * Converts the animation to a string
  34473. * @param fullDetails support for multiple levels of logging within scene loading
  34474. * @returns String form of the animation
  34475. */
  34476. toString(fullDetails?: boolean): string;
  34477. /**
  34478. * Add an event to this animation
  34479. * @param event Event to add
  34480. */
  34481. addEvent(event: AnimationEvent): void;
  34482. /**
  34483. * Remove all events found at the given frame
  34484. * @param frame The frame to remove events from
  34485. */
  34486. removeEvents(frame: number): void;
  34487. /**
  34488. * Retrieves all the events from the animation
  34489. * @returns Events from the animation
  34490. */
  34491. getEvents(): AnimationEvent[];
  34492. /**
  34493. * Creates an animation range
  34494. * @param name Name of the animation range
  34495. * @param from Starting frame of the animation range
  34496. * @param to Ending frame of the animation
  34497. */
  34498. createRange(name: string, from: number, to: number): void;
  34499. /**
  34500. * Deletes an animation range by name
  34501. * @param name Name of the animation range to delete
  34502. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34503. */
  34504. deleteRange(name: string, deleteFrames?: boolean): void;
  34505. /**
  34506. * Gets the animation range by name, or null if not defined
  34507. * @param name Name of the animation range
  34508. * @returns Nullable animation range
  34509. */
  34510. getRange(name: string): Nullable<AnimationRange>;
  34511. /**
  34512. * Gets the key frames from the animation
  34513. * @returns The key frames of the animation
  34514. */
  34515. getKeys(): Array<IAnimationKey>;
  34516. /**
  34517. * Gets the highest frame rate of the animation
  34518. * @returns Highest frame rate of the animation
  34519. */
  34520. getHighestFrame(): number;
  34521. /**
  34522. * Gets the easing function of the animation
  34523. * @returns Easing function of the animation
  34524. */
  34525. getEasingFunction(): IEasingFunction;
  34526. /**
  34527. * Sets the easing function of the animation
  34528. * @param easingFunction A custom mathematical formula for animation
  34529. */
  34530. setEasingFunction(easingFunction: EasingFunction): void;
  34531. /**
  34532. * Interpolates a scalar linearly
  34533. * @param startValue Start value of the animation curve
  34534. * @param endValue End value of the animation curve
  34535. * @param gradient Scalar amount to interpolate
  34536. * @returns Interpolated scalar value
  34537. */
  34538. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34539. /**
  34540. * Interpolates a scalar cubically
  34541. * @param startValue Start value of the animation curve
  34542. * @param outTangent End tangent of the animation
  34543. * @param endValue End value of the animation curve
  34544. * @param inTangent Start tangent of the animation curve
  34545. * @param gradient Scalar amount to interpolate
  34546. * @returns Interpolated scalar value
  34547. */
  34548. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34549. /**
  34550. * Interpolates a quaternion using a spherical linear interpolation
  34551. * @param startValue Start value of the animation curve
  34552. * @param endValue End value of the animation curve
  34553. * @param gradient Scalar amount to interpolate
  34554. * @returns Interpolated quaternion value
  34555. */
  34556. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34557. /**
  34558. * Interpolates a quaternion cubically
  34559. * @param startValue Start value of the animation curve
  34560. * @param outTangent End tangent of the animation curve
  34561. * @param endValue End value of the animation curve
  34562. * @param inTangent Start tangent of the animation curve
  34563. * @param gradient Scalar amount to interpolate
  34564. * @returns Interpolated quaternion value
  34565. */
  34566. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34567. /**
  34568. * Interpolates a Vector3 linearl
  34569. * @param startValue Start value of the animation curve
  34570. * @param endValue End value of the animation curve
  34571. * @param gradient Scalar amount to interpolate
  34572. * @returns Interpolated scalar value
  34573. */
  34574. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34575. /**
  34576. * Interpolates a Vector3 cubically
  34577. * @param startValue Start value of the animation curve
  34578. * @param outTangent End tangent of the animation
  34579. * @param endValue End value of the animation curve
  34580. * @param inTangent Start tangent of the animation curve
  34581. * @param gradient Scalar amount to interpolate
  34582. * @returns InterpolatedVector3 value
  34583. */
  34584. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34585. /**
  34586. * Interpolates a Vector2 linearly
  34587. * @param startValue Start value of the animation curve
  34588. * @param endValue End value of the animation curve
  34589. * @param gradient Scalar amount to interpolate
  34590. * @returns Interpolated Vector2 value
  34591. */
  34592. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34593. /**
  34594. * Interpolates a Vector2 cubically
  34595. * @param startValue Start value of the animation curve
  34596. * @param outTangent End tangent of the animation
  34597. * @param endValue End value of the animation curve
  34598. * @param inTangent Start tangent of the animation curve
  34599. * @param gradient Scalar amount to interpolate
  34600. * @returns Interpolated Vector2 value
  34601. */
  34602. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34603. /**
  34604. * Interpolates a size linearly
  34605. * @param startValue Start value of the animation curve
  34606. * @param endValue End value of the animation curve
  34607. * @param gradient Scalar amount to interpolate
  34608. * @returns Interpolated Size value
  34609. */
  34610. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34611. /**
  34612. * Interpolates a Color3 linearly
  34613. * @param startValue Start value of the animation curve
  34614. * @param endValue End value of the animation curve
  34615. * @param gradient Scalar amount to interpolate
  34616. * @returns Interpolated Color3 value
  34617. */
  34618. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34619. /**
  34620. * Interpolates a Color4 linearly
  34621. * @param startValue Start value of the animation curve
  34622. * @param endValue End value of the animation curve
  34623. * @param gradient Scalar amount to interpolate
  34624. * @returns Interpolated Color3 value
  34625. */
  34626. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34627. /**
  34628. * @hidden Internal use only
  34629. */
  34630. _getKeyValue(value: any): any;
  34631. /**
  34632. * @hidden Internal use only
  34633. */
  34634. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34635. /**
  34636. * Defines the function to use to interpolate matrices
  34637. * @param startValue defines the start matrix
  34638. * @param endValue defines the end matrix
  34639. * @param gradient defines the gradient between both matrices
  34640. * @param result defines an optional target matrix where to store the interpolation
  34641. * @returns the interpolated matrix
  34642. */
  34643. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34644. /**
  34645. * Makes a copy of the animation
  34646. * @returns Cloned animation
  34647. */
  34648. clone(): Animation;
  34649. /**
  34650. * Sets the key frames of the animation
  34651. * @param values The animation key frames to set
  34652. */
  34653. setKeys(values: Array<IAnimationKey>): void;
  34654. /**
  34655. * Serializes the animation to an object
  34656. * @returns Serialized object
  34657. */
  34658. serialize(): any;
  34659. /**
  34660. * Float animation type
  34661. */
  34662. static readonly ANIMATIONTYPE_FLOAT: number;
  34663. /**
  34664. * Vector3 animation type
  34665. */
  34666. static readonly ANIMATIONTYPE_VECTOR3: number;
  34667. /**
  34668. * Quaternion animation type
  34669. */
  34670. static readonly ANIMATIONTYPE_QUATERNION: number;
  34671. /**
  34672. * Matrix animation type
  34673. */
  34674. static readonly ANIMATIONTYPE_MATRIX: number;
  34675. /**
  34676. * Color3 animation type
  34677. */
  34678. static readonly ANIMATIONTYPE_COLOR3: number;
  34679. /**
  34680. * Color3 animation type
  34681. */
  34682. static readonly ANIMATIONTYPE_COLOR4: number;
  34683. /**
  34684. * Vector2 animation type
  34685. */
  34686. static readonly ANIMATIONTYPE_VECTOR2: number;
  34687. /**
  34688. * Size animation type
  34689. */
  34690. static readonly ANIMATIONTYPE_SIZE: number;
  34691. /**
  34692. * Relative Loop Mode
  34693. */
  34694. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34695. /**
  34696. * Cycle Loop Mode
  34697. */
  34698. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34699. /**
  34700. * Constant Loop Mode
  34701. */
  34702. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34703. /** @hidden */
  34704. static _UniversalLerp(left: any, right: any, amount: number): any;
  34705. /**
  34706. * Parses an animation object and creates an animation
  34707. * @param parsedAnimation Parsed animation object
  34708. * @returns Animation object
  34709. */
  34710. static Parse(parsedAnimation: any): Animation;
  34711. /**
  34712. * Appends the serialized animations from the source animations
  34713. * @param source Source containing the animations
  34714. * @param destination Target to store the animations
  34715. */
  34716. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34717. /**
  34718. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34719. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34720. * @param url defines the url to load from
  34721. * @returns a promise that will resolve to the new animation or an array of animations
  34722. */
  34723. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34724. /**
  34725. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34726. * @param snippetId defines the snippet to load
  34727. * @returns a promise that will resolve to the new animation or a new array of animations
  34728. */
  34729. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34730. }
  34731. }
  34732. declare module "babylonjs/Animations/animatable.interface" {
  34733. import { Nullable } from "babylonjs/types";
  34734. import { Animation } from "babylonjs/Animations/animation";
  34735. /**
  34736. * Interface containing an array of animations
  34737. */
  34738. export interface IAnimatable {
  34739. /**
  34740. * Array of animations
  34741. */
  34742. animations: Nullable<Array<Animation>>;
  34743. }
  34744. }
  34745. declare module "babylonjs/Misc/decorators" {
  34746. import { Nullable } from "babylonjs/types";
  34747. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34748. import { Scene } from "babylonjs/scene";
  34749. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34750. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34751. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34753. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34754. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34755. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34756. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34757. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34758. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34759. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34760. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34761. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34762. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34763. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34764. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34765. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34766. /**
  34767. * Decorator used to define property that can be serialized as reference to a camera
  34768. * @param sourceName defines the name of the property to decorate
  34769. */
  34770. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34771. /**
  34772. * Class used to help serialization objects
  34773. */
  34774. export class SerializationHelper {
  34775. /** @hidden */
  34776. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34777. /** @hidden */
  34778. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34779. /** @hidden */
  34780. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34781. /** @hidden */
  34782. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34783. /**
  34784. * Appends the serialized animations from the source animations
  34785. * @param source Source containing the animations
  34786. * @param destination Target to store the animations
  34787. */
  34788. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34789. /**
  34790. * Static function used to serialized a specific entity
  34791. * @param entity defines the entity to serialize
  34792. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34793. * @returns a JSON compatible object representing the serialization of the entity
  34794. */
  34795. static Serialize<T>(entity: T, serializationObject?: any): any;
  34796. /**
  34797. * Creates a new entity from a serialization data object
  34798. * @param creationFunction defines a function used to instanciated the new entity
  34799. * @param source defines the source serialization data
  34800. * @param scene defines the hosting scene
  34801. * @param rootUrl defines the root url for resources
  34802. * @returns a new entity
  34803. */
  34804. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34805. /**
  34806. * Clones an object
  34807. * @param creationFunction defines the function used to instanciate the new object
  34808. * @param source defines the source object
  34809. * @returns the cloned object
  34810. */
  34811. static Clone<T>(creationFunction: () => T, source: T): T;
  34812. /**
  34813. * Instanciates a new object based on a source one (some data will be shared between both object)
  34814. * @param creationFunction defines the function used to instanciate the new object
  34815. * @param source defines the source object
  34816. * @returns the new object
  34817. */
  34818. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34819. }
  34820. }
  34821. declare module "babylonjs/Materials/Textures/baseTexture" {
  34822. import { Observable } from "babylonjs/Misc/observable";
  34823. import { Nullable } from "babylonjs/types";
  34824. import { Scene } from "babylonjs/scene";
  34825. import { Matrix } from "babylonjs/Maths/math.vector";
  34826. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34827. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34828. import { ISize } from "babylonjs/Maths/math.size";
  34829. import "babylonjs/Misc/fileTools";
  34830. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34831. /**
  34832. * Base class of all the textures in babylon.
  34833. * It groups all the common properties the materials, post process, lights... might need
  34834. * in order to make a correct use of the texture.
  34835. */
  34836. export class BaseTexture implements IAnimatable {
  34837. /**
  34838. * Default anisotropic filtering level for the application.
  34839. * It is set to 4 as a good tradeoff between perf and quality.
  34840. */
  34841. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34842. /**
  34843. * Gets or sets the unique id of the texture
  34844. */
  34845. uniqueId: number;
  34846. /**
  34847. * Define the name of the texture.
  34848. */
  34849. name: string;
  34850. /**
  34851. * Gets or sets an object used to store user defined information.
  34852. */
  34853. metadata: any;
  34854. /**
  34855. * For internal use only. Please do not use.
  34856. */
  34857. reservedDataStore: any;
  34858. private _hasAlpha;
  34859. /**
  34860. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34861. */
  34862. set hasAlpha(value: boolean);
  34863. get hasAlpha(): boolean;
  34864. /**
  34865. * Defines if the alpha value should be determined via the rgb values.
  34866. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34867. */
  34868. getAlphaFromRGB: boolean;
  34869. /**
  34870. * Intensity or strength of the texture.
  34871. * It is commonly used by materials to fine tune the intensity of the texture
  34872. */
  34873. level: number;
  34874. /**
  34875. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34876. * This is part of the texture as textures usually maps to one uv set.
  34877. */
  34878. coordinatesIndex: number;
  34879. private _coordinatesMode;
  34880. /**
  34881. * How a texture is mapped.
  34882. *
  34883. * | Value | Type | Description |
  34884. * | ----- | ----------------------------------- | ----------- |
  34885. * | 0 | EXPLICIT_MODE | |
  34886. * | 1 | SPHERICAL_MODE | |
  34887. * | 2 | PLANAR_MODE | |
  34888. * | 3 | CUBIC_MODE | |
  34889. * | 4 | PROJECTION_MODE | |
  34890. * | 5 | SKYBOX_MODE | |
  34891. * | 6 | INVCUBIC_MODE | |
  34892. * | 7 | EQUIRECTANGULAR_MODE | |
  34893. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34894. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34895. */
  34896. set coordinatesMode(value: number);
  34897. get coordinatesMode(): number;
  34898. /**
  34899. * | Value | Type | Description |
  34900. * | ----- | ------------------ | ----------- |
  34901. * | 0 | CLAMP_ADDRESSMODE | |
  34902. * | 1 | WRAP_ADDRESSMODE | |
  34903. * | 2 | MIRROR_ADDRESSMODE | |
  34904. */
  34905. wrapU: number;
  34906. /**
  34907. * | Value | Type | Description |
  34908. * | ----- | ------------------ | ----------- |
  34909. * | 0 | CLAMP_ADDRESSMODE | |
  34910. * | 1 | WRAP_ADDRESSMODE | |
  34911. * | 2 | MIRROR_ADDRESSMODE | |
  34912. */
  34913. wrapV: number;
  34914. /**
  34915. * | Value | Type | Description |
  34916. * | ----- | ------------------ | ----------- |
  34917. * | 0 | CLAMP_ADDRESSMODE | |
  34918. * | 1 | WRAP_ADDRESSMODE | |
  34919. * | 2 | MIRROR_ADDRESSMODE | |
  34920. */
  34921. wrapR: number;
  34922. /**
  34923. * With compliant hardware and browser (supporting anisotropic filtering)
  34924. * this defines the level of anisotropic filtering in the texture.
  34925. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34926. */
  34927. anisotropicFilteringLevel: number;
  34928. /**
  34929. * Define if the texture is a cube texture or if false a 2d texture.
  34930. */
  34931. get isCube(): boolean;
  34932. set isCube(value: boolean);
  34933. /**
  34934. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34935. */
  34936. get is3D(): boolean;
  34937. set is3D(value: boolean);
  34938. /**
  34939. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34940. */
  34941. get is2DArray(): boolean;
  34942. set is2DArray(value: boolean);
  34943. /**
  34944. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34945. * HDR texture are usually stored in linear space.
  34946. * This only impacts the PBR and Background materials
  34947. */
  34948. gammaSpace: boolean;
  34949. /**
  34950. * Gets or sets whether or not the texture contains RGBD data.
  34951. */
  34952. get isRGBD(): boolean;
  34953. set isRGBD(value: boolean);
  34954. /**
  34955. * Is Z inverted in the texture (useful in a cube texture).
  34956. */
  34957. invertZ: boolean;
  34958. /**
  34959. * Are mip maps generated for this texture or not.
  34960. */
  34961. get noMipmap(): boolean;
  34962. /**
  34963. * @hidden
  34964. */
  34965. lodLevelInAlpha: boolean;
  34966. /**
  34967. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34968. */
  34969. get lodGenerationOffset(): number;
  34970. set lodGenerationOffset(value: number);
  34971. /**
  34972. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34973. */
  34974. get lodGenerationScale(): number;
  34975. set lodGenerationScale(value: number);
  34976. /**
  34977. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34978. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34979. * average roughness values.
  34980. */
  34981. get linearSpecularLOD(): boolean;
  34982. set linearSpecularLOD(value: boolean);
  34983. /**
  34984. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34985. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34986. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34987. */
  34988. get irradianceTexture(): Nullable<BaseTexture>;
  34989. set irradianceTexture(value: Nullable<BaseTexture>);
  34990. /**
  34991. * Define if the texture is a render target.
  34992. */
  34993. isRenderTarget: boolean;
  34994. /**
  34995. * Define the unique id of the texture in the scene.
  34996. */
  34997. get uid(): string;
  34998. /** @hidden */
  34999. _prefiltered: boolean;
  35000. /**
  35001. * Return a string representation of the texture.
  35002. * @returns the texture as a string
  35003. */
  35004. toString(): string;
  35005. /**
  35006. * Get the class name of the texture.
  35007. * @returns "BaseTexture"
  35008. */
  35009. getClassName(): string;
  35010. /**
  35011. * Define the list of animation attached to the texture.
  35012. */
  35013. animations: import("babylonjs/Animations/animation").Animation[];
  35014. /**
  35015. * An event triggered when the texture is disposed.
  35016. */
  35017. onDisposeObservable: Observable<BaseTexture>;
  35018. private _onDisposeObserver;
  35019. /**
  35020. * Callback triggered when the texture has been disposed.
  35021. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35022. */
  35023. set onDispose(callback: () => void);
  35024. /**
  35025. * Define the current state of the loading sequence when in delayed load mode.
  35026. */
  35027. delayLoadState: number;
  35028. private _scene;
  35029. private _engine;
  35030. /** @hidden */
  35031. _texture: Nullable<InternalTexture>;
  35032. private _uid;
  35033. /**
  35034. * Define if the texture is preventinga material to render or not.
  35035. * If not and the texture is not ready, the engine will use a default black texture instead.
  35036. */
  35037. get isBlocking(): boolean;
  35038. /**
  35039. * Instantiates a new BaseTexture.
  35040. * Base class of all the textures in babylon.
  35041. * It groups all the common properties the materials, post process, lights... might need
  35042. * in order to make a correct use of the texture.
  35043. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35044. */
  35045. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35046. /**
  35047. * Get the scene the texture belongs to.
  35048. * @returns the scene or null if undefined
  35049. */
  35050. getScene(): Nullable<Scene>;
  35051. /** @hidden */
  35052. protected _getEngine(): Nullable<ThinEngine>;
  35053. /**
  35054. * Get the texture transform matrix used to offset tile the texture for istance.
  35055. * @returns the transformation matrix
  35056. */
  35057. getTextureMatrix(): Matrix;
  35058. /**
  35059. * Get the texture reflection matrix used to rotate/transform the reflection.
  35060. * @returns the reflection matrix
  35061. */
  35062. getReflectionTextureMatrix(): Matrix;
  35063. /**
  35064. * Get the underlying lower level texture from Babylon.
  35065. * @returns the insternal texture
  35066. */
  35067. getInternalTexture(): Nullable<InternalTexture>;
  35068. /**
  35069. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35070. * @returns true if ready or not blocking
  35071. */
  35072. isReadyOrNotBlocking(): boolean;
  35073. /**
  35074. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35075. * @returns true if fully ready
  35076. */
  35077. isReady(): boolean;
  35078. private _cachedSize;
  35079. /**
  35080. * Get the size of the texture.
  35081. * @returns the texture size.
  35082. */
  35083. getSize(): ISize;
  35084. /**
  35085. * Get the base size of the texture.
  35086. * It can be different from the size if the texture has been resized for POT for instance
  35087. * @returns the base size
  35088. */
  35089. getBaseSize(): ISize;
  35090. /**
  35091. * Update the sampling mode of the texture.
  35092. * Default is Trilinear mode.
  35093. *
  35094. * | Value | Type | Description |
  35095. * | ----- | ------------------ | ----------- |
  35096. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35097. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35098. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35099. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35100. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35101. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35102. * | 7 | NEAREST_LINEAR | |
  35103. * | 8 | NEAREST_NEAREST | |
  35104. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35105. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35106. * | 11 | LINEAR_LINEAR | |
  35107. * | 12 | LINEAR_NEAREST | |
  35108. *
  35109. * > _mag_: magnification filter (close to the viewer)
  35110. * > _min_: minification filter (far from the viewer)
  35111. * > _mip_: filter used between mip map levels
  35112. *@param samplingMode Define the new sampling mode of the texture
  35113. */
  35114. updateSamplingMode(samplingMode: number): void;
  35115. /**
  35116. * Scales the texture if is `canRescale()`
  35117. * @param ratio the resize factor we want to use to rescale
  35118. */
  35119. scale(ratio: number): void;
  35120. /**
  35121. * Get if the texture can rescale.
  35122. */
  35123. get canRescale(): boolean;
  35124. /** @hidden */
  35125. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35126. /** @hidden */
  35127. _rebuild(): void;
  35128. /**
  35129. * Triggers the load sequence in delayed load mode.
  35130. */
  35131. delayLoad(): void;
  35132. /**
  35133. * Clones the texture.
  35134. * @returns the cloned texture
  35135. */
  35136. clone(): Nullable<BaseTexture>;
  35137. /**
  35138. * Get the texture underlying type (INT, FLOAT...)
  35139. */
  35140. get textureType(): number;
  35141. /**
  35142. * Get the texture underlying format (RGB, RGBA...)
  35143. */
  35144. get textureFormat(): number;
  35145. /**
  35146. * Indicates that textures need to be re-calculated for all materials
  35147. */
  35148. protected _markAllSubMeshesAsTexturesDirty(): void;
  35149. /**
  35150. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35151. * This will returns an RGBA array buffer containing either in values (0-255) or
  35152. * float values (0-1) depending of the underlying buffer type.
  35153. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35154. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35155. * @param buffer defines a user defined buffer to fill with data (can be null)
  35156. * @returns The Array buffer containing the pixels data.
  35157. */
  35158. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35159. /**
  35160. * Release and destroy the underlying lower level texture aka internalTexture.
  35161. */
  35162. releaseInternalTexture(): void;
  35163. /** @hidden */
  35164. get _lodTextureHigh(): Nullable<BaseTexture>;
  35165. /** @hidden */
  35166. get _lodTextureMid(): Nullable<BaseTexture>;
  35167. /** @hidden */
  35168. get _lodTextureLow(): Nullable<BaseTexture>;
  35169. /**
  35170. * Dispose the texture and release its associated resources.
  35171. */
  35172. dispose(): void;
  35173. /**
  35174. * Serialize the texture into a JSON representation that can be parsed later on.
  35175. * @returns the JSON representation of the texture
  35176. */
  35177. serialize(): any;
  35178. /**
  35179. * Helper function to be called back once a list of texture contains only ready textures.
  35180. * @param textures Define the list of textures to wait for
  35181. * @param callback Define the callback triggered once the entire list will be ready
  35182. */
  35183. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35184. private static _isScene;
  35185. }
  35186. }
  35187. declare module "babylonjs/Materials/effect" {
  35188. import { Observable } from "babylonjs/Misc/observable";
  35189. import { Nullable } from "babylonjs/types";
  35190. import { IDisposable } from "babylonjs/scene";
  35191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35192. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35193. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35194. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35195. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35196. import { Engine } from "babylonjs/Engines/engine";
  35197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35199. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35200. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35201. /**
  35202. * Options to be used when creating an effect.
  35203. */
  35204. export interface IEffectCreationOptions {
  35205. /**
  35206. * Atrributes that will be used in the shader.
  35207. */
  35208. attributes: string[];
  35209. /**
  35210. * Uniform varible names that will be set in the shader.
  35211. */
  35212. uniformsNames: string[];
  35213. /**
  35214. * Uniform buffer variable names that will be set in the shader.
  35215. */
  35216. uniformBuffersNames: string[];
  35217. /**
  35218. * Sampler texture variable names that will be set in the shader.
  35219. */
  35220. samplers: string[];
  35221. /**
  35222. * Define statements that will be set in the shader.
  35223. */
  35224. defines: any;
  35225. /**
  35226. * Possible fallbacks for this effect to improve performance when needed.
  35227. */
  35228. fallbacks: Nullable<IEffectFallbacks>;
  35229. /**
  35230. * Callback that will be called when the shader is compiled.
  35231. */
  35232. onCompiled: Nullable<(effect: Effect) => void>;
  35233. /**
  35234. * Callback that will be called if an error occurs during shader compilation.
  35235. */
  35236. onError: Nullable<(effect: Effect, errors: string) => void>;
  35237. /**
  35238. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35239. */
  35240. indexParameters?: any;
  35241. /**
  35242. * Max number of lights that can be used in the shader.
  35243. */
  35244. maxSimultaneousLights?: number;
  35245. /**
  35246. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35247. */
  35248. transformFeedbackVaryings?: Nullable<string[]>;
  35249. /**
  35250. * 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
  35251. */
  35252. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35253. /**
  35254. * Is this effect rendering to several color attachments ?
  35255. */
  35256. multiTarget?: boolean;
  35257. }
  35258. /**
  35259. * Effect containing vertex and fragment shader that can be executed on an object.
  35260. */
  35261. export class Effect implements IDisposable {
  35262. /**
  35263. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35264. */
  35265. static ShadersRepository: string;
  35266. /**
  35267. * Enable logging of the shader code when a compilation error occurs
  35268. */
  35269. static LogShaderCodeOnCompilationError: boolean;
  35270. /**
  35271. * Name of the effect.
  35272. */
  35273. name: any;
  35274. /**
  35275. * String container all the define statements that should be set on the shader.
  35276. */
  35277. defines: string;
  35278. /**
  35279. * Callback that will be called when the shader is compiled.
  35280. */
  35281. onCompiled: Nullable<(effect: Effect) => void>;
  35282. /**
  35283. * Callback that will be called if an error occurs during shader compilation.
  35284. */
  35285. onError: Nullable<(effect: Effect, errors: string) => void>;
  35286. /**
  35287. * Callback that will be called when effect is bound.
  35288. */
  35289. onBind: Nullable<(effect: Effect) => void>;
  35290. /**
  35291. * Unique ID of the effect.
  35292. */
  35293. uniqueId: number;
  35294. /**
  35295. * Observable that will be called when the shader is compiled.
  35296. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35297. */
  35298. onCompileObservable: Observable<Effect>;
  35299. /**
  35300. * Observable that will be called if an error occurs during shader compilation.
  35301. */
  35302. onErrorObservable: Observable<Effect>;
  35303. /** @hidden */
  35304. _onBindObservable: Nullable<Observable<Effect>>;
  35305. /**
  35306. * @hidden
  35307. * Specifies if the effect was previously ready
  35308. */
  35309. _wasPreviouslyReady: boolean;
  35310. /**
  35311. * Observable that will be called when effect is bound.
  35312. */
  35313. get onBindObservable(): Observable<Effect>;
  35314. /** @hidden */
  35315. _bonesComputationForcedToCPU: boolean;
  35316. /** @hidden */
  35317. _multiTarget: boolean;
  35318. private static _uniqueIdSeed;
  35319. private _engine;
  35320. private _uniformBuffersNames;
  35321. private _uniformBuffersNamesList;
  35322. private _uniformsNames;
  35323. private _samplerList;
  35324. private _samplers;
  35325. private _isReady;
  35326. private _compilationError;
  35327. private _allFallbacksProcessed;
  35328. private _attributesNames;
  35329. private _attributes;
  35330. private _attributeLocationByName;
  35331. private _uniforms;
  35332. /**
  35333. * Key for the effect.
  35334. * @hidden
  35335. */
  35336. _key: string;
  35337. private _indexParameters;
  35338. private _fallbacks;
  35339. private _vertexSourceCode;
  35340. private _fragmentSourceCode;
  35341. private _vertexSourceCodeOverride;
  35342. private _fragmentSourceCodeOverride;
  35343. private _transformFeedbackVaryings;
  35344. /**
  35345. * Compiled shader to webGL program.
  35346. * @hidden
  35347. */
  35348. _pipelineContext: Nullable<IPipelineContext>;
  35349. private _valueCache;
  35350. private static _baseCache;
  35351. /**
  35352. * Instantiates an effect.
  35353. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35354. * @param baseName Name of the effect.
  35355. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35356. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35357. * @param samplers List of sampler variables that will be passed to the shader.
  35358. * @param engine Engine to be used to render the effect
  35359. * @param defines Define statements to be added to the shader.
  35360. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35361. * @param onCompiled Callback that will be called when the shader is compiled.
  35362. * @param onError Callback that will be called if an error occurs during shader compilation.
  35363. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35364. */
  35365. 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);
  35366. private _useFinalCode;
  35367. /**
  35368. * Unique key for this effect
  35369. */
  35370. get key(): string;
  35371. /**
  35372. * If the effect has been compiled and prepared.
  35373. * @returns if the effect is compiled and prepared.
  35374. */
  35375. isReady(): boolean;
  35376. private _isReadyInternal;
  35377. /**
  35378. * The engine the effect was initialized with.
  35379. * @returns the engine.
  35380. */
  35381. getEngine(): Engine;
  35382. /**
  35383. * The pipeline context for this effect
  35384. * @returns the associated pipeline context
  35385. */
  35386. getPipelineContext(): Nullable<IPipelineContext>;
  35387. /**
  35388. * The set of names of attribute variables for the shader.
  35389. * @returns An array of attribute names.
  35390. */
  35391. getAttributesNames(): string[];
  35392. /**
  35393. * Returns the attribute at the given index.
  35394. * @param index The index of the attribute.
  35395. * @returns The location of the attribute.
  35396. */
  35397. getAttributeLocation(index: number): number;
  35398. /**
  35399. * Returns the attribute based on the name of the variable.
  35400. * @param name of the attribute to look up.
  35401. * @returns the attribute location.
  35402. */
  35403. getAttributeLocationByName(name: string): number;
  35404. /**
  35405. * The number of attributes.
  35406. * @returns the numnber of attributes.
  35407. */
  35408. getAttributesCount(): number;
  35409. /**
  35410. * Gets the index of a uniform variable.
  35411. * @param uniformName of the uniform to look up.
  35412. * @returns the index.
  35413. */
  35414. getUniformIndex(uniformName: string): number;
  35415. /**
  35416. * Returns the attribute based on the name of the variable.
  35417. * @param uniformName of the uniform to look up.
  35418. * @returns the location of the uniform.
  35419. */
  35420. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35421. /**
  35422. * Returns an array of sampler variable names
  35423. * @returns The array of sampler variable names.
  35424. */
  35425. getSamplers(): string[];
  35426. /**
  35427. * Returns an array of uniform variable names
  35428. * @returns The array of uniform variable names.
  35429. */
  35430. getUniformNames(): string[];
  35431. /**
  35432. * Returns an array of uniform buffer variable names
  35433. * @returns The array of uniform buffer variable names.
  35434. */
  35435. getUniformBuffersNames(): string[];
  35436. /**
  35437. * Returns the index parameters used to create the effect
  35438. * @returns The index parameters object
  35439. */
  35440. getIndexParameters(): any;
  35441. /**
  35442. * The error from the last compilation.
  35443. * @returns the error string.
  35444. */
  35445. getCompilationError(): string;
  35446. /**
  35447. * Gets a boolean indicating that all fallbacks were used during compilation
  35448. * @returns true if all fallbacks were used
  35449. */
  35450. allFallbacksProcessed(): boolean;
  35451. /**
  35452. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35453. * @param func The callback to be used.
  35454. */
  35455. executeWhenCompiled(func: (effect: Effect) => void): void;
  35456. private _checkIsReady;
  35457. private _loadShader;
  35458. /**
  35459. * Gets the vertex shader source code of this effect
  35460. */
  35461. get vertexSourceCode(): string;
  35462. /**
  35463. * Gets the fragment shader source code of this effect
  35464. */
  35465. get fragmentSourceCode(): string;
  35466. /**
  35467. * Recompiles the webGL program
  35468. * @param vertexSourceCode The source code for the vertex shader.
  35469. * @param fragmentSourceCode The source code for the fragment shader.
  35470. * @param onCompiled Callback called when completed.
  35471. * @param onError Callback called on error.
  35472. * @hidden
  35473. */
  35474. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35475. /**
  35476. * Prepares the effect
  35477. * @hidden
  35478. */
  35479. _prepareEffect(): void;
  35480. private _getShaderCodeAndErrorLine;
  35481. private _processCompilationErrors;
  35482. /**
  35483. * Checks if the effect is supported. (Must be called after compilation)
  35484. */
  35485. get isSupported(): boolean;
  35486. /**
  35487. * Binds a texture to the engine to be used as output of the shader.
  35488. * @param channel Name of the output variable.
  35489. * @param texture Texture to bind.
  35490. * @hidden
  35491. */
  35492. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35493. /**
  35494. * Sets a texture on the engine to be used in the shader.
  35495. * @param channel Name of the sampler variable.
  35496. * @param texture Texture to set.
  35497. */
  35498. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35499. /**
  35500. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35501. * @param channel Name of the sampler variable.
  35502. * @param texture Texture to set.
  35503. */
  35504. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35505. /**
  35506. * Sets an array of textures on the engine to be used in the shader.
  35507. * @param channel Name of the variable.
  35508. * @param textures Textures to set.
  35509. */
  35510. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35511. /**
  35512. * 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)
  35513. * @param channel Name of the sampler variable.
  35514. * @param postProcess Post process to get the input texture from.
  35515. */
  35516. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35517. /**
  35518. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35519. * 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)
  35520. * @param channel Name of the sampler variable.
  35521. * @param postProcess Post process to get the output texture from.
  35522. */
  35523. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35524. /** @hidden */
  35525. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35526. /** @hidden */
  35527. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35528. /** @hidden */
  35529. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35530. /** @hidden */
  35531. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35532. /**
  35533. * Binds a buffer to a uniform.
  35534. * @param buffer Buffer to bind.
  35535. * @param name Name of the uniform variable to bind to.
  35536. */
  35537. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35538. /**
  35539. * Binds block to a uniform.
  35540. * @param blockName Name of the block to bind.
  35541. * @param index Index to bind.
  35542. */
  35543. bindUniformBlock(blockName: string, index: number): void;
  35544. /**
  35545. * Sets an interger value on a uniform variable.
  35546. * @param uniformName Name of the variable.
  35547. * @param value Value to be set.
  35548. * @returns this effect.
  35549. */
  35550. setInt(uniformName: string, value: number): Effect;
  35551. /**
  35552. * Sets an int array on a uniform variable.
  35553. * @param uniformName Name of the variable.
  35554. * @param array array to be set.
  35555. * @returns this effect.
  35556. */
  35557. setIntArray(uniformName: string, array: Int32Array): Effect;
  35558. /**
  35559. * 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)
  35560. * @param uniformName Name of the variable.
  35561. * @param array array to be set.
  35562. * @returns this effect.
  35563. */
  35564. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35565. /**
  35566. * 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)
  35567. * @param uniformName Name of the variable.
  35568. * @param array array to be set.
  35569. * @returns this effect.
  35570. */
  35571. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35572. /**
  35573. * 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)
  35574. * @param uniformName Name of the variable.
  35575. * @param array array to be set.
  35576. * @returns this effect.
  35577. */
  35578. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35579. /**
  35580. * Sets an float array on a uniform variable.
  35581. * @param uniformName Name of the variable.
  35582. * @param array array to be set.
  35583. * @returns this effect.
  35584. */
  35585. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35586. /**
  35587. * 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)
  35588. * @param uniformName Name of the variable.
  35589. * @param array array to be set.
  35590. * @returns this effect.
  35591. */
  35592. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35593. /**
  35594. * 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)
  35595. * @param uniformName Name of the variable.
  35596. * @param array array to be set.
  35597. * @returns this effect.
  35598. */
  35599. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35600. /**
  35601. * 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)
  35602. * @param uniformName Name of the variable.
  35603. * @param array array to be set.
  35604. * @returns this effect.
  35605. */
  35606. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35607. /**
  35608. * Sets an array on a uniform variable.
  35609. * @param uniformName Name of the variable.
  35610. * @param array array to be set.
  35611. * @returns this effect.
  35612. */
  35613. setArray(uniformName: string, array: number[]): Effect;
  35614. /**
  35615. * 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)
  35616. * @param uniformName Name of the variable.
  35617. * @param array array to be set.
  35618. * @returns this effect.
  35619. */
  35620. setArray2(uniformName: string, array: number[]): Effect;
  35621. /**
  35622. * 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)
  35623. * @param uniformName Name of the variable.
  35624. * @param array array to be set.
  35625. * @returns this effect.
  35626. */
  35627. setArray3(uniformName: string, array: number[]): Effect;
  35628. /**
  35629. * 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)
  35630. * @param uniformName Name of the variable.
  35631. * @param array array to be set.
  35632. * @returns this effect.
  35633. */
  35634. setArray4(uniformName: string, array: number[]): Effect;
  35635. /**
  35636. * Sets matrices on a uniform variable.
  35637. * @param uniformName Name of the variable.
  35638. * @param matrices matrices to be set.
  35639. * @returns this effect.
  35640. */
  35641. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35642. /**
  35643. * Sets matrix on a uniform variable.
  35644. * @param uniformName Name of the variable.
  35645. * @param matrix matrix to be set.
  35646. * @returns this effect.
  35647. */
  35648. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35649. /**
  35650. * 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)
  35651. * @param uniformName Name of the variable.
  35652. * @param matrix matrix to be set.
  35653. * @returns this effect.
  35654. */
  35655. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35656. /**
  35657. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35658. * @param uniformName Name of the variable.
  35659. * @param matrix matrix to be set.
  35660. * @returns this effect.
  35661. */
  35662. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35663. /**
  35664. * Sets a float on a uniform variable.
  35665. * @param uniformName Name of the variable.
  35666. * @param value value to be set.
  35667. * @returns this effect.
  35668. */
  35669. setFloat(uniformName: string, value: number): Effect;
  35670. /**
  35671. * Sets a boolean on a uniform variable.
  35672. * @param uniformName Name of the variable.
  35673. * @param bool value to be set.
  35674. * @returns this effect.
  35675. */
  35676. setBool(uniformName: string, bool: boolean): Effect;
  35677. /**
  35678. * Sets a Vector2 on a uniform variable.
  35679. * @param uniformName Name of the variable.
  35680. * @param vector2 vector2 to be set.
  35681. * @returns this effect.
  35682. */
  35683. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35684. /**
  35685. * Sets a float2 on a uniform variable.
  35686. * @param uniformName Name of the variable.
  35687. * @param x First float in float2.
  35688. * @param y Second float in float2.
  35689. * @returns this effect.
  35690. */
  35691. setFloat2(uniformName: string, x: number, y: number): Effect;
  35692. /**
  35693. * Sets a Vector3 on a uniform variable.
  35694. * @param uniformName Name of the variable.
  35695. * @param vector3 Value to be set.
  35696. * @returns this effect.
  35697. */
  35698. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35699. /**
  35700. * Sets a float3 on a uniform variable.
  35701. * @param uniformName Name of the variable.
  35702. * @param x First float in float3.
  35703. * @param y Second float in float3.
  35704. * @param z Third float in float3.
  35705. * @returns this effect.
  35706. */
  35707. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35708. /**
  35709. * Sets a Vector4 on a uniform variable.
  35710. * @param uniformName Name of the variable.
  35711. * @param vector4 Value to be set.
  35712. * @returns this effect.
  35713. */
  35714. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35715. /**
  35716. * Sets a float4 on a uniform variable.
  35717. * @param uniformName Name of the variable.
  35718. * @param x First float in float4.
  35719. * @param y Second float in float4.
  35720. * @param z Third float in float4.
  35721. * @param w Fourth float in float4.
  35722. * @returns this effect.
  35723. */
  35724. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35725. /**
  35726. * Sets a Color3 on a uniform variable.
  35727. * @param uniformName Name of the variable.
  35728. * @param color3 Value to be set.
  35729. * @returns this effect.
  35730. */
  35731. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35732. /**
  35733. * Sets a Color4 on a uniform variable.
  35734. * @param uniformName Name of the variable.
  35735. * @param color3 Value to be set.
  35736. * @param alpha Alpha value to be set.
  35737. * @returns this effect.
  35738. */
  35739. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35740. /**
  35741. * Sets a Color4 on a uniform variable
  35742. * @param uniformName defines the name of the variable
  35743. * @param color4 defines the value to be set
  35744. * @returns this effect.
  35745. */
  35746. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35747. /** Release all associated resources */
  35748. dispose(): void;
  35749. /**
  35750. * This function will add a new shader to the shader store
  35751. * @param name the name of the shader
  35752. * @param pixelShader optional pixel shader content
  35753. * @param vertexShader optional vertex shader content
  35754. */
  35755. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35756. /**
  35757. * Store of each shader (The can be looked up using effect.key)
  35758. */
  35759. static ShadersStore: {
  35760. [key: string]: string;
  35761. };
  35762. /**
  35763. * Store of each included file for a shader (The can be looked up using effect.key)
  35764. */
  35765. static IncludesShadersStore: {
  35766. [key: string]: string;
  35767. };
  35768. /**
  35769. * Resets the cache of effects.
  35770. */
  35771. static ResetCache(): void;
  35772. }
  35773. }
  35774. declare module "babylonjs/Engines/engineCapabilities" {
  35775. /**
  35776. * Interface used to describe the capabilities of the engine relatively to the current browser
  35777. */
  35778. export interface EngineCapabilities {
  35779. /** Maximum textures units per fragment shader */
  35780. maxTexturesImageUnits: number;
  35781. /** Maximum texture units per vertex shader */
  35782. maxVertexTextureImageUnits: number;
  35783. /** Maximum textures units in the entire pipeline */
  35784. maxCombinedTexturesImageUnits: number;
  35785. /** Maximum texture size */
  35786. maxTextureSize: number;
  35787. /** Maximum texture samples */
  35788. maxSamples?: number;
  35789. /** Maximum cube texture size */
  35790. maxCubemapTextureSize: number;
  35791. /** Maximum render texture size */
  35792. maxRenderTextureSize: number;
  35793. /** Maximum number of vertex attributes */
  35794. maxVertexAttribs: number;
  35795. /** Maximum number of varyings */
  35796. maxVaryingVectors: number;
  35797. /** Maximum number of uniforms per vertex shader */
  35798. maxVertexUniformVectors: number;
  35799. /** Maximum number of uniforms per fragment shader */
  35800. maxFragmentUniformVectors: number;
  35801. /** Defines if standard derivates (dx/dy) are supported */
  35802. standardDerivatives: boolean;
  35803. /** Defines if s3tc texture compression is supported */
  35804. s3tc?: WEBGL_compressed_texture_s3tc;
  35805. /** Defines if pvrtc texture compression is supported */
  35806. pvrtc: any;
  35807. /** Defines if etc1 texture compression is supported */
  35808. etc1: any;
  35809. /** Defines if etc2 texture compression is supported */
  35810. etc2: any;
  35811. /** Defines if astc texture compression is supported */
  35812. astc: any;
  35813. /** Defines if float textures are supported */
  35814. textureFloat: boolean;
  35815. /** Defines if vertex array objects are supported */
  35816. vertexArrayObject: boolean;
  35817. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35818. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35819. /** Gets the maximum level of anisotropy supported */
  35820. maxAnisotropy: number;
  35821. /** Defines if instancing is supported */
  35822. instancedArrays: boolean;
  35823. /** Defines if 32 bits indices are supported */
  35824. uintIndices: boolean;
  35825. /** Defines if high precision shaders are supported */
  35826. highPrecisionShaderSupported: boolean;
  35827. /** Defines if depth reading in the fragment shader is supported */
  35828. fragmentDepthSupported: boolean;
  35829. /** Defines if float texture linear filtering is supported*/
  35830. textureFloatLinearFiltering: boolean;
  35831. /** Defines if rendering to float textures is supported */
  35832. textureFloatRender: boolean;
  35833. /** Defines if half float textures are supported*/
  35834. textureHalfFloat: boolean;
  35835. /** Defines if half float texture linear filtering is supported*/
  35836. textureHalfFloatLinearFiltering: boolean;
  35837. /** Defines if rendering to half float textures is supported */
  35838. textureHalfFloatRender: boolean;
  35839. /** Defines if textureLOD shader command is supported */
  35840. textureLOD: boolean;
  35841. /** Defines if draw buffers extension is supported */
  35842. drawBuffersExtension: boolean;
  35843. /** Defines if depth textures are supported */
  35844. depthTextureExtension: boolean;
  35845. /** Defines if float color buffer are supported */
  35846. colorBufferFloat: boolean;
  35847. /** Gets disjoint timer query extension (null if not supported) */
  35848. timerQuery?: EXT_disjoint_timer_query;
  35849. /** Defines if timestamp can be used with timer query */
  35850. canUseTimestampForTimerQuery: boolean;
  35851. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35852. multiview?: any;
  35853. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35854. oculusMultiview?: any;
  35855. /** Function used to let the system compiles shaders in background */
  35856. parallelShaderCompile?: {
  35857. COMPLETION_STATUS_KHR: number;
  35858. };
  35859. /** Max number of texture samples for MSAA */
  35860. maxMSAASamples: number;
  35861. /** Defines if the blend min max extension is supported */
  35862. blendMinMax: boolean;
  35863. }
  35864. }
  35865. declare module "babylonjs/States/depthCullingState" {
  35866. import { Nullable } from "babylonjs/types";
  35867. /**
  35868. * @hidden
  35869. **/
  35870. export class DepthCullingState {
  35871. private _isDepthTestDirty;
  35872. private _isDepthMaskDirty;
  35873. private _isDepthFuncDirty;
  35874. private _isCullFaceDirty;
  35875. private _isCullDirty;
  35876. private _isZOffsetDirty;
  35877. private _isFrontFaceDirty;
  35878. private _depthTest;
  35879. private _depthMask;
  35880. private _depthFunc;
  35881. private _cull;
  35882. private _cullFace;
  35883. private _zOffset;
  35884. private _frontFace;
  35885. /**
  35886. * Initializes the state.
  35887. */
  35888. constructor();
  35889. get isDirty(): boolean;
  35890. get zOffset(): number;
  35891. set zOffset(value: number);
  35892. get cullFace(): Nullable<number>;
  35893. set cullFace(value: Nullable<number>);
  35894. get cull(): Nullable<boolean>;
  35895. set cull(value: Nullable<boolean>);
  35896. get depthFunc(): Nullable<number>;
  35897. set depthFunc(value: Nullable<number>);
  35898. get depthMask(): boolean;
  35899. set depthMask(value: boolean);
  35900. get depthTest(): boolean;
  35901. set depthTest(value: boolean);
  35902. get frontFace(): Nullable<number>;
  35903. set frontFace(value: Nullable<number>);
  35904. reset(): void;
  35905. apply(gl: WebGLRenderingContext): void;
  35906. }
  35907. }
  35908. declare module "babylonjs/States/stencilState" {
  35909. /**
  35910. * @hidden
  35911. **/
  35912. export class StencilState {
  35913. /** 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 */
  35914. static readonly ALWAYS: number;
  35915. /** Passed to stencilOperation to specify that stencil value must be kept */
  35916. static readonly KEEP: number;
  35917. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35918. static readonly REPLACE: number;
  35919. private _isStencilTestDirty;
  35920. private _isStencilMaskDirty;
  35921. private _isStencilFuncDirty;
  35922. private _isStencilOpDirty;
  35923. private _stencilTest;
  35924. private _stencilMask;
  35925. private _stencilFunc;
  35926. private _stencilFuncRef;
  35927. private _stencilFuncMask;
  35928. private _stencilOpStencilFail;
  35929. private _stencilOpDepthFail;
  35930. private _stencilOpStencilDepthPass;
  35931. get isDirty(): boolean;
  35932. get stencilFunc(): number;
  35933. set stencilFunc(value: number);
  35934. get stencilFuncRef(): number;
  35935. set stencilFuncRef(value: number);
  35936. get stencilFuncMask(): number;
  35937. set stencilFuncMask(value: number);
  35938. get stencilOpStencilFail(): number;
  35939. set stencilOpStencilFail(value: number);
  35940. get stencilOpDepthFail(): number;
  35941. set stencilOpDepthFail(value: number);
  35942. get stencilOpStencilDepthPass(): number;
  35943. set stencilOpStencilDepthPass(value: number);
  35944. get stencilMask(): number;
  35945. set stencilMask(value: number);
  35946. get stencilTest(): boolean;
  35947. set stencilTest(value: boolean);
  35948. constructor();
  35949. reset(): void;
  35950. apply(gl: WebGLRenderingContext): void;
  35951. }
  35952. }
  35953. declare module "babylonjs/States/alphaCullingState" {
  35954. /**
  35955. * @hidden
  35956. **/
  35957. export class AlphaState {
  35958. private _isAlphaBlendDirty;
  35959. private _isBlendFunctionParametersDirty;
  35960. private _isBlendEquationParametersDirty;
  35961. private _isBlendConstantsDirty;
  35962. private _alphaBlend;
  35963. private _blendFunctionParameters;
  35964. private _blendEquationParameters;
  35965. private _blendConstants;
  35966. /**
  35967. * Initializes the state.
  35968. */
  35969. constructor();
  35970. get isDirty(): boolean;
  35971. get alphaBlend(): boolean;
  35972. set alphaBlend(value: boolean);
  35973. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35974. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35975. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35976. reset(): void;
  35977. apply(gl: WebGLRenderingContext): void;
  35978. }
  35979. }
  35980. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35981. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35982. /** @hidden */
  35983. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35984. attributeProcessor(attribute: string): string;
  35985. varyingProcessor(varying: string, isFragment: boolean): string;
  35986. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35987. }
  35988. }
  35989. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35990. /**
  35991. * Interface for attribute information associated with buffer instanciation
  35992. */
  35993. export interface InstancingAttributeInfo {
  35994. /**
  35995. * Name of the GLSL attribute
  35996. * if attribute index is not specified, this is used to retrieve the index from the effect
  35997. */
  35998. attributeName: string;
  35999. /**
  36000. * Index/offset of the attribute in the vertex shader
  36001. * if not specified, this will be computes from the name.
  36002. */
  36003. index?: number;
  36004. /**
  36005. * size of the attribute, 1, 2, 3 or 4
  36006. */
  36007. attributeSize: number;
  36008. /**
  36009. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36010. */
  36011. offset: number;
  36012. /**
  36013. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36014. * default to 1
  36015. */
  36016. divisor?: number;
  36017. /**
  36018. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36019. * default is FLOAT
  36020. */
  36021. attributeType?: number;
  36022. /**
  36023. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36024. */
  36025. normalized?: boolean;
  36026. }
  36027. }
  36028. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36029. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36030. import { Nullable } from "babylonjs/types";
  36031. module "babylonjs/Engines/thinEngine" {
  36032. interface ThinEngine {
  36033. /**
  36034. * Update a video texture
  36035. * @param texture defines the texture to update
  36036. * @param video defines the video element to use
  36037. * @param invertY defines if data must be stored with Y axis inverted
  36038. */
  36039. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36040. }
  36041. }
  36042. }
  36043. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36044. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36045. import { Nullable } from "babylonjs/types";
  36046. module "babylonjs/Engines/thinEngine" {
  36047. interface ThinEngine {
  36048. /**
  36049. * Creates a dynamic texture
  36050. * @param width defines the width of the texture
  36051. * @param height defines the height of the texture
  36052. * @param generateMipMaps defines if the engine should generate the mip levels
  36053. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36054. * @returns the dynamic texture inside an InternalTexture
  36055. */
  36056. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36057. /**
  36058. * Update the content of a dynamic texture
  36059. * @param texture defines the texture to update
  36060. * @param canvas defines the canvas containing the source
  36061. * @param invertY defines if data must be stored with Y axis inverted
  36062. * @param premulAlpha defines if alpha is stored as premultiplied
  36063. * @param format defines the format of the data
  36064. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36065. */
  36066. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36067. }
  36068. }
  36069. }
  36070. declare module "babylonjs/Materials/Textures/videoTexture" {
  36071. import { Observable } from "babylonjs/Misc/observable";
  36072. import { Nullable } from "babylonjs/types";
  36073. import { Scene } from "babylonjs/scene";
  36074. import { Texture } from "babylonjs/Materials/Textures/texture";
  36075. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36076. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36077. /**
  36078. * Settings for finer control over video usage
  36079. */
  36080. export interface VideoTextureSettings {
  36081. /**
  36082. * Applies `autoplay` to video, if specified
  36083. */
  36084. autoPlay?: boolean;
  36085. /**
  36086. * Applies `loop` to video, if specified
  36087. */
  36088. loop?: boolean;
  36089. /**
  36090. * Automatically updates internal texture from video at every frame in the render loop
  36091. */
  36092. autoUpdateTexture: boolean;
  36093. /**
  36094. * Image src displayed during the video loading or until the user interacts with the video.
  36095. */
  36096. poster?: string;
  36097. }
  36098. /**
  36099. * If you want to display a video in your scene, this is the special texture for that.
  36100. * This special texture works similar to other textures, with the exception of a few parameters.
  36101. * @see https://doc.babylonjs.com/how_to/video_texture
  36102. */
  36103. export class VideoTexture extends Texture {
  36104. /**
  36105. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36106. */
  36107. readonly autoUpdateTexture: boolean;
  36108. /**
  36109. * The video instance used by the texture internally
  36110. */
  36111. readonly video: HTMLVideoElement;
  36112. private _onUserActionRequestedObservable;
  36113. /**
  36114. * Event triggerd when a dom action is required by the user to play the video.
  36115. * This happens due to recent changes in browser policies preventing video to auto start.
  36116. */
  36117. get onUserActionRequestedObservable(): Observable<Texture>;
  36118. private _generateMipMaps;
  36119. private _stillImageCaptured;
  36120. private _displayingPosterTexture;
  36121. private _settings;
  36122. private _createInternalTextureOnEvent;
  36123. private _frameId;
  36124. private _currentSrc;
  36125. /**
  36126. * Creates a video texture.
  36127. * If you want to display a video in your scene, this is the special texture for that.
  36128. * This special texture works similar to other textures, with the exception of a few parameters.
  36129. * @see https://doc.babylonjs.com/how_to/video_texture
  36130. * @param name optional name, will detect from video source, if not defined
  36131. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36132. * @param scene is obviously the current scene.
  36133. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36134. * @param invertY is false by default but can be used to invert video on Y axis
  36135. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36136. * @param settings allows finer control over video usage
  36137. */
  36138. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36139. private _getName;
  36140. private _getVideo;
  36141. private _createInternalTexture;
  36142. private reset;
  36143. /**
  36144. * @hidden Internal method to initiate `update`.
  36145. */
  36146. _rebuild(): void;
  36147. /**
  36148. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36149. */
  36150. update(): void;
  36151. /**
  36152. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36153. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36154. */
  36155. updateTexture(isVisible: boolean): void;
  36156. protected _updateInternalTexture: () => void;
  36157. /**
  36158. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36159. * @param url New url.
  36160. */
  36161. updateURL(url: string): void;
  36162. /**
  36163. * Clones the texture.
  36164. * @returns the cloned texture
  36165. */
  36166. clone(): VideoTexture;
  36167. /**
  36168. * Dispose the texture and release its associated resources.
  36169. */
  36170. dispose(): void;
  36171. /**
  36172. * Creates a video texture straight from a stream.
  36173. * @param scene Define the scene the texture should be created in
  36174. * @param stream Define the stream the texture should be created from
  36175. * @returns The created video texture as a promise
  36176. */
  36177. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36178. /**
  36179. * Creates a video texture straight from your WebCam video feed.
  36180. * @param scene Define the scene the texture should be created in
  36181. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36182. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36183. * @returns The created video texture as a promise
  36184. */
  36185. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36186. minWidth: number;
  36187. maxWidth: number;
  36188. minHeight: number;
  36189. maxHeight: number;
  36190. deviceId: string;
  36191. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36192. /**
  36193. * Creates a video texture straight from your WebCam video feed.
  36194. * @param scene Define the scene the texture should be created in
  36195. * @param onReady Define a callback to triggered once the texture will be ready
  36196. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36197. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36198. */
  36199. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36200. minWidth: number;
  36201. maxWidth: number;
  36202. minHeight: number;
  36203. maxHeight: number;
  36204. deviceId: string;
  36205. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36206. }
  36207. }
  36208. declare module "babylonjs/Engines/thinEngine" {
  36209. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36210. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36211. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36212. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36213. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36214. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36215. import { Observable } from "babylonjs/Misc/observable";
  36216. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36217. import { StencilState } from "babylonjs/States/stencilState";
  36218. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36219. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36220. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36221. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36222. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36223. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36224. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36225. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36226. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36228. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36229. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36230. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36231. import { WebRequest } from "babylonjs/Misc/webRequest";
  36232. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36233. /**
  36234. * Defines the interface used by objects working like Scene
  36235. * @hidden
  36236. */
  36237. export interface ISceneLike {
  36238. _addPendingData(data: any): void;
  36239. _removePendingData(data: any): void;
  36240. offlineProvider: IOfflineProvider;
  36241. }
  36242. /** Interface defining initialization parameters for Engine class */
  36243. export interface EngineOptions extends WebGLContextAttributes {
  36244. /**
  36245. * Defines if the engine should no exceed a specified device ratio
  36246. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36247. */
  36248. limitDeviceRatio?: number;
  36249. /**
  36250. * Defines if webvr should be enabled automatically
  36251. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36252. */
  36253. autoEnableWebVR?: boolean;
  36254. /**
  36255. * Defines if webgl2 should be turned off even if supported
  36256. * @see https://doc.babylonjs.com/features/webgl2
  36257. */
  36258. disableWebGL2Support?: boolean;
  36259. /**
  36260. * Defines if webaudio should be initialized as well
  36261. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36262. */
  36263. audioEngine?: boolean;
  36264. /**
  36265. * Defines if animations should run using a deterministic lock step
  36266. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36267. */
  36268. deterministicLockstep?: boolean;
  36269. /** Defines the maximum steps to use with deterministic lock step mode */
  36270. lockstepMaxSteps?: number;
  36271. /** Defines the seconds between each deterministic lock step */
  36272. timeStep?: number;
  36273. /**
  36274. * Defines that engine should ignore context lost events
  36275. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36276. */
  36277. doNotHandleContextLost?: boolean;
  36278. /**
  36279. * Defines that engine should ignore modifying touch action attribute and style
  36280. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36281. */
  36282. doNotHandleTouchAction?: boolean;
  36283. /**
  36284. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36285. */
  36286. useHighPrecisionFloats?: boolean;
  36287. /**
  36288. * Make the canvas XR Compatible for XR sessions
  36289. */
  36290. xrCompatible?: boolean;
  36291. /**
  36292. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36293. */
  36294. useHighPrecisionMatrix?: boolean;
  36295. }
  36296. /**
  36297. * The base engine class (root of all engines)
  36298. */
  36299. export class ThinEngine {
  36300. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36301. static ExceptionList: ({
  36302. key: string;
  36303. capture: string;
  36304. captureConstraint: number;
  36305. targets: string[];
  36306. } | {
  36307. key: string;
  36308. capture: null;
  36309. captureConstraint: null;
  36310. targets: string[];
  36311. })[];
  36312. /** @hidden */
  36313. static _TextureLoaders: IInternalTextureLoader[];
  36314. /**
  36315. * Returns the current npm package of the sdk
  36316. */
  36317. static get NpmPackage(): string;
  36318. /**
  36319. * Returns the current version of the framework
  36320. */
  36321. static get Version(): string;
  36322. /**
  36323. * Returns a string describing the current engine
  36324. */
  36325. get description(): string;
  36326. /**
  36327. * Gets or sets the epsilon value used by collision engine
  36328. */
  36329. static CollisionsEpsilon: number;
  36330. /**
  36331. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36332. */
  36333. static get ShadersRepository(): string;
  36334. static set ShadersRepository(value: string);
  36335. /** @hidden */
  36336. _shaderProcessor: IShaderProcessor;
  36337. /**
  36338. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36339. */
  36340. forcePOTTextures: boolean;
  36341. /**
  36342. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36343. */
  36344. isFullscreen: boolean;
  36345. /**
  36346. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36347. */
  36348. cullBackFaces: boolean;
  36349. /**
  36350. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36351. */
  36352. renderEvenInBackground: boolean;
  36353. /**
  36354. * Gets or sets a boolean indicating that cache can be kept between frames
  36355. */
  36356. preventCacheWipeBetweenFrames: boolean;
  36357. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36358. validateShaderPrograms: boolean;
  36359. /**
  36360. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36361. * This can provide greater z depth for distant objects.
  36362. */
  36363. useReverseDepthBuffer: boolean;
  36364. /**
  36365. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36366. */
  36367. disableUniformBuffers: boolean;
  36368. /** @hidden */
  36369. _uniformBuffers: UniformBuffer[];
  36370. /**
  36371. * Gets a boolean indicating that the engine supports uniform buffers
  36372. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36373. */
  36374. get supportsUniformBuffers(): boolean;
  36375. /** @hidden */
  36376. _gl: WebGLRenderingContext;
  36377. /** @hidden */
  36378. _webGLVersion: number;
  36379. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36380. protected _windowIsBackground: boolean;
  36381. protected _creationOptions: EngineOptions;
  36382. protected _highPrecisionShadersAllowed: boolean;
  36383. /** @hidden */
  36384. get _shouldUseHighPrecisionShader(): boolean;
  36385. /**
  36386. * Gets a boolean indicating that only power of 2 textures are supported
  36387. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36388. */
  36389. get needPOTTextures(): boolean;
  36390. /** @hidden */
  36391. _badOS: boolean;
  36392. /** @hidden */
  36393. _badDesktopOS: boolean;
  36394. private _hardwareScalingLevel;
  36395. /** @hidden */
  36396. _caps: EngineCapabilities;
  36397. private _isStencilEnable;
  36398. private _glVersion;
  36399. private _glRenderer;
  36400. private _glVendor;
  36401. /** @hidden */
  36402. _videoTextureSupported: boolean;
  36403. protected _renderingQueueLaunched: boolean;
  36404. protected _activeRenderLoops: (() => void)[];
  36405. /**
  36406. * Observable signaled when a context lost event is raised
  36407. */
  36408. onContextLostObservable: Observable<ThinEngine>;
  36409. /**
  36410. * Observable signaled when a context restored event is raised
  36411. */
  36412. onContextRestoredObservable: Observable<ThinEngine>;
  36413. private _onContextLost;
  36414. private _onContextRestored;
  36415. protected _contextWasLost: boolean;
  36416. /** @hidden */
  36417. _doNotHandleContextLost: boolean;
  36418. /**
  36419. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36420. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36421. */
  36422. get doNotHandleContextLost(): boolean;
  36423. set doNotHandleContextLost(value: boolean);
  36424. /**
  36425. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36426. */
  36427. disableVertexArrayObjects: boolean;
  36428. /** @hidden */
  36429. protected _colorWrite: boolean;
  36430. /** @hidden */
  36431. protected _colorWriteChanged: boolean;
  36432. /** @hidden */
  36433. protected _depthCullingState: DepthCullingState;
  36434. /** @hidden */
  36435. protected _stencilState: StencilState;
  36436. /** @hidden */
  36437. _alphaState: AlphaState;
  36438. /** @hidden */
  36439. _alphaMode: number;
  36440. /** @hidden */
  36441. _alphaEquation: number;
  36442. /** @hidden */
  36443. _internalTexturesCache: InternalTexture[];
  36444. /** @hidden */
  36445. protected _activeChannel: number;
  36446. private _currentTextureChannel;
  36447. /** @hidden */
  36448. protected _boundTexturesCache: {
  36449. [key: string]: Nullable<InternalTexture>;
  36450. };
  36451. /** @hidden */
  36452. protected _currentEffect: Nullable<Effect>;
  36453. /** @hidden */
  36454. protected _currentProgram: Nullable<WebGLProgram>;
  36455. private _compiledEffects;
  36456. private _vertexAttribArraysEnabled;
  36457. /** @hidden */
  36458. protected _cachedViewport: Nullable<IViewportLike>;
  36459. private _cachedVertexArrayObject;
  36460. /** @hidden */
  36461. protected _cachedVertexBuffers: any;
  36462. /** @hidden */
  36463. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36464. /** @hidden */
  36465. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36466. /** @hidden */
  36467. _currentRenderTarget: Nullable<InternalTexture>;
  36468. private _uintIndicesCurrentlySet;
  36469. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36470. /** @hidden */
  36471. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36472. /** @hidden */
  36473. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36474. private _currentBufferPointers;
  36475. private _currentInstanceLocations;
  36476. private _currentInstanceBuffers;
  36477. private _textureUnits;
  36478. /** @hidden */
  36479. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36480. /** @hidden */
  36481. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36482. /** @hidden */
  36483. _boundRenderFunction: any;
  36484. private _vaoRecordInProgress;
  36485. private _mustWipeVertexAttributes;
  36486. private _emptyTexture;
  36487. private _emptyCubeTexture;
  36488. private _emptyTexture3D;
  36489. private _emptyTexture2DArray;
  36490. /** @hidden */
  36491. _frameHandler: number;
  36492. private _nextFreeTextureSlots;
  36493. private _maxSimultaneousTextures;
  36494. private _activeRequests;
  36495. /** @hidden */
  36496. _transformTextureUrl: Nullable<(url: string) => string>;
  36497. protected get _supportsHardwareTextureRescaling(): boolean;
  36498. private _framebufferDimensionsObject;
  36499. /**
  36500. * sets the object from which width and height will be taken from when getting render width and height
  36501. * Will fallback to the gl object
  36502. * @param dimensions the framebuffer width and height that will be used.
  36503. */
  36504. set framebufferDimensionsObject(dimensions: Nullable<{
  36505. framebufferWidth: number;
  36506. framebufferHeight: number;
  36507. }>);
  36508. /**
  36509. * Gets the current viewport
  36510. */
  36511. get currentViewport(): Nullable<IViewportLike>;
  36512. /**
  36513. * Gets the default empty texture
  36514. */
  36515. get emptyTexture(): InternalTexture;
  36516. /**
  36517. * Gets the default empty 3D texture
  36518. */
  36519. get emptyTexture3D(): InternalTexture;
  36520. /**
  36521. * Gets the default empty 2D array texture
  36522. */
  36523. get emptyTexture2DArray(): InternalTexture;
  36524. /**
  36525. * Gets the default empty cube texture
  36526. */
  36527. get emptyCubeTexture(): InternalTexture;
  36528. /**
  36529. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36530. */
  36531. readonly premultipliedAlpha: boolean;
  36532. /**
  36533. * Observable event triggered before each texture is initialized
  36534. */
  36535. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36536. /**
  36537. * Creates a new engine
  36538. * @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
  36539. * @param antialias defines enable antialiasing (default: false)
  36540. * @param options defines further options to be sent to the getContext() function
  36541. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36542. */
  36543. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36544. private _rebuildInternalTextures;
  36545. private _rebuildEffects;
  36546. /**
  36547. * Gets a boolean indicating if all created effects are ready
  36548. * @returns true if all effects are ready
  36549. */
  36550. areAllEffectsReady(): boolean;
  36551. protected _rebuildBuffers(): void;
  36552. protected _initGLContext(): void;
  36553. /**
  36554. * Gets version of the current webGL context
  36555. */
  36556. get webGLVersion(): number;
  36557. /**
  36558. * Gets a string idenfifying the name of the class
  36559. * @returns "Engine" string
  36560. */
  36561. getClassName(): string;
  36562. /**
  36563. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36564. */
  36565. get isStencilEnable(): boolean;
  36566. /** @hidden */
  36567. _prepareWorkingCanvas(): void;
  36568. /**
  36569. * Reset the texture cache to empty state
  36570. */
  36571. resetTextureCache(): void;
  36572. /**
  36573. * Gets an object containing information about the current webGL context
  36574. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36575. */
  36576. getGlInfo(): {
  36577. vendor: string;
  36578. renderer: string;
  36579. version: string;
  36580. };
  36581. /**
  36582. * Defines the hardware scaling level.
  36583. * By default the hardware scaling level is computed from the window device ratio.
  36584. * 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.
  36585. * @param level defines the level to use
  36586. */
  36587. setHardwareScalingLevel(level: number): void;
  36588. /**
  36589. * Gets the current hardware scaling level.
  36590. * By default the hardware scaling level is computed from the window device ratio.
  36591. * 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.
  36592. * @returns a number indicating the current hardware scaling level
  36593. */
  36594. getHardwareScalingLevel(): number;
  36595. /**
  36596. * Gets the list of loaded textures
  36597. * @returns an array containing all loaded textures
  36598. */
  36599. getLoadedTexturesCache(): InternalTexture[];
  36600. /**
  36601. * Gets the object containing all engine capabilities
  36602. * @returns the EngineCapabilities object
  36603. */
  36604. getCaps(): EngineCapabilities;
  36605. /**
  36606. * stop executing a render loop function and remove it from the execution array
  36607. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36608. */
  36609. stopRenderLoop(renderFunction?: () => void): void;
  36610. /** @hidden */
  36611. _renderLoop(): void;
  36612. /**
  36613. * Gets the HTML canvas attached with the current webGL context
  36614. * @returns a HTML canvas
  36615. */
  36616. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36617. /**
  36618. * Gets host window
  36619. * @returns the host window object
  36620. */
  36621. getHostWindow(): Nullable<Window>;
  36622. /**
  36623. * Gets the current render width
  36624. * @param useScreen defines if screen size must be used (or the current render target if any)
  36625. * @returns a number defining the current render width
  36626. */
  36627. getRenderWidth(useScreen?: boolean): number;
  36628. /**
  36629. * Gets the current render height
  36630. * @param useScreen defines if screen size must be used (or the current render target if any)
  36631. * @returns a number defining the current render height
  36632. */
  36633. getRenderHeight(useScreen?: boolean): number;
  36634. /**
  36635. * Can be used to override the current requestAnimationFrame requester.
  36636. * @hidden
  36637. */
  36638. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36639. /**
  36640. * Register and execute a render loop. The engine can have more than one render function
  36641. * @param renderFunction defines the function to continuously execute
  36642. */
  36643. runRenderLoop(renderFunction: () => void): void;
  36644. /**
  36645. * Clear the current render buffer or the current render target (if any is set up)
  36646. * @param color defines the color to use
  36647. * @param backBuffer defines if the back buffer must be cleared
  36648. * @param depth defines if the depth buffer must be cleared
  36649. * @param stencil defines if the stencil buffer must be cleared
  36650. */
  36651. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36652. private _viewportCached;
  36653. /** @hidden */
  36654. _viewport(x: number, y: number, width: number, height: number): void;
  36655. /**
  36656. * Set the WebGL's viewport
  36657. * @param viewport defines the viewport element to be used
  36658. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36659. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36660. */
  36661. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36662. /**
  36663. * Begin a new frame
  36664. */
  36665. beginFrame(): void;
  36666. /**
  36667. * Enf the current frame
  36668. */
  36669. endFrame(): void;
  36670. /**
  36671. * Resize the view according to the canvas' size
  36672. */
  36673. resize(): void;
  36674. /**
  36675. * Force a specific size of the canvas
  36676. * @param width defines the new canvas' width
  36677. * @param height defines the new canvas' height
  36678. * @returns true if the size was changed
  36679. */
  36680. setSize(width: number, height: number): boolean;
  36681. /**
  36682. * Binds the frame buffer to the specified texture.
  36683. * @param texture The texture to render to or null for the default canvas
  36684. * @param faceIndex The face of the texture to render to in case of cube texture
  36685. * @param requiredWidth The width of the target to render to
  36686. * @param requiredHeight The height of the target to render to
  36687. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36688. * @param lodLevel defines the lod level to bind to the frame buffer
  36689. * @param layer defines the 2d array index to bind to frame buffer to
  36690. */
  36691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36692. /** @hidden */
  36693. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36694. /**
  36695. * Unbind the current render target texture from the webGL context
  36696. * @param texture defines the render target texture to unbind
  36697. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36698. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36699. */
  36700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36701. /**
  36702. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36703. */
  36704. flushFramebuffer(): void;
  36705. /**
  36706. * Unbind the current render target and bind the default framebuffer
  36707. */
  36708. restoreDefaultFramebuffer(): void;
  36709. /** @hidden */
  36710. protected _resetVertexBufferBinding(): void;
  36711. /**
  36712. * Creates a vertex buffer
  36713. * @param data the data for the vertex buffer
  36714. * @returns the new WebGL static buffer
  36715. */
  36716. createVertexBuffer(data: DataArray): DataBuffer;
  36717. private _createVertexBuffer;
  36718. /**
  36719. * Creates a dynamic vertex buffer
  36720. * @param data the data for the dynamic vertex buffer
  36721. * @returns the new WebGL dynamic buffer
  36722. */
  36723. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36724. protected _resetIndexBufferBinding(): void;
  36725. /**
  36726. * Creates a new index buffer
  36727. * @param indices defines the content of the index buffer
  36728. * @param updatable defines if the index buffer must be updatable
  36729. * @returns a new webGL buffer
  36730. */
  36731. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36732. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36733. /**
  36734. * Bind a webGL buffer to the webGL context
  36735. * @param buffer defines the buffer to bind
  36736. */
  36737. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36738. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36739. private bindBuffer;
  36740. /**
  36741. * update the bound buffer with the given data
  36742. * @param data defines the data to update
  36743. */
  36744. updateArrayBuffer(data: Float32Array): void;
  36745. private _vertexAttribPointer;
  36746. /** @hidden */
  36747. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36748. private _bindVertexBuffersAttributes;
  36749. /**
  36750. * Records a vertex array object
  36751. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36752. * @param vertexBuffers defines the list of vertex buffers to store
  36753. * @param indexBuffer defines the index buffer to store
  36754. * @param effect defines the effect to store
  36755. * @returns the new vertex array object
  36756. */
  36757. recordVertexArrayObject(vertexBuffers: {
  36758. [key: string]: VertexBuffer;
  36759. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36760. /**
  36761. * Bind a specific vertex array object
  36762. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36763. * @param vertexArrayObject defines the vertex array object to bind
  36764. * @param indexBuffer defines the index buffer to bind
  36765. */
  36766. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36767. /**
  36768. * Bind webGl buffers directly to the webGL context
  36769. * @param vertexBuffer defines the vertex buffer to bind
  36770. * @param indexBuffer defines the index buffer to bind
  36771. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36772. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36773. * @param effect defines the effect associated with the vertex buffer
  36774. */
  36775. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36776. private _unbindVertexArrayObject;
  36777. /**
  36778. * Bind a list of vertex buffers to the webGL context
  36779. * @param vertexBuffers defines the list of vertex buffers to bind
  36780. * @param indexBuffer defines the index buffer to bind
  36781. * @param effect defines the effect associated with the vertex buffers
  36782. */
  36783. bindBuffers(vertexBuffers: {
  36784. [key: string]: Nullable<VertexBuffer>;
  36785. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36786. /**
  36787. * Unbind all instance attributes
  36788. */
  36789. unbindInstanceAttributes(): void;
  36790. /**
  36791. * Release and free the memory of a vertex array object
  36792. * @param vao defines the vertex array object to delete
  36793. */
  36794. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36795. /** @hidden */
  36796. _releaseBuffer(buffer: DataBuffer): boolean;
  36797. protected _deleteBuffer(buffer: DataBuffer): void;
  36798. /**
  36799. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36800. * @param instancesBuffer defines the webGL buffer to update and bind
  36801. * @param data defines the data to store in the buffer
  36802. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36803. */
  36804. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36805. /**
  36806. * Bind the content of a webGL buffer used with instantiation
  36807. * @param instancesBuffer defines the webGL buffer to bind
  36808. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36809. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36810. */
  36811. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36812. /**
  36813. * Disable the instance attribute corresponding to the name in parameter
  36814. * @param name defines the name of the attribute to disable
  36815. */
  36816. disableInstanceAttributeByName(name: string): void;
  36817. /**
  36818. * Disable the instance attribute corresponding to the location in parameter
  36819. * @param attributeLocation defines the attribute location of the attribute to disable
  36820. */
  36821. disableInstanceAttribute(attributeLocation: number): void;
  36822. /**
  36823. * Disable the attribute corresponding to the location in parameter
  36824. * @param attributeLocation defines the attribute location of the attribute to disable
  36825. */
  36826. disableAttributeByIndex(attributeLocation: number): void;
  36827. /**
  36828. * Send a draw order
  36829. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36830. * @param indexStart defines the starting index
  36831. * @param indexCount defines the number of index to draw
  36832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36833. */
  36834. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36835. /**
  36836. * Draw a list of points
  36837. * @param verticesStart defines the index of first vertex to draw
  36838. * @param verticesCount defines the count of vertices to draw
  36839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36840. */
  36841. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36842. /**
  36843. * Draw a list of unindexed primitives
  36844. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36845. * @param verticesStart defines the index of first vertex to draw
  36846. * @param verticesCount defines the count of vertices to draw
  36847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36848. */
  36849. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36850. /**
  36851. * Draw a list of indexed primitives
  36852. * @param fillMode defines the primitive to use
  36853. * @param indexStart defines the starting index
  36854. * @param indexCount defines the number of index to draw
  36855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36856. */
  36857. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36858. /**
  36859. * Draw a list of unindexed primitives
  36860. * @param fillMode defines the primitive to use
  36861. * @param verticesStart defines the index of first vertex to draw
  36862. * @param verticesCount defines the count of vertices to draw
  36863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36864. */
  36865. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36866. private _drawMode;
  36867. /** @hidden */
  36868. protected _reportDrawCall(): void;
  36869. /** @hidden */
  36870. _releaseEffect(effect: Effect): void;
  36871. /** @hidden */
  36872. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36873. /**
  36874. * Create a new effect (used to store vertex/fragment shaders)
  36875. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36876. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36877. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36878. * @param samplers defines an array of string used to represent textures
  36879. * @param defines defines the string containing the defines to use to compile the shaders
  36880. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36881. * @param onCompiled defines a function to call when the effect creation is successful
  36882. * @param onError defines a function to call when the effect creation has failed
  36883. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36884. * @returns the new Effect
  36885. */
  36886. 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;
  36887. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36888. private _compileShader;
  36889. private _compileRawShader;
  36890. /** @hidden */
  36891. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36892. /**
  36893. * Directly creates a webGL program
  36894. * @param pipelineContext defines the pipeline context to attach to
  36895. * @param vertexCode defines the vertex shader code to use
  36896. * @param fragmentCode defines the fragment shader code to use
  36897. * @param context defines the webGL context to use (if not set, the current one will be used)
  36898. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36899. * @returns the new webGL program
  36900. */
  36901. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36902. /**
  36903. * Creates a webGL program
  36904. * @param pipelineContext defines the pipeline context to attach to
  36905. * @param vertexCode defines the vertex shader code to use
  36906. * @param fragmentCode defines the fragment shader code to use
  36907. * @param defines defines the string containing the defines to use to compile the shaders
  36908. * @param context defines the webGL context to use (if not set, the current one will be used)
  36909. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36910. * @returns the new webGL program
  36911. */
  36912. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36913. /**
  36914. * Creates a new pipeline context
  36915. * @returns the new pipeline
  36916. */
  36917. createPipelineContext(): IPipelineContext;
  36918. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36919. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36920. /** @hidden */
  36921. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36922. /** @hidden */
  36923. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36924. /** @hidden */
  36925. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36926. /**
  36927. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36928. * @param pipelineContext defines the pipeline context to use
  36929. * @param uniformsNames defines the list of uniform names
  36930. * @returns an array of webGL uniform locations
  36931. */
  36932. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36933. /**
  36934. * Gets the lsit of active attributes for a given webGL program
  36935. * @param pipelineContext defines the pipeline context to use
  36936. * @param attributesNames defines the list of attribute names to get
  36937. * @returns an array of indices indicating the offset of each attribute
  36938. */
  36939. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36940. /**
  36941. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36942. * @param effect defines the effect to activate
  36943. */
  36944. enableEffect(effect: Nullable<Effect>): void;
  36945. /**
  36946. * Set the value of an uniform to a number (int)
  36947. * @param uniform defines the webGL uniform location where to store the value
  36948. * @param value defines the int number to store
  36949. */
  36950. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36951. /**
  36952. * Set the value of an uniform to an array of int32
  36953. * @param uniform defines the webGL uniform location where to store the value
  36954. * @param array defines the array of int32 to store
  36955. */
  36956. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36957. /**
  36958. * Set the value of an uniform to an array of int32 (stored as vec2)
  36959. * @param uniform defines the webGL uniform location where to store the value
  36960. * @param array defines the array of int32 to store
  36961. */
  36962. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36963. /**
  36964. * Set the value of an uniform to an array of int32 (stored as vec3)
  36965. * @param uniform defines the webGL uniform location where to store the value
  36966. * @param array defines the array of int32 to store
  36967. */
  36968. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36969. /**
  36970. * Set the value of an uniform to an array of int32 (stored as vec4)
  36971. * @param uniform defines the webGL uniform location where to store the value
  36972. * @param array defines the array of int32 to store
  36973. */
  36974. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36975. /**
  36976. * Set the value of an uniform to an array of number
  36977. * @param uniform defines the webGL uniform location where to store the value
  36978. * @param array defines the array of number to store
  36979. */
  36980. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36981. /**
  36982. * Set the value of an uniform to an array of number (stored as vec2)
  36983. * @param uniform defines the webGL uniform location where to store the value
  36984. * @param array defines the array of number to store
  36985. */
  36986. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36987. /**
  36988. * Set the value of an uniform to an array of number (stored as vec3)
  36989. * @param uniform defines the webGL uniform location where to store the value
  36990. * @param array defines the array of number to store
  36991. */
  36992. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36993. /**
  36994. * Set the value of an uniform to an array of number (stored as vec4)
  36995. * @param uniform defines the webGL uniform location where to store the value
  36996. * @param array defines the array of number to store
  36997. */
  36998. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36999. /**
  37000. * Set the value of an uniform to an array of float32 (stored as matrices)
  37001. * @param uniform defines the webGL uniform location where to store the value
  37002. * @param matrices defines the array of float32 to store
  37003. */
  37004. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37005. /**
  37006. * Set the value of an uniform to a matrix (3x3)
  37007. * @param uniform defines the webGL uniform location where to store the value
  37008. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37009. */
  37010. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37011. /**
  37012. * Set the value of an uniform to a matrix (2x2)
  37013. * @param uniform defines the webGL uniform location where to store the value
  37014. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37015. */
  37016. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37017. /**
  37018. * Set the value of an uniform to a number (float)
  37019. * @param uniform defines the webGL uniform location where to store the value
  37020. * @param value defines the float number to store
  37021. */
  37022. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37023. /**
  37024. * Set the value of an uniform to a vec2
  37025. * @param uniform defines the webGL uniform location where to store the value
  37026. * @param x defines the 1st component of the value
  37027. * @param y defines the 2nd component of the value
  37028. */
  37029. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37030. /**
  37031. * Set the value of an uniform to a vec3
  37032. * @param uniform defines the webGL uniform location where to store the value
  37033. * @param x defines the 1st component of the value
  37034. * @param y defines the 2nd component of the value
  37035. * @param z defines the 3rd component of the value
  37036. */
  37037. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37038. /**
  37039. * Set the value of an uniform to a vec4
  37040. * @param uniform defines the webGL uniform location where to store the value
  37041. * @param x defines the 1st component of the value
  37042. * @param y defines the 2nd component of the value
  37043. * @param z defines the 3rd component of the value
  37044. * @param w defines the 4th component of the value
  37045. */
  37046. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37047. /**
  37048. * Apply all cached states (depth, culling, stencil and alpha)
  37049. */
  37050. applyStates(): void;
  37051. /**
  37052. * Enable or disable color writing
  37053. * @param enable defines the state to set
  37054. */
  37055. setColorWrite(enable: boolean): void;
  37056. /**
  37057. * Gets a boolean indicating if color writing is enabled
  37058. * @returns the current color writing state
  37059. */
  37060. getColorWrite(): boolean;
  37061. /**
  37062. * Gets the depth culling state manager
  37063. */
  37064. get depthCullingState(): DepthCullingState;
  37065. /**
  37066. * Gets the alpha state manager
  37067. */
  37068. get alphaState(): AlphaState;
  37069. /**
  37070. * Gets the stencil state manager
  37071. */
  37072. get stencilState(): StencilState;
  37073. /**
  37074. * Clears the list of texture accessible through engine.
  37075. * This can help preventing texture load conflict due to name collision.
  37076. */
  37077. clearInternalTexturesCache(): void;
  37078. /**
  37079. * Force the entire cache to be cleared
  37080. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37081. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37082. */
  37083. wipeCaches(bruteForce?: boolean): void;
  37084. /** @hidden */
  37085. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37086. min: number;
  37087. mag: number;
  37088. };
  37089. /** @hidden */
  37090. _createTexture(): WebGLTexture;
  37091. /**
  37092. * Usually called from Texture.ts.
  37093. * Passed information to create a WebGLTexture
  37094. * @param url defines a value which contains one of the following:
  37095. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37096. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37097. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37099. * @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)
  37100. * @param scene needed for loading to the correct scene
  37101. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37102. * @param onLoad optional callback to be called upon successful completion
  37103. * @param onError optional callback to be called upon failure
  37104. * @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
  37105. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37106. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37107. * @param forcedExtension defines the extension to use to pick the right loader
  37108. * @param mimeType defines an optional mime type
  37109. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37110. */
  37111. 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;
  37112. /**
  37113. * Loads an image as an HTMLImageElement.
  37114. * @param input url string, ArrayBuffer, or Blob to load
  37115. * @param onLoad callback called when the image successfully loads
  37116. * @param onError callback called when the image fails to load
  37117. * @param offlineProvider offline provider for caching
  37118. * @param mimeType optional mime type
  37119. * @returns the HTMLImageElement of the loaded image
  37120. * @hidden
  37121. */
  37122. 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>;
  37123. /**
  37124. * @hidden
  37125. */
  37126. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37127. private _unpackFlipYCached;
  37128. /**
  37129. * In case you are sharing the context with other applications, it might
  37130. * be interested to not cache the unpack flip y state to ensure a consistent
  37131. * value would be set.
  37132. */
  37133. enableUnpackFlipYCached: boolean;
  37134. /** @hidden */
  37135. _unpackFlipY(value: boolean): void;
  37136. /** @hidden */
  37137. _getUnpackAlignement(): number;
  37138. private _getTextureTarget;
  37139. /**
  37140. * Update the sampling mode of a given texture
  37141. * @param samplingMode defines the required sampling mode
  37142. * @param texture defines the texture to update
  37143. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37144. */
  37145. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37146. /**
  37147. * Update the sampling mode of a given texture
  37148. * @param texture defines the texture to update
  37149. * @param wrapU defines the texture wrap mode of the u coordinates
  37150. * @param wrapV defines the texture wrap mode of the v coordinates
  37151. * @param wrapR defines the texture wrap mode of the r coordinates
  37152. */
  37153. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37154. /** @hidden */
  37155. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37156. width: number;
  37157. height: number;
  37158. layers?: number;
  37159. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37160. /** @hidden */
  37161. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37162. /** @hidden */
  37163. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37164. /**
  37165. * Update a portion of an internal texture
  37166. * @param texture defines the texture to update
  37167. * @param imageData defines the data to store into the texture
  37168. * @param xOffset defines the x coordinates of the update rectangle
  37169. * @param yOffset defines the y coordinates of the update rectangle
  37170. * @param width defines the width of the update rectangle
  37171. * @param height defines the height of the update rectangle
  37172. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37173. * @param lod defines the lod level to update (0 by default)
  37174. */
  37175. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37176. /** @hidden */
  37177. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37178. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37179. private _prepareWebGLTexture;
  37180. /** @hidden */
  37181. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37182. private _getDepthStencilBuffer;
  37183. /** @hidden */
  37184. _releaseFramebufferObjects(texture: InternalTexture): void;
  37185. /** @hidden */
  37186. _releaseTexture(texture: InternalTexture): void;
  37187. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37188. protected _setProgram(program: WebGLProgram): void;
  37189. protected _boundUniforms: {
  37190. [key: number]: WebGLUniformLocation;
  37191. };
  37192. /**
  37193. * Binds an effect to the webGL context
  37194. * @param effect defines the effect to bind
  37195. */
  37196. bindSamplers(effect: Effect): void;
  37197. private _activateCurrentTexture;
  37198. /** @hidden */
  37199. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37200. /** @hidden */
  37201. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37202. /**
  37203. * Unbind all textures from the webGL context
  37204. */
  37205. unbindAllTextures(): void;
  37206. /**
  37207. * Sets a texture to the according uniform.
  37208. * @param channel The texture channel
  37209. * @param uniform The uniform to set
  37210. * @param texture The texture to apply
  37211. */
  37212. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37213. private _bindSamplerUniformToChannel;
  37214. private _getTextureWrapMode;
  37215. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37216. /**
  37217. * Sets an array of texture to the webGL context
  37218. * @param channel defines the channel where the texture array must be set
  37219. * @param uniform defines the associated uniform location
  37220. * @param textures defines the array of textures to bind
  37221. */
  37222. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37223. /** @hidden */
  37224. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37225. private _setTextureParameterFloat;
  37226. private _setTextureParameterInteger;
  37227. /**
  37228. * Unbind all vertex attributes from the webGL context
  37229. */
  37230. unbindAllAttributes(): void;
  37231. /**
  37232. * 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
  37233. */
  37234. releaseEffects(): void;
  37235. /**
  37236. * Dispose and release all associated resources
  37237. */
  37238. dispose(): void;
  37239. /**
  37240. * Attach a new callback raised when context lost event is fired
  37241. * @param callback defines the callback to call
  37242. */
  37243. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37244. /**
  37245. * Attach a new callback raised when context restored event is fired
  37246. * @param callback defines the callback to call
  37247. */
  37248. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37249. /**
  37250. * Get the current error code of the webGL context
  37251. * @returns the error code
  37252. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37253. */
  37254. getError(): number;
  37255. private _canRenderToFloatFramebuffer;
  37256. private _canRenderToHalfFloatFramebuffer;
  37257. private _canRenderToFramebuffer;
  37258. /** @hidden */
  37259. _getWebGLTextureType(type: number): number;
  37260. /** @hidden */
  37261. _getInternalFormat(format: number): number;
  37262. /** @hidden */
  37263. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37264. /** @hidden */
  37265. _getRGBAMultiSampleBufferFormat(type: number): number;
  37266. /** @hidden */
  37267. _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;
  37268. /**
  37269. * Loads a file from a url
  37270. * @param url url to load
  37271. * @param onSuccess callback called when the file successfully loads
  37272. * @param onProgress callback called while file is loading (if the server supports this mode)
  37273. * @param offlineProvider defines the offline provider for caching
  37274. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37275. * @param onError callback called when the file fails to load
  37276. * @returns a file request object
  37277. * @hidden
  37278. */
  37279. 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;
  37280. /**
  37281. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37282. * @param x defines the x coordinate of the rectangle where pixels must be read
  37283. * @param y defines the y coordinate of the rectangle where pixels must be read
  37284. * @param width defines the width of the rectangle where pixels must be read
  37285. * @param height defines the height of the rectangle where pixels must be read
  37286. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37287. * @returns a Uint8Array containing RGBA colors
  37288. */
  37289. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37290. private static _isSupported;
  37291. /**
  37292. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37293. * @returns true if the engine can be created
  37294. * @ignorenaming
  37295. */
  37296. static isSupported(): boolean;
  37297. /**
  37298. * Find the next highest power of two.
  37299. * @param x Number to start search from.
  37300. * @return Next highest power of two.
  37301. */
  37302. static CeilingPOT(x: number): number;
  37303. /**
  37304. * Find the next lowest power of two.
  37305. * @param x Number to start search from.
  37306. * @return Next lowest power of two.
  37307. */
  37308. static FloorPOT(x: number): number;
  37309. /**
  37310. * Find the nearest power of two.
  37311. * @param x Number to start search from.
  37312. * @return Next nearest power of two.
  37313. */
  37314. static NearestPOT(x: number): number;
  37315. /**
  37316. * Get the closest exponent of two
  37317. * @param value defines the value to approximate
  37318. * @param max defines the maximum value to return
  37319. * @param mode defines how to define the closest value
  37320. * @returns closest exponent of two of the given value
  37321. */
  37322. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37323. /**
  37324. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37325. * @param func - the function to be called
  37326. * @param requester - the object that will request the next frame. Falls back to window.
  37327. * @returns frame number
  37328. */
  37329. static QueueNewFrame(func: () => void, requester?: any): number;
  37330. /**
  37331. * Gets host document
  37332. * @returns the host document object
  37333. */
  37334. getHostDocument(): Nullable<Document>;
  37335. }
  37336. }
  37337. declare module "babylonjs/Maths/sphericalPolynomial" {
  37338. import { Vector3 } from "babylonjs/Maths/math.vector";
  37339. import { Color3 } from "babylonjs/Maths/math.color";
  37340. /**
  37341. * Class representing spherical harmonics coefficients to the 3rd degree
  37342. */
  37343. export class SphericalHarmonics {
  37344. /**
  37345. * Defines whether or not the harmonics have been prescaled for rendering.
  37346. */
  37347. preScaled: boolean;
  37348. /**
  37349. * The l0,0 coefficients of the spherical harmonics
  37350. */
  37351. l00: Vector3;
  37352. /**
  37353. * The l1,-1 coefficients of the spherical harmonics
  37354. */
  37355. l1_1: Vector3;
  37356. /**
  37357. * The l1,0 coefficients of the spherical harmonics
  37358. */
  37359. l10: Vector3;
  37360. /**
  37361. * The l1,1 coefficients of the spherical harmonics
  37362. */
  37363. l11: Vector3;
  37364. /**
  37365. * The l2,-2 coefficients of the spherical harmonics
  37366. */
  37367. l2_2: Vector3;
  37368. /**
  37369. * The l2,-1 coefficients of the spherical harmonics
  37370. */
  37371. l2_1: Vector3;
  37372. /**
  37373. * The l2,0 coefficients of the spherical harmonics
  37374. */
  37375. l20: Vector3;
  37376. /**
  37377. * The l2,1 coefficients of the spherical harmonics
  37378. */
  37379. l21: Vector3;
  37380. /**
  37381. * The l2,2 coefficients of the spherical harmonics
  37382. */
  37383. l22: Vector3;
  37384. /**
  37385. * Adds a light to the spherical harmonics
  37386. * @param direction the direction of the light
  37387. * @param color the color of the light
  37388. * @param deltaSolidAngle the delta solid angle of the light
  37389. */
  37390. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37391. /**
  37392. * Scales the spherical harmonics by the given amount
  37393. * @param scale the amount to scale
  37394. */
  37395. scaleInPlace(scale: number): void;
  37396. /**
  37397. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37398. *
  37399. * ```
  37400. * E_lm = A_l * L_lm
  37401. * ```
  37402. *
  37403. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37404. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37405. * the scaling factors are given in equation 9.
  37406. */
  37407. convertIncidentRadianceToIrradiance(): void;
  37408. /**
  37409. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37410. *
  37411. * ```
  37412. * L = (1/pi) * E * rho
  37413. * ```
  37414. *
  37415. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37416. */
  37417. convertIrradianceToLambertianRadiance(): void;
  37418. /**
  37419. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37420. * required operations at run time.
  37421. *
  37422. * This is simply done by scaling back the SH with Ylm constants parameter.
  37423. * The trigonometric part being applied by the shader at run time.
  37424. */
  37425. preScaleForRendering(): void;
  37426. /**
  37427. * Constructs a spherical harmonics from an array.
  37428. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37429. * @returns the spherical harmonics
  37430. */
  37431. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37432. /**
  37433. * Gets the spherical harmonics from polynomial
  37434. * @param polynomial the spherical polynomial
  37435. * @returns the spherical harmonics
  37436. */
  37437. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37438. }
  37439. /**
  37440. * Class representing spherical polynomial coefficients to the 3rd degree
  37441. */
  37442. export class SphericalPolynomial {
  37443. private _harmonics;
  37444. /**
  37445. * The spherical harmonics used to create the polynomials.
  37446. */
  37447. get preScaledHarmonics(): SphericalHarmonics;
  37448. /**
  37449. * The x coefficients of the spherical polynomial
  37450. */
  37451. x: Vector3;
  37452. /**
  37453. * The y coefficients of the spherical polynomial
  37454. */
  37455. y: Vector3;
  37456. /**
  37457. * The z coefficients of the spherical polynomial
  37458. */
  37459. z: Vector3;
  37460. /**
  37461. * The xx coefficients of the spherical polynomial
  37462. */
  37463. xx: Vector3;
  37464. /**
  37465. * The yy coefficients of the spherical polynomial
  37466. */
  37467. yy: Vector3;
  37468. /**
  37469. * The zz coefficients of the spherical polynomial
  37470. */
  37471. zz: Vector3;
  37472. /**
  37473. * The xy coefficients of the spherical polynomial
  37474. */
  37475. xy: Vector3;
  37476. /**
  37477. * The yz coefficients of the spherical polynomial
  37478. */
  37479. yz: Vector3;
  37480. /**
  37481. * The zx coefficients of the spherical polynomial
  37482. */
  37483. zx: Vector3;
  37484. /**
  37485. * Adds an ambient color to the spherical polynomial
  37486. * @param color the color to add
  37487. */
  37488. addAmbient(color: Color3): void;
  37489. /**
  37490. * Scales the spherical polynomial by the given amount
  37491. * @param scale the amount to scale
  37492. */
  37493. scaleInPlace(scale: number): void;
  37494. /**
  37495. * Gets the spherical polynomial from harmonics
  37496. * @param harmonics the spherical harmonics
  37497. * @returns the spherical polynomial
  37498. */
  37499. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37500. /**
  37501. * Constructs a spherical polynomial from an array.
  37502. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37503. * @returns the spherical polynomial
  37504. */
  37505. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37506. }
  37507. }
  37508. declare module "babylonjs/Materials/Textures/internalTexture" {
  37509. import { Observable } from "babylonjs/Misc/observable";
  37510. import { Nullable, int } from "babylonjs/types";
  37511. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37513. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37514. /**
  37515. * Defines the source of the internal texture
  37516. */
  37517. export enum InternalTextureSource {
  37518. /**
  37519. * The source of the texture data is unknown
  37520. */
  37521. Unknown = 0,
  37522. /**
  37523. * Texture data comes from an URL
  37524. */
  37525. Url = 1,
  37526. /**
  37527. * Texture data is only used for temporary storage
  37528. */
  37529. Temp = 2,
  37530. /**
  37531. * Texture data comes from raw data (ArrayBuffer)
  37532. */
  37533. Raw = 3,
  37534. /**
  37535. * Texture content is dynamic (video or dynamic texture)
  37536. */
  37537. Dynamic = 4,
  37538. /**
  37539. * Texture content is generated by rendering to it
  37540. */
  37541. RenderTarget = 5,
  37542. /**
  37543. * Texture content is part of a multi render target process
  37544. */
  37545. MultiRenderTarget = 6,
  37546. /**
  37547. * Texture data comes from a cube data file
  37548. */
  37549. Cube = 7,
  37550. /**
  37551. * Texture data comes from a raw cube data
  37552. */
  37553. CubeRaw = 8,
  37554. /**
  37555. * Texture data come from a prefiltered cube data file
  37556. */
  37557. CubePrefiltered = 9,
  37558. /**
  37559. * Texture content is raw 3D data
  37560. */
  37561. Raw3D = 10,
  37562. /**
  37563. * Texture content is raw 2D array data
  37564. */
  37565. Raw2DArray = 11,
  37566. /**
  37567. * Texture content is a depth texture
  37568. */
  37569. Depth = 12,
  37570. /**
  37571. * Texture data comes from a raw cube data encoded with RGBD
  37572. */
  37573. CubeRawRGBD = 13
  37574. }
  37575. /**
  37576. * Class used to store data associated with WebGL texture data for the engine
  37577. * This class should not be used directly
  37578. */
  37579. export class InternalTexture {
  37580. /** @hidden */
  37581. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37582. /**
  37583. * Defines if the texture is ready
  37584. */
  37585. isReady: boolean;
  37586. /**
  37587. * Defines if the texture is a cube texture
  37588. */
  37589. isCube: boolean;
  37590. /**
  37591. * Defines if the texture contains 3D data
  37592. */
  37593. is3D: boolean;
  37594. /**
  37595. * Defines if the texture contains 2D array data
  37596. */
  37597. is2DArray: boolean;
  37598. /**
  37599. * Defines if the texture contains multiview data
  37600. */
  37601. isMultiview: boolean;
  37602. /**
  37603. * Gets the URL used to load this texture
  37604. */
  37605. url: string;
  37606. /**
  37607. * Gets the sampling mode of the texture
  37608. */
  37609. samplingMode: number;
  37610. /**
  37611. * Gets a boolean indicating if the texture needs mipmaps generation
  37612. */
  37613. generateMipMaps: boolean;
  37614. /**
  37615. * Gets the number of samples used by the texture (WebGL2+ only)
  37616. */
  37617. samples: number;
  37618. /**
  37619. * Gets the type of the texture (int, float...)
  37620. */
  37621. type: number;
  37622. /**
  37623. * Gets the format of the texture (RGB, RGBA...)
  37624. */
  37625. format: number;
  37626. /**
  37627. * Observable called when the texture is loaded
  37628. */
  37629. onLoadedObservable: Observable<InternalTexture>;
  37630. /**
  37631. * Gets the width of the texture
  37632. */
  37633. width: number;
  37634. /**
  37635. * Gets the height of the texture
  37636. */
  37637. height: number;
  37638. /**
  37639. * Gets the depth of the texture
  37640. */
  37641. depth: number;
  37642. /**
  37643. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37644. */
  37645. baseWidth: number;
  37646. /**
  37647. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37648. */
  37649. baseHeight: number;
  37650. /**
  37651. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37652. */
  37653. baseDepth: number;
  37654. /**
  37655. * Gets a boolean indicating if the texture is inverted on Y axis
  37656. */
  37657. invertY: boolean;
  37658. /** @hidden */
  37659. _invertVScale: boolean;
  37660. /** @hidden */
  37661. _associatedChannel: number;
  37662. /** @hidden */
  37663. _source: InternalTextureSource;
  37664. /** @hidden */
  37665. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37666. /** @hidden */
  37667. _bufferView: Nullable<ArrayBufferView>;
  37668. /** @hidden */
  37669. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37670. /** @hidden */
  37671. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37672. /** @hidden */
  37673. _size: number;
  37674. /** @hidden */
  37675. _extension: string;
  37676. /** @hidden */
  37677. _files: Nullable<string[]>;
  37678. /** @hidden */
  37679. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37680. /** @hidden */
  37681. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37682. /** @hidden */
  37683. _framebuffer: Nullable<WebGLFramebuffer>;
  37684. /** @hidden */
  37685. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37686. /** @hidden */
  37687. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37688. /** @hidden */
  37689. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37690. /** @hidden */
  37691. _attachments: Nullable<number[]>;
  37692. /** @hidden */
  37693. _textureArray: Nullable<InternalTexture[]>;
  37694. /** @hidden */
  37695. _cachedCoordinatesMode: Nullable<number>;
  37696. /** @hidden */
  37697. _cachedWrapU: Nullable<number>;
  37698. /** @hidden */
  37699. _cachedWrapV: Nullable<number>;
  37700. /** @hidden */
  37701. _cachedWrapR: Nullable<number>;
  37702. /** @hidden */
  37703. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37704. /** @hidden */
  37705. _isDisabled: boolean;
  37706. /** @hidden */
  37707. _compression: Nullable<string>;
  37708. /** @hidden */
  37709. _generateStencilBuffer: boolean;
  37710. /** @hidden */
  37711. _generateDepthBuffer: boolean;
  37712. /** @hidden */
  37713. _comparisonFunction: number;
  37714. /** @hidden */
  37715. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37716. /** @hidden */
  37717. _lodGenerationScale: number;
  37718. /** @hidden */
  37719. _lodGenerationOffset: number;
  37720. /** @hidden */
  37721. _depthStencilTexture: Nullable<InternalTexture>;
  37722. /** @hidden */
  37723. _colorTextureArray: Nullable<WebGLTexture>;
  37724. /** @hidden */
  37725. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37726. /** @hidden */
  37727. _lodTextureHigh: Nullable<BaseTexture>;
  37728. /** @hidden */
  37729. _lodTextureMid: Nullable<BaseTexture>;
  37730. /** @hidden */
  37731. _lodTextureLow: Nullable<BaseTexture>;
  37732. /** @hidden */
  37733. _isRGBD: boolean;
  37734. /** @hidden */
  37735. _linearSpecularLOD: boolean;
  37736. /** @hidden */
  37737. _irradianceTexture: Nullable<BaseTexture>;
  37738. /** @hidden */
  37739. _webGLTexture: Nullable<WebGLTexture>;
  37740. /** @hidden */
  37741. _references: number;
  37742. private _engine;
  37743. /**
  37744. * Gets the Engine the texture belongs to.
  37745. * @returns The babylon engine
  37746. */
  37747. getEngine(): ThinEngine;
  37748. /**
  37749. * Gets the data source type of the texture
  37750. */
  37751. get source(): InternalTextureSource;
  37752. /**
  37753. * Creates a new InternalTexture
  37754. * @param engine defines the engine to use
  37755. * @param source defines the type of data that will be used
  37756. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37757. */
  37758. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37759. /**
  37760. * Increments the number of references (ie. the number of Texture that point to it)
  37761. */
  37762. incrementReferences(): void;
  37763. /**
  37764. * Change the size of the texture (not the size of the content)
  37765. * @param width defines the new width
  37766. * @param height defines the new height
  37767. * @param depth defines the new depth (1 by default)
  37768. */
  37769. updateSize(width: int, height: int, depth?: int): void;
  37770. /** @hidden */
  37771. _rebuild(): void;
  37772. /** @hidden */
  37773. _swapAndDie(target: InternalTexture): void;
  37774. /**
  37775. * Dispose the current allocated resources
  37776. */
  37777. dispose(): void;
  37778. }
  37779. }
  37780. declare module "babylonjs/Audio/analyser" {
  37781. import { Scene } from "babylonjs/scene";
  37782. /**
  37783. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37784. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37785. */
  37786. export class Analyser {
  37787. /**
  37788. * Gets or sets the smoothing
  37789. * @ignorenaming
  37790. */
  37791. SMOOTHING: number;
  37792. /**
  37793. * Gets or sets the FFT table size
  37794. * @ignorenaming
  37795. */
  37796. FFT_SIZE: number;
  37797. /**
  37798. * Gets or sets the bar graph amplitude
  37799. * @ignorenaming
  37800. */
  37801. BARGRAPHAMPLITUDE: number;
  37802. /**
  37803. * Gets or sets the position of the debug canvas
  37804. * @ignorenaming
  37805. */
  37806. DEBUGCANVASPOS: {
  37807. x: number;
  37808. y: number;
  37809. };
  37810. /**
  37811. * Gets or sets the debug canvas size
  37812. * @ignorenaming
  37813. */
  37814. DEBUGCANVASSIZE: {
  37815. width: number;
  37816. height: number;
  37817. };
  37818. private _byteFreqs;
  37819. private _byteTime;
  37820. private _floatFreqs;
  37821. private _webAudioAnalyser;
  37822. private _debugCanvas;
  37823. private _debugCanvasContext;
  37824. private _scene;
  37825. private _registerFunc;
  37826. private _audioEngine;
  37827. /**
  37828. * Creates a new analyser
  37829. * @param scene defines hosting scene
  37830. */
  37831. constructor(scene: Scene);
  37832. /**
  37833. * Get the number of data values you will have to play with for the visualization
  37834. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37835. * @returns a number
  37836. */
  37837. getFrequencyBinCount(): number;
  37838. /**
  37839. * Gets the current frequency data as a byte array
  37840. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37841. * @returns a Uint8Array
  37842. */
  37843. getByteFrequencyData(): Uint8Array;
  37844. /**
  37845. * Gets the current waveform as a byte array
  37846. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37847. * @returns a Uint8Array
  37848. */
  37849. getByteTimeDomainData(): Uint8Array;
  37850. /**
  37851. * Gets the current frequency data as a float array
  37852. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37853. * @returns a Float32Array
  37854. */
  37855. getFloatFrequencyData(): Float32Array;
  37856. /**
  37857. * Renders the debug canvas
  37858. */
  37859. drawDebugCanvas(): void;
  37860. /**
  37861. * Stops rendering the debug canvas and removes it
  37862. */
  37863. stopDebugCanvas(): void;
  37864. /**
  37865. * Connects two audio nodes
  37866. * @param inputAudioNode defines first node to connect
  37867. * @param outputAudioNode defines second node to connect
  37868. */
  37869. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37870. /**
  37871. * Releases all associated resources
  37872. */
  37873. dispose(): void;
  37874. }
  37875. }
  37876. declare module "babylonjs/Audio/audioEngine" {
  37877. import { IDisposable } from "babylonjs/scene";
  37878. import { Analyser } from "babylonjs/Audio/analyser";
  37879. import { Nullable } from "babylonjs/types";
  37880. import { Observable } from "babylonjs/Misc/observable";
  37881. /**
  37882. * This represents an audio engine and it is responsible
  37883. * to play, synchronize and analyse sounds throughout the application.
  37884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37885. */
  37886. export interface IAudioEngine extends IDisposable {
  37887. /**
  37888. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37889. */
  37890. readonly canUseWebAudio: boolean;
  37891. /**
  37892. * Gets the current AudioContext if available.
  37893. */
  37894. readonly audioContext: Nullable<AudioContext>;
  37895. /**
  37896. * The master gain node defines the global audio volume of your audio engine.
  37897. */
  37898. readonly masterGain: GainNode;
  37899. /**
  37900. * Gets whether or not mp3 are supported by your browser.
  37901. */
  37902. readonly isMP3supported: boolean;
  37903. /**
  37904. * Gets whether or not ogg are supported by your browser.
  37905. */
  37906. readonly isOGGsupported: boolean;
  37907. /**
  37908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37909. * @ignoreNaming
  37910. */
  37911. WarnedWebAudioUnsupported: boolean;
  37912. /**
  37913. * Defines if the audio engine relies on a custom unlocked button.
  37914. * In this case, the embedded button will not be displayed.
  37915. */
  37916. useCustomUnlockedButton: boolean;
  37917. /**
  37918. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37919. */
  37920. readonly unlocked: boolean;
  37921. /**
  37922. * Event raised when audio has been unlocked on the browser.
  37923. */
  37924. onAudioUnlockedObservable: Observable<AudioEngine>;
  37925. /**
  37926. * Event raised when audio has been locked on the browser.
  37927. */
  37928. onAudioLockedObservable: Observable<AudioEngine>;
  37929. /**
  37930. * Flags the audio engine in Locked state.
  37931. * This happens due to new browser policies preventing audio to autoplay.
  37932. */
  37933. lock(): void;
  37934. /**
  37935. * Unlocks the audio engine once a user action has been done on the dom.
  37936. * This is helpful to resume play once browser policies have been satisfied.
  37937. */
  37938. unlock(): void;
  37939. /**
  37940. * Gets the global volume sets on the master gain.
  37941. * @returns the global volume if set or -1 otherwise
  37942. */
  37943. getGlobalVolume(): number;
  37944. /**
  37945. * Sets the global volume of your experience (sets on the master gain).
  37946. * @param newVolume Defines the new global volume of the application
  37947. */
  37948. setGlobalVolume(newVolume: number): void;
  37949. /**
  37950. * Connect the audio engine to an audio analyser allowing some amazing
  37951. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37953. * @param analyser The analyser to connect to the engine
  37954. */
  37955. connectToAnalyser(analyser: Analyser): void;
  37956. }
  37957. /**
  37958. * This represents the default audio engine used in babylon.
  37959. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37960. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37961. */
  37962. export class AudioEngine implements IAudioEngine {
  37963. private _audioContext;
  37964. private _audioContextInitialized;
  37965. private _muteButton;
  37966. private _hostElement;
  37967. /**
  37968. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37969. */
  37970. canUseWebAudio: boolean;
  37971. /**
  37972. * The master gain node defines the global audio volume of your audio engine.
  37973. */
  37974. masterGain: GainNode;
  37975. /**
  37976. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37977. * @ignoreNaming
  37978. */
  37979. WarnedWebAudioUnsupported: boolean;
  37980. /**
  37981. * Gets whether or not mp3 are supported by your browser.
  37982. */
  37983. isMP3supported: boolean;
  37984. /**
  37985. * Gets whether or not ogg are supported by your browser.
  37986. */
  37987. isOGGsupported: boolean;
  37988. /**
  37989. * Gets whether audio has been unlocked on the device.
  37990. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37991. * a user interaction has happened.
  37992. */
  37993. unlocked: boolean;
  37994. /**
  37995. * Defines if the audio engine relies on a custom unlocked button.
  37996. * In this case, the embedded button will not be displayed.
  37997. */
  37998. useCustomUnlockedButton: boolean;
  37999. /**
  38000. * Event raised when audio has been unlocked on the browser.
  38001. */
  38002. onAudioUnlockedObservable: Observable<AudioEngine>;
  38003. /**
  38004. * Event raised when audio has been locked on the browser.
  38005. */
  38006. onAudioLockedObservable: Observable<AudioEngine>;
  38007. /**
  38008. * Gets the current AudioContext if available.
  38009. */
  38010. get audioContext(): Nullable<AudioContext>;
  38011. private _connectedAnalyser;
  38012. /**
  38013. * Instantiates a new audio engine.
  38014. *
  38015. * There should be only one per page as some browsers restrict the number
  38016. * of audio contexts you can create.
  38017. * @param hostElement defines the host element where to display the mute icon if necessary
  38018. */
  38019. constructor(hostElement?: Nullable<HTMLElement>);
  38020. /**
  38021. * Flags the audio engine in Locked state.
  38022. * This happens due to new browser policies preventing audio to autoplay.
  38023. */
  38024. lock(): void;
  38025. /**
  38026. * Unlocks the audio engine once a user action has been done on the dom.
  38027. * This is helpful to resume play once browser policies have been satisfied.
  38028. */
  38029. unlock(): void;
  38030. private _resumeAudioContext;
  38031. private _initializeAudioContext;
  38032. private _tryToRun;
  38033. private _triggerRunningState;
  38034. private _triggerSuspendedState;
  38035. private _displayMuteButton;
  38036. private _moveButtonToTopLeft;
  38037. private _onResize;
  38038. private _hideMuteButton;
  38039. /**
  38040. * Destroy and release the resources associated with the audio ccontext.
  38041. */
  38042. dispose(): void;
  38043. /**
  38044. * Gets the global volume sets on the master gain.
  38045. * @returns the global volume if set or -1 otherwise
  38046. */
  38047. getGlobalVolume(): number;
  38048. /**
  38049. * Sets the global volume of your experience (sets on the master gain).
  38050. * @param newVolume Defines the new global volume of the application
  38051. */
  38052. setGlobalVolume(newVolume: number): void;
  38053. /**
  38054. * Connect the audio engine to an audio analyser allowing some amazing
  38055. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38057. * @param analyser The analyser to connect to the engine
  38058. */
  38059. connectToAnalyser(analyser: Analyser): void;
  38060. }
  38061. }
  38062. declare module "babylonjs/Loading/loadingScreen" {
  38063. /**
  38064. * Interface used to present a loading screen while loading a scene
  38065. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38066. */
  38067. export interface ILoadingScreen {
  38068. /**
  38069. * Function called to display the loading screen
  38070. */
  38071. displayLoadingUI: () => void;
  38072. /**
  38073. * Function called to hide the loading screen
  38074. */
  38075. hideLoadingUI: () => void;
  38076. /**
  38077. * Gets or sets the color to use for the background
  38078. */
  38079. loadingUIBackgroundColor: string;
  38080. /**
  38081. * Gets or sets the text to display while loading
  38082. */
  38083. loadingUIText: string;
  38084. }
  38085. /**
  38086. * Class used for the default loading screen
  38087. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38088. */
  38089. export class DefaultLoadingScreen implements ILoadingScreen {
  38090. private _renderingCanvas;
  38091. private _loadingText;
  38092. private _loadingDivBackgroundColor;
  38093. private _loadingDiv;
  38094. private _loadingTextDiv;
  38095. /** Gets or sets the logo url to use for the default loading screen */
  38096. static DefaultLogoUrl: string;
  38097. /** Gets or sets the spinner url to use for the default loading screen */
  38098. static DefaultSpinnerUrl: string;
  38099. /**
  38100. * Creates a new default loading screen
  38101. * @param _renderingCanvas defines the canvas used to render the scene
  38102. * @param _loadingText defines the default text to display
  38103. * @param _loadingDivBackgroundColor defines the default background color
  38104. */
  38105. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38106. /**
  38107. * Function called to display the loading screen
  38108. */
  38109. displayLoadingUI(): void;
  38110. /**
  38111. * Function called to hide the loading screen
  38112. */
  38113. hideLoadingUI(): void;
  38114. /**
  38115. * Gets or sets the text to display while loading
  38116. */
  38117. set loadingUIText(text: string);
  38118. get loadingUIText(): string;
  38119. /**
  38120. * Gets or sets the color to use for the background
  38121. */
  38122. get loadingUIBackgroundColor(): string;
  38123. set loadingUIBackgroundColor(color: string);
  38124. private _resizeLoadingUI;
  38125. }
  38126. }
  38127. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38128. /**
  38129. * Interface for any object that can request an animation frame
  38130. */
  38131. export interface ICustomAnimationFrameRequester {
  38132. /**
  38133. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38134. */
  38135. renderFunction?: Function;
  38136. /**
  38137. * Called to request the next frame to render to
  38138. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38139. */
  38140. requestAnimationFrame: Function;
  38141. /**
  38142. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38143. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38144. */
  38145. requestID?: number;
  38146. }
  38147. }
  38148. declare module "babylonjs/Misc/performanceMonitor" {
  38149. /**
  38150. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38151. */
  38152. export class PerformanceMonitor {
  38153. private _enabled;
  38154. private _rollingFrameTime;
  38155. private _lastFrameTimeMs;
  38156. /**
  38157. * constructor
  38158. * @param frameSampleSize The number of samples required to saturate the sliding window
  38159. */
  38160. constructor(frameSampleSize?: number);
  38161. /**
  38162. * Samples current frame
  38163. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38164. */
  38165. sampleFrame(timeMs?: number): void;
  38166. /**
  38167. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38168. */
  38169. get averageFrameTime(): number;
  38170. /**
  38171. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38172. */
  38173. get averageFrameTimeVariance(): number;
  38174. /**
  38175. * Returns the frame time of the most recent frame
  38176. */
  38177. get instantaneousFrameTime(): number;
  38178. /**
  38179. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38180. */
  38181. get averageFPS(): number;
  38182. /**
  38183. * Returns the average framerate in frames per second using the most recent frame time
  38184. */
  38185. get instantaneousFPS(): number;
  38186. /**
  38187. * Returns true if enough samples have been taken to completely fill the sliding window
  38188. */
  38189. get isSaturated(): boolean;
  38190. /**
  38191. * Enables contributions to the sliding window sample set
  38192. */
  38193. enable(): void;
  38194. /**
  38195. * Disables contributions to the sliding window sample set
  38196. * Samples will not be interpolated over the disabled period
  38197. */
  38198. disable(): void;
  38199. /**
  38200. * Returns true if sampling is enabled
  38201. */
  38202. get isEnabled(): boolean;
  38203. /**
  38204. * Resets performance monitor
  38205. */
  38206. reset(): void;
  38207. }
  38208. /**
  38209. * RollingAverage
  38210. *
  38211. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38212. */
  38213. export class RollingAverage {
  38214. /**
  38215. * Current average
  38216. */
  38217. average: number;
  38218. /**
  38219. * Current variance
  38220. */
  38221. variance: number;
  38222. protected _samples: Array<number>;
  38223. protected _sampleCount: number;
  38224. protected _pos: number;
  38225. protected _m2: number;
  38226. /**
  38227. * constructor
  38228. * @param length The number of samples required to saturate the sliding window
  38229. */
  38230. constructor(length: number);
  38231. /**
  38232. * Adds a sample to the sample set
  38233. * @param v The sample value
  38234. */
  38235. add(v: number): void;
  38236. /**
  38237. * Returns previously added values or null if outside of history or outside the sliding window domain
  38238. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38239. * @return Value previously recorded with add() or null if outside of range
  38240. */
  38241. history(i: number): number;
  38242. /**
  38243. * Returns true if enough samples have been taken to completely fill the sliding window
  38244. * @return true if sample-set saturated
  38245. */
  38246. isSaturated(): boolean;
  38247. /**
  38248. * Resets the rolling average (equivalent to 0 samples taken so far)
  38249. */
  38250. reset(): void;
  38251. /**
  38252. * Wraps a value around the sample range boundaries
  38253. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38254. * @return Wrapped position in sample range
  38255. */
  38256. protected _wrapPosition(i: number): number;
  38257. }
  38258. }
  38259. declare module "babylonjs/Misc/perfCounter" {
  38260. /**
  38261. * This class is used to track a performance counter which is number based.
  38262. * The user has access to many properties which give statistics of different nature.
  38263. *
  38264. * The implementer can track two kinds of Performance Counter: time and count.
  38265. * 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.
  38266. * 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.
  38267. */
  38268. export class PerfCounter {
  38269. /**
  38270. * Gets or sets a global boolean to turn on and off all the counters
  38271. */
  38272. static Enabled: boolean;
  38273. /**
  38274. * Returns the smallest value ever
  38275. */
  38276. get min(): number;
  38277. /**
  38278. * Returns the biggest value ever
  38279. */
  38280. get max(): number;
  38281. /**
  38282. * Returns the average value since the performance counter is running
  38283. */
  38284. get average(): number;
  38285. /**
  38286. * Returns the average value of the last second the counter was monitored
  38287. */
  38288. get lastSecAverage(): number;
  38289. /**
  38290. * Returns the current value
  38291. */
  38292. get current(): number;
  38293. /**
  38294. * Gets the accumulated total
  38295. */
  38296. get total(): number;
  38297. /**
  38298. * Gets the total value count
  38299. */
  38300. get count(): number;
  38301. /**
  38302. * Creates a new counter
  38303. */
  38304. constructor();
  38305. /**
  38306. * Call this method to start monitoring a new frame.
  38307. * 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.
  38308. */
  38309. fetchNewFrame(): void;
  38310. /**
  38311. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38312. * @param newCount the count value to add to the monitored count
  38313. * @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.
  38314. */
  38315. addCount(newCount: number, fetchResult: boolean): void;
  38316. /**
  38317. * Start monitoring this performance counter
  38318. */
  38319. beginMonitoring(): void;
  38320. /**
  38321. * Compute the time lapsed since the previous beginMonitoring() call.
  38322. * @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
  38323. */
  38324. endMonitoring(newFrame?: boolean): void;
  38325. private _fetchResult;
  38326. private _startMonitoringTime;
  38327. private _min;
  38328. private _max;
  38329. private _average;
  38330. private _current;
  38331. private _totalValueCount;
  38332. private _totalAccumulated;
  38333. private _lastSecAverage;
  38334. private _lastSecAccumulated;
  38335. private _lastSecTime;
  38336. private _lastSecValueCount;
  38337. }
  38338. }
  38339. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38340. module "babylonjs/Engines/thinEngine" {
  38341. interface ThinEngine {
  38342. /**
  38343. * Sets alpha constants used by some alpha blending modes
  38344. * @param r defines the red component
  38345. * @param g defines the green component
  38346. * @param b defines the blue component
  38347. * @param a defines the alpha component
  38348. */
  38349. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38350. /**
  38351. * Sets the current alpha mode
  38352. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38353. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38354. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38355. */
  38356. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38357. /**
  38358. * Gets the current alpha mode
  38359. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38360. * @returns the current alpha mode
  38361. */
  38362. getAlphaMode(): number;
  38363. /**
  38364. * Sets the current alpha equation
  38365. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38366. */
  38367. setAlphaEquation(equation: number): void;
  38368. /**
  38369. * Gets the current alpha equation.
  38370. * @returns the current alpha equation
  38371. */
  38372. getAlphaEquation(): number;
  38373. }
  38374. }
  38375. }
  38376. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38377. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38378. import { Nullable } from "babylonjs/types";
  38379. module "babylonjs/Engines/thinEngine" {
  38380. interface ThinEngine {
  38381. /** @hidden */
  38382. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38383. }
  38384. }
  38385. }
  38386. declare module "babylonjs/Engines/engine" {
  38387. import { Observable } from "babylonjs/Misc/observable";
  38388. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38389. import { Scene } from "babylonjs/scene";
  38390. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38391. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38392. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38393. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38394. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38395. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38396. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38397. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38398. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38400. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38401. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38402. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38403. import "babylonjs/Engines/Extensions/engine.alpha";
  38404. import "babylonjs/Engines/Extensions/engine.readTexture";
  38405. import { Material } from "babylonjs/Materials/material";
  38406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38407. /**
  38408. * Defines the interface used by display changed events
  38409. */
  38410. export interface IDisplayChangedEventArgs {
  38411. /** Gets the vrDisplay object (if any) */
  38412. vrDisplay: Nullable<any>;
  38413. /** Gets a boolean indicating if webVR is supported */
  38414. vrSupported: boolean;
  38415. }
  38416. /**
  38417. * Defines the interface used by objects containing a viewport (like a camera)
  38418. */
  38419. interface IViewportOwnerLike {
  38420. /**
  38421. * Gets or sets the viewport
  38422. */
  38423. viewport: IViewportLike;
  38424. }
  38425. /**
  38426. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38427. */
  38428. export class Engine extends ThinEngine {
  38429. /** Defines that alpha blending is disabled */
  38430. static readonly ALPHA_DISABLE: number;
  38431. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38432. static readonly ALPHA_ADD: number;
  38433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38434. static readonly ALPHA_COMBINE: number;
  38435. /** Defines that alpha blending to DEST - SRC * DEST */
  38436. static readonly ALPHA_SUBTRACT: number;
  38437. /** Defines that alpha blending to SRC * DEST */
  38438. static readonly ALPHA_MULTIPLY: number;
  38439. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38440. static readonly ALPHA_MAXIMIZED: number;
  38441. /** Defines that alpha blending to SRC + DEST */
  38442. static readonly ALPHA_ONEONE: number;
  38443. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38444. static readonly ALPHA_PREMULTIPLIED: number;
  38445. /**
  38446. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38447. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38448. */
  38449. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38450. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38451. static readonly ALPHA_INTERPOLATE: number;
  38452. /**
  38453. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38454. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38455. */
  38456. static readonly ALPHA_SCREENMODE: number;
  38457. /** Defines that the ressource is not delayed*/
  38458. static readonly DELAYLOADSTATE_NONE: number;
  38459. /** Defines that the ressource was successfully delay loaded */
  38460. static readonly DELAYLOADSTATE_LOADED: number;
  38461. /** Defines that the ressource is currently delay loading */
  38462. static readonly DELAYLOADSTATE_LOADING: number;
  38463. /** Defines that the ressource is delayed and has not started loading */
  38464. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38466. static readonly NEVER: number;
  38467. /** 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 */
  38468. static readonly ALWAYS: number;
  38469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38470. static readonly LESS: number;
  38471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38472. static readonly EQUAL: number;
  38473. /** 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 */
  38474. static readonly LEQUAL: number;
  38475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38476. static readonly GREATER: number;
  38477. /** 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 */
  38478. static readonly GEQUAL: number;
  38479. /** 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 */
  38480. static readonly NOTEQUAL: number;
  38481. /** Passed to stencilOperation to specify that stencil value must be kept */
  38482. static readonly KEEP: number;
  38483. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38484. static readonly REPLACE: number;
  38485. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38486. static readonly INCR: number;
  38487. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38488. static readonly DECR: number;
  38489. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38490. static readonly INVERT: number;
  38491. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38492. static readonly INCR_WRAP: number;
  38493. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38494. static readonly DECR_WRAP: number;
  38495. /** Texture is not repeating outside of 0..1 UVs */
  38496. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38497. /** Texture is repeating outside of 0..1 UVs */
  38498. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38499. /** Texture is repeating and mirrored */
  38500. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38501. /** ALPHA */
  38502. static readonly TEXTUREFORMAT_ALPHA: number;
  38503. /** LUMINANCE */
  38504. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38505. /** LUMINANCE_ALPHA */
  38506. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38507. /** RGB */
  38508. static readonly TEXTUREFORMAT_RGB: number;
  38509. /** RGBA */
  38510. static readonly TEXTUREFORMAT_RGBA: number;
  38511. /** RED */
  38512. static readonly TEXTUREFORMAT_RED: number;
  38513. /** RED (2nd reference) */
  38514. static readonly TEXTUREFORMAT_R: number;
  38515. /** RG */
  38516. static readonly TEXTUREFORMAT_RG: number;
  38517. /** RED_INTEGER */
  38518. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38519. /** RED_INTEGER (2nd reference) */
  38520. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38521. /** RG_INTEGER */
  38522. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38523. /** RGB_INTEGER */
  38524. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38525. /** RGBA_INTEGER */
  38526. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38527. /** UNSIGNED_BYTE */
  38528. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38529. /** UNSIGNED_BYTE (2nd reference) */
  38530. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38531. /** FLOAT */
  38532. static readonly TEXTURETYPE_FLOAT: number;
  38533. /** HALF_FLOAT */
  38534. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38535. /** BYTE */
  38536. static readonly TEXTURETYPE_BYTE: number;
  38537. /** SHORT */
  38538. static readonly TEXTURETYPE_SHORT: number;
  38539. /** UNSIGNED_SHORT */
  38540. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38541. /** INT */
  38542. static readonly TEXTURETYPE_INT: number;
  38543. /** UNSIGNED_INT */
  38544. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38545. /** UNSIGNED_SHORT_4_4_4_4 */
  38546. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38547. /** UNSIGNED_SHORT_5_5_5_1 */
  38548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38549. /** UNSIGNED_SHORT_5_6_5 */
  38550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38551. /** UNSIGNED_INT_2_10_10_10_REV */
  38552. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38553. /** UNSIGNED_INT_24_8 */
  38554. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38555. /** UNSIGNED_INT_10F_11F_11F_REV */
  38556. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38557. /** UNSIGNED_INT_5_9_9_9_REV */
  38558. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38559. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38560. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38561. /** nearest is mag = nearest and min = nearest and mip = linear */
  38562. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38564. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38565. /** Trilinear is mag = linear and min = linear and mip = linear */
  38566. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38567. /** nearest is mag = nearest and min = nearest and mip = linear */
  38568. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38569. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38570. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38571. /** Trilinear is mag = linear and min = linear and mip = linear */
  38572. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38573. /** mag = nearest and min = nearest and mip = nearest */
  38574. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38575. /** mag = nearest and min = linear and mip = nearest */
  38576. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38577. /** mag = nearest and min = linear and mip = linear */
  38578. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38579. /** mag = nearest and min = linear and mip = none */
  38580. static readonly TEXTURE_NEAREST_LINEAR: number;
  38581. /** mag = nearest and min = nearest and mip = none */
  38582. static readonly TEXTURE_NEAREST_NEAREST: number;
  38583. /** mag = linear and min = nearest and mip = nearest */
  38584. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38585. /** mag = linear and min = nearest and mip = linear */
  38586. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38587. /** mag = linear and min = linear and mip = none */
  38588. static readonly TEXTURE_LINEAR_LINEAR: number;
  38589. /** mag = linear and min = nearest and mip = none */
  38590. static readonly TEXTURE_LINEAR_NEAREST: number;
  38591. /** Explicit coordinates mode */
  38592. static readonly TEXTURE_EXPLICIT_MODE: number;
  38593. /** Spherical coordinates mode */
  38594. static readonly TEXTURE_SPHERICAL_MODE: number;
  38595. /** Planar coordinates mode */
  38596. static readonly TEXTURE_PLANAR_MODE: number;
  38597. /** Cubic coordinates mode */
  38598. static readonly TEXTURE_CUBIC_MODE: number;
  38599. /** Projection coordinates mode */
  38600. static readonly TEXTURE_PROJECTION_MODE: number;
  38601. /** Skybox coordinates mode */
  38602. static readonly TEXTURE_SKYBOX_MODE: number;
  38603. /** Inverse Cubic coordinates mode */
  38604. static readonly TEXTURE_INVCUBIC_MODE: number;
  38605. /** Equirectangular coordinates mode */
  38606. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38607. /** Equirectangular Fixed coordinates mode */
  38608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38609. /** Equirectangular Fixed Mirrored coordinates mode */
  38610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38611. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38612. static readonly SCALEMODE_FLOOR: number;
  38613. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38614. static readonly SCALEMODE_NEAREST: number;
  38615. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38616. static readonly SCALEMODE_CEILING: number;
  38617. /**
  38618. * Returns the current npm package of the sdk
  38619. */
  38620. static get NpmPackage(): string;
  38621. /**
  38622. * Returns the current version of the framework
  38623. */
  38624. static get Version(): string;
  38625. /** Gets the list of created engines */
  38626. static get Instances(): Engine[];
  38627. /**
  38628. * Gets the latest created engine
  38629. */
  38630. static get LastCreatedEngine(): Nullable<Engine>;
  38631. /**
  38632. * Gets the latest created scene
  38633. */
  38634. static get LastCreatedScene(): Nullable<Scene>;
  38635. /**
  38636. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38637. * @param flag defines which part of the materials must be marked as dirty
  38638. * @param predicate defines a predicate used to filter which materials should be affected
  38639. */
  38640. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38641. /**
  38642. * Method called to create the default loading screen.
  38643. * This can be overriden in your own app.
  38644. * @param canvas The rendering canvas element
  38645. * @returns The loading screen
  38646. */
  38647. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38648. /**
  38649. * Method called to create the default rescale post process on each engine.
  38650. */
  38651. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38652. /**
  38653. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38654. **/
  38655. enableOfflineSupport: boolean;
  38656. /**
  38657. * 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)
  38658. **/
  38659. disableManifestCheck: boolean;
  38660. /**
  38661. * Gets the list of created scenes
  38662. */
  38663. scenes: Scene[];
  38664. /**
  38665. * Event raised when a new scene is created
  38666. */
  38667. onNewSceneAddedObservable: Observable<Scene>;
  38668. /**
  38669. * Gets the list of created postprocesses
  38670. */
  38671. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38672. /**
  38673. * Gets a boolean indicating if the pointer is currently locked
  38674. */
  38675. isPointerLock: boolean;
  38676. /**
  38677. * Observable event triggered each time the rendering canvas is resized
  38678. */
  38679. onResizeObservable: Observable<Engine>;
  38680. /**
  38681. * Observable event triggered each time the canvas loses focus
  38682. */
  38683. onCanvasBlurObservable: Observable<Engine>;
  38684. /**
  38685. * Observable event triggered each time the canvas gains focus
  38686. */
  38687. onCanvasFocusObservable: Observable<Engine>;
  38688. /**
  38689. * Observable event triggered each time the canvas receives pointerout event
  38690. */
  38691. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38692. /**
  38693. * Observable raised when the engine begins a new frame
  38694. */
  38695. onBeginFrameObservable: Observable<Engine>;
  38696. /**
  38697. * If set, will be used to request the next animation frame for the render loop
  38698. */
  38699. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38700. /**
  38701. * Observable raised when the engine ends the current frame
  38702. */
  38703. onEndFrameObservable: Observable<Engine>;
  38704. /**
  38705. * Observable raised when the engine is about to compile a shader
  38706. */
  38707. onBeforeShaderCompilationObservable: Observable<Engine>;
  38708. /**
  38709. * Observable raised when the engine has jsut compiled a shader
  38710. */
  38711. onAfterShaderCompilationObservable: Observable<Engine>;
  38712. /**
  38713. * Gets the audio engine
  38714. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38715. * @ignorenaming
  38716. */
  38717. static audioEngine: IAudioEngine;
  38718. /**
  38719. * Default AudioEngine factory responsible of creating the Audio Engine.
  38720. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38721. */
  38722. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38723. /**
  38724. * Default offline support factory responsible of creating a tool used to store data locally.
  38725. * By default, this will create a Database object if the workload has been embedded.
  38726. */
  38727. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38728. private _loadingScreen;
  38729. private _pointerLockRequested;
  38730. private _rescalePostProcess;
  38731. private _deterministicLockstep;
  38732. private _lockstepMaxSteps;
  38733. private _timeStep;
  38734. protected get _supportsHardwareTextureRescaling(): boolean;
  38735. private _fps;
  38736. private _deltaTime;
  38737. /** @hidden */
  38738. _drawCalls: PerfCounter;
  38739. /** 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 */
  38740. canvasTabIndex: number;
  38741. /**
  38742. * Turn this value on if you want to pause FPS computation when in background
  38743. */
  38744. disablePerformanceMonitorInBackground: boolean;
  38745. private _performanceMonitor;
  38746. /**
  38747. * Gets the performance monitor attached to this engine
  38748. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38749. */
  38750. get performanceMonitor(): PerformanceMonitor;
  38751. private _onFocus;
  38752. private _onBlur;
  38753. private _onCanvasPointerOut;
  38754. private _onCanvasBlur;
  38755. private _onCanvasFocus;
  38756. private _onFullscreenChange;
  38757. private _onPointerLockChange;
  38758. /**
  38759. * Gets the HTML element used to attach event listeners
  38760. * @returns a HTML element
  38761. */
  38762. getInputElement(): Nullable<HTMLElement>;
  38763. /**
  38764. * Creates a new engine
  38765. * @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
  38766. * @param antialias defines enable antialiasing (default: false)
  38767. * @param options defines further options to be sent to the getContext() function
  38768. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38769. */
  38770. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38771. /**
  38772. * Gets current aspect ratio
  38773. * @param viewportOwner defines the camera to use to get the aspect ratio
  38774. * @param useScreen defines if screen size must be used (or the current render target if any)
  38775. * @returns a number defining the aspect ratio
  38776. */
  38777. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38778. /**
  38779. * Gets current screen aspect ratio
  38780. * @returns a number defining the aspect ratio
  38781. */
  38782. getScreenAspectRatio(): number;
  38783. /**
  38784. * Gets the client rect of the HTML canvas attached with the current webGL context
  38785. * @returns a client rectanglee
  38786. */
  38787. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38788. /**
  38789. * Gets the client rect of the HTML element used for events
  38790. * @returns a client rectanglee
  38791. */
  38792. getInputElementClientRect(): Nullable<ClientRect>;
  38793. /**
  38794. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38795. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38796. * @returns true if engine is in deterministic lock step mode
  38797. */
  38798. isDeterministicLockStep(): boolean;
  38799. /**
  38800. * Gets the max steps when engine is running in deterministic lock step
  38801. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38802. * @returns the max steps
  38803. */
  38804. getLockstepMaxSteps(): number;
  38805. /**
  38806. * Returns the time in ms between steps when using deterministic lock step.
  38807. * @returns time step in (ms)
  38808. */
  38809. getTimeStep(): number;
  38810. /**
  38811. * Force the mipmap generation for the given render target texture
  38812. * @param texture defines the render target texture to use
  38813. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38814. */
  38815. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38816. /** States */
  38817. /**
  38818. * Set various states to the webGL context
  38819. * @param culling defines backface culling state
  38820. * @param zOffset defines the value to apply to zOffset (0 by default)
  38821. * @param force defines if states must be applied even if cache is up to date
  38822. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38823. */
  38824. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38825. /**
  38826. * Set the z offset to apply to current rendering
  38827. * @param value defines the offset to apply
  38828. */
  38829. setZOffset(value: number): void;
  38830. /**
  38831. * Gets the current value of the zOffset
  38832. * @returns the current zOffset state
  38833. */
  38834. getZOffset(): number;
  38835. /**
  38836. * Enable or disable depth buffering
  38837. * @param enable defines the state to set
  38838. */
  38839. setDepthBuffer(enable: boolean): void;
  38840. /**
  38841. * Gets a boolean indicating if depth writing is enabled
  38842. * @returns the current depth writing state
  38843. */
  38844. getDepthWrite(): boolean;
  38845. /**
  38846. * Enable or disable depth writing
  38847. * @param enable defines the state to set
  38848. */
  38849. setDepthWrite(enable: boolean): void;
  38850. /**
  38851. * Gets a boolean indicating if stencil buffer is enabled
  38852. * @returns the current stencil buffer state
  38853. */
  38854. getStencilBuffer(): boolean;
  38855. /**
  38856. * Enable or disable the stencil buffer
  38857. * @param enable defines if the stencil buffer must be enabled or disabled
  38858. */
  38859. setStencilBuffer(enable: boolean): void;
  38860. /**
  38861. * Gets the current stencil mask
  38862. * @returns a number defining the new stencil mask to use
  38863. */
  38864. getStencilMask(): number;
  38865. /**
  38866. * Sets the current stencil mask
  38867. * @param mask defines the new stencil mask to use
  38868. */
  38869. setStencilMask(mask: number): void;
  38870. /**
  38871. * Gets the current stencil function
  38872. * @returns a number defining the stencil function to use
  38873. */
  38874. getStencilFunction(): number;
  38875. /**
  38876. * Gets the current stencil reference value
  38877. * @returns a number defining the stencil reference value to use
  38878. */
  38879. getStencilFunctionReference(): number;
  38880. /**
  38881. * Gets the current stencil mask
  38882. * @returns a number defining the stencil mask to use
  38883. */
  38884. getStencilFunctionMask(): number;
  38885. /**
  38886. * Sets the current stencil function
  38887. * @param stencilFunc defines the new stencil function to use
  38888. */
  38889. setStencilFunction(stencilFunc: number): void;
  38890. /**
  38891. * Sets the current stencil reference
  38892. * @param reference defines the new stencil reference to use
  38893. */
  38894. setStencilFunctionReference(reference: number): void;
  38895. /**
  38896. * Sets the current stencil mask
  38897. * @param mask defines the new stencil mask to use
  38898. */
  38899. setStencilFunctionMask(mask: number): void;
  38900. /**
  38901. * Gets the current stencil operation when stencil fails
  38902. * @returns a number defining stencil operation to use when stencil fails
  38903. */
  38904. getStencilOperationFail(): number;
  38905. /**
  38906. * Gets the current stencil operation when depth fails
  38907. * @returns a number defining stencil operation to use when depth fails
  38908. */
  38909. getStencilOperationDepthFail(): number;
  38910. /**
  38911. * Gets the current stencil operation when stencil passes
  38912. * @returns a number defining stencil operation to use when stencil passes
  38913. */
  38914. getStencilOperationPass(): number;
  38915. /**
  38916. * Sets the stencil operation to use when stencil fails
  38917. * @param operation defines the stencil operation to use when stencil fails
  38918. */
  38919. setStencilOperationFail(operation: number): void;
  38920. /**
  38921. * Sets the stencil operation to use when depth fails
  38922. * @param operation defines the stencil operation to use when depth fails
  38923. */
  38924. setStencilOperationDepthFail(operation: number): void;
  38925. /**
  38926. * Sets the stencil operation to use when stencil passes
  38927. * @param operation defines the stencil operation to use when stencil passes
  38928. */
  38929. setStencilOperationPass(operation: number): void;
  38930. /**
  38931. * Sets a boolean indicating if the dithering state is enabled or disabled
  38932. * @param value defines the dithering state
  38933. */
  38934. setDitheringState(value: boolean): void;
  38935. /**
  38936. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38937. * @param value defines the rasterizer state
  38938. */
  38939. setRasterizerState(value: boolean): void;
  38940. /**
  38941. * Gets the current depth function
  38942. * @returns a number defining the depth function
  38943. */
  38944. getDepthFunction(): Nullable<number>;
  38945. /**
  38946. * Sets the current depth function
  38947. * @param depthFunc defines the function to use
  38948. */
  38949. setDepthFunction(depthFunc: number): void;
  38950. /**
  38951. * Sets the current depth function to GREATER
  38952. */
  38953. setDepthFunctionToGreater(): void;
  38954. /**
  38955. * Sets the current depth function to GEQUAL
  38956. */
  38957. setDepthFunctionToGreaterOrEqual(): void;
  38958. /**
  38959. * Sets the current depth function to LESS
  38960. */
  38961. setDepthFunctionToLess(): void;
  38962. /**
  38963. * Sets the current depth function to LEQUAL
  38964. */
  38965. setDepthFunctionToLessOrEqual(): void;
  38966. private _cachedStencilBuffer;
  38967. private _cachedStencilFunction;
  38968. private _cachedStencilMask;
  38969. private _cachedStencilOperationPass;
  38970. private _cachedStencilOperationFail;
  38971. private _cachedStencilOperationDepthFail;
  38972. private _cachedStencilReference;
  38973. /**
  38974. * Caches the the state of the stencil buffer
  38975. */
  38976. cacheStencilState(): void;
  38977. /**
  38978. * Restores the state of the stencil buffer
  38979. */
  38980. restoreStencilState(): void;
  38981. /**
  38982. * Directly set the WebGL Viewport
  38983. * @param x defines the x coordinate of the viewport (in screen space)
  38984. * @param y defines the y coordinate of the viewport (in screen space)
  38985. * @param width defines the width of the viewport (in screen space)
  38986. * @param height defines the height of the viewport (in screen space)
  38987. * @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
  38988. */
  38989. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38990. /**
  38991. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38992. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38993. * @param y defines the y-coordinate of the corner of the clear rectangle
  38994. * @param width defines the width of the clear rectangle
  38995. * @param height defines the height of the clear rectangle
  38996. * @param clearColor defines the clear color
  38997. */
  38998. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38999. /**
  39000. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39001. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39002. * @param y defines the y-coordinate of the corner of the clear rectangle
  39003. * @param width defines the width of the clear rectangle
  39004. * @param height defines the height of the clear rectangle
  39005. */
  39006. enableScissor(x: number, y: number, width: number, height: number): void;
  39007. /**
  39008. * Disable previously set scissor test rectangle
  39009. */
  39010. disableScissor(): void;
  39011. protected _reportDrawCall(): void;
  39012. /**
  39013. * Initializes a webVR display and starts listening to display change events
  39014. * The onVRDisplayChangedObservable will be notified upon these changes
  39015. * @returns The onVRDisplayChangedObservable
  39016. */
  39017. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39018. /** @hidden */
  39019. _prepareVRComponent(): void;
  39020. /** @hidden */
  39021. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39022. /** @hidden */
  39023. _submitVRFrame(): void;
  39024. /**
  39025. * Call this function to leave webVR mode
  39026. * Will do nothing if webVR is not supported or if there is no webVR device
  39027. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39028. */
  39029. disableVR(): void;
  39030. /**
  39031. * Gets a boolean indicating that the system is in VR mode and is presenting
  39032. * @returns true if VR mode is engaged
  39033. */
  39034. isVRPresenting(): boolean;
  39035. /** @hidden */
  39036. _requestVRFrame(): void;
  39037. /** @hidden */
  39038. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39039. /**
  39040. * Gets the source code of the vertex shader associated with a specific webGL program
  39041. * @param program defines the program to use
  39042. * @returns a string containing the source code of the vertex shader associated with the program
  39043. */
  39044. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39045. /**
  39046. * Gets the source code of the fragment shader associated with a specific webGL program
  39047. * @param program defines the program to use
  39048. * @returns a string containing the source code of the fragment shader associated with the program
  39049. */
  39050. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39051. /**
  39052. * Sets a depth stencil texture from a render target to the according uniform.
  39053. * @param channel The texture channel
  39054. * @param uniform The uniform to set
  39055. * @param texture The render target texture containing the depth stencil texture to apply
  39056. */
  39057. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39058. /**
  39059. * Sets a texture to the webGL context from a postprocess
  39060. * @param channel defines the channel to use
  39061. * @param postProcess defines the source postprocess
  39062. */
  39063. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39064. /**
  39065. * Binds the output of the passed in post process to the texture channel specified
  39066. * @param channel The channel the texture should be bound to
  39067. * @param postProcess The post process which's output should be bound
  39068. */
  39069. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39070. protected _rebuildBuffers(): void;
  39071. /** @hidden */
  39072. _renderFrame(): void;
  39073. _renderLoop(): void;
  39074. /** @hidden */
  39075. _renderViews(): boolean;
  39076. /**
  39077. * Toggle full screen mode
  39078. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39079. */
  39080. switchFullscreen(requestPointerLock: boolean): void;
  39081. /**
  39082. * Enters full screen mode
  39083. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39084. */
  39085. enterFullscreen(requestPointerLock: boolean): void;
  39086. /**
  39087. * Exits full screen mode
  39088. */
  39089. exitFullscreen(): void;
  39090. /**
  39091. * Enters Pointerlock mode
  39092. */
  39093. enterPointerlock(): void;
  39094. /**
  39095. * Exits Pointerlock mode
  39096. */
  39097. exitPointerlock(): void;
  39098. /**
  39099. * Begin a new frame
  39100. */
  39101. beginFrame(): void;
  39102. /**
  39103. * Enf the current frame
  39104. */
  39105. endFrame(): void;
  39106. resize(): void;
  39107. /**
  39108. * Force a specific size of the canvas
  39109. * @param width defines the new canvas' width
  39110. * @param height defines the new canvas' height
  39111. * @returns true if the size was changed
  39112. */
  39113. setSize(width: number, height: number): boolean;
  39114. /**
  39115. * Updates a dynamic vertex buffer.
  39116. * @param vertexBuffer the vertex buffer to update
  39117. * @param data the data used to update the vertex buffer
  39118. * @param byteOffset the byte offset of the data
  39119. * @param byteLength the byte length of the data
  39120. */
  39121. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39122. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39123. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39124. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39125. _releaseTexture(texture: InternalTexture): void;
  39126. /**
  39127. * @hidden
  39128. * Rescales a texture
  39129. * @param source input texutre
  39130. * @param destination destination texture
  39131. * @param scene scene to use to render the resize
  39132. * @param internalFormat format to use when resizing
  39133. * @param onComplete callback to be called when resize has completed
  39134. */
  39135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39136. /**
  39137. * Gets the current framerate
  39138. * @returns a number representing the framerate
  39139. */
  39140. getFps(): number;
  39141. /**
  39142. * Gets the time spent between current and previous frame
  39143. * @returns a number representing the delta time in ms
  39144. */
  39145. getDeltaTime(): number;
  39146. private _measureFps;
  39147. /** @hidden */
  39148. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39149. /**
  39150. * Update a dynamic index buffer
  39151. * @param indexBuffer defines the target index buffer
  39152. * @param indices defines the data to update
  39153. * @param offset defines the offset in the target index buffer where update should start
  39154. */
  39155. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39156. /**
  39157. * Updates the sample count of a render target texture
  39158. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39159. * @param texture defines the texture to update
  39160. * @param samples defines the sample count to set
  39161. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39162. */
  39163. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39164. /**
  39165. * Updates a depth texture Comparison Mode and Function.
  39166. * If the comparison Function is equal to 0, the mode will be set to none.
  39167. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39168. * @param texture The texture to set the comparison function for
  39169. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39170. */
  39171. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39172. /**
  39173. * Creates a webGL buffer to use with instanciation
  39174. * @param capacity defines the size of the buffer
  39175. * @returns the webGL buffer
  39176. */
  39177. createInstancesBuffer(capacity: number): DataBuffer;
  39178. /**
  39179. * Delete a webGL buffer used with instanciation
  39180. * @param buffer defines the webGL buffer to delete
  39181. */
  39182. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39183. private _clientWaitAsync;
  39184. /** @hidden */
  39185. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39186. dispose(): void;
  39187. private _disableTouchAction;
  39188. /**
  39189. * Display the loading screen
  39190. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39191. */
  39192. displayLoadingUI(): void;
  39193. /**
  39194. * Hide the loading screen
  39195. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39196. */
  39197. hideLoadingUI(): void;
  39198. /**
  39199. * Gets the current loading screen object
  39200. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39201. */
  39202. get loadingScreen(): ILoadingScreen;
  39203. /**
  39204. * Sets the current loading screen object
  39205. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39206. */
  39207. set loadingScreen(loadingScreen: ILoadingScreen);
  39208. /**
  39209. * Sets the current loading screen text
  39210. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39211. */
  39212. set loadingUIText(text: string);
  39213. /**
  39214. * Sets the current loading screen background color
  39215. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39216. */
  39217. set loadingUIBackgroundColor(color: string);
  39218. /** Pointerlock and fullscreen */
  39219. /**
  39220. * Ask the browser to promote the current element to pointerlock mode
  39221. * @param element defines the DOM element to promote
  39222. */
  39223. static _RequestPointerlock(element: HTMLElement): void;
  39224. /**
  39225. * Asks the browser to exit pointerlock mode
  39226. */
  39227. static _ExitPointerlock(): void;
  39228. /**
  39229. * Ask the browser to promote the current element to fullscreen rendering mode
  39230. * @param element defines the DOM element to promote
  39231. */
  39232. static _RequestFullscreen(element: HTMLElement): void;
  39233. /**
  39234. * Asks the browser to exit fullscreen mode
  39235. */
  39236. static _ExitFullscreen(): void;
  39237. }
  39238. }
  39239. declare module "babylonjs/Engines/engineStore" {
  39240. import { Nullable } from "babylonjs/types";
  39241. import { Engine } from "babylonjs/Engines/engine";
  39242. import { Scene } from "babylonjs/scene";
  39243. /**
  39244. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39245. * during the life time of the application.
  39246. */
  39247. export class EngineStore {
  39248. /** Gets the list of created engines */
  39249. static Instances: import("babylonjs/Engines/engine").Engine[];
  39250. /** @hidden */
  39251. static _LastCreatedScene: Nullable<Scene>;
  39252. /**
  39253. * Gets the latest created engine
  39254. */
  39255. static get LastCreatedEngine(): Nullable<Engine>;
  39256. /**
  39257. * Gets the latest created scene
  39258. */
  39259. static get LastCreatedScene(): Nullable<Scene>;
  39260. /**
  39261. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39262. * @ignorenaming
  39263. */
  39264. static UseFallbackTexture: boolean;
  39265. /**
  39266. * Texture content used if a texture cannot loaded
  39267. * @ignorenaming
  39268. */
  39269. static FallbackTexture: string;
  39270. }
  39271. }
  39272. declare module "babylonjs/Misc/promise" {
  39273. /**
  39274. * Helper class that provides a small promise polyfill
  39275. */
  39276. export class PromisePolyfill {
  39277. /**
  39278. * Static function used to check if the polyfill is required
  39279. * If this is the case then the function will inject the polyfill to window.Promise
  39280. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39281. */
  39282. static Apply(force?: boolean): void;
  39283. }
  39284. }
  39285. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39286. /**
  39287. * Interface for screenshot methods with describe argument called `size` as object with options
  39288. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39289. */
  39290. export interface IScreenshotSize {
  39291. /**
  39292. * number in pixels for canvas height
  39293. */
  39294. height?: number;
  39295. /**
  39296. * multiplier allowing render at a higher or lower resolution
  39297. * If value is defined then height and width will be ignored and taken from camera
  39298. */
  39299. precision?: number;
  39300. /**
  39301. * number in pixels for canvas width
  39302. */
  39303. width?: number;
  39304. }
  39305. }
  39306. declare module "babylonjs/Misc/tools" {
  39307. import { Nullable, float } from "babylonjs/types";
  39308. import { DomManagement } from "babylonjs/Misc/domManagement";
  39309. import { WebRequest } from "babylonjs/Misc/webRequest";
  39310. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39311. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39312. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39313. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39314. import { Camera } from "babylonjs/Cameras/camera";
  39315. import { Engine } from "babylonjs/Engines/engine";
  39316. interface IColor4Like {
  39317. r: float;
  39318. g: float;
  39319. b: float;
  39320. a: float;
  39321. }
  39322. /**
  39323. * Class containing a set of static utilities functions
  39324. */
  39325. export class Tools {
  39326. /**
  39327. * Gets or sets the base URL to use to load assets
  39328. */
  39329. static get BaseUrl(): string;
  39330. static set BaseUrl(value: string);
  39331. /**
  39332. * Enable/Disable Custom HTTP Request Headers globally.
  39333. * default = false
  39334. * @see CustomRequestHeaders
  39335. */
  39336. static UseCustomRequestHeaders: boolean;
  39337. /**
  39338. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39339. * i.e. when loading files, where the server/service expects an Authorization header
  39340. */
  39341. static CustomRequestHeaders: {
  39342. [key: string]: string;
  39343. };
  39344. /**
  39345. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39346. */
  39347. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39348. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39349. /**
  39350. * Default behaviour for cors in the application.
  39351. * It can be a string if the expected behavior is identical in the entire app.
  39352. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39353. */
  39354. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39355. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39356. /**
  39357. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39358. * @ignorenaming
  39359. */
  39360. static get UseFallbackTexture(): boolean;
  39361. static set UseFallbackTexture(value: boolean);
  39362. /**
  39363. * Use this object to register external classes like custom textures or material
  39364. * to allow the laoders to instantiate them
  39365. */
  39366. static get RegisteredExternalClasses(): {
  39367. [key: string]: Object;
  39368. };
  39369. static set RegisteredExternalClasses(classes: {
  39370. [key: string]: Object;
  39371. });
  39372. /**
  39373. * Texture content used if a texture cannot loaded
  39374. * @ignorenaming
  39375. */
  39376. static get fallbackTexture(): string;
  39377. static set fallbackTexture(value: string);
  39378. /**
  39379. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39380. * @param u defines the coordinate on X axis
  39381. * @param v defines the coordinate on Y axis
  39382. * @param width defines the width of the source data
  39383. * @param height defines the height of the source data
  39384. * @param pixels defines the source byte array
  39385. * @param color defines the output color
  39386. */
  39387. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39388. /**
  39389. * Interpolates between a and b via alpha
  39390. * @param a The lower value (returned when alpha = 0)
  39391. * @param b The upper value (returned when alpha = 1)
  39392. * @param alpha The interpolation-factor
  39393. * @return The mixed value
  39394. */
  39395. static Mix(a: number, b: number, alpha: number): number;
  39396. /**
  39397. * Tries to instantiate a new object from a given class name
  39398. * @param className defines the class name to instantiate
  39399. * @returns the new object or null if the system was not able to do the instantiation
  39400. */
  39401. static Instantiate(className: string): any;
  39402. /**
  39403. * Provides a slice function that will work even on IE
  39404. * @param data defines the array to slice
  39405. * @param start defines the start of the data (optional)
  39406. * @param end defines the end of the data (optional)
  39407. * @returns the new sliced array
  39408. */
  39409. static Slice<T>(data: T, start?: number, end?: number): T;
  39410. /**
  39411. * Polyfill for setImmediate
  39412. * @param action defines the action to execute after the current execution block
  39413. */
  39414. static SetImmediate(action: () => void): void;
  39415. /**
  39416. * Function indicating if a number is an exponent of 2
  39417. * @param value defines the value to test
  39418. * @returns true if the value is an exponent of 2
  39419. */
  39420. static IsExponentOfTwo(value: number): boolean;
  39421. private static _tmpFloatArray;
  39422. /**
  39423. * Returns the nearest 32-bit single precision float representation of a Number
  39424. * @param value A Number. If the parameter is of a different type, it will get converted
  39425. * to a number or to NaN if it cannot be converted
  39426. * @returns number
  39427. */
  39428. static FloatRound(value: number): number;
  39429. /**
  39430. * Extracts the filename from a path
  39431. * @param path defines the path to use
  39432. * @returns the filename
  39433. */
  39434. static GetFilename(path: string): string;
  39435. /**
  39436. * Extracts the "folder" part of a path (everything before the filename).
  39437. * @param uri The URI to extract the info from
  39438. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39439. * @returns The "folder" part of the path
  39440. */
  39441. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39442. /**
  39443. * Extracts text content from a DOM element hierarchy
  39444. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39445. */
  39446. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39447. /**
  39448. * Convert an angle in radians to degrees
  39449. * @param angle defines the angle to convert
  39450. * @returns the angle in degrees
  39451. */
  39452. static ToDegrees(angle: number): number;
  39453. /**
  39454. * Convert an angle in degrees to radians
  39455. * @param angle defines the angle to convert
  39456. * @returns the angle in radians
  39457. */
  39458. static ToRadians(angle: number): number;
  39459. /**
  39460. * Returns an array if obj is not an array
  39461. * @param obj defines the object to evaluate as an array
  39462. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39463. * @returns either obj directly if obj is an array or a new array containing obj
  39464. */
  39465. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39466. /**
  39467. * Gets the pointer prefix to use
  39468. * @param engine defines the engine we are finding the prefix for
  39469. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39470. */
  39471. static GetPointerPrefix(engine: Engine): string;
  39472. /**
  39473. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39474. * @param url define the url we are trying
  39475. * @param element define the dom element where to configure the cors policy
  39476. */
  39477. static SetCorsBehavior(url: string | string[], element: {
  39478. crossOrigin: string | null;
  39479. }): void;
  39480. /**
  39481. * Removes unwanted characters from an url
  39482. * @param url defines the url to clean
  39483. * @returns the cleaned url
  39484. */
  39485. static CleanUrl(url: string): string;
  39486. /**
  39487. * Gets or sets a function used to pre-process url before using them to load assets
  39488. */
  39489. static get PreprocessUrl(): (url: string) => string;
  39490. static set PreprocessUrl(processor: (url: string) => string);
  39491. /**
  39492. * Loads an image as an HTMLImageElement.
  39493. * @param input url string, ArrayBuffer, or Blob to load
  39494. * @param onLoad callback called when the image successfully loads
  39495. * @param onError callback called when the image fails to load
  39496. * @param offlineProvider offline provider for caching
  39497. * @param mimeType optional mime type
  39498. * @returns the HTMLImageElement of the loaded image
  39499. */
  39500. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39501. /**
  39502. * Loads a file from a url
  39503. * @param url url string, ArrayBuffer, or Blob to load
  39504. * @param onSuccess callback called when the file successfully loads
  39505. * @param onProgress callback called while file is loading (if the server supports this mode)
  39506. * @param offlineProvider defines the offline provider for caching
  39507. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39508. * @param onError callback called when the file fails to load
  39509. * @returns a file request object
  39510. */
  39511. 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;
  39512. /**
  39513. * Loads a file from a url
  39514. * @param url the file url to load
  39515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39516. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39517. */
  39518. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39519. /**
  39520. * Load a script (identified by an url). When the url returns, the
  39521. * content of this file is added into a new script element, attached to the DOM (body element)
  39522. * @param scriptUrl defines the url of the script to laod
  39523. * @param onSuccess defines the callback called when the script is loaded
  39524. * @param onError defines the callback to call if an error occurs
  39525. * @param scriptId defines the id of the script element
  39526. */
  39527. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39528. /**
  39529. * Load an asynchronous script (identified by an url). When the url returns, the
  39530. * content of this file is added into a new script element, attached to the DOM (body element)
  39531. * @param scriptUrl defines the url of the script to laod
  39532. * @param scriptId defines the id of the script element
  39533. * @returns a promise request object
  39534. */
  39535. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39536. /**
  39537. * Loads a file from a blob
  39538. * @param fileToLoad defines the blob to use
  39539. * @param callback defines the callback to call when data is loaded
  39540. * @param progressCallback defines the callback to call during loading process
  39541. * @returns a file request object
  39542. */
  39543. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39544. /**
  39545. * Reads a file from a File object
  39546. * @param file defines the file to load
  39547. * @param onSuccess defines the callback to call when data is loaded
  39548. * @param onProgress defines the callback to call during loading process
  39549. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39550. * @param onError defines the callback to call when an error occurs
  39551. * @returns a file request object
  39552. */
  39553. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39554. /**
  39555. * Creates a data url from a given string content
  39556. * @param content defines the content to convert
  39557. * @returns the new data url link
  39558. */
  39559. static FileAsURL(content: string): string;
  39560. /**
  39561. * Format the given number to a specific decimal format
  39562. * @param value defines the number to format
  39563. * @param decimals defines the number of decimals to use
  39564. * @returns the formatted string
  39565. */
  39566. static Format(value: number, decimals?: number): string;
  39567. /**
  39568. * Tries to copy an object by duplicating every property
  39569. * @param source defines the source object
  39570. * @param destination defines the target object
  39571. * @param doNotCopyList defines a list of properties to avoid
  39572. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39573. */
  39574. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39575. /**
  39576. * Gets a boolean indicating if the given object has no own property
  39577. * @param obj defines the object to test
  39578. * @returns true if object has no own property
  39579. */
  39580. static IsEmpty(obj: any): boolean;
  39581. /**
  39582. * Function used to register events at window level
  39583. * @param windowElement defines the Window object to use
  39584. * @param events defines the events to register
  39585. */
  39586. static RegisterTopRootEvents(windowElement: Window, events: {
  39587. name: string;
  39588. handler: Nullable<(e: FocusEvent) => any>;
  39589. }[]): void;
  39590. /**
  39591. * Function used to unregister events from window level
  39592. * @param windowElement defines the Window object to use
  39593. * @param events defines the events to unregister
  39594. */
  39595. static UnregisterTopRootEvents(windowElement: Window, events: {
  39596. name: string;
  39597. handler: Nullable<(e: FocusEvent) => any>;
  39598. }[]): void;
  39599. /**
  39600. * @ignore
  39601. */
  39602. static _ScreenshotCanvas: HTMLCanvasElement;
  39603. /**
  39604. * Dumps the current bound framebuffer
  39605. * @param width defines the rendering width
  39606. * @param height defines the rendering height
  39607. * @param engine defines the hosting engine
  39608. * @param successCallback defines the callback triggered once the data are available
  39609. * @param mimeType defines the mime type of the result
  39610. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39611. */
  39612. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39613. /**
  39614. * Converts the canvas data to blob.
  39615. * This acts as a polyfill for browsers not supporting the to blob function.
  39616. * @param canvas Defines the canvas to extract the data from
  39617. * @param successCallback Defines the callback triggered once the data are available
  39618. * @param mimeType Defines the mime type of the result
  39619. */
  39620. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39621. /**
  39622. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39623. * @param successCallback defines the callback triggered once the data are available
  39624. * @param mimeType defines the mime type of the result
  39625. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39626. */
  39627. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39628. /**
  39629. * Downloads a blob in the browser
  39630. * @param blob defines the blob to download
  39631. * @param fileName defines the name of the downloaded file
  39632. */
  39633. static Download(blob: Blob, fileName: string): void;
  39634. /**
  39635. * Captures a screenshot of the current rendering
  39636. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39637. * @param engine defines the rendering engine
  39638. * @param camera defines the source camera
  39639. * @param size This parameter can be set to a single number or to an object with the
  39640. * following (optional) properties: precision, width, height. If a single number is passed,
  39641. * it will be used for both width and height. If an object is passed, the screenshot size
  39642. * will be derived from the parameters. The precision property is a multiplier allowing
  39643. * rendering at a higher or lower resolution
  39644. * @param successCallback defines the callback receives a single parameter which contains the
  39645. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39646. * src parameter of an <img> to display it
  39647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39648. * Check your browser for supported MIME types
  39649. */
  39650. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39651. /**
  39652. * Captures a screenshot of the current rendering
  39653. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39654. * @param engine defines the rendering engine
  39655. * @param camera defines the source camera
  39656. * @param size This parameter can be set to a single number or to an object with the
  39657. * following (optional) properties: precision, width, height. If a single number is passed,
  39658. * it will be used for both width and height. If an object is passed, the screenshot size
  39659. * will be derived from the parameters. The precision property is a multiplier allowing
  39660. * rendering at a higher or lower resolution
  39661. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39662. * Check your browser for supported MIME types
  39663. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39664. * to the src parameter of an <img> to display it
  39665. */
  39666. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39667. /**
  39668. * Generates an image screenshot from the specified camera.
  39669. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39670. * @param engine The engine to use for rendering
  39671. * @param camera The camera to use for rendering
  39672. * @param size This parameter can be set to a single number or to an object with the
  39673. * following (optional) properties: precision, width, height. If a single number is passed,
  39674. * it will be used for both width and height. If an object is passed, the screenshot size
  39675. * will be derived from the parameters. The precision property is a multiplier allowing
  39676. * rendering at a higher or lower resolution
  39677. * @param successCallback The callback receives a single parameter which contains the
  39678. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39679. * src parameter of an <img> to display it
  39680. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39681. * Check your browser for supported MIME types
  39682. * @param samples Texture samples (default: 1)
  39683. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39684. * @param fileName A name for for the downloaded file.
  39685. */
  39686. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39687. /**
  39688. * Generates an image screenshot from the specified camera.
  39689. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39690. * @param engine The engine to use for rendering
  39691. * @param camera The camera to use for rendering
  39692. * @param size This parameter can be set to a single number or to an object with the
  39693. * following (optional) properties: precision, width, height. If a single number is passed,
  39694. * it will be used for both width and height. If an object is passed, the screenshot size
  39695. * will be derived from the parameters. The precision property is a multiplier allowing
  39696. * rendering at a higher or lower resolution
  39697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39698. * Check your browser for supported MIME types
  39699. * @param samples Texture samples (default: 1)
  39700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39701. * @param fileName A name for for the downloaded file.
  39702. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39703. * to the src parameter of an <img> to display it
  39704. */
  39705. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39706. /**
  39707. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39708. * Be aware Math.random() could cause collisions, but:
  39709. * "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"
  39710. * @returns a pseudo random id
  39711. */
  39712. static RandomId(): string;
  39713. /**
  39714. * Test if the given uri is a base64 string
  39715. * @param uri The uri to test
  39716. * @return True if the uri is a base64 string or false otherwise
  39717. */
  39718. static IsBase64(uri: string): boolean;
  39719. /**
  39720. * Decode the given base64 uri.
  39721. * @param uri The uri to decode
  39722. * @return The decoded base64 data.
  39723. */
  39724. static DecodeBase64(uri: string): ArrayBuffer;
  39725. /**
  39726. * Gets the absolute url.
  39727. * @param url the input url
  39728. * @return the absolute url
  39729. */
  39730. static GetAbsoluteUrl(url: string): string;
  39731. /**
  39732. * No log
  39733. */
  39734. static readonly NoneLogLevel: number;
  39735. /**
  39736. * Only message logs
  39737. */
  39738. static readonly MessageLogLevel: number;
  39739. /**
  39740. * Only warning logs
  39741. */
  39742. static readonly WarningLogLevel: number;
  39743. /**
  39744. * Only error logs
  39745. */
  39746. static readonly ErrorLogLevel: number;
  39747. /**
  39748. * All logs
  39749. */
  39750. static readonly AllLogLevel: number;
  39751. /**
  39752. * Gets a value indicating the number of loading errors
  39753. * @ignorenaming
  39754. */
  39755. static get errorsCount(): number;
  39756. /**
  39757. * Callback called when a new log is added
  39758. */
  39759. static OnNewCacheEntry: (entry: string) => void;
  39760. /**
  39761. * Log a message to the console
  39762. * @param message defines the message to log
  39763. */
  39764. static Log(message: string): void;
  39765. /**
  39766. * Write a warning message to the console
  39767. * @param message defines the message to log
  39768. */
  39769. static Warn(message: string): void;
  39770. /**
  39771. * Write an error message to the console
  39772. * @param message defines the message to log
  39773. */
  39774. static Error(message: string): void;
  39775. /**
  39776. * Gets current log cache (list of logs)
  39777. */
  39778. static get LogCache(): string;
  39779. /**
  39780. * Clears the log cache
  39781. */
  39782. static ClearLogCache(): void;
  39783. /**
  39784. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39785. */
  39786. static set LogLevels(level: number);
  39787. /**
  39788. * Checks if the window object exists
  39789. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39790. */
  39791. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39792. /**
  39793. * No performance log
  39794. */
  39795. static readonly PerformanceNoneLogLevel: number;
  39796. /**
  39797. * Use user marks to log performance
  39798. */
  39799. static readonly PerformanceUserMarkLogLevel: number;
  39800. /**
  39801. * Log performance to the console
  39802. */
  39803. static readonly PerformanceConsoleLogLevel: number;
  39804. private static _performance;
  39805. /**
  39806. * Sets the current performance log level
  39807. */
  39808. static set PerformanceLogLevel(level: number);
  39809. private static _StartPerformanceCounterDisabled;
  39810. private static _EndPerformanceCounterDisabled;
  39811. private static _StartUserMark;
  39812. private static _EndUserMark;
  39813. private static _StartPerformanceConsole;
  39814. private static _EndPerformanceConsole;
  39815. /**
  39816. * Starts a performance counter
  39817. */
  39818. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39819. /**
  39820. * Ends a specific performance coutner
  39821. */
  39822. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39823. /**
  39824. * Gets either window.performance.now() if supported or Date.now() else
  39825. */
  39826. static get Now(): number;
  39827. /**
  39828. * This method will return the name of the class used to create the instance of the given object.
  39829. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39830. * @param object the object to get the class name from
  39831. * @param isType defines if the object is actually a type
  39832. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39833. */
  39834. static GetClassName(object: any, isType?: boolean): string;
  39835. /**
  39836. * Gets the first element of an array satisfying a given predicate
  39837. * @param array defines the array to browse
  39838. * @param predicate defines the predicate to use
  39839. * @returns null if not found or the element
  39840. */
  39841. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39842. /**
  39843. * This method will return the name of the full name of the class, including its owning module (if any).
  39844. * 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).
  39845. * @param object the object to get the class name from
  39846. * @param isType defines if the object is actually a type
  39847. * @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.
  39848. * @ignorenaming
  39849. */
  39850. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39851. /**
  39852. * Returns a promise that resolves after the given amount of time.
  39853. * @param delay Number of milliseconds to delay
  39854. * @returns Promise that resolves after the given amount of time
  39855. */
  39856. static DelayAsync(delay: number): Promise<void>;
  39857. /**
  39858. * Utility function to detect if the current user agent is Safari
  39859. * @returns whether or not the current user agent is safari
  39860. */
  39861. static IsSafari(): boolean;
  39862. }
  39863. /**
  39864. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39865. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39866. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39867. * @param name The name of the class, case should be preserved
  39868. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39869. */
  39870. export function className(name: string, module?: string): (target: Object) => void;
  39871. /**
  39872. * An implementation of a loop for asynchronous functions.
  39873. */
  39874. export class AsyncLoop {
  39875. /**
  39876. * Defines the number of iterations for the loop
  39877. */
  39878. iterations: number;
  39879. /**
  39880. * Defines the current index of the loop.
  39881. */
  39882. index: number;
  39883. private _done;
  39884. private _fn;
  39885. private _successCallback;
  39886. /**
  39887. * Constructor.
  39888. * @param iterations the number of iterations.
  39889. * @param func the function to run each iteration
  39890. * @param successCallback the callback that will be called upon succesful execution
  39891. * @param offset starting offset.
  39892. */
  39893. constructor(
  39894. /**
  39895. * Defines the number of iterations for the loop
  39896. */
  39897. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39898. /**
  39899. * Execute the next iteration. Must be called after the last iteration was finished.
  39900. */
  39901. executeNext(): void;
  39902. /**
  39903. * Break the loop and run the success callback.
  39904. */
  39905. breakLoop(): void;
  39906. /**
  39907. * Create and run an async loop.
  39908. * @param iterations the number of iterations.
  39909. * @param fn the function to run each iteration
  39910. * @param successCallback the callback that will be called upon succesful execution
  39911. * @param offset starting offset.
  39912. * @returns the created async loop object
  39913. */
  39914. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39915. /**
  39916. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39917. * @param iterations total number of iterations
  39918. * @param syncedIterations number of synchronous iterations in each async iteration.
  39919. * @param fn the function to call each iteration.
  39920. * @param callback a success call back that will be called when iterating stops.
  39921. * @param breakFunction a break condition (optional)
  39922. * @param timeout timeout settings for the setTimeout function. default - 0.
  39923. * @returns the created async loop object
  39924. */
  39925. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39926. }
  39927. }
  39928. declare module "babylonjs/Misc/stringDictionary" {
  39929. import { Nullable } from "babylonjs/types";
  39930. /**
  39931. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39932. * The underlying implementation relies on an associative array to ensure the best performances.
  39933. * The value can be anything including 'null' but except 'undefined'
  39934. */
  39935. export class StringDictionary<T> {
  39936. /**
  39937. * This will clear this dictionary and copy the content from the 'source' one.
  39938. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39939. * @param source the dictionary to take the content from and copy to this dictionary
  39940. */
  39941. copyFrom(source: StringDictionary<T>): void;
  39942. /**
  39943. * Get a value based from its key
  39944. * @param key the given key to get the matching value from
  39945. * @return the value if found, otherwise undefined is returned
  39946. */
  39947. get(key: string): T | undefined;
  39948. /**
  39949. * Get a value from its key or add it if it doesn't exist.
  39950. * This method will ensure you that a given key/data will be present in the dictionary.
  39951. * @param key the given key to get the matching value from
  39952. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39953. * The factory will only be invoked if there's no data for the given key.
  39954. * @return the value corresponding to the key.
  39955. */
  39956. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39957. /**
  39958. * Get a value from its key if present in the dictionary otherwise add it
  39959. * @param key the key to get the value from
  39960. * @param val if there's no such key/value pair in the dictionary add it with this value
  39961. * @return the value corresponding to the key
  39962. */
  39963. getOrAdd(key: string, val: T): T;
  39964. /**
  39965. * Check if there's a given key in the dictionary
  39966. * @param key the key to check for
  39967. * @return true if the key is present, false otherwise
  39968. */
  39969. contains(key: string): boolean;
  39970. /**
  39971. * Add a new key and its corresponding value
  39972. * @param key the key to add
  39973. * @param value the value corresponding to the key
  39974. * @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
  39975. */
  39976. add(key: string, value: T): boolean;
  39977. /**
  39978. * Update a specific value associated to a key
  39979. * @param key defines the key to use
  39980. * @param value defines the value to store
  39981. * @returns true if the value was updated (or false if the key was not found)
  39982. */
  39983. set(key: string, value: T): boolean;
  39984. /**
  39985. * Get the element of the given key and remove it from the dictionary
  39986. * @param key defines the key to search
  39987. * @returns the value associated with the key or null if not found
  39988. */
  39989. getAndRemove(key: string): Nullable<T>;
  39990. /**
  39991. * Remove a key/value from the dictionary.
  39992. * @param key the key to remove
  39993. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39994. */
  39995. remove(key: string): boolean;
  39996. /**
  39997. * Clear the whole content of the dictionary
  39998. */
  39999. clear(): void;
  40000. /**
  40001. * Gets the current count
  40002. */
  40003. get count(): number;
  40004. /**
  40005. * Execute a callback on each key/val of the dictionary.
  40006. * Note that you can remove any element in this dictionary in the callback implementation
  40007. * @param callback the callback to execute on a given key/value pair
  40008. */
  40009. forEach(callback: (key: string, val: T) => void): void;
  40010. /**
  40011. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40012. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40013. * Note that you can remove any element in this dictionary in the callback implementation
  40014. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40015. * @returns the first item
  40016. */
  40017. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40018. private _count;
  40019. private _data;
  40020. }
  40021. }
  40022. declare module "babylonjs/Collisions/collisionCoordinator" {
  40023. import { Nullable } from "babylonjs/types";
  40024. import { Scene } from "babylonjs/scene";
  40025. import { Vector3 } from "babylonjs/Maths/math.vector";
  40026. import { Collider } from "babylonjs/Collisions/collider";
  40027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40028. /** @hidden */
  40029. export interface ICollisionCoordinator {
  40030. createCollider(): Collider;
  40031. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40032. init(scene: Scene): void;
  40033. }
  40034. /** @hidden */
  40035. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40036. private _scene;
  40037. private _scaledPosition;
  40038. private _scaledVelocity;
  40039. private _finalPosition;
  40040. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40041. createCollider(): Collider;
  40042. init(scene: Scene): void;
  40043. private _collideWithWorld;
  40044. }
  40045. }
  40046. declare module "babylonjs/Inputs/scene.inputManager" {
  40047. import { Nullable } from "babylonjs/types";
  40048. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40049. import { Vector2 } from "babylonjs/Maths/math.vector";
  40050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40051. import { Scene } from "babylonjs/scene";
  40052. /**
  40053. * Class used to manage all inputs for the scene.
  40054. */
  40055. export class InputManager {
  40056. /** The distance in pixel that you have to move to prevent some events */
  40057. static DragMovementThreshold: number;
  40058. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40059. static LongPressDelay: number;
  40060. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40061. static DoubleClickDelay: number;
  40062. /** If you need to check double click without raising a single click at first click, enable this flag */
  40063. static ExclusiveDoubleClickMode: boolean;
  40064. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  40065. private _alreadyAttached;
  40066. private _wheelEventName;
  40067. private _onPointerMove;
  40068. private _onPointerDown;
  40069. private _onPointerUp;
  40070. private _initClickEvent;
  40071. private _initActionManager;
  40072. private _delayedSimpleClick;
  40073. private _delayedSimpleClickTimeout;
  40074. private _previousDelayedSimpleClickTimeout;
  40075. private _meshPickProceed;
  40076. private _previousButtonPressed;
  40077. private _currentPickResult;
  40078. private _previousPickResult;
  40079. private _totalPointersPressed;
  40080. private _doubleClickOccured;
  40081. private _pointerOverMesh;
  40082. private _pickedDownMesh;
  40083. private _pickedUpMesh;
  40084. private _pointerX;
  40085. private _pointerY;
  40086. private _unTranslatedPointerX;
  40087. private _unTranslatedPointerY;
  40088. private _startingPointerPosition;
  40089. private _previousStartingPointerPosition;
  40090. private _startingPointerTime;
  40091. private _previousStartingPointerTime;
  40092. private _pointerCaptures;
  40093. private _onKeyDown;
  40094. private _onKeyUp;
  40095. private _onCanvasFocusObserver;
  40096. private _onCanvasBlurObserver;
  40097. private _scene;
  40098. /**
  40099. * Creates a new InputManager
  40100. * @param scene defines the hosting scene
  40101. */
  40102. constructor(scene: Scene);
  40103. /**
  40104. * Gets the mesh that is currently under the pointer
  40105. */
  40106. get meshUnderPointer(): Nullable<AbstractMesh>;
  40107. /**
  40108. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40109. */
  40110. get unTranslatedPointer(): Vector2;
  40111. /**
  40112. * Gets or sets the current on-screen X position of the pointer
  40113. */
  40114. get pointerX(): number;
  40115. set pointerX(value: number);
  40116. /**
  40117. * Gets or sets the current on-screen Y position of the pointer
  40118. */
  40119. get pointerY(): number;
  40120. set pointerY(value: number);
  40121. private _updatePointerPosition;
  40122. private _processPointerMove;
  40123. private _setRayOnPointerInfo;
  40124. private _checkPrePointerObservable;
  40125. /**
  40126. * Use this method to simulate a pointer move on a mesh
  40127. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40128. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40129. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40130. */
  40131. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40132. /**
  40133. * Use this method to simulate a pointer down on a mesh
  40134. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40135. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40136. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40137. */
  40138. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40139. private _processPointerDown;
  40140. /** @hidden */
  40141. _isPointerSwiping(): boolean;
  40142. /**
  40143. * Use this method to simulate a pointer up on a mesh
  40144. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40145. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40146. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40147. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40148. */
  40149. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40150. private _processPointerUp;
  40151. /**
  40152. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40153. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40154. * @returns true if the pointer was captured
  40155. */
  40156. isPointerCaptured(pointerId?: number): boolean;
  40157. /**
  40158. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40159. * @param attachUp defines if you want to attach events to pointerup
  40160. * @param attachDown defines if you want to attach events to pointerdown
  40161. * @param attachMove defines if you want to attach events to pointermove
  40162. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40163. */
  40164. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40165. /**
  40166. * Detaches all event handlers
  40167. */
  40168. detachControl(): void;
  40169. /**
  40170. * Force the value of meshUnderPointer
  40171. * @param mesh defines the mesh to use
  40172. */
  40173. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40174. /**
  40175. * Gets the mesh under the pointer
  40176. * @returns a Mesh or null if no mesh is under the pointer
  40177. */
  40178. getPointerOverMesh(): Nullable<AbstractMesh>;
  40179. }
  40180. }
  40181. declare module "babylonjs/Animations/animationGroup" {
  40182. import { Animatable } from "babylonjs/Animations/animatable";
  40183. import { Animation } from "babylonjs/Animations/animation";
  40184. import { Scene, IDisposable } from "babylonjs/scene";
  40185. import { Observable } from "babylonjs/Misc/observable";
  40186. import { Nullable } from "babylonjs/types";
  40187. import "babylonjs/Animations/animatable";
  40188. /**
  40189. * This class defines the direct association between an animation and a target
  40190. */
  40191. export class TargetedAnimation {
  40192. /**
  40193. * Animation to perform
  40194. */
  40195. animation: Animation;
  40196. /**
  40197. * Target to animate
  40198. */
  40199. target: any;
  40200. /**
  40201. * Returns the string "TargetedAnimation"
  40202. * @returns "TargetedAnimation"
  40203. */
  40204. getClassName(): string;
  40205. /**
  40206. * Serialize the object
  40207. * @returns the JSON object representing the current entity
  40208. */
  40209. serialize(): any;
  40210. }
  40211. /**
  40212. * Use this class to create coordinated animations on multiple targets
  40213. */
  40214. export class AnimationGroup implements IDisposable {
  40215. /** The name of the animation group */
  40216. name: string;
  40217. private _scene;
  40218. private _targetedAnimations;
  40219. private _animatables;
  40220. private _from;
  40221. private _to;
  40222. private _isStarted;
  40223. private _isPaused;
  40224. private _speedRatio;
  40225. private _loopAnimation;
  40226. private _isAdditive;
  40227. /**
  40228. * Gets or sets the unique id of the node
  40229. */
  40230. uniqueId: number;
  40231. /**
  40232. * This observable will notify when one animation have ended
  40233. */
  40234. onAnimationEndObservable: Observable<TargetedAnimation>;
  40235. /**
  40236. * Observer raised when one animation loops
  40237. */
  40238. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40239. /**
  40240. * Observer raised when all animations have looped
  40241. */
  40242. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40243. /**
  40244. * This observable will notify when all animations have ended.
  40245. */
  40246. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40247. /**
  40248. * This observable will notify when all animations have paused.
  40249. */
  40250. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40251. /**
  40252. * This observable will notify when all animations are playing.
  40253. */
  40254. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40255. /**
  40256. * Gets the first frame
  40257. */
  40258. get from(): number;
  40259. /**
  40260. * Gets the last frame
  40261. */
  40262. get to(): number;
  40263. /**
  40264. * Define if the animations are started
  40265. */
  40266. get isStarted(): boolean;
  40267. /**
  40268. * Gets a value indicating that the current group is playing
  40269. */
  40270. get isPlaying(): boolean;
  40271. /**
  40272. * Gets or sets the speed ratio to use for all animations
  40273. */
  40274. get speedRatio(): number;
  40275. /**
  40276. * Gets or sets the speed ratio to use for all animations
  40277. */
  40278. set speedRatio(value: number);
  40279. /**
  40280. * Gets or sets if all animations should loop or not
  40281. */
  40282. get loopAnimation(): boolean;
  40283. set loopAnimation(value: boolean);
  40284. /**
  40285. * Gets or sets if all animations should be evaluated additively
  40286. */
  40287. get isAdditive(): boolean;
  40288. set isAdditive(value: boolean);
  40289. /**
  40290. * Gets the targeted animations for this animation group
  40291. */
  40292. get targetedAnimations(): Array<TargetedAnimation>;
  40293. /**
  40294. * returning the list of animatables controlled by this animation group.
  40295. */
  40296. get animatables(): Array<Animatable>;
  40297. /**
  40298. * Gets the list of target animations
  40299. */
  40300. get children(): TargetedAnimation[];
  40301. /**
  40302. * Instantiates a new Animation Group.
  40303. * This helps managing several animations at once.
  40304. * @see https://doc.babylonjs.com/how_to/group
  40305. * @param name Defines the name of the group
  40306. * @param scene Defines the scene the group belongs to
  40307. */
  40308. constructor(
  40309. /** The name of the animation group */
  40310. name: string, scene?: Nullable<Scene>);
  40311. /**
  40312. * Add an animation (with its target) in the group
  40313. * @param animation defines the animation we want to add
  40314. * @param target defines the target of the animation
  40315. * @returns the TargetedAnimation object
  40316. */
  40317. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40318. /**
  40319. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40320. * It can add constant keys at begin or end
  40321. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40322. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40323. * @returns the animation group
  40324. */
  40325. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40326. private _animationLoopCount;
  40327. private _animationLoopFlags;
  40328. private _processLoop;
  40329. /**
  40330. * Start all animations on given targets
  40331. * @param loop defines if animations must loop
  40332. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40333. * @param from defines the from key (optional)
  40334. * @param to defines the to key (optional)
  40335. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40336. * @returns the current animation group
  40337. */
  40338. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40339. /**
  40340. * Pause all animations
  40341. * @returns the animation group
  40342. */
  40343. pause(): AnimationGroup;
  40344. /**
  40345. * Play all animations to initial state
  40346. * This function will start() the animations if they were not started or will restart() them if they were paused
  40347. * @param loop defines if animations must loop
  40348. * @returns the animation group
  40349. */
  40350. play(loop?: boolean): AnimationGroup;
  40351. /**
  40352. * Reset all animations to initial state
  40353. * @returns the animation group
  40354. */
  40355. reset(): AnimationGroup;
  40356. /**
  40357. * Restart animations from key 0
  40358. * @returns the animation group
  40359. */
  40360. restart(): AnimationGroup;
  40361. /**
  40362. * Stop all animations
  40363. * @returns the animation group
  40364. */
  40365. stop(): AnimationGroup;
  40366. /**
  40367. * Set animation weight for all animatables
  40368. * @param weight defines the weight to use
  40369. * @return the animationGroup
  40370. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40371. */
  40372. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40373. /**
  40374. * Synchronize and normalize all animatables with a source animatable
  40375. * @param root defines the root animatable to synchronize with
  40376. * @return the animationGroup
  40377. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40378. */
  40379. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40380. /**
  40381. * Goes to a specific frame in this animation group
  40382. * @param frame the frame number to go to
  40383. * @return the animationGroup
  40384. */
  40385. goToFrame(frame: number): AnimationGroup;
  40386. /**
  40387. * Dispose all associated resources
  40388. */
  40389. dispose(): void;
  40390. private _checkAnimationGroupEnded;
  40391. /**
  40392. * Clone the current animation group and returns a copy
  40393. * @param newName defines the name of the new group
  40394. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40395. * @returns the new aniamtion group
  40396. */
  40397. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40398. /**
  40399. * Serializes the animationGroup to an object
  40400. * @returns Serialized object
  40401. */
  40402. serialize(): any;
  40403. /**
  40404. * Returns a new AnimationGroup object parsed from the source provided.
  40405. * @param parsedAnimationGroup defines the source
  40406. * @param scene defines the scene that will receive the animationGroup
  40407. * @returns a new AnimationGroup
  40408. */
  40409. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40410. /**
  40411. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40412. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40413. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40414. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40415. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40416. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40417. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40418. */
  40419. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40420. /**
  40421. * Returns the string "AnimationGroup"
  40422. * @returns "AnimationGroup"
  40423. */
  40424. getClassName(): string;
  40425. /**
  40426. * Creates a detailled string about the object
  40427. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40428. * @returns a string representing the object
  40429. */
  40430. toString(fullDetails?: boolean): string;
  40431. }
  40432. }
  40433. declare module "babylonjs/scene" {
  40434. import { Nullable } from "babylonjs/types";
  40435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40436. import { Observable } from "babylonjs/Misc/observable";
  40437. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40438. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40439. import { Geometry } from "babylonjs/Meshes/geometry";
  40440. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40443. import { Mesh } from "babylonjs/Meshes/mesh";
  40444. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40445. import { Bone } from "babylonjs/Bones/bone";
  40446. import { Skeleton } from "babylonjs/Bones/skeleton";
  40447. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40448. import { Camera } from "babylonjs/Cameras/camera";
  40449. import { AbstractScene } from "babylonjs/abstractScene";
  40450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40452. import { Material } from "babylonjs/Materials/material";
  40453. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40454. import { Effect } from "babylonjs/Materials/effect";
  40455. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40456. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40457. import { Light } from "babylonjs/Lights/light";
  40458. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40459. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40460. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40461. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40462. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40463. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40464. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40465. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40466. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40467. import { Engine } from "babylonjs/Engines/engine";
  40468. import { Node } from "babylonjs/node";
  40469. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40470. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40471. import { WebRequest } from "babylonjs/Misc/webRequest";
  40472. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40473. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40474. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40475. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40476. import { Plane } from "babylonjs/Maths/math.plane";
  40477. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40478. import { Ray } from "babylonjs/Culling/ray";
  40479. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40480. import { Animation } from "babylonjs/Animations/animation";
  40481. import { Animatable } from "babylonjs/Animations/animatable";
  40482. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40483. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40484. import { Collider } from "babylonjs/Collisions/collider";
  40485. /**
  40486. * Define an interface for all classes that will hold resources
  40487. */
  40488. export interface IDisposable {
  40489. /**
  40490. * Releases all held resources
  40491. */
  40492. dispose(): void;
  40493. }
  40494. /** Interface defining initialization parameters for Scene class */
  40495. export interface SceneOptions {
  40496. /**
  40497. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40498. * It will improve performance when the number of geometries becomes important.
  40499. */
  40500. useGeometryUniqueIdsMap?: boolean;
  40501. /**
  40502. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40503. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40504. */
  40505. useMaterialMeshMap?: boolean;
  40506. /**
  40507. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40508. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40509. */
  40510. useClonedMeshMap?: boolean;
  40511. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40512. virtual?: boolean;
  40513. }
  40514. /**
  40515. * Represents a scene to be rendered by the engine.
  40516. * @see https://doc.babylonjs.com/features/scene
  40517. */
  40518. export class Scene extends AbstractScene implements IAnimatable {
  40519. /** The fog is deactivated */
  40520. static readonly FOGMODE_NONE: number;
  40521. /** The fog density is following an exponential function */
  40522. static readonly FOGMODE_EXP: number;
  40523. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40524. static readonly FOGMODE_EXP2: number;
  40525. /** The fog density is following a linear function. */
  40526. static readonly FOGMODE_LINEAR: number;
  40527. /**
  40528. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40529. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40530. */
  40531. static MinDeltaTime: number;
  40532. /**
  40533. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40534. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40535. */
  40536. static MaxDeltaTime: number;
  40537. /**
  40538. * Factory used to create the default material.
  40539. * @param name The name of the material to create
  40540. * @param scene The scene to create the material for
  40541. * @returns The default material
  40542. */
  40543. static DefaultMaterialFactory(scene: Scene): Material;
  40544. /**
  40545. * Factory used to create the a collision coordinator.
  40546. * @returns The collision coordinator
  40547. */
  40548. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40549. /** @hidden */
  40550. _inputManager: InputManager;
  40551. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40552. cameraToUseForPointers: Nullable<Camera>;
  40553. /** @hidden */
  40554. readonly _isScene: boolean;
  40555. /** @hidden */
  40556. _blockEntityCollection: boolean;
  40557. /**
  40558. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40559. */
  40560. autoClear: boolean;
  40561. /**
  40562. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40563. */
  40564. autoClearDepthAndStencil: boolean;
  40565. /**
  40566. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40567. */
  40568. clearColor: Color4;
  40569. /**
  40570. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40571. */
  40572. ambientColor: Color3;
  40573. /**
  40574. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40575. * It should only be one of the following (if not the default embedded one):
  40576. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40577. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40578. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40579. * The material properties need to be setup according to the type of texture in use.
  40580. */
  40581. environmentBRDFTexture: BaseTexture;
  40582. /** @hidden */
  40583. protected _environmentTexture: Nullable<BaseTexture>;
  40584. /**
  40585. * Texture used in all pbr material as the reflection texture.
  40586. * As in the majority of the scene they are the same (exception for multi room and so on),
  40587. * this is easier to reference from here than from all the materials.
  40588. */
  40589. get environmentTexture(): Nullable<BaseTexture>;
  40590. /**
  40591. * Texture used in all pbr material as the reflection texture.
  40592. * As in the majority of the scene they are the same (exception for multi room and so on),
  40593. * this is easier to set here than in all the materials.
  40594. */
  40595. set environmentTexture(value: Nullable<BaseTexture>);
  40596. /** @hidden */
  40597. protected _environmentIntensity: number;
  40598. /**
  40599. * Intensity of the environment in all pbr material.
  40600. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40601. * As in the majority of the scene they are the same (exception for multi room and so on),
  40602. * this is easier to reference from here than from all the materials.
  40603. */
  40604. get environmentIntensity(): number;
  40605. /**
  40606. * Intensity of the environment in all pbr material.
  40607. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40608. * As in the majority of the scene they are the same (exception for multi room and so on),
  40609. * this is easier to set here than in all the materials.
  40610. */
  40611. set environmentIntensity(value: number);
  40612. /** @hidden */
  40613. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40614. /**
  40615. * Default image processing configuration used either in the rendering
  40616. * Forward main pass or through the imageProcessingPostProcess if present.
  40617. * As in the majority of the scene they are the same (exception for multi camera),
  40618. * this is easier to reference from here than from all the materials and post process.
  40619. *
  40620. * No setter as we it is a shared configuration, you can set the values instead.
  40621. */
  40622. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40623. private _forceWireframe;
  40624. /**
  40625. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40626. */
  40627. set forceWireframe(value: boolean);
  40628. get forceWireframe(): boolean;
  40629. private _skipFrustumClipping;
  40630. /**
  40631. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40632. */
  40633. set skipFrustumClipping(value: boolean);
  40634. get skipFrustumClipping(): boolean;
  40635. private _forcePointsCloud;
  40636. /**
  40637. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40638. */
  40639. set forcePointsCloud(value: boolean);
  40640. get forcePointsCloud(): boolean;
  40641. /**
  40642. * Gets or sets the active clipplane 1
  40643. */
  40644. clipPlane: Nullable<Plane>;
  40645. /**
  40646. * Gets or sets the active clipplane 2
  40647. */
  40648. clipPlane2: Nullable<Plane>;
  40649. /**
  40650. * Gets or sets the active clipplane 3
  40651. */
  40652. clipPlane3: Nullable<Plane>;
  40653. /**
  40654. * Gets or sets the active clipplane 4
  40655. */
  40656. clipPlane4: Nullable<Plane>;
  40657. /**
  40658. * Gets or sets the active clipplane 5
  40659. */
  40660. clipPlane5: Nullable<Plane>;
  40661. /**
  40662. * Gets or sets the active clipplane 6
  40663. */
  40664. clipPlane6: Nullable<Plane>;
  40665. /**
  40666. * Gets or sets a boolean indicating if animations are enabled
  40667. */
  40668. animationsEnabled: boolean;
  40669. private _animationPropertiesOverride;
  40670. /**
  40671. * Gets or sets the animation properties override
  40672. */
  40673. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40674. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40675. /**
  40676. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40677. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40678. */
  40679. useConstantAnimationDeltaTime: boolean;
  40680. /**
  40681. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40682. * Please note that it requires to run a ray cast through the scene on every frame
  40683. */
  40684. constantlyUpdateMeshUnderPointer: boolean;
  40685. /**
  40686. * Defines the HTML cursor to use when hovering over interactive elements
  40687. */
  40688. hoverCursor: string;
  40689. /**
  40690. * Defines the HTML default cursor to use (empty by default)
  40691. */
  40692. defaultCursor: string;
  40693. /**
  40694. * Defines whether cursors are handled by the scene.
  40695. */
  40696. doNotHandleCursors: boolean;
  40697. /**
  40698. * This is used to call preventDefault() on pointer down
  40699. * in order to block unwanted artifacts like system double clicks
  40700. */
  40701. preventDefaultOnPointerDown: boolean;
  40702. /**
  40703. * This is used to call preventDefault() on pointer up
  40704. * in order to block unwanted artifacts like system double clicks
  40705. */
  40706. preventDefaultOnPointerUp: boolean;
  40707. /**
  40708. * Gets or sets user defined metadata
  40709. */
  40710. metadata: any;
  40711. /**
  40712. * For internal use only. Please do not use.
  40713. */
  40714. reservedDataStore: any;
  40715. /**
  40716. * Gets the name of the plugin used to load this scene (null by default)
  40717. */
  40718. loadingPluginName: string;
  40719. /**
  40720. * Use this array to add regular expressions used to disable offline support for specific urls
  40721. */
  40722. disableOfflineSupportExceptionRules: RegExp[];
  40723. /**
  40724. * An event triggered when the scene is disposed.
  40725. */
  40726. onDisposeObservable: Observable<Scene>;
  40727. private _onDisposeObserver;
  40728. /** Sets a function to be executed when this scene is disposed. */
  40729. set onDispose(callback: () => void);
  40730. /**
  40731. * An event triggered before rendering the scene (right after animations and physics)
  40732. */
  40733. onBeforeRenderObservable: Observable<Scene>;
  40734. private _onBeforeRenderObserver;
  40735. /** Sets a function to be executed before rendering this scene */
  40736. set beforeRender(callback: Nullable<() => void>);
  40737. /**
  40738. * An event triggered after rendering the scene
  40739. */
  40740. onAfterRenderObservable: Observable<Scene>;
  40741. /**
  40742. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40743. */
  40744. onAfterRenderCameraObservable: Observable<Camera>;
  40745. private _onAfterRenderObserver;
  40746. /** Sets a function to be executed after rendering this scene */
  40747. set afterRender(callback: Nullable<() => void>);
  40748. /**
  40749. * An event triggered before animating the scene
  40750. */
  40751. onBeforeAnimationsObservable: Observable<Scene>;
  40752. /**
  40753. * An event triggered after animations processing
  40754. */
  40755. onAfterAnimationsObservable: Observable<Scene>;
  40756. /**
  40757. * An event triggered before draw calls are ready to be sent
  40758. */
  40759. onBeforeDrawPhaseObservable: Observable<Scene>;
  40760. /**
  40761. * An event triggered after draw calls have been sent
  40762. */
  40763. onAfterDrawPhaseObservable: Observable<Scene>;
  40764. /**
  40765. * An event triggered when the scene is ready
  40766. */
  40767. onReadyObservable: Observable<Scene>;
  40768. /**
  40769. * An event triggered before rendering a camera
  40770. */
  40771. onBeforeCameraRenderObservable: Observable<Camera>;
  40772. private _onBeforeCameraRenderObserver;
  40773. /** Sets a function to be executed before rendering a camera*/
  40774. set beforeCameraRender(callback: () => void);
  40775. /**
  40776. * An event triggered after rendering a camera
  40777. */
  40778. onAfterCameraRenderObservable: Observable<Camera>;
  40779. private _onAfterCameraRenderObserver;
  40780. /** Sets a function to be executed after rendering a camera*/
  40781. set afterCameraRender(callback: () => void);
  40782. /**
  40783. * An event triggered when active meshes evaluation is about to start
  40784. */
  40785. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40786. /**
  40787. * An event triggered when active meshes evaluation is done
  40788. */
  40789. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40790. /**
  40791. * An event triggered when particles rendering is about to start
  40792. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40793. */
  40794. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40795. /**
  40796. * An event triggered when particles rendering is done
  40797. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40798. */
  40799. onAfterParticlesRenderingObservable: Observable<Scene>;
  40800. /**
  40801. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40802. */
  40803. onDataLoadedObservable: Observable<Scene>;
  40804. /**
  40805. * An event triggered when a camera is created
  40806. */
  40807. onNewCameraAddedObservable: Observable<Camera>;
  40808. /**
  40809. * An event triggered when a camera is removed
  40810. */
  40811. onCameraRemovedObservable: Observable<Camera>;
  40812. /**
  40813. * An event triggered when a light is created
  40814. */
  40815. onNewLightAddedObservable: Observable<Light>;
  40816. /**
  40817. * An event triggered when a light is removed
  40818. */
  40819. onLightRemovedObservable: Observable<Light>;
  40820. /**
  40821. * An event triggered when a geometry is created
  40822. */
  40823. onNewGeometryAddedObservable: Observable<Geometry>;
  40824. /**
  40825. * An event triggered when a geometry is removed
  40826. */
  40827. onGeometryRemovedObservable: Observable<Geometry>;
  40828. /**
  40829. * An event triggered when a transform node is created
  40830. */
  40831. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40832. /**
  40833. * An event triggered when a transform node is removed
  40834. */
  40835. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40836. /**
  40837. * An event triggered when a mesh is created
  40838. */
  40839. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40840. /**
  40841. * An event triggered when a mesh is removed
  40842. */
  40843. onMeshRemovedObservable: Observable<AbstractMesh>;
  40844. /**
  40845. * An event triggered when a skeleton is created
  40846. */
  40847. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40848. /**
  40849. * An event triggered when a skeleton is removed
  40850. */
  40851. onSkeletonRemovedObservable: Observable<Skeleton>;
  40852. /**
  40853. * An event triggered when a material is created
  40854. */
  40855. onNewMaterialAddedObservable: Observable<Material>;
  40856. /**
  40857. * An event triggered when a material is removed
  40858. */
  40859. onMaterialRemovedObservable: Observable<Material>;
  40860. /**
  40861. * An event triggered when a texture is created
  40862. */
  40863. onNewTextureAddedObservable: Observable<BaseTexture>;
  40864. /**
  40865. * An event triggered when a texture is removed
  40866. */
  40867. onTextureRemovedObservable: Observable<BaseTexture>;
  40868. /**
  40869. * An event triggered when render targets are about to be rendered
  40870. * Can happen multiple times per frame.
  40871. */
  40872. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40873. /**
  40874. * An event triggered when render targets were rendered.
  40875. * Can happen multiple times per frame.
  40876. */
  40877. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40878. /**
  40879. * An event triggered before calculating deterministic simulation step
  40880. */
  40881. onBeforeStepObservable: Observable<Scene>;
  40882. /**
  40883. * An event triggered after calculating deterministic simulation step
  40884. */
  40885. onAfterStepObservable: Observable<Scene>;
  40886. /**
  40887. * An event triggered when the activeCamera property is updated
  40888. */
  40889. onActiveCameraChanged: Observable<Scene>;
  40890. /**
  40891. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40892. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40893. * 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)
  40894. */
  40895. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40896. /**
  40897. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40898. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40899. * 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)
  40900. */
  40901. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40902. /**
  40903. * This Observable will when a mesh has been imported into the scene.
  40904. */
  40905. onMeshImportedObservable: Observable<AbstractMesh>;
  40906. /**
  40907. * This Observable will when an animation file has been imported into the scene.
  40908. */
  40909. onAnimationFileImportedObservable: Observable<Scene>;
  40910. /**
  40911. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40912. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40913. */
  40914. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40915. /** @hidden */
  40916. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40917. /**
  40918. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40919. */
  40920. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40921. /**
  40922. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40923. */
  40924. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40925. /**
  40926. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40927. */
  40928. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40929. /** Callback called when a pointer move is detected */
  40930. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40931. /** Callback called when a pointer down is detected */
  40932. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40933. /** Callback called when a pointer up is detected */
  40934. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40935. /** Callback called when a pointer pick is detected */
  40936. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40937. /**
  40938. * 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).
  40939. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40940. */
  40941. onPrePointerObservable: Observable<PointerInfoPre>;
  40942. /**
  40943. * Observable event triggered each time an input event is received from the rendering canvas
  40944. */
  40945. onPointerObservable: Observable<PointerInfo>;
  40946. /**
  40947. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40948. */
  40949. get unTranslatedPointer(): Vector2;
  40950. /**
  40951. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40952. */
  40953. static get DragMovementThreshold(): number;
  40954. static set DragMovementThreshold(value: number);
  40955. /**
  40956. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40957. */
  40958. static get LongPressDelay(): number;
  40959. static set LongPressDelay(value: number);
  40960. /**
  40961. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40962. */
  40963. static get DoubleClickDelay(): number;
  40964. static set DoubleClickDelay(value: number);
  40965. /** If you need to check double click without raising a single click at first click, enable this flag */
  40966. static get ExclusiveDoubleClickMode(): boolean;
  40967. static set ExclusiveDoubleClickMode(value: boolean);
  40968. /** @hidden */
  40969. _mirroredCameraPosition: Nullable<Vector3>;
  40970. /**
  40971. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40972. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40973. */
  40974. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40975. /**
  40976. * Observable event triggered each time an keyboard event is received from the hosting window
  40977. */
  40978. onKeyboardObservable: Observable<KeyboardInfo>;
  40979. private _useRightHandedSystem;
  40980. /**
  40981. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40982. */
  40983. set useRightHandedSystem(value: boolean);
  40984. get useRightHandedSystem(): boolean;
  40985. private _timeAccumulator;
  40986. private _currentStepId;
  40987. private _currentInternalStep;
  40988. /**
  40989. * Sets the step Id used by deterministic lock step
  40990. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40991. * @param newStepId defines the step Id
  40992. */
  40993. setStepId(newStepId: number): void;
  40994. /**
  40995. * Gets the step Id used by deterministic lock step
  40996. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40997. * @returns the step Id
  40998. */
  40999. getStepId(): number;
  41000. /**
  41001. * Gets the internal step used by deterministic lock step
  41002. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41003. * @returns the internal step
  41004. */
  41005. getInternalStep(): number;
  41006. private _fogEnabled;
  41007. /**
  41008. * Gets or sets a boolean indicating if fog is enabled on this scene
  41009. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41010. * (Default is true)
  41011. */
  41012. set fogEnabled(value: boolean);
  41013. get fogEnabled(): boolean;
  41014. private _fogMode;
  41015. /**
  41016. * Gets or sets the fog mode to use
  41017. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41018. * | mode | value |
  41019. * | --- | --- |
  41020. * | FOGMODE_NONE | 0 |
  41021. * | FOGMODE_EXP | 1 |
  41022. * | FOGMODE_EXP2 | 2 |
  41023. * | FOGMODE_LINEAR | 3 |
  41024. */
  41025. set fogMode(value: number);
  41026. get fogMode(): number;
  41027. /**
  41028. * Gets or sets the fog color to use
  41029. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41030. * (Default is Color3(0.2, 0.2, 0.3))
  41031. */
  41032. fogColor: Color3;
  41033. /**
  41034. * Gets or sets the fog density to use
  41035. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41036. * (Default is 0.1)
  41037. */
  41038. fogDensity: number;
  41039. /**
  41040. * Gets or sets the fog start distance to use
  41041. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41042. * (Default is 0)
  41043. */
  41044. fogStart: number;
  41045. /**
  41046. * Gets or sets the fog end distance to use
  41047. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41048. * (Default is 1000)
  41049. */
  41050. fogEnd: number;
  41051. /**
  41052. * Flag indicating that the frame buffer binding is handled by another component
  41053. */
  41054. prePass: boolean;
  41055. private _shadowsEnabled;
  41056. /**
  41057. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41058. */
  41059. set shadowsEnabled(value: boolean);
  41060. get shadowsEnabled(): boolean;
  41061. private _lightsEnabled;
  41062. /**
  41063. * Gets or sets a boolean indicating if lights are enabled on this scene
  41064. */
  41065. set lightsEnabled(value: boolean);
  41066. get lightsEnabled(): boolean;
  41067. /** All of the active cameras added to this scene. */
  41068. activeCameras: Camera[];
  41069. /** @hidden */
  41070. _activeCamera: Nullable<Camera>;
  41071. /** Gets or sets the current active camera */
  41072. get activeCamera(): Nullable<Camera>;
  41073. set activeCamera(value: Nullable<Camera>);
  41074. private _defaultMaterial;
  41075. /** The default material used on meshes when no material is affected */
  41076. get defaultMaterial(): Material;
  41077. /** The default material used on meshes when no material is affected */
  41078. set defaultMaterial(value: Material);
  41079. private _texturesEnabled;
  41080. /**
  41081. * Gets or sets a boolean indicating if textures are enabled on this scene
  41082. */
  41083. set texturesEnabled(value: boolean);
  41084. get texturesEnabled(): boolean;
  41085. /**
  41086. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41087. */
  41088. physicsEnabled: boolean;
  41089. /**
  41090. * Gets or sets a boolean indicating if particles are enabled on this scene
  41091. */
  41092. particlesEnabled: boolean;
  41093. /**
  41094. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41095. */
  41096. spritesEnabled: boolean;
  41097. private _skeletonsEnabled;
  41098. /**
  41099. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41100. */
  41101. set skeletonsEnabled(value: boolean);
  41102. get skeletonsEnabled(): boolean;
  41103. /**
  41104. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41105. */
  41106. lensFlaresEnabled: boolean;
  41107. /**
  41108. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41109. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41110. */
  41111. collisionsEnabled: boolean;
  41112. private _collisionCoordinator;
  41113. /** @hidden */
  41114. get collisionCoordinator(): ICollisionCoordinator;
  41115. /**
  41116. * Defines the gravity applied to this scene (used only for collisions)
  41117. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41118. */
  41119. gravity: Vector3;
  41120. /**
  41121. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41122. */
  41123. postProcessesEnabled: boolean;
  41124. /**
  41125. * The list of postprocesses added to the scene
  41126. */
  41127. postProcesses: PostProcess[];
  41128. /**
  41129. * Gets the current postprocess manager
  41130. */
  41131. postProcessManager: PostProcessManager;
  41132. /**
  41133. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41134. */
  41135. renderTargetsEnabled: boolean;
  41136. /**
  41137. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41138. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41139. */
  41140. dumpNextRenderTargets: boolean;
  41141. /**
  41142. * The list of user defined render targets added to the scene
  41143. */
  41144. customRenderTargets: RenderTargetTexture[];
  41145. /**
  41146. * Defines if texture loading must be delayed
  41147. * If true, textures will only be loaded when they need to be rendered
  41148. */
  41149. useDelayedTextureLoading: boolean;
  41150. /**
  41151. * Gets the list of meshes imported to the scene through SceneLoader
  41152. */
  41153. importedMeshesFiles: String[];
  41154. /**
  41155. * Gets or sets a boolean indicating if probes are enabled on this scene
  41156. */
  41157. probesEnabled: boolean;
  41158. /**
  41159. * Gets or sets the current offline provider to use to store scene data
  41160. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41161. */
  41162. offlineProvider: IOfflineProvider;
  41163. /**
  41164. * Gets or sets the action manager associated with the scene
  41165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41166. */
  41167. actionManager: AbstractActionManager;
  41168. private _meshesForIntersections;
  41169. /**
  41170. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41171. */
  41172. proceduralTexturesEnabled: boolean;
  41173. private _engine;
  41174. private _totalVertices;
  41175. /** @hidden */
  41176. _activeIndices: PerfCounter;
  41177. /** @hidden */
  41178. _activeParticles: PerfCounter;
  41179. /** @hidden */
  41180. _activeBones: PerfCounter;
  41181. private _animationRatio;
  41182. /** @hidden */
  41183. _animationTimeLast: number;
  41184. /** @hidden */
  41185. _animationTime: number;
  41186. /**
  41187. * Gets or sets a general scale for animation speed
  41188. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41189. */
  41190. animationTimeScale: number;
  41191. /** @hidden */
  41192. _cachedMaterial: Nullable<Material>;
  41193. /** @hidden */
  41194. _cachedEffect: Nullable<Effect>;
  41195. /** @hidden */
  41196. _cachedVisibility: Nullable<number>;
  41197. private _renderId;
  41198. private _frameId;
  41199. private _executeWhenReadyTimeoutId;
  41200. private _intermediateRendering;
  41201. private _viewUpdateFlag;
  41202. private _projectionUpdateFlag;
  41203. /** @hidden */
  41204. _toBeDisposed: Nullable<IDisposable>[];
  41205. private _activeRequests;
  41206. /** @hidden */
  41207. _pendingData: any[];
  41208. private _isDisposed;
  41209. /**
  41210. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41211. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41212. */
  41213. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41214. private _activeMeshes;
  41215. private _processedMaterials;
  41216. private _renderTargets;
  41217. /** @hidden */
  41218. _activeParticleSystems: SmartArray<IParticleSystem>;
  41219. private _activeSkeletons;
  41220. private _softwareSkinnedMeshes;
  41221. private _renderingManager;
  41222. /** @hidden */
  41223. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41224. private _transformMatrix;
  41225. private _sceneUbo;
  41226. /** @hidden */
  41227. _viewMatrix: Matrix;
  41228. private _projectionMatrix;
  41229. /** @hidden */
  41230. _forcedViewPosition: Nullable<Vector3>;
  41231. /** @hidden */
  41232. _frustumPlanes: Plane[];
  41233. /**
  41234. * Gets the list of frustum planes (built from the active camera)
  41235. */
  41236. get frustumPlanes(): Plane[];
  41237. /**
  41238. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41239. * This is useful if there are more lights that the maximum simulteanous authorized
  41240. */
  41241. requireLightSorting: boolean;
  41242. /** @hidden */
  41243. readonly useMaterialMeshMap: boolean;
  41244. /** @hidden */
  41245. readonly useClonedMeshMap: boolean;
  41246. private _externalData;
  41247. private _uid;
  41248. /**
  41249. * @hidden
  41250. * Backing store of defined scene components.
  41251. */
  41252. _components: ISceneComponent[];
  41253. /**
  41254. * @hidden
  41255. * Backing store of defined scene components.
  41256. */
  41257. _serializableComponents: ISceneSerializableComponent[];
  41258. /**
  41259. * List of components to register on the next registration step.
  41260. */
  41261. private _transientComponents;
  41262. /**
  41263. * Registers the transient components if needed.
  41264. */
  41265. private _registerTransientComponents;
  41266. /**
  41267. * @hidden
  41268. * Add a component to the scene.
  41269. * Note that the ccomponent could be registered on th next frame if this is called after
  41270. * the register component stage.
  41271. * @param component Defines the component to add to the scene
  41272. */
  41273. _addComponent(component: ISceneComponent): void;
  41274. /**
  41275. * @hidden
  41276. * Gets a component from the scene.
  41277. * @param name defines the name of the component to retrieve
  41278. * @returns the component or null if not present
  41279. */
  41280. _getComponent(name: string): Nullable<ISceneComponent>;
  41281. /**
  41282. * @hidden
  41283. * Defines the actions happening before camera updates.
  41284. */
  41285. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41286. /**
  41287. * @hidden
  41288. * Defines the actions happening before clear the canvas.
  41289. */
  41290. _beforeClearStage: Stage<SimpleStageAction>;
  41291. /**
  41292. * @hidden
  41293. * Defines the actions when collecting render targets for the frame.
  41294. */
  41295. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41296. /**
  41297. * @hidden
  41298. * Defines the actions happening for one camera in the frame.
  41299. */
  41300. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41301. /**
  41302. * @hidden
  41303. * Defines the actions happening during the per mesh ready checks.
  41304. */
  41305. _isReadyForMeshStage: Stage<MeshStageAction>;
  41306. /**
  41307. * @hidden
  41308. * Defines the actions happening before evaluate active mesh checks.
  41309. */
  41310. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41311. /**
  41312. * @hidden
  41313. * Defines the actions happening during the evaluate sub mesh checks.
  41314. */
  41315. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41316. /**
  41317. * @hidden
  41318. * Defines the actions happening during the active mesh stage.
  41319. */
  41320. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41321. /**
  41322. * @hidden
  41323. * Defines the actions happening during the per camera render target step.
  41324. */
  41325. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41326. /**
  41327. * @hidden
  41328. * Defines the actions happening just before the active camera is drawing.
  41329. */
  41330. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41331. /**
  41332. * @hidden
  41333. * Defines the actions happening just before a render target is drawing.
  41334. */
  41335. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41336. /**
  41337. * @hidden
  41338. * Defines the actions happening just before a rendering group is drawing.
  41339. */
  41340. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41341. /**
  41342. * @hidden
  41343. * Defines the actions happening just before a mesh is drawing.
  41344. */
  41345. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41346. /**
  41347. * @hidden
  41348. * Defines the actions happening just after a mesh has been drawn.
  41349. */
  41350. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41351. /**
  41352. * @hidden
  41353. * Defines the actions happening just after a rendering group has been drawn.
  41354. */
  41355. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41356. /**
  41357. * @hidden
  41358. * Defines the actions happening just after the active camera has been drawn.
  41359. */
  41360. _afterCameraDrawStage: Stage<CameraStageAction>;
  41361. /**
  41362. * @hidden
  41363. * Defines the actions happening just after a render target has been drawn.
  41364. */
  41365. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41366. /**
  41367. * @hidden
  41368. * Defines the actions happening just after rendering all cameras and computing intersections.
  41369. */
  41370. _afterRenderStage: Stage<SimpleStageAction>;
  41371. /**
  41372. * @hidden
  41373. * Defines the actions happening when a pointer move event happens.
  41374. */
  41375. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41376. /**
  41377. * @hidden
  41378. * Defines the actions happening when a pointer down event happens.
  41379. */
  41380. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41381. /**
  41382. * @hidden
  41383. * Defines the actions happening when a pointer up event happens.
  41384. */
  41385. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41386. /**
  41387. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41388. */
  41389. private geometriesByUniqueId;
  41390. /**
  41391. * Creates a new Scene
  41392. * @param engine defines the engine to use to render this scene
  41393. * @param options defines the scene options
  41394. */
  41395. constructor(engine: Engine, options?: SceneOptions);
  41396. /**
  41397. * Gets a string idenfifying the name of the class
  41398. * @returns "Scene" string
  41399. */
  41400. getClassName(): string;
  41401. private _defaultMeshCandidates;
  41402. /**
  41403. * @hidden
  41404. */
  41405. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41406. private _defaultSubMeshCandidates;
  41407. /**
  41408. * @hidden
  41409. */
  41410. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41411. /**
  41412. * Sets the default candidate providers for the scene.
  41413. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41414. * and getCollidingSubMeshCandidates to their default function
  41415. */
  41416. setDefaultCandidateProviders(): void;
  41417. /**
  41418. * Gets the mesh that is currently under the pointer
  41419. */
  41420. get meshUnderPointer(): Nullable<AbstractMesh>;
  41421. /**
  41422. * Gets or sets the current on-screen X position of the pointer
  41423. */
  41424. get pointerX(): number;
  41425. set pointerX(value: number);
  41426. /**
  41427. * Gets or sets the current on-screen Y position of the pointer
  41428. */
  41429. get pointerY(): number;
  41430. set pointerY(value: number);
  41431. /**
  41432. * Gets the cached material (ie. the latest rendered one)
  41433. * @returns the cached material
  41434. */
  41435. getCachedMaterial(): Nullable<Material>;
  41436. /**
  41437. * Gets the cached effect (ie. the latest rendered one)
  41438. * @returns the cached effect
  41439. */
  41440. getCachedEffect(): Nullable<Effect>;
  41441. /**
  41442. * Gets the cached visibility state (ie. the latest rendered one)
  41443. * @returns the cached visibility state
  41444. */
  41445. getCachedVisibility(): Nullable<number>;
  41446. /**
  41447. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41448. * @param material defines the current material
  41449. * @param effect defines the current effect
  41450. * @param visibility defines the current visibility state
  41451. * @returns true if one parameter is not cached
  41452. */
  41453. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41454. /**
  41455. * Gets the engine associated with the scene
  41456. * @returns an Engine
  41457. */
  41458. getEngine(): Engine;
  41459. /**
  41460. * Gets the total number of vertices rendered per frame
  41461. * @returns the total number of vertices rendered per frame
  41462. */
  41463. getTotalVertices(): number;
  41464. /**
  41465. * Gets the performance counter for total vertices
  41466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41467. */
  41468. get totalVerticesPerfCounter(): PerfCounter;
  41469. /**
  41470. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41471. * @returns the total number of active indices rendered per frame
  41472. */
  41473. getActiveIndices(): number;
  41474. /**
  41475. * Gets the performance counter for active indices
  41476. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41477. */
  41478. get totalActiveIndicesPerfCounter(): PerfCounter;
  41479. /**
  41480. * Gets the total number of active particles rendered per frame
  41481. * @returns the total number of active particles rendered per frame
  41482. */
  41483. getActiveParticles(): number;
  41484. /**
  41485. * Gets the performance counter for active particles
  41486. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41487. */
  41488. get activeParticlesPerfCounter(): PerfCounter;
  41489. /**
  41490. * Gets the total number of active bones rendered per frame
  41491. * @returns the total number of active bones rendered per frame
  41492. */
  41493. getActiveBones(): number;
  41494. /**
  41495. * Gets the performance counter for active bones
  41496. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41497. */
  41498. get activeBonesPerfCounter(): PerfCounter;
  41499. /**
  41500. * Gets the array of active meshes
  41501. * @returns an array of AbstractMesh
  41502. */
  41503. getActiveMeshes(): SmartArray<AbstractMesh>;
  41504. /**
  41505. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41506. * @returns a number
  41507. */
  41508. getAnimationRatio(): number;
  41509. /**
  41510. * Gets an unique Id for the current render phase
  41511. * @returns a number
  41512. */
  41513. getRenderId(): number;
  41514. /**
  41515. * Gets an unique Id for the current frame
  41516. * @returns a number
  41517. */
  41518. getFrameId(): number;
  41519. /** Call this function if you want to manually increment the render Id*/
  41520. incrementRenderId(): void;
  41521. private _createUbo;
  41522. /**
  41523. * Use this method to simulate a pointer move on a mesh
  41524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41527. * @returns the current scene
  41528. */
  41529. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41530. /**
  41531. * Use this method to simulate a pointer down on a mesh
  41532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41535. * @returns the current scene
  41536. */
  41537. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41538. /**
  41539. * Use this method to simulate a pointer up on a mesh
  41540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41543. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41544. * @returns the current scene
  41545. */
  41546. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41547. /**
  41548. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41549. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41550. * @returns true if the pointer was captured
  41551. */
  41552. isPointerCaptured(pointerId?: number): boolean;
  41553. /**
  41554. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41555. * @param attachUp defines if you want to attach events to pointerup
  41556. * @param attachDown defines if you want to attach events to pointerdown
  41557. * @param attachMove defines if you want to attach events to pointermove
  41558. */
  41559. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41560. /** Detaches all event handlers*/
  41561. detachControl(): void;
  41562. /**
  41563. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41564. * Delay loaded resources are not taking in account
  41565. * @return true if all required resources are ready
  41566. */
  41567. isReady(): boolean;
  41568. /** Resets all cached information relative to material (including effect and visibility) */
  41569. resetCachedMaterial(): void;
  41570. /**
  41571. * Registers a function to be called before every frame render
  41572. * @param func defines the function to register
  41573. */
  41574. registerBeforeRender(func: () => void): void;
  41575. /**
  41576. * Unregisters a function called before every frame render
  41577. * @param func defines the function to unregister
  41578. */
  41579. unregisterBeforeRender(func: () => void): void;
  41580. /**
  41581. * Registers a function to be called after every frame render
  41582. * @param func defines the function to register
  41583. */
  41584. registerAfterRender(func: () => void): void;
  41585. /**
  41586. * Unregisters a function called after every frame render
  41587. * @param func defines the function to unregister
  41588. */
  41589. unregisterAfterRender(func: () => void): void;
  41590. private _executeOnceBeforeRender;
  41591. /**
  41592. * The provided function will run before render once and will be disposed afterwards.
  41593. * A timeout delay can be provided so that the function will be executed in N ms.
  41594. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41595. * @param func The function to be executed.
  41596. * @param timeout optional delay in ms
  41597. */
  41598. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41599. /** @hidden */
  41600. _addPendingData(data: any): void;
  41601. /** @hidden */
  41602. _removePendingData(data: any): void;
  41603. /**
  41604. * Returns the number of items waiting to be loaded
  41605. * @returns the number of items waiting to be loaded
  41606. */
  41607. getWaitingItemsCount(): number;
  41608. /**
  41609. * Returns a boolean indicating if the scene is still loading data
  41610. */
  41611. get isLoading(): boolean;
  41612. /**
  41613. * Registers a function to be executed when the scene is ready
  41614. * @param {Function} func - the function to be executed
  41615. */
  41616. executeWhenReady(func: () => void): void;
  41617. /**
  41618. * Returns a promise that resolves when the scene is ready
  41619. * @returns A promise that resolves when the scene is ready
  41620. */
  41621. whenReadyAsync(): Promise<void>;
  41622. /** @hidden */
  41623. _checkIsReady(): void;
  41624. /**
  41625. * Gets all animatable attached to the scene
  41626. */
  41627. get animatables(): Animatable[];
  41628. /**
  41629. * Resets the last animation time frame.
  41630. * Useful to override when animations start running when loading a scene for the first time.
  41631. */
  41632. resetLastAnimationTimeFrame(): void;
  41633. /**
  41634. * Gets the current view matrix
  41635. * @returns a Matrix
  41636. */
  41637. getViewMatrix(): Matrix;
  41638. /**
  41639. * Gets the current projection matrix
  41640. * @returns a Matrix
  41641. */
  41642. getProjectionMatrix(): Matrix;
  41643. /**
  41644. * Gets the current transform matrix
  41645. * @returns a Matrix made of View * Projection
  41646. */
  41647. getTransformMatrix(): Matrix;
  41648. /**
  41649. * Sets the current transform matrix
  41650. * @param viewL defines the View matrix to use
  41651. * @param projectionL defines the Projection matrix to use
  41652. * @param viewR defines the right View matrix to use (if provided)
  41653. * @param projectionR defines the right Projection matrix to use (if provided)
  41654. */
  41655. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41656. /**
  41657. * Gets the uniform buffer used to store scene data
  41658. * @returns a UniformBuffer
  41659. */
  41660. getSceneUniformBuffer(): UniformBuffer;
  41661. /**
  41662. * Gets an unique (relatively to the current scene) Id
  41663. * @returns an unique number for the scene
  41664. */
  41665. getUniqueId(): number;
  41666. /**
  41667. * Add a mesh to the list of scene's meshes
  41668. * @param newMesh defines the mesh to add
  41669. * @param recursive if all child meshes should also be added to the scene
  41670. */
  41671. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41672. /**
  41673. * Remove a mesh for the list of scene's meshes
  41674. * @param toRemove defines the mesh to remove
  41675. * @param recursive if all child meshes should also be removed from the scene
  41676. * @returns the index where the mesh was in the mesh list
  41677. */
  41678. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41679. /**
  41680. * Add a transform node to the list of scene's transform nodes
  41681. * @param newTransformNode defines the transform node to add
  41682. */
  41683. addTransformNode(newTransformNode: TransformNode): void;
  41684. /**
  41685. * Remove a transform node for the list of scene's transform nodes
  41686. * @param toRemove defines the transform node to remove
  41687. * @returns the index where the transform node was in the transform node list
  41688. */
  41689. removeTransformNode(toRemove: TransformNode): number;
  41690. /**
  41691. * Remove a skeleton for the list of scene's skeletons
  41692. * @param toRemove defines the skeleton to remove
  41693. * @returns the index where the skeleton was in the skeleton list
  41694. */
  41695. removeSkeleton(toRemove: Skeleton): number;
  41696. /**
  41697. * Remove a morph target for the list of scene's morph targets
  41698. * @param toRemove defines the morph target to remove
  41699. * @returns the index where the morph target was in the morph target list
  41700. */
  41701. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41702. /**
  41703. * Remove a light for the list of scene's lights
  41704. * @param toRemove defines the light to remove
  41705. * @returns the index where the light was in the light list
  41706. */
  41707. removeLight(toRemove: Light): number;
  41708. /**
  41709. * Remove a camera for the list of scene's cameras
  41710. * @param toRemove defines the camera to remove
  41711. * @returns the index where the camera was in the camera list
  41712. */
  41713. removeCamera(toRemove: Camera): number;
  41714. /**
  41715. * Remove a particle system for the list of scene's particle systems
  41716. * @param toRemove defines the particle system to remove
  41717. * @returns the index where the particle system was in the particle system list
  41718. */
  41719. removeParticleSystem(toRemove: IParticleSystem): number;
  41720. /**
  41721. * Remove a animation for the list of scene's animations
  41722. * @param toRemove defines the animation to remove
  41723. * @returns the index where the animation was in the animation list
  41724. */
  41725. removeAnimation(toRemove: Animation): number;
  41726. /**
  41727. * Will stop the animation of the given target
  41728. * @param target - the target
  41729. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41730. * @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)
  41731. */
  41732. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41733. /**
  41734. * Removes the given animation group from this scene.
  41735. * @param toRemove The animation group to remove
  41736. * @returns The index of the removed animation group
  41737. */
  41738. removeAnimationGroup(toRemove: AnimationGroup): number;
  41739. /**
  41740. * Removes the given multi-material from this scene.
  41741. * @param toRemove The multi-material to remove
  41742. * @returns The index of the removed multi-material
  41743. */
  41744. removeMultiMaterial(toRemove: MultiMaterial): number;
  41745. /**
  41746. * Removes the given material from this scene.
  41747. * @param toRemove The material to remove
  41748. * @returns The index of the removed material
  41749. */
  41750. removeMaterial(toRemove: Material): number;
  41751. /**
  41752. * Removes the given action manager from this scene.
  41753. * @param toRemove The action manager to remove
  41754. * @returns The index of the removed action manager
  41755. */
  41756. removeActionManager(toRemove: AbstractActionManager): number;
  41757. /**
  41758. * Removes the given texture from this scene.
  41759. * @param toRemove The texture to remove
  41760. * @returns The index of the removed texture
  41761. */
  41762. removeTexture(toRemove: BaseTexture): number;
  41763. /**
  41764. * Adds the given light to this scene
  41765. * @param newLight The light to add
  41766. */
  41767. addLight(newLight: Light): void;
  41768. /**
  41769. * Sorts the list list based on light priorities
  41770. */
  41771. sortLightsByPriority(): void;
  41772. /**
  41773. * Adds the given camera to this scene
  41774. * @param newCamera The camera to add
  41775. */
  41776. addCamera(newCamera: Camera): void;
  41777. /**
  41778. * Adds the given skeleton to this scene
  41779. * @param newSkeleton The skeleton to add
  41780. */
  41781. addSkeleton(newSkeleton: Skeleton): void;
  41782. /**
  41783. * Adds the given particle system to this scene
  41784. * @param newParticleSystem The particle system to add
  41785. */
  41786. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41787. /**
  41788. * Adds the given animation to this scene
  41789. * @param newAnimation The animation to add
  41790. */
  41791. addAnimation(newAnimation: Animation): void;
  41792. /**
  41793. * Adds the given animation group to this scene.
  41794. * @param newAnimationGroup The animation group to add
  41795. */
  41796. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41797. /**
  41798. * Adds the given multi-material to this scene
  41799. * @param newMultiMaterial The multi-material to add
  41800. */
  41801. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41802. /**
  41803. * Adds the given material to this scene
  41804. * @param newMaterial The material to add
  41805. */
  41806. addMaterial(newMaterial: Material): void;
  41807. /**
  41808. * Adds the given morph target to this scene
  41809. * @param newMorphTargetManager The morph target to add
  41810. */
  41811. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41812. /**
  41813. * Adds the given geometry to this scene
  41814. * @param newGeometry The geometry to add
  41815. */
  41816. addGeometry(newGeometry: Geometry): void;
  41817. /**
  41818. * Adds the given action manager to this scene
  41819. * @param newActionManager The action manager to add
  41820. */
  41821. addActionManager(newActionManager: AbstractActionManager): void;
  41822. /**
  41823. * Adds the given texture to this scene.
  41824. * @param newTexture The texture to add
  41825. */
  41826. addTexture(newTexture: BaseTexture): void;
  41827. /**
  41828. * Switch active camera
  41829. * @param newCamera defines the new active camera
  41830. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41831. */
  41832. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41833. /**
  41834. * sets the active camera of the scene using its ID
  41835. * @param id defines the camera's ID
  41836. * @return the new active camera or null if none found.
  41837. */
  41838. setActiveCameraByID(id: string): Nullable<Camera>;
  41839. /**
  41840. * sets the active camera of the scene using its name
  41841. * @param name defines the camera's name
  41842. * @returns the new active camera or null if none found.
  41843. */
  41844. setActiveCameraByName(name: string): Nullable<Camera>;
  41845. /**
  41846. * get an animation group using its name
  41847. * @param name defines the material's name
  41848. * @return the animation group or null if none found.
  41849. */
  41850. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41851. /**
  41852. * Get a material using its unique id
  41853. * @param uniqueId defines the material's unique id
  41854. * @return the material or null if none found.
  41855. */
  41856. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41857. /**
  41858. * get a material using its id
  41859. * @param id defines the material's ID
  41860. * @return the material or null if none found.
  41861. */
  41862. getMaterialByID(id: string): Nullable<Material>;
  41863. /**
  41864. * Gets a the last added material using a given id
  41865. * @param id defines the material's ID
  41866. * @return the last material with the given id or null if none found.
  41867. */
  41868. getLastMaterialByID(id: string): Nullable<Material>;
  41869. /**
  41870. * Gets a material using its name
  41871. * @param name defines the material's name
  41872. * @return the material or null if none found.
  41873. */
  41874. getMaterialByName(name: string): Nullable<Material>;
  41875. /**
  41876. * Get a texture using its unique id
  41877. * @param uniqueId defines the texture's unique id
  41878. * @return the texture or null if none found.
  41879. */
  41880. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41881. /**
  41882. * Gets a camera using its id
  41883. * @param id defines the id to look for
  41884. * @returns the camera or null if not found
  41885. */
  41886. getCameraByID(id: string): Nullable<Camera>;
  41887. /**
  41888. * Gets a camera using its unique id
  41889. * @param uniqueId defines the unique id to look for
  41890. * @returns the camera or null if not found
  41891. */
  41892. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41893. /**
  41894. * Gets a camera using its name
  41895. * @param name defines the camera's name
  41896. * @return the camera or null if none found.
  41897. */
  41898. getCameraByName(name: string): Nullable<Camera>;
  41899. /**
  41900. * Gets a bone using its id
  41901. * @param id defines the bone's id
  41902. * @return the bone or null if not found
  41903. */
  41904. getBoneByID(id: string): Nullable<Bone>;
  41905. /**
  41906. * Gets a bone using its id
  41907. * @param name defines the bone's name
  41908. * @return the bone or null if not found
  41909. */
  41910. getBoneByName(name: string): Nullable<Bone>;
  41911. /**
  41912. * Gets a light node using its name
  41913. * @param name defines the the light's name
  41914. * @return the light or null if none found.
  41915. */
  41916. getLightByName(name: string): Nullable<Light>;
  41917. /**
  41918. * Gets a light node using its id
  41919. * @param id defines the light's id
  41920. * @return the light or null if none found.
  41921. */
  41922. getLightByID(id: string): Nullable<Light>;
  41923. /**
  41924. * Gets a light node using its scene-generated unique ID
  41925. * @param uniqueId defines the light's unique id
  41926. * @return the light or null if none found.
  41927. */
  41928. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41929. /**
  41930. * Gets a particle system by id
  41931. * @param id defines the particle system id
  41932. * @return the corresponding system or null if none found
  41933. */
  41934. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41935. /**
  41936. * Gets a geometry using its ID
  41937. * @param id defines the geometry's id
  41938. * @return the geometry or null if none found.
  41939. */
  41940. getGeometryByID(id: string): Nullable<Geometry>;
  41941. private _getGeometryByUniqueID;
  41942. /**
  41943. * Add a new geometry to this scene
  41944. * @param geometry defines the geometry to be added to the scene.
  41945. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41946. * @return a boolean defining if the geometry was added or not
  41947. */
  41948. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41949. /**
  41950. * Removes an existing geometry
  41951. * @param geometry defines the geometry to be removed from the scene
  41952. * @return a boolean defining if the geometry was removed or not
  41953. */
  41954. removeGeometry(geometry: Geometry): boolean;
  41955. /**
  41956. * Gets the list of geometries attached to the scene
  41957. * @returns an array of Geometry
  41958. */
  41959. getGeometries(): Geometry[];
  41960. /**
  41961. * Gets the first added mesh found of a given ID
  41962. * @param id defines the id to search for
  41963. * @return the mesh found or null if not found at all
  41964. */
  41965. getMeshByID(id: string): Nullable<AbstractMesh>;
  41966. /**
  41967. * Gets a list of meshes using their id
  41968. * @param id defines the id to search for
  41969. * @returns a list of meshes
  41970. */
  41971. getMeshesByID(id: string): Array<AbstractMesh>;
  41972. /**
  41973. * Gets the first added transform node found of a given ID
  41974. * @param id defines the id to search for
  41975. * @return the found transform node or null if not found at all.
  41976. */
  41977. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41978. /**
  41979. * Gets a transform node with its auto-generated unique id
  41980. * @param uniqueId efines the unique id to search for
  41981. * @return the found transform node or null if not found at all.
  41982. */
  41983. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41984. /**
  41985. * Gets a list of transform nodes using their id
  41986. * @param id defines the id to search for
  41987. * @returns a list of transform nodes
  41988. */
  41989. getTransformNodesByID(id: string): Array<TransformNode>;
  41990. /**
  41991. * Gets a mesh with its auto-generated unique id
  41992. * @param uniqueId defines the unique id to search for
  41993. * @return the found mesh or null if not found at all.
  41994. */
  41995. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41996. /**
  41997. * Gets a the last added mesh using a given id
  41998. * @param id defines the id to search for
  41999. * @return the found mesh or null if not found at all.
  42000. */
  42001. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42002. /**
  42003. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42004. * @param id defines the id to search for
  42005. * @return the found node or null if not found at all
  42006. */
  42007. getLastEntryByID(id: string): Nullable<Node>;
  42008. /**
  42009. * Gets a node (Mesh, Camera, Light) using a given id
  42010. * @param id defines the id to search for
  42011. * @return the found node or null if not found at all
  42012. */
  42013. getNodeByID(id: string): Nullable<Node>;
  42014. /**
  42015. * Gets a node (Mesh, Camera, Light) using a given name
  42016. * @param name defines the name to search for
  42017. * @return the found node or null if not found at all.
  42018. */
  42019. getNodeByName(name: string): Nullable<Node>;
  42020. /**
  42021. * Gets a mesh using a given name
  42022. * @param name defines the name to search for
  42023. * @return the found mesh or null if not found at all.
  42024. */
  42025. getMeshByName(name: string): Nullable<AbstractMesh>;
  42026. /**
  42027. * Gets a transform node using a given name
  42028. * @param name defines the name to search for
  42029. * @return the found transform node or null if not found at all.
  42030. */
  42031. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42032. /**
  42033. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42034. * @param id defines the id to search for
  42035. * @return the found skeleton or null if not found at all.
  42036. */
  42037. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42038. /**
  42039. * Gets a skeleton using a given auto generated unique id
  42040. * @param uniqueId defines the unique id to search for
  42041. * @return the found skeleton or null if not found at all.
  42042. */
  42043. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42044. /**
  42045. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42046. * @param id defines the id to search for
  42047. * @return the found skeleton or null if not found at all.
  42048. */
  42049. getSkeletonById(id: string): Nullable<Skeleton>;
  42050. /**
  42051. * Gets a skeleton using a given name
  42052. * @param name defines the name to search for
  42053. * @return the found skeleton or null if not found at all.
  42054. */
  42055. getSkeletonByName(name: string): Nullable<Skeleton>;
  42056. /**
  42057. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42058. * @param id defines the id to search for
  42059. * @return the found morph target manager or null if not found at all.
  42060. */
  42061. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42062. /**
  42063. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42064. * @param id defines the id to search for
  42065. * @return the found morph target or null if not found at all.
  42066. */
  42067. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42068. /**
  42069. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42070. * @param name defines the name to search for
  42071. * @return the found morph target or null if not found at all.
  42072. */
  42073. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42074. /**
  42075. * Gets a boolean indicating if the given mesh is active
  42076. * @param mesh defines the mesh to look for
  42077. * @returns true if the mesh is in the active list
  42078. */
  42079. isActiveMesh(mesh: AbstractMesh): boolean;
  42080. /**
  42081. * Return a unique id as a string which can serve as an identifier for the scene
  42082. */
  42083. get uid(): string;
  42084. /**
  42085. * Add an externaly attached data from its key.
  42086. * This method call will fail and return false, if such key already exists.
  42087. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42088. * @param key the unique key that identifies the data
  42089. * @param data the data object to associate to the key for this Engine instance
  42090. * @return true if no such key were already present and the data was added successfully, false otherwise
  42091. */
  42092. addExternalData<T>(key: string, data: T): boolean;
  42093. /**
  42094. * Get an externaly attached data from its key
  42095. * @param key the unique key that identifies the data
  42096. * @return the associated data, if present (can be null), or undefined if not present
  42097. */
  42098. getExternalData<T>(key: string): Nullable<T>;
  42099. /**
  42100. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42101. * @param key the unique key that identifies the data
  42102. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42103. * @return the associated data, can be null if the factory returned null.
  42104. */
  42105. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42106. /**
  42107. * Remove an externaly attached data from the Engine instance
  42108. * @param key the unique key that identifies the data
  42109. * @return true if the data was successfully removed, false if it doesn't exist
  42110. */
  42111. removeExternalData(key: string): boolean;
  42112. private _evaluateSubMesh;
  42113. /**
  42114. * Clear the processed materials smart array preventing retention point in material dispose.
  42115. */
  42116. freeProcessedMaterials(): void;
  42117. private _preventFreeActiveMeshesAndRenderingGroups;
  42118. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42119. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42120. * when disposing several meshes in a row or a hierarchy of meshes.
  42121. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42122. */
  42123. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42124. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42125. /**
  42126. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42127. */
  42128. freeActiveMeshes(): void;
  42129. /**
  42130. * Clear the info related to rendering groups preventing retention points during dispose.
  42131. */
  42132. freeRenderingGroups(): void;
  42133. /** @hidden */
  42134. _isInIntermediateRendering(): boolean;
  42135. /**
  42136. * Lambda returning the list of potentially active meshes.
  42137. */
  42138. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42139. /**
  42140. * Lambda returning the list of potentially active sub meshes.
  42141. */
  42142. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42143. /**
  42144. * Lambda returning the list of potentially intersecting sub meshes.
  42145. */
  42146. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42147. /**
  42148. * Lambda returning the list of potentially colliding sub meshes.
  42149. */
  42150. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42151. private _activeMeshesFrozen;
  42152. private _skipEvaluateActiveMeshesCompletely;
  42153. /**
  42154. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42155. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42156. * @returns the current scene
  42157. */
  42158. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42159. /**
  42160. * Use this function to restart evaluating active meshes on every frame
  42161. * @returns the current scene
  42162. */
  42163. unfreezeActiveMeshes(): Scene;
  42164. private _evaluateActiveMeshes;
  42165. private _activeMesh;
  42166. /**
  42167. * Update the transform matrix to update from the current active camera
  42168. * @param force defines a boolean used to force the update even if cache is up to date
  42169. */
  42170. updateTransformMatrix(force?: boolean): void;
  42171. private _bindFrameBuffer;
  42172. /** @hidden */
  42173. _allowPostProcessClearColor: boolean;
  42174. /** @hidden */
  42175. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42176. private _processSubCameras;
  42177. private _checkIntersections;
  42178. /** @hidden */
  42179. _advancePhysicsEngineStep(step: number): void;
  42180. /**
  42181. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42182. */
  42183. getDeterministicFrameTime: () => number;
  42184. /** @hidden */
  42185. _animate(): void;
  42186. /** Execute all animations (for a frame) */
  42187. animate(): void;
  42188. /**
  42189. * Render the scene
  42190. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42191. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42192. */
  42193. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42194. /**
  42195. * Freeze all materials
  42196. * A frozen material will not be updatable but should be faster to render
  42197. */
  42198. freezeMaterials(): void;
  42199. /**
  42200. * Unfreeze all materials
  42201. * A frozen material will not be updatable but should be faster to render
  42202. */
  42203. unfreezeMaterials(): void;
  42204. /**
  42205. * Releases all held ressources
  42206. */
  42207. dispose(): void;
  42208. /**
  42209. * Gets if the scene is already disposed
  42210. */
  42211. get isDisposed(): boolean;
  42212. /**
  42213. * Call this function to reduce memory footprint of the scene.
  42214. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42215. */
  42216. clearCachedVertexData(): void;
  42217. /**
  42218. * This function will remove the local cached buffer data from texture.
  42219. * It will save memory but will prevent the texture from being rebuilt
  42220. */
  42221. cleanCachedTextureBuffer(): void;
  42222. /**
  42223. * Get the world extend vectors with an optional filter
  42224. *
  42225. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42226. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42227. */
  42228. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42229. min: Vector3;
  42230. max: Vector3;
  42231. };
  42232. /**
  42233. * Creates a ray that can be used to pick in the scene
  42234. * @param x defines the x coordinate of the origin (on-screen)
  42235. * @param y defines the y coordinate of the origin (on-screen)
  42236. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42237. * @param camera defines the camera to use for the picking
  42238. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42239. * @returns a Ray
  42240. */
  42241. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42242. /**
  42243. * Creates a ray that can be used to pick in the scene
  42244. * @param x defines the x coordinate of the origin (on-screen)
  42245. * @param y defines the y coordinate of the origin (on-screen)
  42246. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42247. * @param result defines the ray where to store the picking ray
  42248. * @param camera defines the camera to use for the picking
  42249. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42250. * @returns the current scene
  42251. */
  42252. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42253. /**
  42254. * Creates a ray that can be used to pick in the scene
  42255. * @param x defines the x coordinate of the origin (on-screen)
  42256. * @param y defines the y coordinate of the origin (on-screen)
  42257. * @param camera defines the camera to use for the picking
  42258. * @returns a Ray
  42259. */
  42260. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42261. /**
  42262. * Creates a ray that can be used to pick in the scene
  42263. * @param x defines the x coordinate of the origin (on-screen)
  42264. * @param y defines the y coordinate of the origin (on-screen)
  42265. * @param result defines the ray where to store the picking ray
  42266. * @param camera defines the camera to use for the picking
  42267. * @returns the current scene
  42268. */
  42269. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42270. /** Launch a ray to try to pick a mesh in the scene
  42271. * @param x position on screen
  42272. * @param y position on screen
  42273. * @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
  42274. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42275. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42276. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42277. * @returns a PickingInfo
  42278. */
  42279. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42280. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42281. * @param x position on screen
  42282. * @param y position on screen
  42283. * @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
  42284. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42285. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42286. * @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)
  42287. */
  42288. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42289. /** Use the given ray to pick a mesh in the scene
  42290. * @param ray The ray to use to pick meshes
  42291. * @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
  42292. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42293. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42294. * @returns a PickingInfo
  42295. */
  42296. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42297. /**
  42298. * Launch a ray to try to pick a mesh in the scene
  42299. * @param x X position on screen
  42300. * @param y Y position on screen
  42301. * @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
  42302. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42303. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42304. * @returns an array of PickingInfo
  42305. */
  42306. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42307. /**
  42308. * Launch a ray to try to pick a mesh in the scene
  42309. * @param ray Ray to use
  42310. * @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
  42311. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42312. * @returns an array of PickingInfo
  42313. */
  42314. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42315. /**
  42316. * Force the value of meshUnderPointer
  42317. * @param mesh defines the mesh to use
  42318. */
  42319. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42320. /**
  42321. * Gets the mesh under the pointer
  42322. * @returns a Mesh or null if no mesh is under the pointer
  42323. */
  42324. getPointerOverMesh(): Nullable<AbstractMesh>;
  42325. /** @hidden */
  42326. _rebuildGeometries(): void;
  42327. /** @hidden */
  42328. _rebuildTextures(): void;
  42329. private _getByTags;
  42330. /**
  42331. * Get a list of meshes by tags
  42332. * @param tagsQuery defines the tags query to use
  42333. * @param forEach defines a predicate used to filter results
  42334. * @returns an array of Mesh
  42335. */
  42336. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42337. /**
  42338. * Get a list of cameras by tags
  42339. * @param tagsQuery defines the tags query to use
  42340. * @param forEach defines a predicate used to filter results
  42341. * @returns an array of Camera
  42342. */
  42343. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42344. /**
  42345. * Get a list of lights by tags
  42346. * @param tagsQuery defines the tags query to use
  42347. * @param forEach defines a predicate used to filter results
  42348. * @returns an array of Light
  42349. */
  42350. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42351. /**
  42352. * Get a list of materials by tags
  42353. * @param tagsQuery defines the tags query to use
  42354. * @param forEach defines a predicate used to filter results
  42355. * @returns an array of Material
  42356. */
  42357. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42358. /**
  42359. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42360. * This allowed control for front to back rendering or reversly depending of the special needs.
  42361. *
  42362. * @param renderingGroupId The rendering group id corresponding to its index
  42363. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42364. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42365. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42366. */
  42367. 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;
  42368. /**
  42369. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42370. *
  42371. * @param renderingGroupId The rendering group id corresponding to its index
  42372. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42373. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42374. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42375. */
  42376. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42377. /**
  42378. * Gets the current auto clear configuration for one rendering group of the rendering
  42379. * manager.
  42380. * @param index the rendering group index to get the information for
  42381. * @returns The auto clear setup for the requested rendering group
  42382. */
  42383. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42384. private _blockMaterialDirtyMechanism;
  42385. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42386. get blockMaterialDirtyMechanism(): boolean;
  42387. set blockMaterialDirtyMechanism(value: boolean);
  42388. /**
  42389. * Will flag all materials as dirty to trigger new shader compilation
  42390. * @param flag defines the flag used to specify which material part must be marked as dirty
  42391. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42392. */
  42393. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42394. /** @hidden */
  42395. _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;
  42396. /** @hidden */
  42397. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42398. /** @hidden */
  42399. _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;
  42400. /** @hidden */
  42401. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42402. /** @hidden */
  42403. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42404. /** @hidden */
  42405. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42406. }
  42407. }
  42408. declare module "babylonjs/assetContainer" {
  42409. import { AbstractScene } from "babylonjs/abstractScene";
  42410. import { Scene } from "babylonjs/scene";
  42411. import { Mesh } from "babylonjs/Meshes/mesh";
  42412. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42413. import { Skeleton } from "babylonjs/Bones/skeleton";
  42414. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42415. import { Animatable } from "babylonjs/Animations/animatable";
  42416. import { Nullable } from "babylonjs/types";
  42417. import { Node } from "babylonjs/node";
  42418. /**
  42419. * Set of assets to keep when moving a scene into an asset container.
  42420. */
  42421. export class KeepAssets extends AbstractScene {
  42422. }
  42423. /**
  42424. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42425. */
  42426. export class InstantiatedEntries {
  42427. /**
  42428. * List of new root nodes (eg. nodes with no parent)
  42429. */
  42430. rootNodes: TransformNode[];
  42431. /**
  42432. * List of new skeletons
  42433. */
  42434. skeletons: Skeleton[];
  42435. /**
  42436. * List of new animation groups
  42437. */
  42438. animationGroups: AnimationGroup[];
  42439. }
  42440. /**
  42441. * Container with a set of assets that can be added or removed from a scene.
  42442. */
  42443. export class AssetContainer extends AbstractScene {
  42444. private _wasAddedToScene;
  42445. /**
  42446. * The scene the AssetContainer belongs to.
  42447. */
  42448. scene: Scene;
  42449. /**
  42450. * Instantiates an AssetContainer.
  42451. * @param scene The scene the AssetContainer belongs to.
  42452. */
  42453. constructor(scene: Scene);
  42454. /**
  42455. * Instantiate or clone all meshes and add the new ones to the scene.
  42456. * Skeletons and animation groups will all be cloned
  42457. * @param nameFunction defines an optional function used to get new names for clones
  42458. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42459. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42460. */
  42461. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42462. /**
  42463. * Adds all the assets from the container to the scene.
  42464. */
  42465. addAllToScene(): void;
  42466. /**
  42467. * Removes all the assets in the container from the scene
  42468. */
  42469. removeAllFromScene(): void;
  42470. /**
  42471. * Disposes all the assets in the container
  42472. */
  42473. dispose(): void;
  42474. private _moveAssets;
  42475. /**
  42476. * Removes all the assets contained in the scene and adds them to the container.
  42477. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42478. */
  42479. moveAllFromScene(keepAssets?: KeepAssets): void;
  42480. /**
  42481. * 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.
  42482. * @returns the root mesh
  42483. */
  42484. createRootMesh(): Mesh;
  42485. /**
  42486. * Merge animations (direct and animation groups) from this asset container into a scene
  42487. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42488. * @param animatables set of animatables to retarget to a node from the scene
  42489. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42490. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42491. */
  42492. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42493. }
  42494. }
  42495. declare module "babylonjs/abstractScene" {
  42496. import { Scene } from "babylonjs/scene";
  42497. import { Nullable } from "babylonjs/types";
  42498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42500. import { Geometry } from "babylonjs/Meshes/geometry";
  42501. import { Skeleton } from "babylonjs/Bones/skeleton";
  42502. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42503. import { AssetContainer } from "babylonjs/assetContainer";
  42504. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42505. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42507. import { Material } from "babylonjs/Materials/material";
  42508. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42509. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42510. import { Camera } from "babylonjs/Cameras/camera";
  42511. import { Light } from "babylonjs/Lights/light";
  42512. import { Node } from "babylonjs/node";
  42513. import { Animation } from "babylonjs/Animations/animation";
  42514. /**
  42515. * Defines how the parser contract is defined.
  42516. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42517. */
  42518. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42519. /**
  42520. * Defines how the individual parser contract is defined.
  42521. * These parser can parse an individual asset
  42522. */
  42523. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42524. /**
  42525. * Base class of the scene acting as a container for the different elements composing a scene.
  42526. * This class is dynamically extended by the different components of the scene increasing
  42527. * flexibility and reducing coupling
  42528. */
  42529. export abstract class AbstractScene {
  42530. /**
  42531. * Stores the list of available parsers in the application.
  42532. */
  42533. private static _BabylonFileParsers;
  42534. /**
  42535. * Stores the list of available individual parsers in the application.
  42536. */
  42537. private static _IndividualBabylonFileParsers;
  42538. /**
  42539. * Adds a parser in the list of available ones
  42540. * @param name Defines the name of the parser
  42541. * @param parser Defines the parser to add
  42542. */
  42543. static AddParser(name: string, parser: BabylonFileParser): void;
  42544. /**
  42545. * Gets a general parser from the list of avaialble ones
  42546. * @param name Defines the name of the parser
  42547. * @returns the requested parser or null
  42548. */
  42549. static GetParser(name: string): Nullable<BabylonFileParser>;
  42550. /**
  42551. * Adds n individual parser in the list of available ones
  42552. * @param name Defines the name of the parser
  42553. * @param parser Defines the parser to add
  42554. */
  42555. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42556. /**
  42557. * Gets an individual parser from the list of avaialble ones
  42558. * @param name Defines the name of the parser
  42559. * @returns the requested parser or null
  42560. */
  42561. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42562. /**
  42563. * Parser json data and populate both a scene and its associated container object
  42564. * @param jsonData Defines the data to parse
  42565. * @param scene Defines the scene to parse the data for
  42566. * @param container Defines the container attached to the parsing sequence
  42567. * @param rootUrl Defines the root url of the data
  42568. */
  42569. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42570. /**
  42571. * Gets the list of root nodes (ie. nodes with no parent)
  42572. */
  42573. rootNodes: Node[];
  42574. /** All of the cameras added to this scene
  42575. * @see https://doc.babylonjs.com/babylon101/cameras
  42576. */
  42577. cameras: Camera[];
  42578. /**
  42579. * All of the lights added to this scene
  42580. * @see https://doc.babylonjs.com/babylon101/lights
  42581. */
  42582. lights: Light[];
  42583. /**
  42584. * All of the (abstract) meshes added to this scene
  42585. */
  42586. meshes: AbstractMesh[];
  42587. /**
  42588. * The list of skeletons added to the scene
  42589. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42590. */
  42591. skeletons: Skeleton[];
  42592. /**
  42593. * All of the particle systems added to this scene
  42594. * @see https://doc.babylonjs.com/babylon101/particles
  42595. */
  42596. particleSystems: IParticleSystem[];
  42597. /**
  42598. * Gets a list of Animations associated with the scene
  42599. */
  42600. animations: Animation[];
  42601. /**
  42602. * All of the animation groups added to this scene
  42603. * @see https://doc.babylonjs.com/how_to/group
  42604. */
  42605. animationGroups: AnimationGroup[];
  42606. /**
  42607. * All of the multi-materials added to this scene
  42608. * @see https://doc.babylonjs.com/how_to/multi_materials
  42609. */
  42610. multiMaterials: MultiMaterial[];
  42611. /**
  42612. * All of the materials added to this scene
  42613. * In the context of a Scene, it is not supposed to be modified manually.
  42614. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42615. * Note also that the order of the Material within the array is not significant and might change.
  42616. * @see https://doc.babylonjs.com/babylon101/materials
  42617. */
  42618. materials: Material[];
  42619. /**
  42620. * The list of morph target managers added to the scene
  42621. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42622. */
  42623. morphTargetManagers: MorphTargetManager[];
  42624. /**
  42625. * The list of geometries used in the scene.
  42626. */
  42627. geometries: Geometry[];
  42628. /**
  42629. * All of the tranform nodes added to this scene
  42630. * In the context of a Scene, it is not supposed to be modified manually.
  42631. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42632. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42633. * @see https://doc.babylonjs.com/how_to/transformnode
  42634. */
  42635. transformNodes: TransformNode[];
  42636. /**
  42637. * ActionManagers available on the scene.
  42638. */
  42639. actionManagers: AbstractActionManager[];
  42640. /**
  42641. * Textures to keep.
  42642. */
  42643. textures: BaseTexture[];
  42644. /**
  42645. * Environment texture for the scene
  42646. */
  42647. environmentTexture: Nullable<BaseTexture>;
  42648. /**
  42649. * @returns all meshes, lights, cameras, transformNodes and bones
  42650. */
  42651. getNodes(): Array<Node>;
  42652. }
  42653. }
  42654. declare module "babylonjs/Audio/sound" {
  42655. import { Observable } from "babylonjs/Misc/observable";
  42656. import { Vector3 } from "babylonjs/Maths/math.vector";
  42657. import { Nullable } from "babylonjs/types";
  42658. import { Scene } from "babylonjs/scene";
  42659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42660. /**
  42661. * Interface used to define options for Sound class
  42662. */
  42663. export interface ISoundOptions {
  42664. /**
  42665. * Does the sound autoplay once loaded.
  42666. */
  42667. autoplay?: boolean;
  42668. /**
  42669. * Does the sound loop after it finishes playing once.
  42670. */
  42671. loop?: boolean;
  42672. /**
  42673. * Sound's volume
  42674. */
  42675. volume?: number;
  42676. /**
  42677. * Is it a spatial sound?
  42678. */
  42679. spatialSound?: boolean;
  42680. /**
  42681. * Maximum distance to hear that sound
  42682. */
  42683. maxDistance?: number;
  42684. /**
  42685. * Uses user defined attenuation function
  42686. */
  42687. useCustomAttenuation?: boolean;
  42688. /**
  42689. * Define the roll off factor of spatial sounds.
  42690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42691. */
  42692. rolloffFactor?: number;
  42693. /**
  42694. * Define the reference distance the sound should be heard perfectly.
  42695. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42696. */
  42697. refDistance?: number;
  42698. /**
  42699. * Define the distance attenuation model the sound will follow.
  42700. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42701. */
  42702. distanceModel?: string;
  42703. /**
  42704. * Defines the playback speed (1 by default)
  42705. */
  42706. playbackRate?: number;
  42707. /**
  42708. * Defines if the sound is from a streaming source
  42709. */
  42710. streaming?: boolean;
  42711. /**
  42712. * Defines an optional length (in seconds) inside the sound file
  42713. */
  42714. length?: number;
  42715. /**
  42716. * Defines an optional offset (in seconds) inside the sound file
  42717. */
  42718. offset?: number;
  42719. /**
  42720. * If true, URLs will not be required to state the audio file codec to use.
  42721. */
  42722. skipCodecCheck?: boolean;
  42723. }
  42724. /**
  42725. * Defines a sound that can be played in the application.
  42726. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42728. */
  42729. export class Sound {
  42730. /**
  42731. * The name of the sound in the scene.
  42732. */
  42733. name: string;
  42734. /**
  42735. * Does the sound autoplay once loaded.
  42736. */
  42737. autoplay: boolean;
  42738. /**
  42739. * Does the sound loop after it finishes playing once.
  42740. */
  42741. loop: boolean;
  42742. /**
  42743. * Does the sound use a custom attenuation curve to simulate the falloff
  42744. * happening when the source gets further away from the camera.
  42745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42746. */
  42747. useCustomAttenuation: boolean;
  42748. /**
  42749. * The sound track id this sound belongs to.
  42750. */
  42751. soundTrackId: number;
  42752. /**
  42753. * Is this sound currently played.
  42754. */
  42755. isPlaying: boolean;
  42756. /**
  42757. * Is this sound currently paused.
  42758. */
  42759. isPaused: boolean;
  42760. /**
  42761. * Does this sound enables spatial sound.
  42762. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42763. */
  42764. spatialSound: boolean;
  42765. /**
  42766. * Define the reference distance the sound should be heard perfectly.
  42767. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42768. */
  42769. refDistance: number;
  42770. /**
  42771. * Define the roll off factor of spatial sounds.
  42772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42773. */
  42774. rolloffFactor: number;
  42775. /**
  42776. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42778. */
  42779. maxDistance: number;
  42780. /**
  42781. * Define the distance attenuation model the sound will follow.
  42782. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42783. */
  42784. distanceModel: string;
  42785. /**
  42786. * @hidden
  42787. * Back Compat
  42788. **/
  42789. onended: () => any;
  42790. /**
  42791. * Gets or sets an object used to store user defined information for the sound.
  42792. */
  42793. metadata: any;
  42794. /**
  42795. * Observable event when the current playing sound finishes.
  42796. */
  42797. onEndedObservable: Observable<Sound>;
  42798. private _panningModel;
  42799. private _playbackRate;
  42800. private _streaming;
  42801. private _startTime;
  42802. private _startOffset;
  42803. private _position;
  42804. /** @hidden */
  42805. _positionInEmitterSpace: boolean;
  42806. private _localDirection;
  42807. private _volume;
  42808. private _isReadyToPlay;
  42809. private _isDirectional;
  42810. private _readyToPlayCallback;
  42811. private _audioBuffer;
  42812. private _soundSource;
  42813. private _streamingSource;
  42814. private _soundPanner;
  42815. private _soundGain;
  42816. private _inputAudioNode;
  42817. private _outputAudioNode;
  42818. private _coneInnerAngle;
  42819. private _coneOuterAngle;
  42820. private _coneOuterGain;
  42821. private _scene;
  42822. private _connectedTransformNode;
  42823. private _customAttenuationFunction;
  42824. private _registerFunc;
  42825. private _isOutputConnected;
  42826. private _htmlAudioElement;
  42827. private _urlType;
  42828. private _length?;
  42829. private _offset?;
  42830. /** @hidden */
  42831. static _SceneComponentInitialization: (scene: Scene) => void;
  42832. /**
  42833. * Create a sound and attach it to a scene
  42834. * @param name Name of your sound
  42835. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42836. * @param scene defines the scene the sound belongs to
  42837. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42838. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42839. */
  42840. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42841. /**
  42842. * Release the sound and its associated resources
  42843. */
  42844. dispose(): void;
  42845. /**
  42846. * Gets if the sounds is ready to be played or not.
  42847. * @returns true if ready, otherwise false
  42848. */
  42849. isReady(): boolean;
  42850. private _soundLoaded;
  42851. /**
  42852. * Sets the data of the sound from an audiobuffer
  42853. * @param audioBuffer The audioBuffer containing the data
  42854. */
  42855. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42856. /**
  42857. * Updates the current sounds options such as maxdistance, loop...
  42858. * @param options A JSON object containing values named as the object properties
  42859. */
  42860. updateOptions(options: ISoundOptions): void;
  42861. private _createSpatialParameters;
  42862. private _updateSpatialParameters;
  42863. /**
  42864. * Switch the panning model to HRTF:
  42865. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42867. */
  42868. switchPanningModelToHRTF(): void;
  42869. /**
  42870. * Switch the panning model to Equal Power:
  42871. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42872. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42873. */
  42874. switchPanningModelToEqualPower(): void;
  42875. private _switchPanningModel;
  42876. /**
  42877. * Connect this sound to a sound track audio node like gain...
  42878. * @param soundTrackAudioNode the sound track audio node to connect to
  42879. */
  42880. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42881. /**
  42882. * Transform this sound into a directional source
  42883. * @param coneInnerAngle Size of the inner cone in degree
  42884. * @param coneOuterAngle Size of the outer cone in degree
  42885. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42886. */
  42887. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42888. /**
  42889. * Gets or sets the inner angle for the directional cone.
  42890. */
  42891. get directionalConeInnerAngle(): number;
  42892. /**
  42893. * Gets or sets the inner angle for the directional cone.
  42894. */
  42895. set directionalConeInnerAngle(value: number);
  42896. /**
  42897. * Gets or sets the outer angle for the directional cone.
  42898. */
  42899. get directionalConeOuterAngle(): number;
  42900. /**
  42901. * Gets or sets the outer angle for the directional cone.
  42902. */
  42903. set directionalConeOuterAngle(value: number);
  42904. /**
  42905. * Sets the position of the emitter if spatial sound is enabled
  42906. * @param newPosition Defines the new posisiton
  42907. */
  42908. setPosition(newPosition: Vector3): void;
  42909. /**
  42910. * Sets the local direction of the emitter if spatial sound is enabled
  42911. * @param newLocalDirection Defines the new local direction
  42912. */
  42913. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42914. private _updateDirection;
  42915. /** @hidden */
  42916. updateDistanceFromListener(): void;
  42917. /**
  42918. * Sets a new custom attenuation function for the sound.
  42919. * @param callback Defines the function used for the attenuation
  42920. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42921. */
  42922. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42923. /**
  42924. * Play the sound
  42925. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42926. * @param offset (optional) Start the sound at a specific time in seconds
  42927. * @param length (optional) Sound duration (in seconds)
  42928. */
  42929. play(time?: number, offset?: number, length?: number): void;
  42930. private _onended;
  42931. /**
  42932. * Stop the sound
  42933. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42934. */
  42935. stop(time?: number): void;
  42936. /**
  42937. * Put the sound in pause
  42938. */
  42939. pause(): void;
  42940. /**
  42941. * Sets a dedicated volume for this sounds
  42942. * @param newVolume Define the new volume of the sound
  42943. * @param time Define time for gradual change to new volume
  42944. */
  42945. setVolume(newVolume: number, time?: number): void;
  42946. /**
  42947. * Set the sound play back rate
  42948. * @param newPlaybackRate Define the playback rate the sound should be played at
  42949. */
  42950. setPlaybackRate(newPlaybackRate: number): void;
  42951. /**
  42952. * Gets the volume of the sound.
  42953. * @returns the volume of the sound
  42954. */
  42955. getVolume(): number;
  42956. /**
  42957. * Attach the sound to a dedicated mesh
  42958. * @param transformNode The transform node to connect the sound with
  42959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42960. */
  42961. attachToMesh(transformNode: TransformNode): void;
  42962. /**
  42963. * Detach the sound from the previously attached mesh
  42964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42965. */
  42966. detachFromMesh(): void;
  42967. private _onRegisterAfterWorldMatrixUpdate;
  42968. /**
  42969. * Clone the current sound in the scene.
  42970. * @returns the new sound clone
  42971. */
  42972. clone(): Nullable<Sound>;
  42973. /**
  42974. * Gets the current underlying audio buffer containing the data
  42975. * @returns the audio buffer
  42976. */
  42977. getAudioBuffer(): Nullable<AudioBuffer>;
  42978. /**
  42979. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42980. * @returns the source node
  42981. */
  42982. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42983. /**
  42984. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42985. * @returns the gain node
  42986. */
  42987. getSoundGain(): Nullable<GainNode>;
  42988. /**
  42989. * Serializes the Sound in a JSON representation
  42990. * @returns the JSON representation of the sound
  42991. */
  42992. serialize(): any;
  42993. /**
  42994. * Parse a JSON representation of a sound to innstantiate in a given scene
  42995. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42996. * @param scene Define the scene the new parsed sound should be created in
  42997. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42998. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42999. * @returns the newly parsed sound
  43000. */
  43001. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43002. }
  43003. }
  43004. declare module "babylonjs/Actions/directAudioActions" {
  43005. import { Action } from "babylonjs/Actions/action";
  43006. import { Condition } from "babylonjs/Actions/condition";
  43007. import { Sound } from "babylonjs/Audio/sound";
  43008. /**
  43009. * This defines an action helpful to play a defined sound on a triggered action.
  43010. */
  43011. export class PlaySoundAction extends Action {
  43012. private _sound;
  43013. /**
  43014. * Instantiate the action
  43015. * @param triggerOptions defines the trigger options
  43016. * @param sound defines the sound to play
  43017. * @param condition defines the trigger related conditions
  43018. */
  43019. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43020. /** @hidden */
  43021. _prepare(): void;
  43022. /**
  43023. * Execute the action and play the sound.
  43024. */
  43025. execute(): void;
  43026. /**
  43027. * Serializes the actions and its related information.
  43028. * @param parent defines the object to serialize in
  43029. * @returns the serialized object
  43030. */
  43031. serialize(parent: any): any;
  43032. }
  43033. /**
  43034. * This defines an action helpful to stop a defined sound on a triggered action.
  43035. */
  43036. export class StopSoundAction extends Action {
  43037. private _sound;
  43038. /**
  43039. * Instantiate the action
  43040. * @param triggerOptions defines the trigger options
  43041. * @param sound defines the sound to stop
  43042. * @param condition defines the trigger related conditions
  43043. */
  43044. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43045. /** @hidden */
  43046. _prepare(): void;
  43047. /**
  43048. * Execute the action and stop the sound.
  43049. */
  43050. execute(): void;
  43051. /**
  43052. * Serializes the actions and its related information.
  43053. * @param parent defines the object to serialize in
  43054. * @returns the serialized object
  43055. */
  43056. serialize(parent: any): any;
  43057. }
  43058. }
  43059. declare module "babylonjs/Actions/interpolateValueAction" {
  43060. import { Action } from "babylonjs/Actions/action";
  43061. import { Condition } from "babylonjs/Actions/condition";
  43062. import { Observable } from "babylonjs/Misc/observable";
  43063. /**
  43064. * This defines an action responsible to change the value of a property
  43065. * by interpolating between its current value and the newly set one once triggered.
  43066. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43067. */
  43068. export class InterpolateValueAction extends Action {
  43069. /**
  43070. * Defines the path of the property where the value should be interpolated
  43071. */
  43072. propertyPath: string;
  43073. /**
  43074. * Defines the target value at the end of the interpolation.
  43075. */
  43076. value: any;
  43077. /**
  43078. * Defines the time it will take for the property to interpolate to the value.
  43079. */
  43080. duration: number;
  43081. /**
  43082. * Defines if the other scene animations should be stopped when the action has been triggered
  43083. */
  43084. stopOtherAnimations?: boolean;
  43085. /**
  43086. * Defines a callback raised once the interpolation animation has been done.
  43087. */
  43088. onInterpolationDone?: () => void;
  43089. /**
  43090. * Observable triggered once the interpolation animation has been done.
  43091. */
  43092. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43093. private _target;
  43094. private _effectiveTarget;
  43095. private _property;
  43096. /**
  43097. * Instantiate the action
  43098. * @param triggerOptions defines the trigger options
  43099. * @param target defines the object containing the value to interpolate
  43100. * @param propertyPath defines the path to the property in the target object
  43101. * @param value defines the target value at the end of the interpolation
  43102. * @param duration deines the time it will take for the property to interpolate to the value.
  43103. * @param condition defines the trigger related conditions
  43104. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43105. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43106. */
  43107. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43108. /** @hidden */
  43109. _prepare(): void;
  43110. /**
  43111. * Execute the action starts the value interpolation.
  43112. */
  43113. execute(): void;
  43114. /**
  43115. * Serializes the actions and its related information.
  43116. * @param parent defines the object to serialize in
  43117. * @returns the serialized object
  43118. */
  43119. serialize(parent: any): any;
  43120. }
  43121. }
  43122. declare module "babylonjs/Actions/index" {
  43123. export * from "babylonjs/Actions/abstractActionManager";
  43124. export * from "babylonjs/Actions/action";
  43125. export * from "babylonjs/Actions/actionEvent";
  43126. export * from "babylonjs/Actions/actionManager";
  43127. export * from "babylonjs/Actions/condition";
  43128. export * from "babylonjs/Actions/directActions";
  43129. export * from "babylonjs/Actions/directAudioActions";
  43130. export * from "babylonjs/Actions/interpolateValueAction";
  43131. }
  43132. declare module "babylonjs/Animations/index" {
  43133. export * from "babylonjs/Animations/animatable";
  43134. export * from "babylonjs/Animations/animation";
  43135. export * from "babylonjs/Animations/animationGroup";
  43136. export * from "babylonjs/Animations/animationPropertiesOverride";
  43137. export * from "babylonjs/Animations/easing";
  43138. export * from "babylonjs/Animations/runtimeAnimation";
  43139. export * from "babylonjs/Animations/animationEvent";
  43140. export * from "babylonjs/Animations/animationGroup";
  43141. export * from "babylonjs/Animations/animationKey";
  43142. export * from "babylonjs/Animations/animationRange";
  43143. export * from "babylonjs/Animations/animatable.interface";
  43144. }
  43145. declare module "babylonjs/Audio/soundTrack" {
  43146. import { Sound } from "babylonjs/Audio/sound";
  43147. import { Analyser } from "babylonjs/Audio/analyser";
  43148. import { Scene } from "babylonjs/scene";
  43149. /**
  43150. * Options allowed during the creation of a sound track.
  43151. */
  43152. export interface ISoundTrackOptions {
  43153. /**
  43154. * The volume the sound track should take during creation
  43155. */
  43156. volume?: number;
  43157. /**
  43158. * Define if the sound track is the main sound track of the scene
  43159. */
  43160. mainTrack?: boolean;
  43161. }
  43162. /**
  43163. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43164. * It will be also used in a future release to apply effects on a specific track.
  43165. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43166. */
  43167. export class SoundTrack {
  43168. /**
  43169. * The unique identifier of the sound track in the scene.
  43170. */
  43171. id: number;
  43172. /**
  43173. * The list of sounds included in the sound track.
  43174. */
  43175. soundCollection: Array<Sound>;
  43176. private _outputAudioNode;
  43177. private _scene;
  43178. private _connectedAnalyser;
  43179. private _options;
  43180. private _isInitialized;
  43181. /**
  43182. * Creates a new sound track.
  43183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43184. * @param scene Define the scene the sound track belongs to
  43185. * @param options
  43186. */
  43187. constructor(scene: Scene, options?: ISoundTrackOptions);
  43188. private _initializeSoundTrackAudioGraph;
  43189. /**
  43190. * Release the sound track and its associated resources
  43191. */
  43192. dispose(): void;
  43193. /**
  43194. * Adds a sound to this sound track
  43195. * @param sound define the cound to add
  43196. * @ignoreNaming
  43197. */
  43198. AddSound(sound: Sound): void;
  43199. /**
  43200. * Removes a sound to this sound track
  43201. * @param sound define the cound to remove
  43202. * @ignoreNaming
  43203. */
  43204. RemoveSound(sound: Sound): void;
  43205. /**
  43206. * Set a global volume for the full sound track.
  43207. * @param newVolume Define the new volume of the sound track
  43208. */
  43209. setVolume(newVolume: number): void;
  43210. /**
  43211. * Switch the panning model to HRTF:
  43212. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43214. */
  43215. switchPanningModelToHRTF(): void;
  43216. /**
  43217. * Switch the panning model to Equal Power:
  43218. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43220. */
  43221. switchPanningModelToEqualPower(): void;
  43222. /**
  43223. * Connect the sound track to an audio analyser allowing some amazing
  43224. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43226. * @param analyser The analyser to connect to the engine
  43227. */
  43228. connectToAnalyser(analyser: Analyser): void;
  43229. }
  43230. }
  43231. declare module "babylonjs/Audio/audioSceneComponent" {
  43232. import { Sound } from "babylonjs/Audio/sound";
  43233. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43234. import { Nullable } from "babylonjs/types";
  43235. import { Vector3 } from "babylonjs/Maths/math.vector";
  43236. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43237. import { Scene } from "babylonjs/scene";
  43238. import { AbstractScene } from "babylonjs/abstractScene";
  43239. import "babylonjs/Audio/audioEngine";
  43240. module "babylonjs/abstractScene" {
  43241. interface AbstractScene {
  43242. /**
  43243. * The list of sounds used in the scene.
  43244. */
  43245. sounds: Nullable<Array<Sound>>;
  43246. }
  43247. }
  43248. module "babylonjs/scene" {
  43249. interface Scene {
  43250. /**
  43251. * @hidden
  43252. * Backing field
  43253. */
  43254. _mainSoundTrack: SoundTrack;
  43255. /**
  43256. * The main sound track played by the scene.
  43257. * It cotains your primary collection of sounds.
  43258. */
  43259. mainSoundTrack: SoundTrack;
  43260. /**
  43261. * The list of sound tracks added to the scene
  43262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43263. */
  43264. soundTracks: Nullable<Array<SoundTrack>>;
  43265. /**
  43266. * Gets a sound using a given name
  43267. * @param name defines the name to search for
  43268. * @return the found sound or null if not found at all.
  43269. */
  43270. getSoundByName(name: string): Nullable<Sound>;
  43271. /**
  43272. * Gets or sets if audio support is enabled
  43273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43274. */
  43275. audioEnabled: boolean;
  43276. /**
  43277. * Gets or sets if audio will be output to headphones
  43278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43279. */
  43280. headphone: boolean;
  43281. /**
  43282. * Gets or sets custom audio listener position provider
  43283. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43284. */
  43285. audioListenerPositionProvider: Nullable<() => Vector3>;
  43286. /**
  43287. * Gets or sets a refresh rate when using 3D audio positioning
  43288. */
  43289. audioPositioningRefreshRate: number;
  43290. }
  43291. }
  43292. /**
  43293. * Defines the sound scene component responsible to manage any sounds
  43294. * in a given scene.
  43295. */
  43296. export class AudioSceneComponent implements ISceneSerializableComponent {
  43297. /**
  43298. * The component name helpfull to identify the component in the list of scene components.
  43299. */
  43300. readonly name: string;
  43301. /**
  43302. * The scene the component belongs to.
  43303. */
  43304. scene: Scene;
  43305. private _audioEnabled;
  43306. /**
  43307. * Gets whether audio is enabled or not.
  43308. * Please use related enable/disable method to switch state.
  43309. */
  43310. get audioEnabled(): boolean;
  43311. private _headphone;
  43312. /**
  43313. * Gets whether audio is outputing to headphone or not.
  43314. * Please use the according Switch methods to change output.
  43315. */
  43316. get headphone(): boolean;
  43317. /**
  43318. * Gets or sets a refresh rate when using 3D audio positioning
  43319. */
  43320. audioPositioningRefreshRate: number;
  43321. private _audioListenerPositionProvider;
  43322. /**
  43323. * Gets the current audio listener position provider
  43324. */
  43325. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43326. /**
  43327. * Sets a custom listener position for all sounds in the scene
  43328. * By default, this is the position of the first active camera
  43329. */
  43330. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43331. /**
  43332. * Creates a new instance of the component for the given scene
  43333. * @param scene Defines the scene to register the component in
  43334. */
  43335. constructor(scene: Scene);
  43336. /**
  43337. * Registers the component in a given scene
  43338. */
  43339. register(): void;
  43340. /**
  43341. * Rebuilds the elements related to this component in case of
  43342. * context lost for instance.
  43343. */
  43344. rebuild(): void;
  43345. /**
  43346. * Serializes the component data to the specified json object
  43347. * @param serializationObject The object to serialize to
  43348. */
  43349. serialize(serializationObject: any): void;
  43350. /**
  43351. * Adds all the elements from the container to the scene
  43352. * @param container the container holding the elements
  43353. */
  43354. addFromContainer(container: AbstractScene): void;
  43355. /**
  43356. * Removes all the elements in the container from the scene
  43357. * @param container contains the elements to remove
  43358. * @param dispose if the removed element should be disposed (default: false)
  43359. */
  43360. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43361. /**
  43362. * Disposes the component and the associated ressources.
  43363. */
  43364. dispose(): void;
  43365. /**
  43366. * Disables audio in the associated scene.
  43367. */
  43368. disableAudio(): void;
  43369. /**
  43370. * Enables audio in the associated scene.
  43371. */
  43372. enableAudio(): void;
  43373. /**
  43374. * Switch audio to headphone output.
  43375. */
  43376. switchAudioModeForHeadphones(): void;
  43377. /**
  43378. * Switch audio to normal speakers.
  43379. */
  43380. switchAudioModeForNormalSpeakers(): void;
  43381. private _cachedCameraDirection;
  43382. private _cachedCameraPosition;
  43383. private _lastCheck;
  43384. private _afterRender;
  43385. }
  43386. }
  43387. declare module "babylonjs/Audio/weightedsound" {
  43388. import { Sound } from "babylonjs/Audio/sound";
  43389. /**
  43390. * Wraps one or more Sound objects and selects one with random weight for playback.
  43391. */
  43392. export class WeightedSound {
  43393. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43394. loop: boolean;
  43395. private _coneInnerAngle;
  43396. private _coneOuterAngle;
  43397. private _volume;
  43398. /** A Sound is currently playing. */
  43399. isPlaying: boolean;
  43400. /** A Sound is currently paused. */
  43401. isPaused: boolean;
  43402. private _sounds;
  43403. private _weights;
  43404. private _currentIndex?;
  43405. /**
  43406. * Creates a new WeightedSound from the list of sounds given.
  43407. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43408. * @param sounds Array of Sounds that will be selected from.
  43409. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43410. */
  43411. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43412. /**
  43413. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43414. */
  43415. get directionalConeInnerAngle(): number;
  43416. /**
  43417. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43418. */
  43419. set directionalConeInnerAngle(value: number);
  43420. /**
  43421. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43422. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43423. */
  43424. get directionalConeOuterAngle(): number;
  43425. /**
  43426. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43427. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43428. */
  43429. set directionalConeOuterAngle(value: number);
  43430. /**
  43431. * Playback volume.
  43432. */
  43433. get volume(): number;
  43434. /**
  43435. * Playback volume.
  43436. */
  43437. set volume(value: number);
  43438. private _onended;
  43439. /**
  43440. * Suspend playback
  43441. */
  43442. pause(): void;
  43443. /**
  43444. * Stop playback
  43445. */
  43446. stop(): void;
  43447. /**
  43448. * Start playback.
  43449. * @param startOffset Position the clip head at a specific time in seconds.
  43450. */
  43451. play(startOffset?: number): void;
  43452. }
  43453. }
  43454. declare module "babylonjs/Audio/index" {
  43455. export * from "babylonjs/Audio/analyser";
  43456. export * from "babylonjs/Audio/audioEngine";
  43457. export * from "babylonjs/Audio/audioSceneComponent";
  43458. export * from "babylonjs/Audio/sound";
  43459. export * from "babylonjs/Audio/soundTrack";
  43460. export * from "babylonjs/Audio/weightedsound";
  43461. }
  43462. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43463. import { Behavior } from "babylonjs/Behaviors/behavior";
  43464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43465. import { BackEase } from "babylonjs/Animations/easing";
  43466. /**
  43467. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43468. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43469. */
  43470. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43471. /**
  43472. * Gets the name of the behavior.
  43473. */
  43474. get name(): string;
  43475. /**
  43476. * The easing function used by animations
  43477. */
  43478. static EasingFunction: BackEase;
  43479. /**
  43480. * The easing mode used by animations
  43481. */
  43482. static EasingMode: number;
  43483. /**
  43484. * The duration of the animation, in milliseconds
  43485. */
  43486. transitionDuration: number;
  43487. /**
  43488. * Length of the distance animated by the transition when lower radius is reached
  43489. */
  43490. lowerRadiusTransitionRange: number;
  43491. /**
  43492. * Length of the distance animated by the transition when upper radius is reached
  43493. */
  43494. upperRadiusTransitionRange: number;
  43495. private _autoTransitionRange;
  43496. /**
  43497. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43498. */
  43499. get autoTransitionRange(): boolean;
  43500. /**
  43501. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43502. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43503. */
  43504. set autoTransitionRange(value: boolean);
  43505. private _attachedCamera;
  43506. private _onAfterCheckInputsObserver;
  43507. private _onMeshTargetChangedObserver;
  43508. /**
  43509. * Initializes the behavior.
  43510. */
  43511. init(): void;
  43512. /**
  43513. * Attaches the behavior to its arc rotate camera.
  43514. * @param camera Defines the camera to attach the behavior to
  43515. */
  43516. attach(camera: ArcRotateCamera): void;
  43517. /**
  43518. * Detaches the behavior from its current arc rotate camera.
  43519. */
  43520. detach(): void;
  43521. private _radiusIsAnimating;
  43522. private _radiusBounceTransition;
  43523. private _animatables;
  43524. private _cachedWheelPrecision;
  43525. /**
  43526. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43527. * @param radiusLimit The limit to check against.
  43528. * @return Bool to indicate if at limit.
  43529. */
  43530. private _isRadiusAtLimit;
  43531. /**
  43532. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43533. * @param radiusDelta The delta by which to animate to. Can be negative.
  43534. */
  43535. private _applyBoundRadiusAnimation;
  43536. /**
  43537. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43538. */
  43539. protected _clearAnimationLocks(): void;
  43540. /**
  43541. * Stops and removes all animations that have been applied to the camera
  43542. */
  43543. stopAllAnimations(): void;
  43544. }
  43545. }
  43546. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43547. import { Behavior } from "babylonjs/Behaviors/behavior";
  43548. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43549. import { ExponentialEase } from "babylonjs/Animations/easing";
  43550. import { Nullable } from "babylonjs/types";
  43551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43552. import { Vector3 } from "babylonjs/Maths/math.vector";
  43553. /**
  43554. * 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.
  43555. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43556. */
  43557. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43558. /**
  43559. * Gets the name of the behavior.
  43560. */
  43561. get name(): string;
  43562. private _mode;
  43563. private _radiusScale;
  43564. private _positionScale;
  43565. private _defaultElevation;
  43566. private _elevationReturnTime;
  43567. private _elevationReturnWaitTime;
  43568. private _zoomStopsAnimation;
  43569. private _framingTime;
  43570. /**
  43571. * The easing function used by animations
  43572. */
  43573. static EasingFunction: ExponentialEase;
  43574. /**
  43575. * The easing mode used by animations
  43576. */
  43577. static EasingMode: number;
  43578. /**
  43579. * Sets the current mode used by the behavior
  43580. */
  43581. set mode(mode: number);
  43582. /**
  43583. * Gets current mode used by the behavior.
  43584. */
  43585. get mode(): number;
  43586. /**
  43587. * Sets the scale applied to the radius (1 by default)
  43588. */
  43589. set radiusScale(radius: number);
  43590. /**
  43591. * Gets the scale applied to the radius
  43592. */
  43593. get radiusScale(): number;
  43594. /**
  43595. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43596. */
  43597. set positionScale(scale: number);
  43598. /**
  43599. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43600. */
  43601. get positionScale(): number;
  43602. /**
  43603. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43604. * behaviour is triggered, in radians.
  43605. */
  43606. set defaultElevation(elevation: number);
  43607. /**
  43608. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43609. * behaviour is triggered, in radians.
  43610. */
  43611. get defaultElevation(): number;
  43612. /**
  43613. * Sets the time (in milliseconds) taken to return to the default beta position.
  43614. * Negative value indicates camera should not return to default.
  43615. */
  43616. set elevationReturnTime(speed: number);
  43617. /**
  43618. * Gets the time (in milliseconds) taken to return to the default beta position.
  43619. * Negative value indicates camera should not return to default.
  43620. */
  43621. get elevationReturnTime(): number;
  43622. /**
  43623. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43624. */
  43625. set elevationReturnWaitTime(time: number);
  43626. /**
  43627. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43628. */
  43629. get elevationReturnWaitTime(): number;
  43630. /**
  43631. * Sets the flag that indicates if user zooming should stop animation.
  43632. */
  43633. set zoomStopsAnimation(flag: boolean);
  43634. /**
  43635. * Gets the flag that indicates if user zooming should stop animation.
  43636. */
  43637. get zoomStopsAnimation(): boolean;
  43638. /**
  43639. * Sets the transition time when framing the mesh, in milliseconds
  43640. */
  43641. set framingTime(time: number);
  43642. /**
  43643. * Gets the transition time when framing the mesh, in milliseconds
  43644. */
  43645. get framingTime(): number;
  43646. /**
  43647. * Define if the behavior should automatically change the configured
  43648. * camera limits and sensibilities.
  43649. */
  43650. autoCorrectCameraLimitsAndSensibility: boolean;
  43651. private _onPrePointerObservableObserver;
  43652. private _onAfterCheckInputsObserver;
  43653. private _onMeshTargetChangedObserver;
  43654. private _attachedCamera;
  43655. private _isPointerDown;
  43656. private _lastInteractionTime;
  43657. /**
  43658. * Initializes the behavior.
  43659. */
  43660. init(): void;
  43661. /**
  43662. * Attaches the behavior to its arc rotate camera.
  43663. * @param camera Defines the camera to attach the behavior to
  43664. */
  43665. attach(camera: ArcRotateCamera): void;
  43666. /**
  43667. * Detaches the behavior from its current arc rotate camera.
  43668. */
  43669. detach(): void;
  43670. private _animatables;
  43671. private _betaIsAnimating;
  43672. private _betaTransition;
  43673. private _radiusTransition;
  43674. private _vectorTransition;
  43675. /**
  43676. * Targets the given mesh and updates zoom level accordingly.
  43677. * @param mesh The mesh to target.
  43678. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43679. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43680. */
  43681. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43682. /**
  43683. * Targets the given mesh with its children and updates zoom level accordingly.
  43684. * @param mesh The mesh to target.
  43685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43687. */
  43688. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43689. /**
  43690. * Targets the given meshes with their children and updates zoom level accordingly.
  43691. * @param meshes The mesh to target.
  43692. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43693. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43694. */
  43695. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43696. /**
  43697. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43698. * @param minimumWorld Determines the smaller position of the bounding box extend
  43699. * @param maximumWorld Determines the bigger position of the bounding box extend
  43700. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43701. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43702. */
  43703. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43704. /**
  43705. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43706. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43707. * frustum width.
  43708. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43709. * to fully enclose the mesh in the viewing frustum.
  43710. */
  43711. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43712. /**
  43713. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43714. * is automatically returned to its default position (expected to be above ground plane).
  43715. */
  43716. private _maintainCameraAboveGround;
  43717. /**
  43718. * Returns the frustum slope based on the canvas ratio and camera FOV
  43719. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43720. */
  43721. private _getFrustumSlope;
  43722. /**
  43723. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43724. */
  43725. private _clearAnimationLocks;
  43726. /**
  43727. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43728. */
  43729. private _applyUserInteraction;
  43730. /**
  43731. * Stops and removes all animations that have been applied to the camera
  43732. */
  43733. stopAllAnimations(): void;
  43734. /**
  43735. * Gets a value indicating if the user is moving the camera
  43736. */
  43737. get isUserIsMoving(): boolean;
  43738. /**
  43739. * The camera can move all the way towards the mesh.
  43740. */
  43741. static IgnoreBoundsSizeMode: number;
  43742. /**
  43743. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43744. */
  43745. static FitFrustumSidesMode: number;
  43746. }
  43747. }
  43748. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43749. import { Nullable } from "babylonjs/types";
  43750. import { Camera } from "babylonjs/Cameras/camera";
  43751. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43752. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43753. /**
  43754. * Base class for Camera Pointer Inputs.
  43755. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43756. * for example usage.
  43757. */
  43758. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43759. /**
  43760. * Defines the camera the input is attached to.
  43761. */
  43762. abstract camera: Camera;
  43763. /**
  43764. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43765. */
  43766. protected _altKey: boolean;
  43767. protected _ctrlKey: boolean;
  43768. protected _metaKey: boolean;
  43769. protected _shiftKey: boolean;
  43770. /**
  43771. * Which mouse buttons were pressed at time of last mouse event.
  43772. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43773. */
  43774. protected _buttonsPressed: number;
  43775. /**
  43776. * Defines the buttons associated with the input to handle camera move.
  43777. */
  43778. buttons: number[];
  43779. /**
  43780. * Attach the input controls to a specific dom element to get the input from.
  43781. * @param element Defines the element the controls should be listened from
  43782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43783. */
  43784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43785. /**
  43786. * Detach the current controls from the specified dom element.
  43787. * @param element Defines the element to stop listening the inputs from
  43788. */
  43789. detachControl(element: Nullable<HTMLElement>): void;
  43790. /**
  43791. * Gets the class name of the current input.
  43792. * @returns the class name
  43793. */
  43794. getClassName(): string;
  43795. /**
  43796. * Get the friendly name associated with the input class.
  43797. * @returns the input friendly name
  43798. */
  43799. getSimpleName(): string;
  43800. /**
  43801. * Called on pointer POINTERDOUBLETAP event.
  43802. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43803. */
  43804. protected onDoubleTap(type: string): void;
  43805. /**
  43806. * Called on pointer POINTERMOVE event if only a single touch is active.
  43807. * Override this method to provide functionality.
  43808. */
  43809. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43810. /**
  43811. * Called on pointer POINTERMOVE event if multiple touches are active.
  43812. * Override this method to provide functionality.
  43813. */
  43814. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43815. /**
  43816. * Called on JS contextmenu event.
  43817. * Override this method to provide functionality.
  43818. */
  43819. protected onContextMenu(evt: PointerEvent): void;
  43820. /**
  43821. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43822. * press.
  43823. * Override this method to provide functionality.
  43824. */
  43825. protected onButtonDown(evt: PointerEvent): void;
  43826. /**
  43827. * Called each time a new POINTERUP event occurs. Ie, for each button
  43828. * release.
  43829. * Override this method to provide functionality.
  43830. */
  43831. protected onButtonUp(evt: PointerEvent): void;
  43832. /**
  43833. * Called when window becomes inactive.
  43834. * Override this method to provide functionality.
  43835. */
  43836. protected onLostFocus(): void;
  43837. private _pointerInput;
  43838. private _observer;
  43839. private _onLostFocus;
  43840. private pointA;
  43841. private pointB;
  43842. }
  43843. }
  43844. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43845. import { Nullable } from "babylonjs/types";
  43846. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43847. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43848. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43849. /**
  43850. * Manage the pointers inputs to control an arc rotate camera.
  43851. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43852. */
  43853. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43854. /**
  43855. * Defines the camera the input is attached to.
  43856. */
  43857. camera: ArcRotateCamera;
  43858. /**
  43859. * Gets the class name of the current input.
  43860. * @returns the class name
  43861. */
  43862. getClassName(): string;
  43863. /**
  43864. * Defines the buttons associated with the input to handle camera move.
  43865. */
  43866. buttons: number[];
  43867. /**
  43868. * Defines the pointer angular sensibility along the X axis or how fast is
  43869. * the camera rotating.
  43870. */
  43871. angularSensibilityX: number;
  43872. /**
  43873. * Defines the pointer angular sensibility along the Y axis or how fast is
  43874. * the camera rotating.
  43875. */
  43876. angularSensibilityY: number;
  43877. /**
  43878. * Defines the pointer pinch precision or how fast is the camera zooming.
  43879. */
  43880. pinchPrecision: number;
  43881. /**
  43882. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43883. * from 0.
  43884. * It defines the percentage of current camera.radius to use as delta when
  43885. * pinch zoom is used.
  43886. */
  43887. pinchDeltaPercentage: number;
  43888. /**
  43889. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43890. * that any object in the plane at the camera's target point will scale
  43891. * perfectly with finger motion.
  43892. * Overrides pinchDeltaPercentage and pinchPrecision.
  43893. */
  43894. useNaturalPinchZoom: boolean;
  43895. /**
  43896. * Defines the pointer panning sensibility or how fast is the camera moving.
  43897. */
  43898. panningSensibility: number;
  43899. /**
  43900. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43901. */
  43902. multiTouchPanning: boolean;
  43903. /**
  43904. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43905. * zoom (pinch) through multitouch.
  43906. */
  43907. multiTouchPanAndZoom: boolean;
  43908. /**
  43909. * Revers pinch action direction.
  43910. */
  43911. pinchInwards: boolean;
  43912. private _isPanClick;
  43913. private _twoFingerActivityCount;
  43914. private _isPinching;
  43915. /**
  43916. * Called on pointer POINTERMOVE event if only a single touch is active.
  43917. */
  43918. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43919. /**
  43920. * Called on pointer POINTERDOUBLETAP event.
  43921. */
  43922. protected onDoubleTap(type: string): void;
  43923. /**
  43924. * Called on pointer POINTERMOVE event if multiple touches are active.
  43925. */
  43926. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43927. /**
  43928. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43929. * press.
  43930. */
  43931. protected onButtonDown(evt: PointerEvent): void;
  43932. /**
  43933. * Called each time a new POINTERUP event occurs. Ie, for each button
  43934. * release.
  43935. */
  43936. protected onButtonUp(evt: PointerEvent): void;
  43937. /**
  43938. * Called when window becomes inactive.
  43939. */
  43940. protected onLostFocus(): void;
  43941. }
  43942. }
  43943. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43944. import { Nullable } from "babylonjs/types";
  43945. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43946. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43947. /**
  43948. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43949. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43950. */
  43951. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43952. /**
  43953. * Defines the camera the input is attached to.
  43954. */
  43955. camera: ArcRotateCamera;
  43956. /**
  43957. * Defines the list of key codes associated with the up action (increase alpha)
  43958. */
  43959. keysUp: number[];
  43960. /**
  43961. * Defines the list of key codes associated with the down action (decrease alpha)
  43962. */
  43963. keysDown: number[];
  43964. /**
  43965. * Defines the list of key codes associated with the left action (increase beta)
  43966. */
  43967. keysLeft: number[];
  43968. /**
  43969. * Defines the list of key codes associated with the right action (decrease beta)
  43970. */
  43971. keysRight: number[];
  43972. /**
  43973. * Defines the list of key codes associated with the reset action.
  43974. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43975. */
  43976. keysReset: number[];
  43977. /**
  43978. * Defines the panning sensibility of the inputs.
  43979. * (How fast is the camera panning)
  43980. */
  43981. panningSensibility: number;
  43982. /**
  43983. * Defines the zooming sensibility of the inputs.
  43984. * (How fast is the camera zooming)
  43985. */
  43986. zoomingSensibility: number;
  43987. /**
  43988. * Defines whether maintaining the alt key down switch the movement mode from
  43989. * orientation to zoom.
  43990. */
  43991. useAltToZoom: boolean;
  43992. /**
  43993. * Rotation speed of the camera
  43994. */
  43995. angularSpeed: number;
  43996. private _keys;
  43997. private _ctrlPressed;
  43998. private _altPressed;
  43999. private _onCanvasBlurObserver;
  44000. private _onKeyboardObserver;
  44001. private _engine;
  44002. private _scene;
  44003. /**
  44004. * Attach the input controls to a specific dom element to get the input from.
  44005. * @param element Defines the element the controls should be listened from
  44006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44007. */
  44008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44009. /**
  44010. * Detach the current controls from the specified dom element.
  44011. * @param element Defines the element to stop listening the inputs from
  44012. */
  44013. detachControl(element: Nullable<HTMLElement>): void;
  44014. /**
  44015. * Update the current camera state depending on the inputs that have been used this frame.
  44016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44017. */
  44018. checkInputs(): void;
  44019. /**
  44020. * Gets the class name of the current intput.
  44021. * @returns the class name
  44022. */
  44023. getClassName(): string;
  44024. /**
  44025. * Get the friendly name associated with the input class.
  44026. * @returns the input friendly name
  44027. */
  44028. getSimpleName(): string;
  44029. }
  44030. }
  44031. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44032. import { Nullable } from "babylonjs/types";
  44033. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44035. /**
  44036. * Manage the mouse wheel inputs to control an arc rotate camera.
  44037. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44038. */
  44039. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44040. /**
  44041. * Defines the camera the input is attached to.
  44042. */
  44043. camera: ArcRotateCamera;
  44044. /**
  44045. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44046. */
  44047. wheelPrecision: number;
  44048. /**
  44049. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44050. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44051. */
  44052. wheelDeltaPercentage: number;
  44053. private _wheel;
  44054. private _observer;
  44055. private computeDeltaFromMouseWheelLegacyEvent;
  44056. /**
  44057. * Attach the input controls to a specific dom element to get the input from.
  44058. * @param element Defines the element the controls should be listened from
  44059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44060. */
  44061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44062. /**
  44063. * Detach the current controls from the specified dom element.
  44064. * @param element Defines the element to stop listening the inputs from
  44065. */
  44066. detachControl(element: Nullable<HTMLElement>): void;
  44067. /**
  44068. * Gets the class name of the current intput.
  44069. * @returns the class name
  44070. */
  44071. getClassName(): string;
  44072. /**
  44073. * Get the friendly name associated with the input class.
  44074. * @returns the input friendly name
  44075. */
  44076. getSimpleName(): string;
  44077. }
  44078. }
  44079. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44080. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44081. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44082. /**
  44083. * Default Inputs manager for the ArcRotateCamera.
  44084. * It groups all the default supported inputs for ease of use.
  44085. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44086. */
  44087. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44088. /**
  44089. * Instantiates a new ArcRotateCameraInputsManager.
  44090. * @param camera Defines the camera the inputs belong to
  44091. */
  44092. constructor(camera: ArcRotateCamera);
  44093. /**
  44094. * Add mouse wheel input support to the input manager.
  44095. * @returns the current input manager
  44096. */
  44097. addMouseWheel(): ArcRotateCameraInputsManager;
  44098. /**
  44099. * Add pointers input support to the input manager.
  44100. * @returns the current input manager
  44101. */
  44102. addPointers(): ArcRotateCameraInputsManager;
  44103. /**
  44104. * Add keyboard input support to the input manager.
  44105. * @returns the current input manager
  44106. */
  44107. addKeyboard(): ArcRotateCameraInputsManager;
  44108. }
  44109. }
  44110. declare module "babylonjs/Cameras/arcRotateCamera" {
  44111. import { Observable } from "babylonjs/Misc/observable";
  44112. import { Nullable } from "babylonjs/types";
  44113. import { Scene } from "babylonjs/scene";
  44114. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44116. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44117. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44118. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44119. import { Camera } from "babylonjs/Cameras/camera";
  44120. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44121. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44122. import { Collider } from "babylonjs/Collisions/collider";
  44123. /**
  44124. * This represents an orbital type of camera.
  44125. *
  44126. * 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.
  44127. * 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.
  44128. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44129. */
  44130. export class ArcRotateCamera extends TargetCamera {
  44131. /**
  44132. * Defines the rotation angle of the camera along the longitudinal axis.
  44133. */
  44134. alpha: number;
  44135. /**
  44136. * Defines the rotation angle of the camera along the latitudinal axis.
  44137. */
  44138. beta: number;
  44139. /**
  44140. * Defines the radius of the camera from it s target point.
  44141. */
  44142. radius: number;
  44143. protected _target: Vector3;
  44144. protected _targetHost: Nullable<AbstractMesh>;
  44145. /**
  44146. * Defines the target point of the camera.
  44147. * The camera looks towards it form the radius distance.
  44148. */
  44149. get target(): Vector3;
  44150. set target(value: Vector3);
  44151. /**
  44152. * Define the current local position of the camera in the scene
  44153. */
  44154. get position(): Vector3;
  44155. set position(newPosition: Vector3);
  44156. protected _upVector: Vector3;
  44157. protected _upToYMatrix: Matrix;
  44158. protected _YToUpMatrix: Matrix;
  44159. /**
  44160. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44161. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44162. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44163. */
  44164. set upVector(vec: Vector3);
  44165. get upVector(): Vector3;
  44166. /**
  44167. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44168. */
  44169. setMatUp(): void;
  44170. /**
  44171. * Current inertia value on the longitudinal axis.
  44172. * The bigger this number the longer it will take for the camera to stop.
  44173. */
  44174. inertialAlphaOffset: number;
  44175. /**
  44176. * Current inertia value on the latitudinal axis.
  44177. * The bigger this number the longer it will take for the camera to stop.
  44178. */
  44179. inertialBetaOffset: number;
  44180. /**
  44181. * Current inertia value on the radius axis.
  44182. * The bigger this number the longer it will take for the camera to stop.
  44183. */
  44184. inertialRadiusOffset: number;
  44185. /**
  44186. * Minimum allowed angle on the longitudinal axis.
  44187. * This can help limiting how the Camera is able to move in the scene.
  44188. */
  44189. lowerAlphaLimit: Nullable<number>;
  44190. /**
  44191. * Maximum allowed angle on the longitudinal axis.
  44192. * This can help limiting how the Camera is able to move in the scene.
  44193. */
  44194. upperAlphaLimit: Nullable<number>;
  44195. /**
  44196. * Minimum allowed angle on the latitudinal axis.
  44197. * This can help limiting how the Camera is able to move in the scene.
  44198. */
  44199. lowerBetaLimit: number;
  44200. /**
  44201. * Maximum allowed angle on the latitudinal axis.
  44202. * This can help limiting how the Camera is able to move in the scene.
  44203. */
  44204. upperBetaLimit: number;
  44205. /**
  44206. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44207. * This can help limiting how the Camera is able to move in the scene.
  44208. */
  44209. lowerRadiusLimit: Nullable<number>;
  44210. /**
  44211. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44212. * This can help limiting how the Camera is able to move in the scene.
  44213. */
  44214. upperRadiusLimit: Nullable<number>;
  44215. /**
  44216. * Defines the current inertia value used during panning of the camera along the X axis.
  44217. */
  44218. inertialPanningX: number;
  44219. /**
  44220. * Defines the current inertia value used during panning of the camera along the Y axis.
  44221. */
  44222. inertialPanningY: number;
  44223. /**
  44224. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44225. * Basically if your fingers moves away from more than this distance you will be considered
  44226. * in pinch mode.
  44227. */
  44228. pinchToPanMaxDistance: number;
  44229. /**
  44230. * Defines the maximum distance the camera can pan.
  44231. * This could help keeping the cammera always in your scene.
  44232. */
  44233. panningDistanceLimit: Nullable<number>;
  44234. /**
  44235. * Defines the target of the camera before paning.
  44236. */
  44237. panningOriginTarget: Vector3;
  44238. /**
  44239. * Defines the value of the inertia used during panning.
  44240. * 0 would mean stop inertia and one would mean no decelleration at all.
  44241. */
  44242. panningInertia: number;
  44243. /**
  44244. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44245. */
  44246. get angularSensibilityX(): number;
  44247. set angularSensibilityX(value: number);
  44248. /**
  44249. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44250. */
  44251. get angularSensibilityY(): number;
  44252. set angularSensibilityY(value: number);
  44253. /**
  44254. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44255. */
  44256. get pinchPrecision(): number;
  44257. set pinchPrecision(value: number);
  44258. /**
  44259. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44260. * It will be used instead of pinchDeltaPrecision if different from 0.
  44261. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44262. */
  44263. get pinchDeltaPercentage(): number;
  44264. set pinchDeltaPercentage(value: number);
  44265. /**
  44266. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44267. * and pinch delta percentage.
  44268. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44269. * that any object in the plane at the camera's target point will scale
  44270. * perfectly with finger motion.
  44271. */
  44272. get useNaturalPinchZoom(): boolean;
  44273. set useNaturalPinchZoom(value: boolean);
  44274. /**
  44275. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44276. */
  44277. get panningSensibility(): number;
  44278. set panningSensibility(value: number);
  44279. /**
  44280. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44281. */
  44282. get keysUp(): number[];
  44283. set keysUp(value: number[]);
  44284. /**
  44285. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44286. */
  44287. get keysDown(): number[];
  44288. set keysDown(value: number[]);
  44289. /**
  44290. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44291. */
  44292. get keysLeft(): number[];
  44293. set keysLeft(value: number[]);
  44294. /**
  44295. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44296. */
  44297. get keysRight(): number[];
  44298. set keysRight(value: number[]);
  44299. /**
  44300. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44301. */
  44302. get wheelPrecision(): number;
  44303. set wheelPrecision(value: number);
  44304. /**
  44305. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44306. * It will be used instead of pinchDeltaPrecision if different from 0.
  44307. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44308. */
  44309. get wheelDeltaPercentage(): number;
  44310. set wheelDeltaPercentage(value: number);
  44311. /**
  44312. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44313. */
  44314. zoomOnFactor: number;
  44315. /**
  44316. * Defines a screen offset for the camera position.
  44317. */
  44318. targetScreenOffset: Vector2;
  44319. /**
  44320. * Allows the camera to be completely reversed.
  44321. * If false the camera can not arrive upside down.
  44322. */
  44323. allowUpsideDown: boolean;
  44324. /**
  44325. * Define if double tap/click is used to restore the previously saved state of the camera.
  44326. */
  44327. useInputToRestoreState: boolean;
  44328. /** @hidden */
  44329. _viewMatrix: Matrix;
  44330. /** @hidden */
  44331. _useCtrlForPanning: boolean;
  44332. /** @hidden */
  44333. _panningMouseButton: number;
  44334. /**
  44335. * Defines the input associated to the camera.
  44336. */
  44337. inputs: ArcRotateCameraInputsManager;
  44338. /** @hidden */
  44339. _reset: () => void;
  44340. /**
  44341. * Defines the allowed panning axis.
  44342. */
  44343. panningAxis: Vector3;
  44344. protected _localDirection: Vector3;
  44345. protected _transformedDirection: Vector3;
  44346. private _bouncingBehavior;
  44347. /**
  44348. * Gets the bouncing behavior of the camera if it has been enabled.
  44349. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44350. */
  44351. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44352. /**
  44353. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44354. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44355. */
  44356. get useBouncingBehavior(): boolean;
  44357. set useBouncingBehavior(value: boolean);
  44358. private _framingBehavior;
  44359. /**
  44360. * Gets the framing behavior of the camera if it has been enabled.
  44361. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44362. */
  44363. get framingBehavior(): Nullable<FramingBehavior>;
  44364. /**
  44365. * Defines if the framing behavior of the camera is enabled on the camera.
  44366. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44367. */
  44368. get useFramingBehavior(): boolean;
  44369. set useFramingBehavior(value: boolean);
  44370. private _autoRotationBehavior;
  44371. /**
  44372. * Gets the auto rotation behavior of the camera if it has been enabled.
  44373. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44374. */
  44375. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44376. /**
  44377. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44378. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44379. */
  44380. get useAutoRotationBehavior(): boolean;
  44381. set useAutoRotationBehavior(value: boolean);
  44382. /**
  44383. * Observable triggered when the mesh target has been changed on the camera.
  44384. */
  44385. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44386. /**
  44387. * Event raised when the camera is colliding with a mesh.
  44388. */
  44389. onCollide: (collidedMesh: AbstractMesh) => void;
  44390. /**
  44391. * Defines whether the camera should check collision with the objects oh the scene.
  44392. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44393. */
  44394. checkCollisions: boolean;
  44395. /**
  44396. * Defines the collision radius of the camera.
  44397. * This simulates a sphere around the camera.
  44398. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44399. */
  44400. collisionRadius: Vector3;
  44401. protected _collider: Collider;
  44402. protected _previousPosition: Vector3;
  44403. protected _collisionVelocity: Vector3;
  44404. protected _newPosition: Vector3;
  44405. protected _previousAlpha: number;
  44406. protected _previousBeta: number;
  44407. protected _previousRadius: number;
  44408. protected _collisionTriggered: boolean;
  44409. protected _targetBoundingCenter: Nullable<Vector3>;
  44410. private _computationVector;
  44411. /**
  44412. * Instantiates a new ArcRotateCamera in a given scene
  44413. * @param name Defines the name of the camera
  44414. * @param alpha Defines the camera rotation along the logitudinal axis
  44415. * @param beta Defines the camera rotation along the latitudinal axis
  44416. * @param radius Defines the camera distance from its target
  44417. * @param target Defines the camera target
  44418. * @param scene Defines the scene the camera belongs to
  44419. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44420. */
  44421. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44422. /** @hidden */
  44423. _initCache(): void;
  44424. /** @hidden */
  44425. _updateCache(ignoreParentClass?: boolean): void;
  44426. protected _getTargetPosition(): Vector3;
  44427. private _storedAlpha;
  44428. private _storedBeta;
  44429. private _storedRadius;
  44430. private _storedTarget;
  44431. private _storedTargetScreenOffset;
  44432. /**
  44433. * Stores the current state of the camera (alpha, beta, radius and target)
  44434. * @returns the camera itself
  44435. */
  44436. storeState(): Camera;
  44437. /**
  44438. * @hidden
  44439. * Restored camera state. You must call storeState() first
  44440. */
  44441. _restoreStateValues(): boolean;
  44442. /** @hidden */
  44443. _isSynchronizedViewMatrix(): boolean;
  44444. /**
  44445. * Attached controls to the current camera.
  44446. * @param element Defines the element the controls should be listened from
  44447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44448. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44449. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44450. */
  44451. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44452. /**
  44453. * Detach the current controls from the camera.
  44454. * The camera will stop reacting to inputs.
  44455. * @param element Defines the element to stop listening the inputs from
  44456. */
  44457. detachControl(element: HTMLElement): void;
  44458. /** @hidden */
  44459. _checkInputs(): void;
  44460. protected _checkLimits(): void;
  44461. /**
  44462. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44463. */
  44464. rebuildAnglesAndRadius(): void;
  44465. /**
  44466. * Use a position to define the current camera related information like alpha, beta and radius
  44467. * @param position Defines the position to set the camera at
  44468. */
  44469. setPosition(position: Vector3): void;
  44470. /**
  44471. * Defines the target the camera should look at.
  44472. * This will automatically adapt alpha beta and radius to fit within the new target.
  44473. * @param target Defines the new target as a Vector or a mesh
  44474. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44475. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44476. */
  44477. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44478. /** @hidden */
  44479. _getViewMatrix(): Matrix;
  44480. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44481. /**
  44482. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44483. * @param meshes Defines the mesh to zoom on
  44484. * @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)
  44485. */
  44486. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44487. /**
  44488. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44489. * The target will be changed but the radius
  44490. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44491. * @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)
  44492. */
  44493. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44494. min: Vector3;
  44495. max: Vector3;
  44496. distance: number;
  44497. }, doNotUpdateMaxZ?: boolean): void;
  44498. /**
  44499. * @override
  44500. * Override Camera.createRigCamera
  44501. */
  44502. createRigCamera(name: string, cameraIndex: number): Camera;
  44503. /**
  44504. * @hidden
  44505. * @override
  44506. * Override Camera._updateRigCameras
  44507. */
  44508. _updateRigCameras(): void;
  44509. /**
  44510. * Destroy the camera and release the current resources hold by it.
  44511. */
  44512. dispose(): void;
  44513. /**
  44514. * Gets the current object class name.
  44515. * @return the class name
  44516. */
  44517. getClassName(): string;
  44518. }
  44519. }
  44520. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44521. import { Behavior } from "babylonjs/Behaviors/behavior";
  44522. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44523. /**
  44524. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44525. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44526. */
  44527. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44528. /**
  44529. * Gets the name of the behavior.
  44530. */
  44531. get name(): string;
  44532. private _zoomStopsAnimation;
  44533. private _idleRotationSpeed;
  44534. private _idleRotationWaitTime;
  44535. private _idleRotationSpinupTime;
  44536. /**
  44537. * Sets the flag that indicates if user zooming should stop animation.
  44538. */
  44539. set zoomStopsAnimation(flag: boolean);
  44540. /**
  44541. * Gets the flag that indicates if user zooming should stop animation.
  44542. */
  44543. get zoomStopsAnimation(): boolean;
  44544. /**
  44545. * Sets the default speed at which the camera rotates around the model.
  44546. */
  44547. set idleRotationSpeed(speed: number);
  44548. /**
  44549. * Gets the default speed at which the camera rotates around the model.
  44550. */
  44551. get idleRotationSpeed(): number;
  44552. /**
  44553. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44554. */
  44555. set idleRotationWaitTime(time: number);
  44556. /**
  44557. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44558. */
  44559. get idleRotationWaitTime(): number;
  44560. /**
  44561. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44562. */
  44563. set idleRotationSpinupTime(time: number);
  44564. /**
  44565. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44566. */
  44567. get idleRotationSpinupTime(): number;
  44568. /**
  44569. * Gets a value indicating if the camera is currently rotating because of this behavior
  44570. */
  44571. get rotationInProgress(): boolean;
  44572. private _onPrePointerObservableObserver;
  44573. private _onAfterCheckInputsObserver;
  44574. private _attachedCamera;
  44575. private _isPointerDown;
  44576. private _lastFrameTime;
  44577. private _lastInteractionTime;
  44578. private _cameraRotationSpeed;
  44579. /**
  44580. * Initializes the behavior.
  44581. */
  44582. init(): void;
  44583. /**
  44584. * Attaches the behavior to its arc rotate camera.
  44585. * @param camera Defines the camera to attach the behavior to
  44586. */
  44587. attach(camera: ArcRotateCamera): void;
  44588. /**
  44589. * Detaches the behavior from its current arc rotate camera.
  44590. */
  44591. detach(): void;
  44592. /**
  44593. * Returns true if user is scrolling.
  44594. * @return true if user is scrolling.
  44595. */
  44596. private _userIsZooming;
  44597. private _lastFrameRadius;
  44598. private _shouldAnimationStopForInteraction;
  44599. /**
  44600. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44601. */
  44602. private _applyUserInteraction;
  44603. private _userIsMoving;
  44604. }
  44605. }
  44606. declare module "babylonjs/Behaviors/Cameras/index" {
  44607. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44608. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44609. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44610. }
  44611. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44612. import { Mesh } from "babylonjs/Meshes/mesh";
  44613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44614. import { Behavior } from "babylonjs/Behaviors/behavior";
  44615. /**
  44616. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44617. */
  44618. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44619. private ui;
  44620. /**
  44621. * The name of the behavior
  44622. */
  44623. name: string;
  44624. /**
  44625. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44626. */
  44627. distanceAwayFromFace: number;
  44628. /**
  44629. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44630. */
  44631. distanceAwayFromBottomOfFace: number;
  44632. private _faceVectors;
  44633. private _target;
  44634. private _scene;
  44635. private _onRenderObserver;
  44636. private _tmpMatrix;
  44637. private _tmpVector;
  44638. /**
  44639. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44640. * @param ui The transform node that should be attched to the mesh
  44641. */
  44642. constructor(ui: TransformNode);
  44643. /**
  44644. * Initializes the behavior
  44645. */
  44646. init(): void;
  44647. private _closestFace;
  44648. private _zeroVector;
  44649. private _lookAtTmpMatrix;
  44650. private _lookAtToRef;
  44651. /**
  44652. * Attaches the AttachToBoxBehavior to the passed in mesh
  44653. * @param target The mesh that the specified node will be attached to
  44654. */
  44655. attach(target: Mesh): void;
  44656. /**
  44657. * Detaches the behavior from the mesh
  44658. */
  44659. detach(): void;
  44660. }
  44661. }
  44662. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44663. import { Behavior } from "babylonjs/Behaviors/behavior";
  44664. import { Mesh } from "babylonjs/Meshes/mesh";
  44665. /**
  44666. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44667. */
  44668. export class FadeInOutBehavior implements Behavior<Mesh> {
  44669. /**
  44670. * Time in milliseconds to delay before fading in (Default: 0)
  44671. */
  44672. delay: number;
  44673. /**
  44674. * Time in milliseconds for the mesh to fade in (Default: 300)
  44675. */
  44676. fadeInTime: number;
  44677. private _millisecondsPerFrame;
  44678. private _hovered;
  44679. private _hoverValue;
  44680. private _ownerNode;
  44681. /**
  44682. * Instatiates the FadeInOutBehavior
  44683. */
  44684. constructor();
  44685. /**
  44686. * The name of the behavior
  44687. */
  44688. get name(): string;
  44689. /**
  44690. * Initializes the behavior
  44691. */
  44692. init(): void;
  44693. /**
  44694. * Attaches the fade behavior on the passed in mesh
  44695. * @param ownerNode The mesh that will be faded in/out once attached
  44696. */
  44697. attach(ownerNode: Mesh): void;
  44698. /**
  44699. * Detaches the behavior from the mesh
  44700. */
  44701. detach(): void;
  44702. /**
  44703. * Triggers the mesh to begin fading in or out
  44704. * @param value if the object should fade in or out (true to fade in)
  44705. */
  44706. fadeIn(value: boolean): void;
  44707. private _update;
  44708. private _setAllVisibility;
  44709. }
  44710. }
  44711. declare module "babylonjs/Misc/pivotTools" {
  44712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44713. /**
  44714. * Class containing a set of static utilities functions for managing Pivots
  44715. * @hidden
  44716. */
  44717. export class PivotTools {
  44718. private static _PivotCached;
  44719. private static _OldPivotPoint;
  44720. private static _PivotTranslation;
  44721. private static _PivotTmpVector;
  44722. /** @hidden */
  44723. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44724. /** @hidden */
  44725. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44726. }
  44727. }
  44728. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44729. import { Scene } from "babylonjs/scene";
  44730. import { Vector4 } from "babylonjs/Maths/math.vector";
  44731. import { Mesh } from "babylonjs/Meshes/mesh";
  44732. import { Nullable } from "babylonjs/types";
  44733. import { Plane } from "babylonjs/Maths/math.plane";
  44734. /**
  44735. * Class containing static functions to help procedurally build meshes
  44736. */
  44737. export class PlaneBuilder {
  44738. /**
  44739. * Creates a plane mesh
  44740. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44741. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44742. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44746. * @param name defines the name of the mesh
  44747. * @param options defines the options used to create the mesh
  44748. * @param scene defines the hosting scene
  44749. * @returns the plane mesh
  44750. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44751. */
  44752. static CreatePlane(name: string, options: {
  44753. size?: number;
  44754. width?: number;
  44755. height?: number;
  44756. sideOrientation?: number;
  44757. frontUVs?: Vector4;
  44758. backUVs?: Vector4;
  44759. updatable?: boolean;
  44760. sourcePlane?: Plane;
  44761. }, scene?: Nullable<Scene>): Mesh;
  44762. }
  44763. }
  44764. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44765. import { Behavior } from "babylonjs/Behaviors/behavior";
  44766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44767. import { Observable } from "babylonjs/Misc/observable";
  44768. import { Vector3 } from "babylonjs/Maths/math.vector";
  44769. import { Ray } from "babylonjs/Culling/ray";
  44770. import "babylonjs/Meshes/Builders/planeBuilder";
  44771. /**
  44772. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44773. */
  44774. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44775. private static _AnyMouseID;
  44776. /**
  44777. * Abstract mesh the behavior is set on
  44778. */
  44779. attachedNode: AbstractMesh;
  44780. private _dragPlane;
  44781. private _scene;
  44782. private _pointerObserver;
  44783. private _beforeRenderObserver;
  44784. private static _planeScene;
  44785. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44786. /**
  44787. * 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)
  44788. */
  44789. maxDragAngle: number;
  44790. /**
  44791. * @hidden
  44792. */
  44793. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44794. /**
  44795. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44796. */
  44797. currentDraggingPointerID: number;
  44798. /**
  44799. * The last position where the pointer hit the drag plane in world space
  44800. */
  44801. lastDragPosition: Vector3;
  44802. /**
  44803. * If the behavior is currently in a dragging state
  44804. */
  44805. dragging: boolean;
  44806. /**
  44807. * 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)
  44808. */
  44809. dragDeltaRatio: number;
  44810. /**
  44811. * If the drag plane orientation should be updated during the dragging (Default: true)
  44812. */
  44813. updateDragPlane: boolean;
  44814. private _debugMode;
  44815. private _moving;
  44816. /**
  44817. * Fires each time the attached mesh is dragged with the pointer
  44818. * * delta between last drag position and current drag position in world space
  44819. * * dragDistance along the drag axis
  44820. * * dragPlaneNormal normal of the current drag plane used during the drag
  44821. * * dragPlanePoint in world space where the drag intersects the drag plane
  44822. */
  44823. onDragObservable: Observable<{
  44824. delta: Vector3;
  44825. dragPlanePoint: Vector3;
  44826. dragPlaneNormal: Vector3;
  44827. dragDistance: number;
  44828. pointerId: number;
  44829. }>;
  44830. /**
  44831. * Fires each time a drag begins (eg. mouse down on mesh)
  44832. */
  44833. onDragStartObservable: Observable<{
  44834. dragPlanePoint: Vector3;
  44835. pointerId: number;
  44836. }>;
  44837. /**
  44838. * Fires each time a drag ends (eg. mouse release after drag)
  44839. */
  44840. onDragEndObservable: Observable<{
  44841. dragPlanePoint: Vector3;
  44842. pointerId: number;
  44843. }>;
  44844. /**
  44845. * If the attached mesh should be moved when dragged
  44846. */
  44847. moveAttached: boolean;
  44848. /**
  44849. * If the drag behavior will react to drag events (Default: true)
  44850. */
  44851. enabled: boolean;
  44852. /**
  44853. * If pointer events should start and release the drag (Default: true)
  44854. */
  44855. startAndReleaseDragOnPointerEvents: boolean;
  44856. /**
  44857. * If camera controls should be detached during the drag
  44858. */
  44859. detachCameraControls: boolean;
  44860. /**
  44861. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44862. */
  44863. useObjectOrientationForDragging: boolean;
  44864. private _options;
  44865. /**
  44866. * Gets the options used by the behavior
  44867. */
  44868. get options(): {
  44869. dragAxis?: Vector3;
  44870. dragPlaneNormal?: Vector3;
  44871. };
  44872. /**
  44873. * Sets the options used by the behavior
  44874. */
  44875. set options(options: {
  44876. dragAxis?: Vector3;
  44877. dragPlaneNormal?: Vector3;
  44878. });
  44879. /**
  44880. * Creates a pointer drag behavior that can be attached to a mesh
  44881. * @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)
  44882. */
  44883. constructor(options?: {
  44884. dragAxis?: Vector3;
  44885. dragPlaneNormal?: Vector3;
  44886. });
  44887. /**
  44888. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44889. */
  44890. validateDrag: (targetPosition: Vector3) => boolean;
  44891. /**
  44892. * The name of the behavior
  44893. */
  44894. get name(): string;
  44895. /**
  44896. * Initializes the behavior
  44897. */
  44898. init(): void;
  44899. private _tmpVector;
  44900. private _alternatePickedPoint;
  44901. private _worldDragAxis;
  44902. private _targetPosition;
  44903. private _attachedElement;
  44904. /**
  44905. * Attaches the drag behavior the passed in mesh
  44906. * @param ownerNode The mesh that will be dragged around once attached
  44907. * @param predicate Predicate to use for pick filtering
  44908. */
  44909. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44910. /**
  44911. * Force relase the drag action by code.
  44912. */
  44913. releaseDrag(): void;
  44914. private _startDragRay;
  44915. private _lastPointerRay;
  44916. /**
  44917. * Simulates the start of a pointer drag event on the behavior
  44918. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44919. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44920. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44921. */
  44922. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44923. private _startDrag;
  44924. private _dragDelta;
  44925. private _moveDrag;
  44926. private _pickWithRayOnDragPlane;
  44927. private _pointA;
  44928. private _pointC;
  44929. private _localAxis;
  44930. private _lookAt;
  44931. private _updateDragPlanePosition;
  44932. /**
  44933. * Detaches the behavior from the mesh
  44934. */
  44935. detach(): void;
  44936. }
  44937. }
  44938. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44939. import { Mesh } from "babylonjs/Meshes/mesh";
  44940. import { Behavior } from "babylonjs/Behaviors/behavior";
  44941. /**
  44942. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44943. */
  44944. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44945. private _dragBehaviorA;
  44946. private _dragBehaviorB;
  44947. private _startDistance;
  44948. private _initialScale;
  44949. private _targetScale;
  44950. private _ownerNode;
  44951. private _sceneRenderObserver;
  44952. /**
  44953. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44954. */
  44955. constructor();
  44956. /**
  44957. * The name of the behavior
  44958. */
  44959. get name(): string;
  44960. /**
  44961. * Initializes the behavior
  44962. */
  44963. init(): void;
  44964. private _getCurrentDistance;
  44965. /**
  44966. * Attaches the scale behavior the passed in mesh
  44967. * @param ownerNode The mesh that will be scaled around once attached
  44968. */
  44969. attach(ownerNode: Mesh): void;
  44970. /**
  44971. * Detaches the behavior from the mesh
  44972. */
  44973. detach(): void;
  44974. }
  44975. }
  44976. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44977. import { Behavior } from "babylonjs/Behaviors/behavior";
  44978. import { Mesh } from "babylonjs/Meshes/mesh";
  44979. import { Observable } from "babylonjs/Misc/observable";
  44980. /**
  44981. * 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
  44982. */
  44983. export class SixDofDragBehavior implements Behavior<Mesh> {
  44984. private static _virtualScene;
  44985. private _ownerNode;
  44986. private _sceneRenderObserver;
  44987. private _scene;
  44988. private _targetPosition;
  44989. private _virtualOriginMesh;
  44990. private _virtualDragMesh;
  44991. private _pointerObserver;
  44992. private _moving;
  44993. private _startingOrientation;
  44994. private _attachedElement;
  44995. /**
  44996. * 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)
  44997. */
  44998. private zDragFactor;
  44999. /**
  45000. * If the object should rotate to face the drag origin
  45001. */
  45002. rotateDraggedObject: boolean;
  45003. /**
  45004. * If the behavior is currently in a dragging state
  45005. */
  45006. dragging: boolean;
  45007. /**
  45008. * 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)
  45009. */
  45010. dragDeltaRatio: number;
  45011. /**
  45012. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45013. */
  45014. currentDraggingPointerID: number;
  45015. /**
  45016. * If camera controls should be detached during the drag
  45017. */
  45018. detachCameraControls: boolean;
  45019. /**
  45020. * Fires each time a drag starts
  45021. */
  45022. onDragStartObservable: Observable<{}>;
  45023. /**
  45024. * Fires each time a drag ends (eg. mouse release after drag)
  45025. */
  45026. onDragEndObservable: Observable<{}>;
  45027. /**
  45028. * 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
  45029. */
  45030. constructor();
  45031. /**
  45032. * The name of the behavior
  45033. */
  45034. get name(): string;
  45035. /**
  45036. * Initializes the behavior
  45037. */
  45038. init(): void;
  45039. /**
  45040. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45041. */
  45042. private get _pointerCamera();
  45043. /**
  45044. * Attaches the scale behavior the passed in mesh
  45045. * @param ownerNode The mesh that will be scaled around once attached
  45046. */
  45047. attach(ownerNode: Mesh): void;
  45048. /**
  45049. * Detaches the behavior from the mesh
  45050. */
  45051. detach(): void;
  45052. }
  45053. }
  45054. declare module "babylonjs/Behaviors/Meshes/index" {
  45055. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45056. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45057. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45058. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45059. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45060. }
  45061. declare module "babylonjs/Behaviors/index" {
  45062. export * from "babylonjs/Behaviors/behavior";
  45063. export * from "babylonjs/Behaviors/Cameras/index";
  45064. export * from "babylonjs/Behaviors/Meshes/index";
  45065. }
  45066. declare module "babylonjs/Bones/boneIKController" {
  45067. import { Bone } from "babylonjs/Bones/bone";
  45068. import { Vector3 } from "babylonjs/Maths/math.vector";
  45069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45070. import { Nullable } from "babylonjs/types";
  45071. /**
  45072. * Class used to apply inverse kinematics to bones
  45073. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45074. */
  45075. export class BoneIKController {
  45076. private static _tmpVecs;
  45077. private static _tmpQuat;
  45078. private static _tmpMats;
  45079. /**
  45080. * Gets or sets the target mesh
  45081. */
  45082. targetMesh: AbstractMesh;
  45083. /** Gets or sets the mesh used as pole */
  45084. poleTargetMesh: AbstractMesh;
  45085. /**
  45086. * Gets or sets the bone used as pole
  45087. */
  45088. poleTargetBone: Nullable<Bone>;
  45089. /**
  45090. * Gets or sets the target position
  45091. */
  45092. targetPosition: Vector3;
  45093. /**
  45094. * Gets or sets the pole target position
  45095. */
  45096. poleTargetPosition: Vector3;
  45097. /**
  45098. * Gets or sets the pole target local offset
  45099. */
  45100. poleTargetLocalOffset: Vector3;
  45101. /**
  45102. * Gets or sets the pole angle
  45103. */
  45104. poleAngle: number;
  45105. /**
  45106. * Gets or sets the mesh associated with the controller
  45107. */
  45108. mesh: AbstractMesh;
  45109. /**
  45110. * 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)
  45111. */
  45112. slerpAmount: number;
  45113. private _bone1Quat;
  45114. private _bone1Mat;
  45115. private _bone2Ang;
  45116. private _bone1;
  45117. private _bone2;
  45118. private _bone1Length;
  45119. private _bone2Length;
  45120. private _maxAngle;
  45121. private _maxReach;
  45122. private _rightHandedSystem;
  45123. private _bendAxis;
  45124. private _slerping;
  45125. private _adjustRoll;
  45126. /**
  45127. * Gets or sets maximum allowed angle
  45128. */
  45129. get maxAngle(): number;
  45130. set maxAngle(value: number);
  45131. /**
  45132. * Creates a new BoneIKController
  45133. * @param mesh defines the mesh to control
  45134. * @param bone defines the bone to control
  45135. * @param options defines options to set up the controller
  45136. */
  45137. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45138. targetMesh?: AbstractMesh;
  45139. poleTargetMesh?: AbstractMesh;
  45140. poleTargetBone?: Bone;
  45141. poleTargetLocalOffset?: Vector3;
  45142. poleAngle?: number;
  45143. bendAxis?: Vector3;
  45144. maxAngle?: number;
  45145. slerpAmount?: number;
  45146. });
  45147. private _setMaxAngle;
  45148. /**
  45149. * Force the controller to update the bones
  45150. */
  45151. update(): void;
  45152. }
  45153. }
  45154. declare module "babylonjs/Bones/boneLookController" {
  45155. import { Vector3 } from "babylonjs/Maths/math.vector";
  45156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45157. import { Bone } from "babylonjs/Bones/bone";
  45158. import { Space } from "babylonjs/Maths/math.axis";
  45159. /**
  45160. * Class used to make a bone look toward a point in space
  45161. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45162. */
  45163. export class BoneLookController {
  45164. private static _tmpVecs;
  45165. private static _tmpQuat;
  45166. private static _tmpMats;
  45167. /**
  45168. * The target Vector3 that the bone will look at
  45169. */
  45170. target: Vector3;
  45171. /**
  45172. * The mesh that the bone is attached to
  45173. */
  45174. mesh: AbstractMesh;
  45175. /**
  45176. * The bone that will be looking to the target
  45177. */
  45178. bone: Bone;
  45179. /**
  45180. * The up axis of the coordinate system that is used when the bone is rotated
  45181. */
  45182. upAxis: Vector3;
  45183. /**
  45184. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45185. */
  45186. upAxisSpace: Space;
  45187. /**
  45188. * Used to make an adjustment to the yaw of the bone
  45189. */
  45190. adjustYaw: number;
  45191. /**
  45192. * Used to make an adjustment to the pitch of the bone
  45193. */
  45194. adjustPitch: number;
  45195. /**
  45196. * Used to make an adjustment to the roll of the bone
  45197. */
  45198. adjustRoll: number;
  45199. /**
  45200. * 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)
  45201. */
  45202. slerpAmount: number;
  45203. private _minYaw;
  45204. private _maxYaw;
  45205. private _minPitch;
  45206. private _maxPitch;
  45207. private _minYawSin;
  45208. private _minYawCos;
  45209. private _maxYawSin;
  45210. private _maxYawCos;
  45211. private _midYawConstraint;
  45212. private _minPitchTan;
  45213. private _maxPitchTan;
  45214. private _boneQuat;
  45215. private _slerping;
  45216. private _transformYawPitch;
  45217. private _transformYawPitchInv;
  45218. private _firstFrameSkipped;
  45219. private _yawRange;
  45220. private _fowardAxis;
  45221. /**
  45222. * Gets or sets the minimum yaw angle that the bone can look to
  45223. */
  45224. get minYaw(): number;
  45225. set minYaw(value: number);
  45226. /**
  45227. * Gets or sets the maximum yaw angle that the bone can look to
  45228. */
  45229. get maxYaw(): number;
  45230. set maxYaw(value: number);
  45231. /**
  45232. * Gets or sets the minimum pitch angle that the bone can look to
  45233. */
  45234. get minPitch(): number;
  45235. set minPitch(value: number);
  45236. /**
  45237. * Gets or sets the maximum pitch angle that the bone can look to
  45238. */
  45239. get maxPitch(): number;
  45240. set maxPitch(value: number);
  45241. /**
  45242. * Create a BoneLookController
  45243. * @param mesh the mesh that the bone belongs to
  45244. * @param bone the bone that will be looking to the target
  45245. * @param target the target Vector3 to look at
  45246. * @param options optional settings:
  45247. * * maxYaw: the maximum angle the bone will yaw to
  45248. * * minYaw: the minimum angle the bone will yaw to
  45249. * * maxPitch: the maximum angle the bone will pitch to
  45250. * * minPitch: the minimum angle the bone will yaw to
  45251. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45252. * * upAxis: the up axis of the coordinate system
  45253. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45254. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45255. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45256. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45257. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45258. * * adjustRoll: used to make an adjustment to the roll of the bone
  45259. **/
  45260. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45261. maxYaw?: number;
  45262. minYaw?: number;
  45263. maxPitch?: number;
  45264. minPitch?: number;
  45265. slerpAmount?: number;
  45266. upAxis?: Vector3;
  45267. upAxisSpace?: Space;
  45268. yawAxis?: Vector3;
  45269. pitchAxis?: Vector3;
  45270. adjustYaw?: number;
  45271. adjustPitch?: number;
  45272. adjustRoll?: number;
  45273. });
  45274. /**
  45275. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45276. */
  45277. update(): void;
  45278. private _getAngleDiff;
  45279. private _getAngleBetween;
  45280. private _isAngleBetween;
  45281. }
  45282. }
  45283. declare module "babylonjs/Bones/index" {
  45284. export * from "babylonjs/Bones/bone";
  45285. export * from "babylonjs/Bones/boneIKController";
  45286. export * from "babylonjs/Bones/boneLookController";
  45287. export * from "babylonjs/Bones/skeleton";
  45288. }
  45289. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45290. import { Nullable } from "babylonjs/types";
  45291. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45292. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45293. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45294. /**
  45295. * Manage the gamepad inputs to control an arc rotate camera.
  45296. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45297. */
  45298. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45299. /**
  45300. * Defines the camera the input is attached to.
  45301. */
  45302. camera: ArcRotateCamera;
  45303. /**
  45304. * Defines the gamepad the input is gathering event from.
  45305. */
  45306. gamepad: Nullable<Gamepad>;
  45307. /**
  45308. * Defines the gamepad rotation sensiblity.
  45309. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45310. */
  45311. gamepadRotationSensibility: number;
  45312. /**
  45313. * Defines the gamepad move sensiblity.
  45314. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45315. */
  45316. gamepadMoveSensibility: number;
  45317. private _yAxisScale;
  45318. /**
  45319. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45320. */
  45321. get invertYAxis(): boolean;
  45322. set invertYAxis(value: boolean);
  45323. private _onGamepadConnectedObserver;
  45324. private _onGamepadDisconnectedObserver;
  45325. /**
  45326. * Attach the input controls to a specific dom element to get the input from.
  45327. * @param element Defines the element the controls should be listened from
  45328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45329. */
  45330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45331. /**
  45332. * Detach the current controls from the specified dom element.
  45333. * @param element Defines the element to stop listening the inputs from
  45334. */
  45335. detachControl(element: Nullable<HTMLElement>): void;
  45336. /**
  45337. * Update the current camera state depending on the inputs that have been used this frame.
  45338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45339. */
  45340. checkInputs(): void;
  45341. /**
  45342. * Gets the class name of the current intput.
  45343. * @returns the class name
  45344. */
  45345. getClassName(): string;
  45346. /**
  45347. * Get the friendly name associated with the input class.
  45348. * @returns the input friendly name
  45349. */
  45350. getSimpleName(): string;
  45351. }
  45352. }
  45353. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45354. import { Nullable } from "babylonjs/types";
  45355. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45357. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45358. interface ArcRotateCameraInputsManager {
  45359. /**
  45360. * Add orientation input support to the input manager.
  45361. * @returns the current input manager
  45362. */
  45363. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45364. }
  45365. }
  45366. /**
  45367. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45368. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45369. */
  45370. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45371. /**
  45372. * Defines the camera the input is attached to.
  45373. */
  45374. camera: ArcRotateCamera;
  45375. /**
  45376. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45377. */
  45378. alphaCorrection: number;
  45379. /**
  45380. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45381. */
  45382. gammaCorrection: number;
  45383. private _alpha;
  45384. private _gamma;
  45385. private _dirty;
  45386. private _deviceOrientationHandler;
  45387. /**
  45388. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45389. */
  45390. constructor();
  45391. /**
  45392. * Attach the input controls to a specific dom element to get the input from.
  45393. * @param element Defines the element the controls should be listened from
  45394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45395. */
  45396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45397. /** @hidden */
  45398. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45399. /**
  45400. * Update the current camera state depending on the inputs that have been used this frame.
  45401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45402. */
  45403. checkInputs(): void;
  45404. /**
  45405. * Detach the current controls from the specified dom element.
  45406. * @param element Defines the element to stop listening the inputs from
  45407. */
  45408. detachControl(element: Nullable<HTMLElement>): void;
  45409. /**
  45410. * Gets the class name of the current intput.
  45411. * @returns the class name
  45412. */
  45413. getClassName(): string;
  45414. /**
  45415. * Get the friendly name associated with the input class.
  45416. * @returns the input friendly name
  45417. */
  45418. getSimpleName(): string;
  45419. }
  45420. }
  45421. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45422. import { Nullable } from "babylonjs/types";
  45423. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45424. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45425. /**
  45426. * Listen to mouse events to control the camera.
  45427. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45428. */
  45429. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45430. /**
  45431. * Defines the camera the input is attached to.
  45432. */
  45433. camera: FlyCamera;
  45434. /**
  45435. * Defines if touch is enabled. (Default is true.)
  45436. */
  45437. touchEnabled: boolean;
  45438. /**
  45439. * Defines the buttons associated with the input to handle camera rotation.
  45440. */
  45441. buttons: number[];
  45442. /**
  45443. * Assign buttons for Yaw control.
  45444. */
  45445. buttonsYaw: number[];
  45446. /**
  45447. * Assign buttons for Pitch control.
  45448. */
  45449. buttonsPitch: number[];
  45450. /**
  45451. * Assign buttons for Roll control.
  45452. */
  45453. buttonsRoll: number[];
  45454. /**
  45455. * Detect if any button is being pressed while mouse is moved.
  45456. * -1 = Mouse locked.
  45457. * 0 = Left button.
  45458. * 1 = Middle Button.
  45459. * 2 = Right Button.
  45460. */
  45461. activeButton: number;
  45462. /**
  45463. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45464. * Higher values reduce its sensitivity.
  45465. */
  45466. angularSensibility: number;
  45467. private _mousemoveCallback;
  45468. private _observer;
  45469. private _rollObserver;
  45470. private previousPosition;
  45471. private noPreventDefault;
  45472. private element;
  45473. /**
  45474. * Listen to mouse events to control the camera.
  45475. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45476. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45477. */
  45478. constructor(touchEnabled?: boolean);
  45479. /**
  45480. * Attach the mouse control to the HTML DOM element.
  45481. * @param element Defines the element that listens to the input events.
  45482. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45483. */
  45484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45485. /**
  45486. * Detach the current controls from the specified dom element.
  45487. * @param element Defines the element to stop listening the inputs from
  45488. */
  45489. detachControl(element: Nullable<HTMLElement>): void;
  45490. /**
  45491. * Gets the class name of the current input.
  45492. * @returns the class name.
  45493. */
  45494. getClassName(): string;
  45495. /**
  45496. * Get the friendly name associated with the input class.
  45497. * @returns the input's friendly name.
  45498. */
  45499. getSimpleName(): string;
  45500. private _pointerInput;
  45501. private _onMouseMove;
  45502. /**
  45503. * Rotate camera by mouse offset.
  45504. */
  45505. private rotateCamera;
  45506. }
  45507. }
  45508. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45509. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45510. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45511. /**
  45512. * Default Inputs manager for the FlyCamera.
  45513. * It groups all the default supported inputs for ease of use.
  45514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45515. */
  45516. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45517. /**
  45518. * Instantiates a new FlyCameraInputsManager.
  45519. * @param camera Defines the camera the inputs belong to.
  45520. */
  45521. constructor(camera: FlyCamera);
  45522. /**
  45523. * Add keyboard input support to the input manager.
  45524. * @returns the new FlyCameraKeyboardMoveInput().
  45525. */
  45526. addKeyboard(): FlyCameraInputsManager;
  45527. /**
  45528. * Add mouse input support to the input manager.
  45529. * @param touchEnabled Enable touch screen support.
  45530. * @returns the new FlyCameraMouseInput().
  45531. */
  45532. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45533. }
  45534. }
  45535. declare module "babylonjs/Cameras/flyCamera" {
  45536. import { Scene } from "babylonjs/scene";
  45537. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45539. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45540. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45541. /**
  45542. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45543. * such as in a 3D Space Shooter or a Flight Simulator.
  45544. */
  45545. export class FlyCamera extends TargetCamera {
  45546. /**
  45547. * Define the collision ellipsoid of the camera.
  45548. * This is helpful for simulating a camera body, like a player's body.
  45549. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45550. */
  45551. ellipsoid: Vector3;
  45552. /**
  45553. * Define an offset for the position of the ellipsoid around the camera.
  45554. * This can be helpful if the camera is attached away from the player's body center,
  45555. * such as at its head.
  45556. */
  45557. ellipsoidOffset: Vector3;
  45558. /**
  45559. * Enable or disable collisions of the camera with the rest of the scene objects.
  45560. */
  45561. checkCollisions: boolean;
  45562. /**
  45563. * Enable or disable gravity on the camera.
  45564. */
  45565. applyGravity: boolean;
  45566. /**
  45567. * Define the current direction the camera is moving to.
  45568. */
  45569. cameraDirection: Vector3;
  45570. /**
  45571. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45572. * This overrides and empties cameraRotation.
  45573. */
  45574. rotationQuaternion: Quaternion;
  45575. /**
  45576. * Track Roll to maintain the wanted Rolling when looking around.
  45577. */
  45578. _trackRoll: number;
  45579. /**
  45580. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45581. */
  45582. rollCorrect: number;
  45583. /**
  45584. * Mimic a banked turn, Rolling the camera when Yawing.
  45585. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45586. */
  45587. bankedTurn: boolean;
  45588. /**
  45589. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45590. */
  45591. bankedTurnLimit: number;
  45592. /**
  45593. * Value of 0 disables the banked Roll.
  45594. * Value of 1 is equal to the Yaw angle in radians.
  45595. */
  45596. bankedTurnMultiplier: number;
  45597. /**
  45598. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45599. */
  45600. inputs: FlyCameraInputsManager;
  45601. /**
  45602. * Gets the input sensibility for mouse input.
  45603. * Higher values reduce sensitivity.
  45604. */
  45605. get angularSensibility(): number;
  45606. /**
  45607. * Sets the input sensibility for a mouse input.
  45608. * Higher values reduce sensitivity.
  45609. */
  45610. set angularSensibility(value: number);
  45611. /**
  45612. * Get the keys for camera movement forward.
  45613. */
  45614. get keysForward(): number[];
  45615. /**
  45616. * Set the keys for camera movement forward.
  45617. */
  45618. set keysForward(value: number[]);
  45619. /**
  45620. * Get the keys for camera movement backward.
  45621. */
  45622. get keysBackward(): number[];
  45623. set keysBackward(value: number[]);
  45624. /**
  45625. * Get the keys for camera movement up.
  45626. */
  45627. get keysUp(): number[];
  45628. /**
  45629. * Set the keys for camera movement up.
  45630. */
  45631. set keysUp(value: number[]);
  45632. /**
  45633. * Get the keys for camera movement down.
  45634. */
  45635. get keysDown(): number[];
  45636. /**
  45637. * Set the keys for camera movement down.
  45638. */
  45639. set keysDown(value: number[]);
  45640. /**
  45641. * Get the keys for camera movement left.
  45642. */
  45643. get keysLeft(): number[];
  45644. /**
  45645. * Set the keys for camera movement left.
  45646. */
  45647. set keysLeft(value: number[]);
  45648. /**
  45649. * Set the keys for camera movement right.
  45650. */
  45651. get keysRight(): number[];
  45652. /**
  45653. * Set the keys for camera movement right.
  45654. */
  45655. set keysRight(value: number[]);
  45656. /**
  45657. * Event raised when the camera collides with a mesh in the scene.
  45658. */
  45659. onCollide: (collidedMesh: AbstractMesh) => void;
  45660. private _collider;
  45661. private _needMoveForGravity;
  45662. private _oldPosition;
  45663. private _diffPosition;
  45664. private _newPosition;
  45665. /** @hidden */
  45666. _localDirection: Vector3;
  45667. /** @hidden */
  45668. _transformedDirection: Vector3;
  45669. /**
  45670. * Instantiates a FlyCamera.
  45671. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45672. * such as in a 3D Space Shooter or a Flight Simulator.
  45673. * @param name Define the name of the camera in the scene.
  45674. * @param position Define the starting position of the camera in the scene.
  45675. * @param scene Define the scene the camera belongs to.
  45676. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45677. */
  45678. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45679. /**
  45680. * Attach a control to the HTML DOM element.
  45681. * @param element Defines the element that listens to the input events.
  45682. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45683. */
  45684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45685. /**
  45686. * Detach a control from the HTML DOM element.
  45687. * The camera will stop reacting to that input.
  45688. * @param element Defines the element that listens to the input events.
  45689. */
  45690. detachControl(element: HTMLElement): void;
  45691. private _collisionMask;
  45692. /**
  45693. * Get the mask that the camera ignores in collision events.
  45694. */
  45695. get collisionMask(): number;
  45696. /**
  45697. * Set the mask that the camera ignores in collision events.
  45698. */
  45699. set collisionMask(mask: number);
  45700. /** @hidden */
  45701. _collideWithWorld(displacement: Vector3): void;
  45702. /** @hidden */
  45703. private _onCollisionPositionChange;
  45704. /** @hidden */
  45705. _checkInputs(): void;
  45706. /** @hidden */
  45707. _decideIfNeedsToMove(): boolean;
  45708. /** @hidden */
  45709. _updatePosition(): void;
  45710. /**
  45711. * Restore the Roll to its target value at the rate specified.
  45712. * @param rate - Higher means slower restoring.
  45713. * @hidden
  45714. */
  45715. restoreRoll(rate: number): void;
  45716. /**
  45717. * Destroy the camera and release the current resources held by it.
  45718. */
  45719. dispose(): void;
  45720. /**
  45721. * Get the current object class name.
  45722. * @returns the class name.
  45723. */
  45724. getClassName(): string;
  45725. }
  45726. }
  45727. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45728. import { Nullable } from "babylonjs/types";
  45729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45730. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45731. /**
  45732. * Listen to keyboard events to control the camera.
  45733. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45734. */
  45735. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45736. /**
  45737. * Defines the camera the input is attached to.
  45738. */
  45739. camera: FlyCamera;
  45740. /**
  45741. * The list of keyboard keys used to control the forward move of the camera.
  45742. */
  45743. keysForward: number[];
  45744. /**
  45745. * The list of keyboard keys used to control the backward move of the camera.
  45746. */
  45747. keysBackward: number[];
  45748. /**
  45749. * The list of keyboard keys used to control the forward move of the camera.
  45750. */
  45751. keysUp: number[];
  45752. /**
  45753. * The list of keyboard keys used to control the backward move of the camera.
  45754. */
  45755. keysDown: number[];
  45756. /**
  45757. * The list of keyboard keys used to control the right strafe move of the camera.
  45758. */
  45759. keysRight: number[];
  45760. /**
  45761. * The list of keyboard keys used to control the left strafe move of the camera.
  45762. */
  45763. keysLeft: number[];
  45764. private _keys;
  45765. private _onCanvasBlurObserver;
  45766. private _onKeyboardObserver;
  45767. private _engine;
  45768. private _scene;
  45769. /**
  45770. * Attach the input controls to a specific dom element to get the input from.
  45771. * @param element Defines the element the controls should be listened from
  45772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45773. */
  45774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45775. /**
  45776. * Detach the current controls from the specified dom element.
  45777. * @param element Defines the element to stop listening the inputs from
  45778. */
  45779. detachControl(element: Nullable<HTMLElement>): void;
  45780. /**
  45781. * Gets the class name of the current intput.
  45782. * @returns the class name
  45783. */
  45784. getClassName(): string;
  45785. /** @hidden */
  45786. _onLostFocus(e: FocusEvent): void;
  45787. /**
  45788. * Get the friendly name associated with the input class.
  45789. * @returns the input friendly name
  45790. */
  45791. getSimpleName(): string;
  45792. /**
  45793. * Update the current camera state depending on the inputs that have been used this frame.
  45794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45795. */
  45796. checkInputs(): void;
  45797. }
  45798. }
  45799. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45800. import { Nullable } from "babylonjs/types";
  45801. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45802. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45803. /**
  45804. * Manage the mouse wheel inputs to control a follow camera.
  45805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45806. */
  45807. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45808. /**
  45809. * Defines the camera the input is attached to.
  45810. */
  45811. camera: FollowCamera;
  45812. /**
  45813. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45814. */
  45815. axisControlRadius: boolean;
  45816. /**
  45817. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45818. */
  45819. axisControlHeight: boolean;
  45820. /**
  45821. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45822. */
  45823. axisControlRotation: boolean;
  45824. /**
  45825. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45826. * relation to mouseWheel events.
  45827. */
  45828. wheelPrecision: number;
  45829. /**
  45830. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45831. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45832. */
  45833. wheelDeltaPercentage: number;
  45834. private _wheel;
  45835. private _observer;
  45836. /**
  45837. * Attach the input controls to a specific dom element to get the input from.
  45838. * @param element Defines the element the controls should be listened from
  45839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45840. */
  45841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45842. /**
  45843. * Detach the current controls from the specified dom element.
  45844. * @param element Defines the element to stop listening the inputs from
  45845. */
  45846. detachControl(element: Nullable<HTMLElement>): void;
  45847. /**
  45848. * Gets the class name of the current intput.
  45849. * @returns the class name
  45850. */
  45851. getClassName(): string;
  45852. /**
  45853. * Get the friendly name associated with the input class.
  45854. * @returns the input friendly name
  45855. */
  45856. getSimpleName(): string;
  45857. }
  45858. }
  45859. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45860. import { Nullable } from "babylonjs/types";
  45861. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45862. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45863. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45864. /**
  45865. * Manage the pointers inputs to control an follow camera.
  45866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45867. */
  45868. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45869. /**
  45870. * Defines the camera the input is attached to.
  45871. */
  45872. camera: FollowCamera;
  45873. /**
  45874. * Gets the class name of the current input.
  45875. * @returns the class name
  45876. */
  45877. getClassName(): string;
  45878. /**
  45879. * Defines the pointer angular sensibility along the X axis or how fast is
  45880. * the camera rotating.
  45881. * A negative number will reverse the axis direction.
  45882. */
  45883. angularSensibilityX: number;
  45884. /**
  45885. * Defines the pointer angular sensibility along the Y axis or how fast is
  45886. * the camera rotating.
  45887. * A negative number will reverse the axis direction.
  45888. */
  45889. angularSensibilityY: number;
  45890. /**
  45891. * Defines the pointer pinch precision or how fast is the camera zooming.
  45892. * A negative number will reverse the axis direction.
  45893. */
  45894. pinchPrecision: number;
  45895. /**
  45896. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45897. * from 0.
  45898. * It defines the percentage of current camera.radius to use as delta when
  45899. * pinch zoom is used.
  45900. */
  45901. pinchDeltaPercentage: number;
  45902. /**
  45903. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45904. */
  45905. axisXControlRadius: boolean;
  45906. /**
  45907. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45908. */
  45909. axisXControlHeight: boolean;
  45910. /**
  45911. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45912. */
  45913. axisXControlRotation: boolean;
  45914. /**
  45915. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45916. */
  45917. axisYControlRadius: boolean;
  45918. /**
  45919. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45920. */
  45921. axisYControlHeight: boolean;
  45922. /**
  45923. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45924. */
  45925. axisYControlRotation: boolean;
  45926. /**
  45927. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45928. */
  45929. axisPinchControlRadius: boolean;
  45930. /**
  45931. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45932. */
  45933. axisPinchControlHeight: boolean;
  45934. /**
  45935. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45936. */
  45937. axisPinchControlRotation: boolean;
  45938. /**
  45939. * Log error messages if basic misconfiguration has occurred.
  45940. */
  45941. warningEnable: boolean;
  45942. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45943. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45944. private _warningCounter;
  45945. private _warning;
  45946. }
  45947. }
  45948. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45949. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45950. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45951. /**
  45952. * Default Inputs manager for the FollowCamera.
  45953. * It groups all the default supported inputs for ease of use.
  45954. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45955. */
  45956. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45957. /**
  45958. * Instantiates a new FollowCameraInputsManager.
  45959. * @param camera Defines the camera the inputs belong to
  45960. */
  45961. constructor(camera: FollowCamera);
  45962. /**
  45963. * Add keyboard input support to the input manager.
  45964. * @returns the current input manager
  45965. */
  45966. addKeyboard(): FollowCameraInputsManager;
  45967. /**
  45968. * Add mouse wheel input support to the input manager.
  45969. * @returns the current input manager
  45970. */
  45971. addMouseWheel(): FollowCameraInputsManager;
  45972. /**
  45973. * Add pointers input support to the input manager.
  45974. * @returns the current input manager
  45975. */
  45976. addPointers(): FollowCameraInputsManager;
  45977. /**
  45978. * Add orientation input support to the input manager.
  45979. * @returns the current input manager
  45980. */
  45981. addVRDeviceOrientation(): FollowCameraInputsManager;
  45982. }
  45983. }
  45984. declare module "babylonjs/Cameras/followCamera" {
  45985. import { Nullable } from "babylonjs/types";
  45986. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45987. import { Scene } from "babylonjs/scene";
  45988. import { Vector3 } from "babylonjs/Maths/math.vector";
  45989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45990. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45991. /**
  45992. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45993. * an arc rotate version arcFollowCamera are available.
  45994. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45995. */
  45996. export class FollowCamera extends TargetCamera {
  45997. /**
  45998. * Distance the follow camera should follow an object at
  45999. */
  46000. radius: number;
  46001. /**
  46002. * Minimum allowed distance of the camera to the axis of rotation
  46003. * (The camera can not get closer).
  46004. * This can help limiting how the Camera is able to move in the scene.
  46005. */
  46006. lowerRadiusLimit: Nullable<number>;
  46007. /**
  46008. * Maximum allowed distance of the camera to the axis of rotation
  46009. * (The camera can not get further).
  46010. * This can help limiting how the Camera is able to move in the scene.
  46011. */
  46012. upperRadiusLimit: Nullable<number>;
  46013. /**
  46014. * Define a rotation offset between the camera and the object it follows
  46015. */
  46016. rotationOffset: number;
  46017. /**
  46018. * Minimum allowed angle to camera position relative to target object.
  46019. * This can help limiting how the Camera is able to move in the scene.
  46020. */
  46021. lowerRotationOffsetLimit: Nullable<number>;
  46022. /**
  46023. * Maximum allowed angle to camera position relative to target object.
  46024. * This can help limiting how the Camera is able to move in the scene.
  46025. */
  46026. upperRotationOffsetLimit: Nullable<number>;
  46027. /**
  46028. * Define a height offset between the camera and the object it follows.
  46029. * It can help following an object from the top (like a car chaing a plane)
  46030. */
  46031. heightOffset: number;
  46032. /**
  46033. * Minimum allowed height of camera position relative to target object.
  46034. * This can help limiting how the Camera is able to move in the scene.
  46035. */
  46036. lowerHeightOffsetLimit: Nullable<number>;
  46037. /**
  46038. * Maximum allowed height of camera position relative to target object.
  46039. * This can help limiting how the Camera is able to move in the scene.
  46040. */
  46041. upperHeightOffsetLimit: Nullable<number>;
  46042. /**
  46043. * Define how fast the camera can accelerate to follow it s target.
  46044. */
  46045. cameraAcceleration: number;
  46046. /**
  46047. * Define the speed limit of the camera following an object.
  46048. */
  46049. maxCameraSpeed: number;
  46050. /**
  46051. * Define the target of the camera.
  46052. */
  46053. lockedTarget: Nullable<AbstractMesh>;
  46054. /**
  46055. * Defines the input associated with the camera.
  46056. */
  46057. inputs: FollowCameraInputsManager;
  46058. /**
  46059. * Instantiates the follow camera.
  46060. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46061. * @param name Define the name of the camera in the scene
  46062. * @param position Define the position of the camera
  46063. * @param scene Define the scene the camera belong to
  46064. * @param lockedTarget Define the target of the camera
  46065. */
  46066. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46067. private _follow;
  46068. /**
  46069. * Attached controls to the current camera.
  46070. * @param element Defines the element the controls should be listened from
  46071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46072. */
  46073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46074. /**
  46075. * Detach the current controls from the camera.
  46076. * The camera will stop reacting to inputs.
  46077. * @param element Defines the element to stop listening the inputs from
  46078. */
  46079. detachControl(element: HTMLElement): void;
  46080. /** @hidden */
  46081. _checkInputs(): void;
  46082. private _checkLimits;
  46083. /**
  46084. * Gets the camera class name.
  46085. * @returns the class name
  46086. */
  46087. getClassName(): string;
  46088. }
  46089. /**
  46090. * Arc Rotate version of the follow camera.
  46091. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46092. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46093. */
  46094. export class ArcFollowCamera extends TargetCamera {
  46095. /** The longitudinal angle of the camera */
  46096. alpha: number;
  46097. /** The latitudinal angle of the camera */
  46098. beta: number;
  46099. /** The radius of the camera from its target */
  46100. radius: number;
  46101. /** Define the camera target (the mesh it should follow) */
  46102. target: Nullable<AbstractMesh>;
  46103. private _cartesianCoordinates;
  46104. /**
  46105. * Instantiates a new ArcFollowCamera
  46106. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46107. * @param name Define the name of the camera
  46108. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46109. * @param beta Define the rotation angle of the camera around the elevation axis
  46110. * @param radius Define the radius of the camera from its target point
  46111. * @param target Define the target of the camera
  46112. * @param scene Define the scene the camera belongs to
  46113. */
  46114. constructor(name: string,
  46115. /** The longitudinal angle of the camera */
  46116. alpha: number,
  46117. /** The latitudinal angle of the camera */
  46118. beta: number,
  46119. /** The radius of the camera from its target */
  46120. radius: number,
  46121. /** Define the camera target (the mesh it should follow) */
  46122. target: Nullable<AbstractMesh>, scene: Scene);
  46123. private _follow;
  46124. /** @hidden */
  46125. _checkInputs(): void;
  46126. /**
  46127. * Returns the class name of the object.
  46128. * It is mostly used internally for serialization purposes.
  46129. */
  46130. getClassName(): string;
  46131. }
  46132. }
  46133. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46134. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46135. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46136. import { Nullable } from "babylonjs/types";
  46137. /**
  46138. * Manage the keyboard inputs to control the movement of a follow camera.
  46139. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46140. */
  46141. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46142. /**
  46143. * Defines the camera the input is attached to.
  46144. */
  46145. camera: FollowCamera;
  46146. /**
  46147. * Defines the list of key codes associated with the up action (increase heightOffset)
  46148. */
  46149. keysHeightOffsetIncr: number[];
  46150. /**
  46151. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46152. */
  46153. keysHeightOffsetDecr: number[];
  46154. /**
  46155. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46156. */
  46157. keysHeightOffsetModifierAlt: boolean;
  46158. /**
  46159. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46160. */
  46161. keysHeightOffsetModifierCtrl: boolean;
  46162. /**
  46163. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46164. */
  46165. keysHeightOffsetModifierShift: boolean;
  46166. /**
  46167. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46168. */
  46169. keysRotationOffsetIncr: number[];
  46170. /**
  46171. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46172. */
  46173. keysRotationOffsetDecr: number[];
  46174. /**
  46175. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46176. */
  46177. keysRotationOffsetModifierAlt: boolean;
  46178. /**
  46179. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46180. */
  46181. keysRotationOffsetModifierCtrl: boolean;
  46182. /**
  46183. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46184. */
  46185. keysRotationOffsetModifierShift: boolean;
  46186. /**
  46187. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46188. */
  46189. keysRadiusIncr: number[];
  46190. /**
  46191. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46192. */
  46193. keysRadiusDecr: number[];
  46194. /**
  46195. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46196. */
  46197. keysRadiusModifierAlt: boolean;
  46198. /**
  46199. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46200. */
  46201. keysRadiusModifierCtrl: boolean;
  46202. /**
  46203. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46204. */
  46205. keysRadiusModifierShift: boolean;
  46206. /**
  46207. * Defines the rate of change of heightOffset.
  46208. */
  46209. heightSensibility: number;
  46210. /**
  46211. * Defines the rate of change of rotationOffset.
  46212. */
  46213. rotationSensibility: number;
  46214. /**
  46215. * Defines the rate of change of radius.
  46216. */
  46217. radiusSensibility: number;
  46218. private _keys;
  46219. private _ctrlPressed;
  46220. private _altPressed;
  46221. private _shiftPressed;
  46222. private _onCanvasBlurObserver;
  46223. private _onKeyboardObserver;
  46224. private _engine;
  46225. private _scene;
  46226. /**
  46227. * Attach the input controls to a specific dom element to get the input from.
  46228. * @param element Defines the element the controls should be listened from
  46229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46230. */
  46231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46232. /**
  46233. * Detach the current controls from the specified dom element.
  46234. * @param element Defines the element to stop listening the inputs from
  46235. */
  46236. detachControl(element: Nullable<HTMLElement>): void;
  46237. /**
  46238. * Update the current camera state depending on the inputs that have been used this frame.
  46239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46240. */
  46241. checkInputs(): void;
  46242. /**
  46243. * Gets the class name of the current input.
  46244. * @returns the class name
  46245. */
  46246. getClassName(): string;
  46247. /**
  46248. * Get the friendly name associated with the input class.
  46249. * @returns the input friendly name
  46250. */
  46251. getSimpleName(): string;
  46252. /**
  46253. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46254. * allow modification of the heightOffset value.
  46255. */
  46256. private _modifierHeightOffset;
  46257. /**
  46258. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46259. * allow modification of the rotationOffset value.
  46260. */
  46261. private _modifierRotationOffset;
  46262. /**
  46263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46264. * allow modification of the radius value.
  46265. */
  46266. private _modifierRadius;
  46267. }
  46268. }
  46269. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46270. import { Nullable } from "babylonjs/types";
  46271. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46272. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46273. import { Observable } from "babylonjs/Misc/observable";
  46274. module "babylonjs/Cameras/freeCameraInputsManager" {
  46275. interface FreeCameraInputsManager {
  46276. /**
  46277. * @hidden
  46278. */
  46279. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46280. /**
  46281. * Add orientation input support to the input manager.
  46282. * @returns the current input manager
  46283. */
  46284. addDeviceOrientation(): FreeCameraInputsManager;
  46285. }
  46286. }
  46287. /**
  46288. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46289. * Screen rotation is taken into account.
  46290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46291. */
  46292. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46293. private _camera;
  46294. private _screenOrientationAngle;
  46295. private _constantTranform;
  46296. private _screenQuaternion;
  46297. private _alpha;
  46298. private _beta;
  46299. private _gamma;
  46300. /**
  46301. * Can be used to detect if a device orientation sensor is available on a device
  46302. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46303. * @returns a promise that will resolve on orientation change
  46304. */
  46305. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46306. /**
  46307. * @hidden
  46308. */
  46309. _onDeviceOrientationChangedObservable: Observable<void>;
  46310. /**
  46311. * Instantiates a new input
  46312. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46313. */
  46314. constructor();
  46315. /**
  46316. * Define the camera controlled by the input.
  46317. */
  46318. get camera(): FreeCamera;
  46319. set camera(camera: FreeCamera);
  46320. /**
  46321. * Attach the input controls to a specific dom element to get the input from.
  46322. * @param element Defines the element the controls should be listened from
  46323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46324. */
  46325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46326. private _orientationChanged;
  46327. private _deviceOrientation;
  46328. /**
  46329. * Detach the current controls from the specified dom element.
  46330. * @param element Defines the element to stop listening the inputs from
  46331. */
  46332. detachControl(element: Nullable<HTMLElement>): void;
  46333. /**
  46334. * Update the current camera state depending on the inputs that have been used this frame.
  46335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46336. */
  46337. checkInputs(): void;
  46338. /**
  46339. * Gets the class name of the current intput.
  46340. * @returns the class name
  46341. */
  46342. getClassName(): string;
  46343. /**
  46344. * Get the friendly name associated with the input class.
  46345. * @returns the input friendly name
  46346. */
  46347. getSimpleName(): string;
  46348. }
  46349. }
  46350. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46351. import { Nullable } from "babylonjs/types";
  46352. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46353. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46354. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46355. /**
  46356. * Manage the gamepad inputs to control a free camera.
  46357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46358. */
  46359. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46360. /**
  46361. * Define the camera the input is attached to.
  46362. */
  46363. camera: FreeCamera;
  46364. /**
  46365. * Define the Gamepad controlling the input
  46366. */
  46367. gamepad: Nullable<Gamepad>;
  46368. /**
  46369. * Defines the gamepad rotation sensiblity.
  46370. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46371. */
  46372. gamepadAngularSensibility: number;
  46373. /**
  46374. * Defines the gamepad move sensiblity.
  46375. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46376. */
  46377. gamepadMoveSensibility: number;
  46378. private _yAxisScale;
  46379. /**
  46380. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46381. */
  46382. get invertYAxis(): boolean;
  46383. set invertYAxis(value: boolean);
  46384. private _onGamepadConnectedObserver;
  46385. private _onGamepadDisconnectedObserver;
  46386. private _cameraTransform;
  46387. private _deltaTransform;
  46388. private _vector3;
  46389. private _vector2;
  46390. /**
  46391. * Attach the input controls to a specific dom element to get the input from.
  46392. * @param element Defines the element the controls should be listened from
  46393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46394. */
  46395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46396. /**
  46397. * Detach the current controls from the specified dom element.
  46398. * @param element Defines the element to stop listening the inputs from
  46399. */
  46400. detachControl(element: Nullable<HTMLElement>): void;
  46401. /**
  46402. * Update the current camera state depending on the inputs that have been used this frame.
  46403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46404. */
  46405. checkInputs(): void;
  46406. /**
  46407. * Gets the class name of the current intput.
  46408. * @returns the class name
  46409. */
  46410. getClassName(): string;
  46411. /**
  46412. * Get the friendly name associated with the input class.
  46413. * @returns the input friendly name
  46414. */
  46415. getSimpleName(): string;
  46416. }
  46417. }
  46418. declare module "babylonjs/Misc/virtualJoystick" {
  46419. import { Nullable } from "babylonjs/types";
  46420. import { Vector3 } from "babylonjs/Maths/math.vector";
  46421. /**
  46422. * Defines the potential axis of a Joystick
  46423. */
  46424. export enum JoystickAxis {
  46425. /** X axis */
  46426. X = 0,
  46427. /** Y axis */
  46428. Y = 1,
  46429. /** Z axis */
  46430. Z = 2
  46431. }
  46432. /**
  46433. * Represents the different customization options available
  46434. * for VirtualJoystick
  46435. */
  46436. interface VirtualJoystickCustomizations {
  46437. /**
  46438. * Size of the joystick's puck
  46439. */
  46440. puckSize: number;
  46441. /**
  46442. * Size of the joystick's container
  46443. */
  46444. containerSize: number;
  46445. /**
  46446. * Color of the joystick && puck
  46447. */
  46448. color: string;
  46449. /**
  46450. * Image URL for the joystick's puck
  46451. */
  46452. puckImage?: string;
  46453. /**
  46454. * Image URL for the joystick's container
  46455. */
  46456. containerImage?: string;
  46457. /**
  46458. * Defines the unmoving position of the joystick container
  46459. */
  46460. position?: {
  46461. x: number;
  46462. y: number;
  46463. };
  46464. /**
  46465. * Defines whether or not the joystick container is always visible
  46466. */
  46467. alwaysVisible: boolean;
  46468. /**
  46469. * Defines whether or not to limit the movement of the puck to the joystick's container
  46470. */
  46471. limitToContainer: boolean;
  46472. }
  46473. /**
  46474. * Class used to define virtual joystick (used in touch mode)
  46475. */
  46476. export class VirtualJoystick {
  46477. /**
  46478. * Gets or sets a boolean indicating that left and right values must be inverted
  46479. */
  46480. reverseLeftRight: boolean;
  46481. /**
  46482. * Gets or sets a boolean indicating that up and down values must be inverted
  46483. */
  46484. reverseUpDown: boolean;
  46485. /**
  46486. * Gets the offset value for the position (ie. the change of the position value)
  46487. */
  46488. deltaPosition: Vector3;
  46489. /**
  46490. * Gets a boolean indicating if the virtual joystick was pressed
  46491. */
  46492. pressed: boolean;
  46493. /**
  46494. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46495. */
  46496. static Canvas: Nullable<HTMLCanvasElement>;
  46497. /**
  46498. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46499. */
  46500. limitToContainer: boolean;
  46501. private static _globalJoystickIndex;
  46502. private static _alwaysVisibleSticks;
  46503. private static vjCanvasContext;
  46504. private static vjCanvasWidth;
  46505. private static vjCanvasHeight;
  46506. private static halfWidth;
  46507. private static _GetDefaultOptions;
  46508. private _action;
  46509. private _axisTargetedByLeftAndRight;
  46510. private _axisTargetedByUpAndDown;
  46511. private _joystickSensibility;
  46512. private _inversedSensibility;
  46513. private _joystickPointerID;
  46514. private _joystickColor;
  46515. private _joystickPointerPos;
  46516. private _joystickPreviousPointerPos;
  46517. private _joystickPointerStartPos;
  46518. private _deltaJoystickVector;
  46519. private _leftJoystick;
  46520. private _touches;
  46521. private _joystickPosition;
  46522. private _alwaysVisible;
  46523. private _puckImage;
  46524. private _containerImage;
  46525. private _joystickPuckSize;
  46526. private _joystickContainerSize;
  46527. private _clearPuckSize;
  46528. private _clearContainerSize;
  46529. private _clearPuckSizeOffset;
  46530. private _clearContainerSizeOffset;
  46531. private _onPointerDownHandlerRef;
  46532. private _onPointerMoveHandlerRef;
  46533. private _onPointerUpHandlerRef;
  46534. private _onResize;
  46535. /**
  46536. * Creates a new virtual joystick
  46537. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46538. * @param customizations Defines the options we want to customize the VirtualJoystick
  46539. */
  46540. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46541. /**
  46542. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46543. * @param newJoystickSensibility defines the new sensibility
  46544. */
  46545. setJoystickSensibility(newJoystickSensibility: number): void;
  46546. private _onPointerDown;
  46547. private _onPointerMove;
  46548. private _onPointerUp;
  46549. /**
  46550. * Change the color of the virtual joystick
  46551. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46552. */
  46553. setJoystickColor(newColor: string): void;
  46554. /**
  46555. * Size of the joystick's container
  46556. */
  46557. set containerSize(newSize: number);
  46558. get containerSize(): number;
  46559. /**
  46560. * Size of the joystick's puck
  46561. */
  46562. set puckSize(newSize: number);
  46563. get puckSize(): number;
  46564. /**
  46565. * Clears the set position of the joystick
  46566. */
  46567. clearPosition(): void;
  46568. /**
  46569. * Defines whether or not the joystick container is always visible
  46570. */
  46571. set alwaysVisible(value: boolean);
  46572. get alwaysVisible(): boolean;
  46573. /**
  46574. * Sets the constant position of the Joystick container
  46575. * @param x X axis coordinate
  46576. * @param y Y axis coordinate
  46577. */
  46578. setPosition(x: number, y: number): void;
  46579. /**
  46580. * Defines a callback to call when the joystick is touched
  46581. * @param action defines the callback
  46582. */
  46583. setActionOnTouch(action: () => any): void;
  46584. /**
  46585. * Defines which axis you'd like to control for left & right
  46586. * @param axis defines the axis to use
  46587. */
  46588. setAxisForLeftRight(axis: JoystickAxis): void;
  46589. /**
  46590. * Defines which axis you'd like to control for up & down
  46591. * @param axis defines the axis to use
  46592. */
  46593. setAxisForUpDown(axis: JoystickAxis): void;
  46594. /**
  46595. * Clears the canvas from the previous puck / container draw
  46596. */
  46597. private _clearPreviousDraw;
  46598. /**
  46599. * Loads `urlPath` to be used for the container's image
  46600. * @param urlPath defines the urlPath of an image to use
  46601. */
  46602. setContainerImage(urlPath: string): void;
  46603. /**
  46604. * Loads `urlPath` to be used for the puck's image
  46605. * @param urlPath defines the urlPath of an image to use
  46606. */
  46607. setPuckImage(urlPath: string): void;
  46608. /**
  46609. * Draws the Virtual Joystick's container
  46610. */
  46611. private _drawContainer;
  46612. /**
  46613. * Draws the Virtual Joystick's puck
  46614. */
  46615. private _drawPuck;
  46616. private _drawVirtualJoystick;
  46617. /**
  46618. * Release internal HTML canvas
  46619. */
  46620. releaseCanvas(): void;
  46621. }
  46622. }
  46623. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46624. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46625. import { Nullable } from "babylonjs/types";
  46626. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46627. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46628. module "babylonjs/Cameras/freeCameraInputsManager" {
  46629. interface FreeCameraInputsManager {
  46630. /**
  46631. * Add virtual joystick input support to the input manager.
  46632. * @returns the current input manager
  46633. */
  46634. addVirtualJoystick(): FreeCameraInputsManager;
  46635. }
  46636. }
  46637. /**
  46638. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46639. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46640. */
  46641. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46642. /**
  46643. * Defines the camera the input is attached to.
  46644. */
  46645. camera: FreeCamera;
  46646. private _leftjoystick;
  46647. private _rightjoystick;
  46648. /**
  46649. * Gets the left stick of the virtual joystick.
  46650. * @returns The virtual Joystick
  46651. */
  46652. getLeftJoystick(): VirtualJoystick;
  46653. /**
  46654. * Gets the right stick of the virtual joystick.
  46655. * @returns The virtual Joystick
  46656. */
  46657. getRightJoystick(): VirtualJoystick;
  46658. /**
  46659. * Update the current camera state depending on the inputs that have been used this frame.
  46660. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46661. */
  46662. checkInputs(): void;
  46663. /**
  46664. * Attach the input controls to a specific dom element to get the input from.
  46665. * @param element Defines the element the controls should be listened from
  46666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46667. */
  46668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46669. /**
  46670. * Detach the current controls from the specified dom element.
  46671. * @param element Defines the element to stop listening the inputs from
  46672. */
  46673. detachControl(element: Nullable<HTMLElement>): void;
  46674. /**
  46675. * Gets the class name of the current intput.
  46676. * @returns the class name
  46677. */
  46678. getClassName(): string;
  46679. /**
  46680. * Get the friendly name associated with the input class.
  46681. * @returns the input friendly name
  46682. */
  46683. getSimpleName(): string;
  46684. }
  46685. }
  46686. declare module "babylonjs/Cameras/Inputs/index" {
  46687. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46688. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46689. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46690. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46691. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46692. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46693. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46694. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46695. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46696. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46697. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46698. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46699. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46700. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46701. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46702. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46703. }
  46704. declare module "babylonjs/Cameras/touchCamera" {
  46705. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46706. import { Scene } from "babylonjs/scene";
  46707. import { Vector3 } from "babylonjs/Maths/math.vector";
  46708. /**
  46709. * This represents a FPS type of camera controlled by touch.
  46710. * This is like a universal camera minus the Gamepad controls.
  46711. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46712. */
  46713. export class TouchCamera extends FreeCamera {
  46714. /**
  46715. * Defines the touch sensibility for rotation.
  46716. * The higher the faster.
  46717. */
  46718. get touchAngularSensibility(): number;
  46719. set touchAngularSensibility(value: number);
  46720. /**
  46721. * Defines the touch sensibility for move.
  46722. * The higher the faster.
  46723. */
  46724. get touchMoveSensibility(): number;
  46725. set touchMoveSensibility(value: number);
  46726. /**
  46727. * Instantiates a new touch camera.
  46728. * This represents a FPS type of camera controlled by touch.
  46729. * This is like a universal camera minus the Gamepad controls.
  46730. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46731. * @param name Define the name of the camera in the scene
  46732. * @param position Define the start position of the camera in the scene
  46733. * @param scene Define the scene the camera belongs to
  46734. */
  46735. constructor(name: string, position: Vector3, scene: Scene);
  46736. /**
  46737. * Gets the current object class name.
  46738. * @return the class name
  46739. */
  46740. getClassName(): string;
  46741. /** @hidden */
  46742. _setupInputs(): void;
  46743. }
  46744. }
  46745. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46746. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46747. import { Scene } from "babylonjs/scene";
  46748. import { Vector3 } from "babylonjs/Maths/math.vector";
  46749. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46750. import { Axis } from "babylonjs/Maths/math.axis";
  46751. /**
  46752. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46753. * being tilted forward or back and left or right.
  46754. */
  46755. export class DeviceOrientationCamera extends FreeCamera {
  46756. private _initialQuaternion;
  46757. private _quaternionCache;
  46758. private _tmpDragQuaternion;
  46759. private _disablePointerInputWhenUsingDeviceOrientation;
  46760. /**
  46761. * Creates a new device orientation camera
  46762. * @param name The name of the camera
  46763. * @param position The start position camera
  46764. * @param scene The scene the camera belongs to
  46765. */
  46766. constructor(name: string, position: Vector3, scene: Scene);
  46767. /**
  46768. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46769. */
  46770. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46771. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46772. private _dragFactor;
  46773. /**
  46774. * Enabled turning on the y axis when the orientation sensor is active
  46775. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46776. */
  46777. enableHorizontalDragging(dragFactor?: number): void;
  46778. /**
  46779. * Gets the current instance class name ("DeviceOrientationCamera").
  46780. * This helps avoiding instanceof at run time.
  46781. * @returns the class name
  46782. */
  46783. getClassName(): string;
  46784. /**
  46785. * @hidden
  46786. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46787. */
  46788. _checkInputs(): void;
  46789. /**
  46790. * Reset the camera to its default orientation on the specified axis only.
  46791. * @param axis The axis to reset
  46792. */
  46793. resetToCurrentRotation(axis?: Axis): void;
  46794. }
  46795. }
  46796. declare module "babylonjs/Gamepads/xboxGamepad" {
  46797. import { Observable } from "babylonjs/Misc/observable";
  46798. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46799. /**
  46800. * Defines supported buttons for XBox360 compatible gamepads
  46801. */
  46802. export enum Xbox360Button {
  46803. /** A */
  46804. A = 0,
  46805. /** B */
  46806. B = 1,
  46807. /** X */
  46808. X = 2,
  46809. /** Y */
  46810. Y = 3,
  46811. /** Left button */
  46812. LB = 4,
  46813. /** Right button */
  46814. RB = 5,
  46815. /** Back */
  46816. Back = 8,
  46817. /** Start */
  46818. Start = 9,
  46819. /** Left stick */
  46820. LeftStick = 10,
  46821. /** Right stick */
  46822. RightStick = 11
  46823. }
  46824. /** Defines values for XBox360 DPad */
  46825. export enum Xbox360Dpad {
  46826. /** Up */
  46827. Up = 12,
  46828. /** Down */
  46829. Down = 13,
  46830. /** Left */
  46831. Left = 14,
  46832. /** Right */
  46833. Right = 15
  46834. }
  46835. /**
  46836. * Defines a XBox360 gamepad
  46837. */
  46838. export class Xbox360Pad extends Gamepad {
  46839. private _leftTrigger;
  46840. private _rightTrigger;
  46841. private _onlefttriggerchanged;
  46842. private _onrighttriggerchanged;
  46843. private _onbuttondown;
  46844. private _onbuttonup;
  46845. private _ondpaddown;
  46846. private _ondpadup;
  46847. /** Observable raised when a button is pressed */
  46848. onButtonDownObservable: Observable<Xbox360Button>;
  46849. /** Observable raised when a button is released */
  46850. onButtonUpObservable: Observable<Xbox360Button>;
  46851. /** Observable raised when a pad is pressed */
  46852. onPadDownObservable: Observable<Xbox360Dpad>;
  46853. /** Observable raised when a pad is released */
  46854. onPadUpObservable: Observable<Xbox360Dpad>;
  46855. private _buttonA;
  46856. private _buttonB;
  46857. private _buttonX;
  46858. private _buttonY;
  46859. private _buttonBack;
  46860. private _buttonStart;
  46861. private _buttonLB;
  46862. private _buttonRB;
  46863. private _buttonLeftStick;
  46864. private _buttonRightStick;
  46865. private _dPadUp;
  46866. private _dPadDown;
  46867. private _dPadLeft;
  46868. private _dPadRight;
  46869. private _isXboxOnePad;
  46870. /**
  46871. * Creates a new XBox360 gamepad object
  46872. * @param id defines the id of this gamepad
  46873. * @param index defines its index
  46874. * @param gamepad defines the internal HTML gamepad object
  46875. * @param xboxOne defines if it is a XBox One gamepad
  46876. */
  46877. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46878. /**
  46879. * Defines the callback to call when left trigger is pressed
  46880. * @param callback defines the callback to use
  46881. */
  46882. onlefttriggerchanged(callback: (value: number) => void): void;
  46883. /**
  46884. * Defines the callback to call when right trigger is pressed
  46885. * @param callback defines the callback to use
  46886. */
  46887. onrighttriggerchanged(callback: (value: number) => void): void;
  46888. /**
  46889. * Gets the left trigger value
  46890. */
  46891. get leftTrigger(): number;
  46892. /**
  46893. * Sets the left trigger value
  46894. */
  46895. set leftTrigger(newValue: number);
  46896. /**
  46897. * Gets the right trigger value
  46898. */
  46899. get rightTrigger(): number;
  46900. /**
  46901. * Sets the right trigger value
  46902. */
  46903. set rightTrigger(newValue: number);
  46904. /**
  46905. * Defines the callback to call when a button is pressed
  46906. * @param callback defines the callback to use
  46907. */
  46908. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46909. /**
  46910. * Defines the callback to call when a button is released
  46911. * @param callback defines the callback to use
  46912. */
  46913. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46914. /**
  46915. * Defines the callback to call when a pad is pressed
  46916. * @param callback defines the callback to use
  46917. */
  46918. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46919. /**
  46920. * Defines the callback to call when a pad is released
  46921. * @param callback defines the callback to use
  46922. */
  46923. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46924. private _setButtonValue;
  46925. private _setDPadValue;
  46926. /**
  46927. * Gets the value of the `A` button
  46928. */
  46929. get buttonA(): number;
  46930. /**
  46931. * Sets the value of the `A` button
  46932. */
  46933. set buttonA(value: number);
  46934. /**
  46935. * Gets the value of the `B` button
  46936. */
  46937. get buttonB(): number;
  46938. /**
  46939. * Sets the value of the `B` button
  46940. */
  46941. set buttonB(value: number);
  46942. /**
  46943. * Gets the value of the `X` button
  46944. */
  46945. get buttonX(): number;
  46946. /**
  46947. * Sets the value of the `X` button
  46948. */
  46949. set buttonX(value: number);
  46950. /**
  46951. * Gets the value of the `Y` button
  46952. */
  46953. get buttonY(): number;
  46954. /**
  46955. * Sets the value of the `Y` button
  46956. */
  46957. set buttonY(value: number);
  46958. /**
  46959. * Gets the value of the `Start` button
  46960. */
  46961. get buttonStart(): number;
  46962. /**
  46963. * Sets the value of the `Start` button
  46964. */
  46965. set buttonStart(value: number);
  46966. /**
  46967. * Gets the value of the `Back` button
  46968. */
  46969. get buttonBack(): number;
  46970. /**
  46971. * Sets the value of the `Back` button
  46972. */
  46973. set buttonBack(value: number);
  46974. /**
  46975. * Gets the value of the `Left` button
  46976. */
  46977. get buttonLB(): number;
  46978. /**
  46979. * Sets the value of the `Left` button
  46980. */
  46981. set buttonLB(value: number);
  46982. /**
  46983. * Gets the value of the `Right` button
  46984. */
  46985. get buttonRB(): number;
  46986. /**
  46987. * Sets the value of the `Right` button
  46988. */
  46989. set buttonRB(value: number);
  46990. /**
  46991. * Gets the value of the Left joystick
  46992. */
  46993. get buttonLeftStick(): number;
  46994. /**
  46995. * Sets the value of the Left joystick
  46996. */
  46997. set buttonLeftStick(value: number);
  46998. /**
  46999. * Gets the value of the Right joystick
  47000. */
  47001. get buttonRightStick(): number;
  47002. /**
  47003. * Sets the value of the Right joystick
  47004. */
  47005. set buttonRightStick(value: number);
  47006. /**
  47007. * Gets the value of D-pad up
  47008. */
  47009. get dPadUp(): number;
  47010. /**
  47011. * Sets the value of D-pad up
  47012. */
  47013. set dPadUp(value: number);
  47014. /**
  47015. * Gets the value of D-pad down
  47016. */
  47017. get dPadDown(): number;
  47018. /**
  47019. * Sets the value of D-pad down
  47020. */
  47021. set dPadDown(value: number);
  47022. /**
  47023. * Gets the value of D-pad left
  47024. */
  47025. get dPadLeft(): number;
  47026. /**
  47027. * Sets the value of D-pad left
  47028. */
  47029. set dPadLeft(value: number);
  47030. /**
  47031. * Gets the value of D-pad right
  47032. */
  47033. get dPadRight(): number;
  47034. /**
  47035. * Sets the value of D-pad right
  47036. */
  47037. set dPadRight(value: number);
  47038. /**
  47039. * Force the gamepad to synchronize with device values
  47040. */
  47041. update(): void;
  47042. /**
  47043. * Disposes the gamepad
  47044. */
  47045. dispose(): void;
  47046. }
  47047. }
  47048. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47049. import { Observable } from "babylonjs/Misc/observable";
  47050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47051. /**
  47052. * Defines supported buttons for DualShock compatible gamepads
  47053. */
  47054. export enum DualShockButton {
  47055. /** Cross */
  47056. Cross = 0,
  47057. /** Circle */
  47058. Circle = 1,
  47059. /** Square */
  47060. Square = 2,
  47061. /** Triangle */
  47062. Triangle = 3,
  47063. /** L1 */
  47064. L1 = 4,
  47065. /** R1 */
  47066. R1 = 5,
  47067. /** Share */
  47068. Share = 8,
  47069. /** Options */
  47070. Options = 9,
  47071. /** Left stick */
  47072. LeftStick = 10,
  47073. /** Right stick */
  47074. RightStick = 11
  47075. }
  47076. /** Defines values for DualShock DPad */
  47077. export enum DualShockDpad {
  47078. /** Up */
  47079. Up = 12,
  47080. /** Down */
  47081. Down = 13,
  47082. /** Left */
  47083. Left = 14,
  47084. /** Right */
  47085. Right = 15
  47086. }
  47087. /**
  47088. * Defines a DualShock gamepad
  47089. */
  47090. export class DualShockPad extends Gamepad {
  47091. private _leftTrigger;
  47092. private _rightTrigger;
  47093. private _onlefttriggerchanged;
  47094. private _onrighttriggerchanged;
  47095. private _onbuttondown;
  47096. private _onbuttonup;
  47097. private _ondpaddown;
  47098. private _ondpadup;
  47099. /** Observable raised when a button is pressed */
  47100. onButtonDownObservable: Observable<DualShockButton>;
  47101. /** Observable raised when a button is released */
  47102. onButtonUpObservable: Observable<DualShockButton>;
  47103. /** Observable raised when a pad is pressed */
  47104. onPadDownObservable: Observable<DualShockDpad>;
  47105. /** Observable raised when a pad is released */
  47106. onPadUpObservable: Observable<DualShockDpad>;
  47107. private _buttonCross;
  47108. private _buttonCircle;
  47109. private _buttonSquare;
  47110. private _buttonTriangle;
  47111. private _buttonShare;
  47112. private _buttonOptions;
  47113. private _buttonL1;
  47114. private _buttonR1;
  47115. private _buttonLeftStick;
  47116. private _buttonRightStick;
  47117. private _dPadUp;
  47118. private _dPadDown;
  47119. private _dPadLeft;
  47120. private _dPadRight;
  47121. /**
  47122. * Creates a new DualShock gamepad object
  47123. * @param id defines the id of this gamepad
  47124. * @param index defines its index
  47125. * @param gamepad defines the internal HTML gamepad object
  47126. */
  47127. constructor(id: string, index: number, gamepad: any);
  47128. /**
  47129. * Defines the callback to call when left trigger is pressed
  47130. * @param callback defines the callback to use
  47131. */
  47132. onlefttriggerchanged(callback: (value: number) => void): void;
  47133. /**
  47134. * Defines the callback to call when right trigger is pressed
  47135. * @param callback defines the callback to use
  47136. */
  47137. onrighttriggerchanged(callback: (value: number) => void): void;
  47138. /**
  47139. * Gets the left trigger value
  47140. */
  47141. get leftTrigger(): number;
  47142. /**
  47143. * Sets the left trigger value
  47144. */
  47145. set leftTrigger(newValue: number);
  47146. /**
  47147. * Gets the right trigger value
  47148. */
  47149. get rightTrigger(): number;
  47150. /**
  47151. * Sets the right trigger value
  47152. */
  47153. set rightTrigger(newValue: number);
  47154. /**
  47155. * Defines the callback to call when a button is pressed
  47156. * @param callback defines the callback to use
  47157. */
  47158. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47159. /**
  47160. * Defines the callback to call when a button is released
  47161. * @param callback defines the callback to use
  47162. */
  47163. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47164. /**
  47165. * Defines the callback to call when a pad is pressed
  47166. * @param callback defines the callback to use
  47167. */
  47168. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47169. /**
  47170. * Defines the callback to call when a pad is released
  47171. * @param callback defines the callback to use
  47172. */
  47173. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47174. private _setButtonValue;
  47175. private _setDPadValue;
  47176. /**
  47177. * Gets the value of the `Cross` button
  47178. */
  47179. get buttonCross(): number;
  47180. /**
  47181. * Sets the value of the `Cross` button
  47182. */
  47183. set buttonCross(value: number);
  47184. /**
  47185. * Gets the value of the `Circle` button
  47186. */
  47187. get buttonCircle(): number;
  47188. /**
  47189. * Sets the value of the `Circle` button
  47190. */
  47191. set buttonCircle(value: number);
  47192. /**
  47193. * Gets the value of the `Square` button
  47194. */
  47195. get buttonSquare(): number;
  47196. /**
  47197. * Sets the value of the `Square` button
  47198. */
  47199. set buttonSquare(value: number);
  47200. /**
  47201. * Gets the value of the `Triangle` button
  47202. */
  47203. get buttonTriangle(): number;
  47204. /**
  47205. * Sets the value of the `Triangle` button
  47206. */
  47207. set buttonTriangle(value: number);
  47208. /**
  47209. * Gets the value of the `Options` button
  47210. */
  47211. get buttonOptions(): number;
  47212. /**
  47213. * Sets the value of the `Options` button
  47214. */
  47215. set buttonOptions(value: number);
  47216. /**
  47217. * Gets the value of the `Share` button
  47218. */
  47219. get buttonShare(): number;
  47220. /**
  47221. * Sets the value of the `Share` button
  47222. */
  47223. set buttonShare(value: number);
  47224. /**
  47225. * Gets the value of the `L1` button
  47226. */
  47227. get buttonL1(): number;
  47228. /**
  47229. * Sets the value of the `L1` button
  47230. */
  47231. set buttonL1(value: number);
  47232. /**
  47233. * Gets the value of the `R1` button
  47234. */
  47235. get buttonR1(): number;
  47236. /**
  47237. * Sets the value of the `R1` button
  47238. */
  47239. set buttonR1(value: number);
  47240. /**
  47241. * Gets the value of the Left joystick
  47242. */
  47243. get buttonLeftStick(): number;
  47244. /**
  47245. * Sets the value of the Left joystick
  47246. */
  47247. set buttonLeftStick(value: number);
  47248. /**
  47249. * Gets the value of the Right joystick
  47250. */
  47251. get buttonRightStick(): number;
  47252. /**
  47253. * Sets the value of the Right joystick
  47254. */
  47255. set buttonRightStick(value: number);
  47256. /**
  47257. * Gets the value of D-pad up
  47258. */
  47259. get dPadUp(): number;
  47260. /**
  47261. * Sets the value of D-pad up
  47262. */
  47263. set dPadUp(value: number);
  47264. /**
  47265. * Gets the value of D-pad down
  47266. */
  47267. get dPadDown(): number;
  47268. /**
  47269. * Sets the value of D-pad down
  47270. */
  47271. set dPadDown(value: number);
  47272. /**
  47273. * Gets the value of D-pad left
  47274. */
  47275. get dPadLeft(): number;
  47276. /**
  47277. * Sets the value of D-pad left
  47278. */
  47279. set dPadLeft(value: number);
  47280. /**
  47281. * Gets the value of D-pad right
  47282. */
  47283. get dPadRight(): number;
  47284. /**
  47285. * Sets the value of D-pad right
  47286. */
  47287. set dPadRight(value: number);
  47288. /**
  47289. * Force the gamepad to synchronize with device values
  47290. */
  47291. update(): void;
  47292. /**
  47293. * Disposes the gamepad
  47294. */
  47295. dispose(): void;
  47296. }
  47297. }
  47298. declare module "babylonjs/Gamepads/gamepadManager" {
  47299. import { Observable } from "babylonjs/Misc/observable";
  47300. import { Nullable } from "babylonjs/types";
  47301. import { Scene } from "babylonjs/scene";
  47302. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47303. /**
  47304. * Manager for handling gamepads
  47305. */
  47306. export class GamepadManager {
  47307. private _scene?;
  47308. private _babylonGamepads;
  47309. private _oneGamepadConnected;
  47310. /** @hidden */
  47311. _isMonitoring: boolean;
  47312. private _gamepadEventSupported;
  47313. private _gamepadSupport?;
  47314. /**
  47315. * observable to be triggered when the gamepad controller has been connected
  47316. */
  47317. onGamepadConnectedObservable: Observable<Gamepad>;
  47318. /**
  47319. * observable to be triggered when the gamepad controller has been disconnected
  47320. */
  47321. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47322. private _onGamepadConnectedEvent;
  47323. private _onGamepadDisconnectedEvent;
  47324. /**
  47325. * Initializes the gamepad manager
  47326. * @param _scene BabylonJS scene
  47327. */
  47328. constructor(_scene?: Scene | undefined);
  47329. /**
  47330. * The gamepads in the game pad manager
  47331. */
  47332. get gamepads(): Gamepad[];
  47333. /**
  47334. * Get the gamepad controllers based on type
  47335. * @param type The type of gamepad controller
  47336. * @returns Nullable gamepad
  47337. */
  47338. getGamepadByType(type?: number): Nullable<Gamepad>;
  47339. /**
  47340. * Disposes the gamepad manager
  47341. */
  47342. dispose(): void;
  47343. private _addNewGamepad;
  47344. private _startMonitoringGamepads;
  47345. private _stopMonitoringGamepads;
  47346. /** @hidden */
  47347. _checkGamepadsStatus(): void;
  47348. private _updateGamepadObjects;
  47349. }
  47350. }
  47351. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47352. import { Nullable } from "babylonjs/types";
  47353. import { Scene } from "babylonjs/scene";
  47354. import { ISceneComponent } from "babylonjs/sceneComponent";
  47355. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47356. module "babylonjs/scene" {
  47357. interface Scene {
  47358. /** @hidden */
  47359. _gamepadManager: Nullable<GamepadManager>;
  47360. /**
  47361. * Gets the gamepad manager associated with the scene
  47362. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47363. */
  47364. gamepadManager: GamepadManager;
  47365. }
  47366. }
  47367. module "babylonjs/Cameras/freeCameraInputsManager" {
  47368. /**
  47369. * Interface representing a free camera inputs manager
  47370. */
  47371. interface FreeCameraInputsManager {
  47372. /**
  47373. * Adds gamepad input support to the FreeCameraInputsManager.
  47374. * @returns the FreeCameraInputsManager
  47375. */
  47376. addGamepad(): FreeCameraInputsManager;
  47377. }
  47378. }
  47379. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47380. /**
  47381. * Interface representing an arc rotate camera inputs manager
  47382. */
  47383. interface ArcRotateCameraInputsManager {
  47384. /**
  47385. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47386. * @returns the camera inputs manager
  47387. */
  47388. addGamepad(): ArcRotateCameraInputsManager;
  47389. }
  47390. }
  47391. /**
  47392. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47393. */
  47394. export class GamepadSystemSceneComponent implements ISceneComponent {
  47395. /**
  47396. * The component name helpfull to identify the component in the list of scene components.
  47397. */
  47398. readonly name: string;
  47399. /**
  47400. * The scene the component belongs to.
  47401. */
  47402. scene: Scene;
  47403. /**
  47404. * Creates a new instance of the component for the given scene
  47405. * @param scene Defines the scene to register the component in
  47406. */
  47407. constructor(scene: Scene);
  47408. /**
  47409. * Registers the component in a given scene
  47410. */
  47411. register(): void;
  47412. /**
  47413. * Rebuilds the elements related to this component in case of
  47414. * context lost for instance.
  47415. */
  47416. rebuild(): void;
  47417. /**
  47418. * Disposes the component and the associated ressources
  47419. */
  47420. dispose(): void;
  47421. private _beforeCameraUpdate;
  47422. }
  47423. }
  47424. declare module "babylonjs/Cameras/universalCamera" {
  47425. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47426. import { Scene } from "babylonjs/scene";
  47427. import { Vector3 } from "babylonjs/Maths/math.vector";
  47428. import "babylonjs/Gamepads/gamepadSceneComponent";
  47429. /**
  47430. * 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,
  47431. * which still works and will still be found in many Playgrounds.
  47432. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47433. */
  47434. export class UniversalCamera extends TouchCamera {
  47435. /**
  47436. * Defines the gamepad rotation sensiblity.
  47437. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47438. */
  47439. get gamepadAngularSensibility(): number;
  47440. set gamepadAngularSensibility(value: number);
  47441. /**
  47442. * Defines the gamepad move sensiblity.
  47443. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47444. */
  47445. get gamepadMoveSensibility(): number;
  47446. set gamepadMoveSensibility(value: number);
  47447. /**
  47448. * 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,
  47449. * which still works and will still be found in many Playgrounds.
  47450. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47451. * @param name Define the name of the camera in the scene
  47452. * @param position Define the start position of the camera in the scene
  47453. * @param scene Define the scene the camera belongs to
  47454. */
  47455. constructor(name: string, position: Vector3, scene: Scene);
  47456. /**
  47457. * Gets the current object class name.
  47458. * @return the class name
  47459. */
  47460. getClassName(): string;
  47461. }
  47462. }
  47463. declare module "babylonjs/Cameras/gamepadCamera" {
  47464. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47465. import { Scene } from "babylonjs/scene";
  47466. import { Vector3 } from "babylonjs/Maths/math.vector";
  47467. /**
  47468. * This represents a FPS type of camera. This is only here for back compat purpose.
  47469. * Please use the UniversalCamera instead as both are identical.
  47470. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47471. */
  47472. export class GamepadCamera extends UniversalCamera {
  47473. /**
  47474. * Instantiates a new Gamepad Camera
  47475. * This represents a FPS type of camera. This is only here for back compat purpose.
  47476. * Please use the UniversalCamera instead as both are identical.
  47477. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47478. * @param name Define the name of the camera in the scene
  47479. * @param position Define the start position of the camera in the scene
  47480. * @param scene Define the scene the camera belongs to
  47481. */
  47482. constructor(name: string, position: Vector3, scene: Scene);
  47483. /**
  47484. * Gets the current object class name.
  47485. * @return the class name
  47486. */
  47487. getClassName(): string;
  47488. }
  47489. }
  47490. declare module "babylonjs/Shaders/pass.fragment" {
  47491. /** @hidden */
  47492. export var passPixelShader: {
  47493. name: string;
  47494. shader: string;
  47495. };
  47496. }
  47497. declare module "babylonjs/Shaders/passCube.fragment" {
  47498. /** @hidden */
  47499. export var passCubePixelShader: {
  47500. name: string;
  47501. shader: string;
  47502. };
  47503. }
  47504. declare module "babylonjs/PostProcesses/passPostProcess" {
  47505. import { Nullable } from "babylonjs/types";
  47506. import { Camera } from "babylonjs/Cameras/camera";
  47507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47508. import { Engine } from "babylonjs/Engines/engine";
  47509. import "babylonjs/Shaders/pass.fragment";
  47510. import "babylonjs/Shaders/passCube.fragment";
  47511. /**
  47512. * PassPostProcess which produces an output the same as it's input
  47513. */
  47514. export class PassPostProcess extends PostProcess {
  47515. /**
  47516. * Creates the PassPostProcess
  47517. * @param name The name of the effect.
  47518. * @param options The required width/height ratio to downsize to before computing the render pass.
  47519. * @param camera The camera to apply the render pass to.
  47520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47521. * @param engine The engine which the post process will be applied. (default: current engine)
  47522. * @param reusable If the post process can be reused on the same frame. (default: false)
  47523. * @param textureType The type of texture to be used when performing the post processing.
  47524. * @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)
  47525. */
  47526. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47527. }
  47528. /**
  47529. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47530. */
  47531. export class PassCubePostProcess extends PostProcess {
  47532. private _face;
  47533. /**
  47534. * Gets or sets the cube face to display.
  47535. * * 0 is +X
  47536. * * 1 is -X
  47537. * * 2 is +Y
  47538. * * 3 is -Y
  47539. * * 4 is +Z
  47540. * * 5 is -Z
  47541. */
  47542. get face(): number;
  47543. set face(value: number);
  47544. /**
  47545. * Creates the PassCubePostProcess
  47546. * @param name The name of the effect.
  47547. * @param options The required width/height ratio to downsize to before computing the render pass.
  47548. * @param camera The camera to apply the render pass to.
  47549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47550. * @param engine The engine which the post process will be applied. (default: current engine)
  47551. * @param reusable If the post process can be reused on the same frame. (default: false)
  47552. * @param textureType The type of texture to be used when performing the post processing.
  47553. * @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)
  47554. */
  47555. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47556. }
  47557. }
  47558. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47559. /** @hidden */
  47560. export var anaglyphPixelShader: {
  47561. name: string;
  47562. shader: string;
  47563. };
  47564. }
  47565. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47566. import { Engine } from "babylonjs/Engines/engine";
  47567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47568. import { Camera } from "babylonjs/Cameras/camera";
  47569. import "babylonjs/Shaders/anaglyph.fragment";
  47570. /**
  47571. * Postprocess used to generate anaglyphic rendering
  47572. */
  47573. export class AnaglyphPostProcess extends PostProcess {
  47574. private _passedProcess;
  47575. /**
  47576. * Creates a new AnaglyphPostProcess
  47577. * @param name defines postprocess name
  47578. * @param options defines creation options or target ratio scale
  47579. * @param rigCameras defines cameras using this postprocess
  47580. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47581. * @param engine defines hosting engine
  47582. * @param reusable defines if the postprocess will be reused multiple times per frame
  47583. */
  47584. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47585. }
  47586. }
  47587. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47588. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47589. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47590. import { Scene } from "babylonjs/scene";
  47591. import { Vector3 } from "babylonjs/Maths/math.vector";
  47592. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47593. /**
  47594. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47595. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47596. */
  47597. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47598. /**
  47599. * Creates a new AnaglyphArcRotateCamera
  47600. * @param name defines camera name
  47601. * @param alpha defines alpha angle (in radians)
  47602. * @param beta defines beta angle (in radians)
  47603. * @param radius defines radius
  47604. * @param target defines camera target
  47605. * @param interaxialDistance defines distance between each color axis
  47606. * @param scene defines the hosting scene
  47607. */
  47608. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47609. /**
  47610. * Gets camera class name
  47611. * @returns AnaglyphArcRotateCamera
  47612. */
  47613. getClassName(): string;
  47614. }
  47615. }
  47616. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47617. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47618. import { Scene } from "babylonjs/scene";
  47619. import { Vector3 } from "babylonjs/Maths/math.vector";
  47620. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47621. /**
  47622. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47623. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47624. */
  47625. export class AnaglyphFreeCamera extends FreeCamera {
  47626. /**
  47627. * Creates a new AnaglyphFreeCamera
  47628. * @param name defines camera name
  47629. * @param position defines initial position
  47630. * @param interaxialDistance defines distance between each color axis
  47631. * @param scene defines the hosting scene
  47632. */
  47633. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47634. /**
  47635. * Gets camera class name
  47636. * @returns AnaglyphFreeCamera
  47637. */
  47638. getClassName(): string;
  47639. }
  47640. }
  47641. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47642. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47643. import { Scene } from "babylonjs/scene";
  47644. import { Vector3 } from "babylonjs/Maths/math.vector";
  47645. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47646. /**
  47647. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47648. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47649. */
  47650. export class AnaglyphGamepadCamera extends GamepadCamera {
  47651. /**
  47652. * Creates a new AnaglyphGamepadCamera
  47653. * @param name defines camera name
  47654. * @param position defines initial position
  47655. * @param interaxialDistance defines distance between each color axis
  47656. * @param scene defines the hosting scene
  47657. */
  47658. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47659. /**
  47660. * Gets camera class name
  47661. * @returns AnaglyphGamepadCamera
  47662. */
  47663. getClassName(): string;
  47664. }
  47665. }
  47666. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47667. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47668. import { Scene } from "babylonjs/scene";
  47669. import { Vector3 } from "babylonjs/Maths/math.vector";
  47670. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47671. /**
  47672. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47673. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47674. */
  47675. export class AnaglyphUniversalCamera extends UniversalCamera {
  47676. /**
  47677. * Creates a new AnaglyphUniversalCamera
  47678. * @param name defines camera name
  47679. * @param position defines initial position
  47680. * @param interaxialDistance defines distance between each color axis
  47681. * @param scene defines the hosting scene
  47682. */
  47683. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47684. /**
  47685. * Gets camera class name
  47686. * @returns AnaglyphUniversalCamera
  47687. */
  47688. getClassName(): string;
  47689. }
  47690. }
  47691. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47692. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47693. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47694. import { Scene } from "babylonjs/scene";
  47695. import { Vector3 } from "babylonjs/Maths/math.vector";
  47696. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47697. /**
  47698. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47699. * @see https://doc.babylonjs.com/features/cameras
  47700. */
  47701. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47702. /**
  47703. * Creates a new StereoscopicArcRotateCamera
  47704. * @param name defines camera name
  47705. * @param alpha defines alpha angle (in radians)
  47706. * @param beta defines beta angle (in radians)
  47707. * @param radius defines radius
  47708. * @param target defines camera target
  47709. * @param interaxialDistance defines distance between each color axis
  47710. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47711. * @param scene defines the hosting scene
  47712. */
  47713. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47714. /**
  47715. * Gets camera class name
  47716. * @returns StereoscopicArcRotateCamera
  47717. */
  47718. getClassName(): string;
  47719. }
  47720. }
  47721. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47722. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47723. import { Scene } from "babylonjs/scene";
  47724. import { Vector3 } from "babylonjs/Maths/math.vector";
  47725. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47726. /**
  47727. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47728. * @see https://doc.babylonjs.com/features/cameras
  47729. */
  47730. export class StereoscopicFreeCamera extends FreeCamera {
  47731. /**
  47732. * Creates a new StereoscopicFreeCamera
  47733. * @param name defines camera name
  47734. * @param position defines initial position
  47735. * @param interaxialDistance defines distance between each color axis
  47736. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47737. * @param scene defines the hosting scene
  47738. */
  47739. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47740. /**
  47741. * Gets camera class name
  47742. * @returns StereoscopicFreeCamera
  47743. */
  47744. getClassName(): string;
  47745. }
  47746. }
  47747. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47748. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47749. import { Scene } from "babylonjs/scene";
  47750. import { Vector3 } from "babylonjs/Maths/math.vector";
  47751. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47752. /**
  47753. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47754. * @see https://doc.babylonjs.com/features/cameras
  47755. */
  47756. export class StereoscopicGamepadCamera extends GamepadCamera {
  47757. /**
  47758. * Creates a new StereoscopicGamepadCamera
  47759. * @param name defines camera name
  47760. * @param position defines initial position
  47761. * @param interaxialDistance defines distance between each color axis
  47762. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47763. * @param scene defines the hosting scene
  47764. */
  47765. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47766. /**
  47767. * Gets camera class name
  47768. * @returns StereoscopicGamepadCamera
  47769. */
  47770. getClassName(): string;
  47771. }
  47772. }
  47773. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47774. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47775. import { Scene } from "babylonjs/scene";
  47776. import { Vector3 } from "babylonjs/Maths/math.vector";
  47777. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47778. /**
  47779. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47780. * @see https://doc.babylonjs.com/features/cameras
  47781. */
  47782. export class StereoscopicUniversalCamera extends UniversalCamera {
  47783. /**
  47784. * Creates a new StereoscopicUniversalCamera
  47785. * @param name defines camera name
  47786. * @param position defines initial position
  47787. * @param interaxialDistance defines distance between each color axis
  47788. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47789. * @param scene defines the hosting scene
  47790. */
  47791. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47792. /**
  47793. * Gets camera class name
  47794. * @returns StereoscopicUniversalCamera
  47795. */
  47796. getClassName(): string;
  47797. }
  47798. }
  47799. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47800. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47801. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47802. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47803. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47804. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47805. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47806. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47807. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47808. }
  47809. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47810. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47811. import { Scene } from "babylonjs/scene";
  47812. import { Vector3 } from "babylonjs/Maths/math.vector";
  47813. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47814. /**
  47815. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47816. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47817. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47818. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47819. */
  47820. export class VirtualJoysticksCamera extends FreeCamera {
  47821. /**
  47822. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47823. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47824. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47825. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47826. * @param name Define the name of the camera in the scene
  47827. * @param position Define the start position of the camera in the scene
  47828. * @param scene Define the scene the camera belongs to
  47829. */
  47830. constructor(name: string, position: Vector3, scene: Scene);
  47831. /**
  47832. * Gets the current object class name.
  47833. * @return the class name
  47834. */
  47835. getClassName(): string;
  47836. }
  47837. }
  47838. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47839. import { Matrix } from "babylonjs/Maths/math.vector";
  47840. /**
  47841. * This represents all the required metrics to create a VR camera.
  47842. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47843. */
  47844. export class VRCameraMetrics {
  47845. /**
  47846. * Define the horizontal resolution off the screen.
  47847. */
  47848. hResolution: number;
  47849. /**
  47850. * Define the vertical resolution off the screen.
  47851. */
  47852. vResolution: number;
  47853. /**
  47854. * Define the horizontal screen size.
  47855. */
  47856. hScreenSize: number;
  47857. /**
  47858. * Define the vertical screen size.
  47859. */
  47860. vScreenSize: number;
  47861. /**
  47862. * Define the vertical screen center position.
  47863. */
  47864. vScreenCenter: number;
  47865. /**
  47866. * Define the distance of the eyes to the screen.
  47867. */
  47868. eyeToScreenDistance: number;
  47869. /**
  47870. * Define the distance between both lenses
  47871. */
  47872. lensSeparationDistance: number;
  47873. /**
  47874. * Define the distance between both viewer's eyes.
  47875. */
  47876. interpupillaryDistance: number;
  47877. /**
  47878. * Define the distortion factor of the VR postprocess.
  47879. * Please, touch with care.
  47880. */
  47881. distortionK: number[];
  47882. /**
  47883. * Define the chromatic aberration correction factors for the VR post process.
  47884. */
  47885. chromaAbCorrection: number[];
  47886. /**
  47887. * Define the scale factor of the post process.
  47888. * The smaller the better but the slower.
  47889. */
  47890. postProcessScaleFactor: number;
  47891. /**
  47892. * Define an offset for the lens center.
  47893. */
  47894. lensCenterOffset: number;
  47895. /**
  47896. * Define if the current vr camera should compensate the distortion of the lense or not.
  47897. */
  47898. compensateDistortion: boolean;
  47899. /**
  47900. * Defines if multiview should be enabled when rendering (Default: false)
  47901. */
  47902. multiviewEnabled: boolean;
  47903. /**
  47904. * Gets the rendering aspect ratio based on the provided resolutions.
  47905. */
  47906. get aspectRatio(): number;
  47907. /**
  47908. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47909. */
  47910. get aspectRatioFov(): number;
  47911. /**
  47912. * @hidden
  47913. */
  47914. get leftHMatrix(): Matrix;
  47915. /**
  47916. * @hidden
  47917. */
  47918. get rightHMatrix(): Matrix;
  47919. /**
  47920. * @hidden
  47921. */
  47922. get leftPreViewMatrix(): Matrix;
  47923. /**
  47924. * @hidden
  47925. */
  47926. get rightPreViewMatrix(): Matrix;
  47927. /**
  47928. * Get the default VRMetrics based on the most generic setup.
  47929. * @returns the default vr metrics
  47930. */
  47931. static GetDefault(): VRCameraMetrics;
  47932. }
  47933. }
  47934. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47935. /** @hidden */
  47936. export var vrDistortionCorrectionPixelShader: {
  47937. name: string;
  47938. shader: string;
  47939. };
  47940. }
  47941. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47942. import { Camera } from "babylonjs/Cameras/camera";
  47943. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47944. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47945. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47946. /**
  47947. * VRDistortionCorrectionPostProcess used for mobile VR
  47948. */
  47949. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47950. private _isRightEye;
  47951. private _distortionFactors;
  47952. private _postProcessScaleFactor;
  47953. private _lensCenterOffset;
  47954. private _scaleIn;
  47955. private _scaleFactor;
  47956. private _lensCenter;
  47957. /**
  47958. * Initializes the VRDistortionCorrectionPostProcess
  47959. * @param name The name of the effect.
  47960. * @param camera The camera to apply the render pass to.
  47961. * @param isRightEye If this is for the right eye distortion
  47962. * @param vrMetrics All the required metrics for the VR camera
  47963. */
  47964. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47965. }
  47966. }
  47967. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47968. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47969. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47970. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47971. import { Scene } from "babylonjs/scene";
  47972. import { Vector3 } from "babylonjs/Maths/math.vector";
  47973. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47974. import "babylonjs/Cameras/RigModes/vrRigMode";
  47975. /**
  47976. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47977. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47978. */
  47979. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47980. /**
  47981. * Creates a new VRDeviceOrientationArcRotateCamera
  47982. * @param name defines camera name
  47983. * @param alpha defines the camera rotation along the logitudinal axis
  47984. * @param beta defines the camera rotation along the latitudinal axis
  47985. * @param radius defines the camera distance from its target
  47986. * @param target defines the camera target
  47987. * @param scene defines the scene the camera belongs to
  47988. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47989. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47990. */
  47991. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47992. /**
  47993. * Gets camera class name
  47994. * @returns VRDeviceOrientationArcRotateCamera
  47995. */
  47996. getClassName(): string;
  47997. }
  47998. }
  47999. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48000. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48001. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48002. import { Scene } from "babylonjs/scene";
  48003. import { Vector3 } from "babylonjs/Maths/math.vector";
  48004. import "babylonjs/Cameras/RigModes/vrRigMode";
  48005. /**
  48006. * Camera used to simulate VR rendering (based on FreeCamera)
  48007. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48008. */
  48009. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48010. /**
  48011. * Creates a new VRDeviceOrientationFreeCamera
  48012. * @param name defines camera name
  48013. * @param position defines the start position of the camera
  48014. * @param scene defines the scene the camera belongs to
  48015. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48016. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48017. */
  48018. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48019. /**
  48020. * Gets camera class name
  48021. * @returns VRDeviceOrientationFreeCamera
  48022. */
  48023. getClassName(): string;
  48024. }
  48025. }
  48026. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48027. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48028. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48029. import { Scene } from "babylonjs/scene";
  48030. import { Vector3 } from "babylonjs/Maths/math.vector";
  48031. import "babylonjs/Gamepads/gamepadSceneComponent";
  48032. /**
  48033. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48034. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48035. */
  48036. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48037. /**
  48038. * Creates a new VRDeviceOrientationGamepadCamera
  48039. * @param name defines camera name
  48040. * @param position defines the start position of the camera
  48041. * @param scene defines the scene the camera belongs to
  48042. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48043. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48044. */
  48045. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48046. /**
  48047. * Gets camera class name
  48048. * @returns VRDeviceOrientationGamepadCamera
  48049. */
  48050. getClassName(): string;
  48051. }
  48052. }
  48053. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48054. import { Scene } from "babylonjs/scene";
  48055. import { Texture } from "babylonjs/Materials/Textures/texture";
  48056. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48057. /**
  48058. * A class extending Texture allowing drawing on a texture
  48059. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48060. */
  48061. export class DynamicTexture extends Texture {
  48062. private _generateMipMaps;
  48063. private _canvas;
  48064. private _context;
  48065. /**
  48066. * Creates a DynamicTexture
  48067. * @param name defines the name of the texture
  48068. * @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
  48069. * @param scene defines the scene where you want the texture
  48070. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48071. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48072. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48073. */
  48074. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48075. /**
  48076. * Get the current class name of the texture useful for serialization or dynamic coding.
  48077. * @returns "DynamicTexture"
  48078. */
  48079. getClassName(): string;
  48080. /**
  48081. * Gets the current state of canRescale
  48082. */
  48083. get canRescale(): boolean;
  48084. private _recreate;
  48085. /**
  48086. * Scales the texture
  48087. * @param ratio the scale factor to apply to both width and height
  48088. */
  48089. scale(ratio: number): void;
  48090. /**
  48091. * Resizes the texture
  48092. * @param width the new width
  48093. * @param height the new height
  48094. */
  48095. scaleTo(width: number, height: number): void;
  48096. /**
  48097. * Gets the context of the canvas used by the texture
  48098. * @returns the canvas context of the dynamic texture
  48099. */
  48100. getContext(): CanvasRenderingContext2D;
  48101. /**
  48102. * Clears the texture
  48103. */
  48104. clear(): void;
  48105. /**
  48106. * Updates the texture
  48107. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48108. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48109. */
  48110. update(invertY?: boolean, premulAlpha?: boolean): void;
  48111. /**
  48112. * Draws text onto the texture
  48113. * @param text defines the text to be drawn
  48114. * @param x defines the placement of the text from the left
  48115. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48116. * @param font defines the font to be used with font-style, font-size, font-name
  48117. * @param color defines the color used for the text
  48118. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48119. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48120. * @param update defines whether texture is immediately update (default is true)
  48121. */
  48122. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48123. /**
  48124. * Clones the texture
  48125. * @returns the clone of the texture.
  48126. */
  48127. clone(): DynamicTexture;
  48128. /**
  48129. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48130. * @returns a serialized dynamic texture object
  48131. */
  48132. serialize(): any;
  48133. private _IsCanvasElement;
  48134. /** @hidden */
  48135. _rebuild(): void;
  48136. }
  48137. }
  48138. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48139. import { Scene } from "babylonjs/scene";
  48140. import { Color3 } from "babylonjs/Maths/math.color";
  48141. import { Mesh } from "babylonjs/Meshes/mesh";
  48142. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48143. import { Nullable } from "babylonjs/types";
  48144. /**
  48145. * Class containing static functions to help procedurally build meshes
  48146. */
  48147. export class GroundBuilder {
  48148. /**
  48149. * Creates a ground mesh
  48150. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48151. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48153. * @param name defines the name of the mesh
  48154. * @param options defines the options used to create the mesh
  48155. * @param scene defines the hosting scene
  48156. * @returns the ground mesh
  48157. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48158. */
  48159. static CreateGround(name: string, options: {
  48160. width?: number;
  48161. height?: number;
  48162. subdivisions?: number;
  48163. subdivisionsX?: number;
  48164. subdivisionsY?: number;
  48165. updatable?: boolean;
  48166. }, scene: any): Mesh;
  48167. /**
  48168. * Creates a tiled ground mesh
  48169. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48170. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48171. * * 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
  48172. * * 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
  48173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48174. * @param name defines the name of the mesh
  48175. * @param options defines the options used to create the mesh
  48176. * @param scene defines the hosting scene
  48177. * @returns the tiled ground mesh
  48178. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48179. */
  48180. static CreateTiledGround(name: string, options: {
  48181. xmin: number;
  48182. zmin: number;
  48183. xmax: number;
  48184. zmax: number;
  48185. subdivisions?: {
  48186. w: number;
  48187. h: number;
  48188. };
  48189. precision?: {
  48190. w: number;
  48191. h: number;
  48192. };
  48193. updatable?: boolean;
  48194. }, scene?: Nullable<Scene>): Mesh;
  48195. /**
  48196. * Creates a ground mesh from a height map
  48197. * * The parameter `url` sets the URL of the height map image resource.
  48198. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48199. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48200. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48201. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48202. * * 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.
  48203. * * 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).
  48204. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48206. * @param name defines the name of the mesh
  48207. * @param url defines the url to the height map
  48208. * @param options defines the options used to create the mesh
  48209. * @param scene defines the hosting scene
  48210. * @returns the ground mesh
  48211. * @see https://doc.babylonjs.com/babylon101/height_map
  48212. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48213. */
  48214. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48215. width?: number;
  48216. height?: number;
  48217. subdivisions?: number;
  48218. minHeight?: number;
  48219. maxHeight?: number;
  48220. colorFilter?: Color3;
  48221. alphaFilter?: number;
  48222. updatable?: boolean;
  48223. onReady?: (mesh: GroundMesh) => void;
  48224. }, scene?: Nullable<Scene>): GroundMesh;
  48225. }
  48226. }
  48227. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48228. import { Vector4 } from "babylonjs/Maths/math.vector";
  48229. import { Mesh } from "babylonjs/Meshes/mesh";
  48230. /**
  48231. * Class containing static functions to help procedurally build meshes
  48232. */
  48233. export class TorusBuilder {
  48234. /**
  48235. * Creates a torus mesh
  48236. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48237. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48238. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48242. * @param name defines the name of the mesh
  48243. * @param options defines the options used to create the mesh
  48244. * @param scene defines the hosting scene
  48245. * @returns the torus mesh
  48246. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48247. */
  48248. static CreateTorus(name: string, options: {
  48249. diameter?: number;
  48250. thickness?: number;
  48251. tessellation?: number;
  48252. updatable?: boolean;
  48253. sideOrientation?: number;
  48254. frontUVs?: Vector4;
  48255. backUVs?: Vector4;
  48256. }, scene: any): Mesh;
  48257. }
  48258. }
  48259. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48260. import { Vector4 } from "babylonjs/Maths/math.vector";
  48261. import { Color4 } from "babylonjs/Maths/math.color";
  48262. import { Mesh } from "babylonjs/Meshes/mesh";
  48263. /**
  48264. * Class containing static functions to help procedurally build meshes
  48265. */
  48266. export class CylinderBuilder {
  48267. /**
  48268. * Creates a cylinder or a cone mesh
  48269. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48270. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48271. * * 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.
  48272. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48273. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48274. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48275. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48276. * * 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).
  48277. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48278. * * 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).
  48279. * * 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
  48280. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48281. * * 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
  48282. * * 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.
  48283. * * If `enclose` is false, a ring surface is one element.
  48284. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48285. * * 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
  48286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48289. * @param name defines the name of the mesh
  48290. * @param options defines the options used to create the mesh
  48291. * @param scene defines the hosting scene
  48292. * @returns the cylinder mesh
  48293. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48294. */
  48295. static CreateCylinder(name: string, options: {
  48296. height?: number;
  48297. diameterTop?: number;
  48298. diameterBottom?: number;
  48299. diameter?: number;
  48300. tessellation?: number;
  48301. subdivisions?: number;
  48302. arc?: number;
  48303. faceColors?: Color4[];
  48304. faceUV?: Vector4[];
  48305. updatable?: boolean;
  48306. hasRings?: boolean;
  48307. enclose?: boolean;
  48308. cap?: number;
  48309. sideOrientation?: number;
  48310. frontUVs?: Vector4;
  48311. backUVs?: Vector4;
  48312. }, scene: any): Mesh;
  48313. }
  48314. }
  48315. declare module "babylonjs/XR/webXRTypes" {
  48316. import { Nullable } from "babylonjs/types";
  48317. import { IDisposable } from "babylonjs/scene";
  48318. /**
  48319. * States of the webXR experience
  48320. */
  48321. export enum WebXRState {
  48322. /**
  48323. * Transitioning to being in XR mode
  48324. */
  48325. ENTERING_XR = 0,
  48326. /**
  48327. * Transitioning to non XR mode
  48328. */
  48329. EXITING_XR = 1,
  48330. /**
  48331. * In XR mode and presenting
  48332. */
  48333. IN_XR = 2,
  48334. /**
  48335. * Not entered XR mode
  48336. */
  48337. NOT_IN_XR = 3
  48338. }
  48339. /**
  48340. * Abstraction of the XR render target
  48341. */
  48342. export interface WebXRRenderTarget extends IDisposable {
  48343. /**
  48344. * xrpresent context of the canvas which can be used to display/mirror xr content
  48345. */
  48346. canvasContext: WebGLRenderingContext;
  48347. /**
  48348. * xr layer for the canvas
  48349. */
  48350. xrLayer: Nullable<XRWebGLLayer>;
  48351. /**
  48352. * Initializes the xr layer for the session
  48353. * @param xrSession xr session
  48354. * @returns a promise that will resolve once the XR Layer has been created
  48355. */
  48356. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48357. }
  48358. }
  48359. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48360. import { Nullable } from "babylonjs/types";
  48361. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48362. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48363. import { Observable } from "babylonjs/Misc/observable";
  48364. /**
  48365. * COnfiguration object for WebXR output canvas
  48366. */
  48367. export class WebXRManagedOutputCanvasOptions {
  48368. /**
  48369. * An optional canvas in case you wish to create it yourself and provide it here.
  48370. * If not provided, a new canvas will be created
  48371. */
  48372. canvasElement?: HTMLCanvasElement;
  48373. /**
  48374. * Options for this XR Layer output
  48375. */
  48376. canvasOptions?: XRWebGLLayerOptions;
  48377. /**
  48378. * CSS styling for a newly created canvas (if not provided)
  48379. */
  48380. newCanvasCssStyle?: string;
  48381. /**
  48382. * Get the default values of the configuration object
  48383. * @returns default values of this configuration object
  48384. */
  48385. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48386. }
  48387. /**
  48388. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48389. */
  48390. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48391. private _options;
  48392. private _canvas;
  48393. private _engine;
  48394. private _originalCanvasSize;
  48395. /**
  48396. * Rendering context of the canvas which can be used to display/mirror xr content
  48397. */
  48398. canvasContext: WebGLRenderingContext;
  48399. /**
  48400. * xr layer for the canvas
  48401. */
  48402. xrLayer: Nullable<XRWebGLLayer>;
  48403. /**
  48404. * Obseervers registered here will be triggered when the xr layer was initialized
  48405. */
  48406. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48407. /**
  48408. * Initializes the canvas to be added/removed upon entering/exiting xr
  48409. * @param _xrSessionManager The XR Session manager
  48410. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48411. */
  48412. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48413. /**
  48414. * Disposes of the object
  48415. */
  48416. dispose(): void;
  48417. /**
  48418. * Initializes the xr layer for the session
  48419. * @param xrSession xr session
  48420. * @returns a promise that will resolve once the XR Layer has been created
  48421. */
  48422. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48423. private _addCanvas;
  48424. private _removeCanvas;
  48425. private _setCanvasSize;
  48426. private _setManagedOutputCanvas;
  48427. }
  48428. }
  48429. declare module "babylonjs/XR/webXRSessionManager" {
  48430. import { Observable } from "babylonjs/Misc/observable";
  48431. import { Nullable } from "babylonjs/types";
  48432. import { IDisposable, Scene } from "babylonjs/scene";
  48433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48434. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48435. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48436. /**
  48437. * Manages an XRSession to work with Babylon's engine
  48438. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48439. */
  48440. export class WebXRSessionManager implements IDisposable {
  48441. /** The scene which the session should be created for */
  48442. scene: Scene;
  48443. private _referenceSpace;
  48444. private _rttProvider;
  48445. private _sessionEnded;
  48446. private _xrNavigator;
  48447. private baseLayer;
  48448. /**
  48449. * The base reference space from which the session started. good if you want to reset your
  48450. * reference space
  48451. */
  48452. baseReferenceSpace: XRReferenceSpace;
  48453. /**
  48454. * Current XR frame
  48455. */
  48456. currentFrame: Nullable<XRFrame>;
  48457. /** WebXR timestamp updated every frame */
  48458. currentTimestamp: number;
  48459. /**
  48460. * Used just in case of a failure to initialize an immersive session.
  48461. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48462. */
  48463. defaultHeightCompensation: number;
  48464. /**
  48465. * Fires every time a new xrFrame arrives which can be used to update the camera
  48466. */
  48467. onXRFrameObservable: Observable<XRFrame>;
  48468. /**
  48469. * Fires when the reference space changed
  48470. */
  48471. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48472. /**
  48473. * Fires when the xr session is ended either by the device or manually done
  48474. */
  48475. onXRSessionEnded: Observable<any>;
  48476. /**
  48477. * Fires when the xr session is ended either by the device or manually done
  48478. */
  48479. onXRSessionInit: Observable<XRSession>;
  48480. /**
  48481. * Underlying xr session
  48482. */
  48483. session: XRSession;
  48484. /**
  48485. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48486. * or get the offset the player is currently at.
  48487. */
  48488. viewerReferenceSpace: XRReferenceSpace;
  48489. /**
  48490. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48491. * @param scene The scene which the session should be created for
  48492. */
  48493. constructor(
  48494. /** The scene which the session should be created for */
  48495. scene: Scene);
  48496. /**
  48497. * The current reference space used in this session. This reference space can constantly change!
  48498. * It is mainly used to offset the camera's position.
  48499. */
  48500. get referenceSpace(): XRReferenceSpace;
  48501. /**
  48502. * Set a new reference space and triggers the observable
  48503. */
  48504. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48505. /**
  48506. * Disposes of the session manager
  48507. */
  48508. dispose(): void;
  48509. /**
  48510. * Stops the xrSession and restores the render loop
  48511. * @returns Promise which resolves after it exits XR
  48512. */
  48513. exitXRAsync(): Promise<void>;
  48514. /**
  48515. * Gets the correct render target texture to be rendered this frame for this eye
  48516. * @param eye the eye for which to get the render target
  48517. * @returns the render target for the specified eye
  48518. */
  48519. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48520. /**
  48521. * Creates a WebXRRenderTarget object for the XR session
  48522. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48523. * @param options optional options to provide when creating a new render target
  48524. * @returns a WebXR render target to which the session can render
  48525. */
  48526. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48527. /**
  48528. * Initializes the manager
  48529. * After initialization enterXR can be called to start an XR session
  48530. * @returns Promise which resolves after it is initialized
  48531. */
  48532. initializeAsync(): Promise<void>;
  48533. /**
  48534. * Initializes an xr session
  48535. * @param xrSessionMode mode to initialize
  48536. * @param xrSessionInit defines optional and required values to pass to the session builder
  48537. * @returns a promise which will resolve once the session has been initialized
  48538. */
  48539. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48540. /**
  48541. * Checks if a session would be supported for the creation options specified
  48542. * @param sessionMode session mode to check if supported eg. immersive-vr
  48543. * @returns A Promise that resolves to true if supported and false if not
  48544. */
  48545. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48546. /**
  48547. * Resets the reference space to the one started the session
  48548. */
  48549. resetReferenceSpace(): void;
  48550. /**
  48551. * Starts rendering to the xr layer
  48552. */
  48553. runXRRenderLoop(): void;
  48554. /**
  48555. * Sets the reference space on the xr session
  48556. * @param referenceSpaceType space to set
  48557. * @returns a promise that will resolve once the reference space has been set
  48558. */
  48559. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48560. /**
  48561. * Updates the render state of the session
  48562. * @param state state to set
  48563. * @returns a promise that resolves once the render state has been updated
  48564. */
  48565. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48566. /**
  48567. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48568. * @param sessionMode defines the session to test
  48569. * @returns a promise with boolean as final value
  48570. */
  48571. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48572. private _createRenderTargetTexture;
  48573. }
  48574. }
  48575. declare module "babylonjs/XR/webXRCamera" {
  48576. import { Scene } from "babylonjs/scene";
  48577. import { Camera } from "babylonjs/Cameras/camera";
  48578. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48579. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48580. /**
  48581. * WebXR Camera which holds the views for the xrSession
  48582. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48583. */
  48584. export class WebXRCamera extends FreeCamera {
  48585. private _xrSessionManager;
  48586. private _firstFrame;
  48587. private _referenceQuaternion;
  48588. private _referencedPosition;
  48589. private _xrInvPositionCache;
  48590. private _xrInvQuaternionCache;
  48591. /**
  48592. * Should position compensation execute on first frame.
  48593. * This is used when copying the position from a native (non XR) camera
  48594. */
  48595. compensateOnFirstFrame: boolean;
  48596. /**
  48597. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48598. * @param name the name of the camera
  48599. * @param scene the scene to add the camera to
  48600. * @param _xrSessionManager a constructed xr session manager
  48601. */
  48602. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48603. /**
  48604. * Return the user's height, unrelated to the current ground.
  48605. * This will be the y position of this camera, when ground level is 0.
  48606. */
  48607. get realWorldHeight(): number;
  48608. /** @hidden */
  48609. _updateForDualEyeDebugging(): void;
  48610. /**
  48611. * Sets this camera's transformation based on a non-vr camera
  48612. * @param otherCamera the non-vr camera to copy the transformation from
  48613. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48614. */
  48615. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48616. /**
  48617. * Gets the current instance class name ("WebXRCamera").
  48618. * @returns the class name
  48619. */
  48620. getClassName(): string;
  48621. private _rotate180;
  48622. private _updateFromXRSession;
  48623. private _updateNumberOfRigCameras;
  48624. private _updateReferenceSpace;
  48625. private _updateReferenceSpaceOffset;
  48626. }
  48627. }
  48628. declare module "babylonjs/XR/webXRFeaturesManager" {
  48629. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48630. import { IDisposable } from "babylonjs/scene";
  48631. /**
  48632. * Defining the interface required for a (webxr) feature
  48633. */
  48634. export interface IWebXRFeature extends IDisposable {
  48635. /**
  48636. * Is this feature attached
  48637. */
  48638. attached: boolean;
  48639. /**
  48640. * Should auto-attach be disabled?
  48641. */
  48642. disableAutoAttach: boolean;
  48643. /**
  48644. * Attach the feature to the session
  48645. * Will usually be called by the features manager
  48646. *
  48647. * @param force should attachment be forced (even when already attached)
  48648. * @returns true if successful.
  48649. */
  48650. attach(force?: boolean): boolean;
  48651. /**
  48652. * Detach the feature from the session
  48653. * Will usually be called by the features manager
  48654. *
  48655. * @returns true if successful.
  48656. */
  48657. detach(): boolean;
  48658. /**
  48659. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48660. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48661. *
  48662. * @returns whether or not the feature is compatible in this environment
  48663. */
  48664. isCompatible(): boolean;
  48665. /**
  48666. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48667. */
  48668. xrNativeFeatureName?: string;
  48669. }
  48670. /**
  48671. * A list of the currently available features without referencing them
  48672. */
  48673. export class WebXRFeatureName {
  48674. /**
  48675. * The name of the anchor system feature
  48676. */
  48677. static ANCHOR_SYSTEM: string;
  48678. /**
  48679. * The name of the background remover feature
  48680. */
  48681. static BACKGROUND_REMOVER: string;
  48682. /**
  48683. * The name of the hit test feature
  48684. */
  48685. static HIT_TEST: string;
  48686. /**
  48687. * physics impostors for xr controllers feature
  48688. */
  48689. static PHYSICS_CONTROLLERS: string;
  48690. /**
  48691. * The name of the plane detection feature
  48692. */
  48693. static PLANE_DETECTION: string;
  48694. /**
  48695. * The name of the pointer selection feature
  48696. */
  48697. static POINTER_SELECTION: string;
  48698. /**
  48699. * The name of the teleportation feature
  48700. */
  48701. static TELEPORTATION: string;
  48702. }
  48703. /**
  48704. * Defining the constructor of a feature. Used to register the modules.
  48705. */
  48706. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48707. /**
  48708. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48709. * It is mainly used in AR sessions.
  48710. *
  48711. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48712. */
  48713. export class WebXRFeaturesManager implements IDisposable {
  48714. private _xrSessionManager;
  48715. private static readonly _AvailableFeatures;
  48716. private _features;
  48717. /**
  48718. * constructs a new features manages.
  48719. *
  48720. * @param _xrSessionManager an instance of WebXRSessionManager
  48721. */
  48722. constructor(_xrSessionManager: WebXRSessionManager);
  48723. /**
  48724. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48725. * Mainly used internally.
  48726. *
  48727. * @param featureName the name of the feature to register
  48728. * @param constructorFunction the function used to construct the module
  48729. * @param version the (babylon) version of the module
  48730. * @param stable is that a stable version of this module
  48731. */
  48732. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48733. /**
  48734. * Returns a constructor of a specific feature.
  48735. *
  48736. * @param featureName the name of the feature to construct
  48737. * @param version the version of the feature to load
  48738. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48739. * @param options optional options provided to the module.
  48740. * @returns a function that, when called, will return a new instance of this feature
  48741. */
  48742. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48743. /**
  48744. * Can be used to return the list of features currently registered
  48745. *
  48746. * @returns an Array of available features
  48747. */
  48748. static GetAvailableFeatures(): string[];
  48749. /**
  48750. * Gets the versions available for a specific feature
  48751. * @param featureName the name of the feature
  48752. * @returns an array with the available versions
  48753. */
  48754. static GetAvailableVersions(featureName: string): string[];
  48755. /**
  48756. * Return the latest unstable version of this feature
  48757. * @param featureName the name of the feature to search
  48758. * @returns the version number. if not found will return -1
  48759. */
  48760. static GetLatestVersionOfFeature(featureName: string): number;
  48761. /**
  48762. * Return the latest stable version of this feature
  48763. * @param featureName the name of the feature to search
  48764. * @returns the version number. if not found will return -1
  48765. */
  48766. static GetStableVersionOfFeature(featureName: string): number;
  48767. /**
  48768. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48769. * Can be used during a session to start a feature
  48770. * @param featureName the name of feature to attach
  48771. */
  48772. attachFeature(featureName: string): void;
  48773. /**
  48774. * Can be used inside a session or when the session ends to detach a specific feature
  48775. * @param featureName the name of the feature to detach
  48776. */
  48777. detachFeature(featureName: string): void;
  48778. /**
  48779. * Used to disable an already-enabled feature
  48780. * The feature will be disposed and will be recreated once enabled.
  48781. * @param featureName the feature to disable
  48782. * @returns true if disable was successful
  48783. */
  48784. disableFeature(featureName: string | {
  48785. Name: string;
  48786. }): boolean;
  48787. /**
  48788. * dispose this features manager
  48789. */
  48790. dispose(): void;
  48791. /**
  48792. * 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.
  48793. * 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.
  48794. *
  48795. * @param featureName the name of the feature to load or the class of the feature
  48796. * @param version optional version to load. if not provided the latest version will be enabled
  48797. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48798. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48799. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48800. * @returns a new constructed feature or throws an error if feature not found.
  48801. */
  48802. enableFeature(featureName: string | {
  48803. Name: string;
  48804. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48805. /**
  48806. * get the implementation of an enabled feature.
  48807. * @param featureName the name of the feature to load
  48808. * @returns the feature class, if found
  48809. */
  48810. getEnabledFeature(featureName: string): IWebXRFeature;
  48811. /**
  48812. * Get the list of enabled features
  48813. * @returns an array of enabled features
  48814. */
  48815. getEnabledFeatures(): string[];
  48816. /**
  48817. * This function will exten the session creation configuration object with enabled features.
  48818. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48819. * according to the defined "required" variable, provided during enableFeature call
  48820. * @param xrSessionInit the xr Session init object to extend
  48821. *
  48822. * @returns an extended XRSessionInit object
  48823. */
  48824. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48825. }
  48826. }
  48827. declare module "babylonjs/XR/webXRExperienceHelper" {
  48828. import { Observable } from "babylonjs/Misc/observable";
  48829. import { IDisposable, Scene } from "babylonjs/scene";
  48830. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48831. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48832. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48833. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48834. /**
  48835. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48836. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48837. */
  48838. export class WebXRExperienceHelper implements IDisposable {
  48839. private scene;
  48840. private _nonVRCamera;
  48841. private _originalSceneAutoClear;
  48842. private _supported;
  48843. /**
  48844. * Camera used to render xr content
  48845. */
  48846. camera: WebXRCamera;
  48847. /** A features manager for this xr session */
  48848. featuresManager: WebXRFeaturesManager;
  48849. /**
  48850. * Observers registered here will be triggered after the camera's initial transformation is set
  48851. * This can be used to set a different ground level or an extra rotation.
  48852. *
  48853. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48854. * to the position set after this observable is done executing.
  48855. */
  48856. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48857. /**
  48858. * Fires when the state of the experience helper has changed
  48859. */
  48860. onStateChangedObservable: Observable<WebXRState>;
  48861. /** Session manager used to keep track of xr session */
  48862. sessionManager: WebXRSessionManager;
  48863. /**
  48864. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48865. */
  48866. state: WebXRState;
  48867. /**
  48868. * Creates a WebXRExperienceHelper
  48869. * @param scene The scene the helper should be created in
  48870. */
  48871. private constructor();
  48872. /**
  48873. * Creates the experience helper
  48874. * @param scene the scene to attach the experience helper to
  48875. * @returns a promise for the experience helper
  48876. */
  48877. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48878. /**
  48879. * Disposes of the experience helper
  48880. */
  48881. dispose(): void;
  48882. /**
  48883. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48884. * @param sessionMode options for the XR session
  48885. * @param referenceSpaceType frame of reference of the XR session
  48886. * @param renderTarget the output canvas that will be used to enter XR mode
  48887. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48888. * @returns promise that resolves after xr mode has entered
  48889. */
  48890. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48891. /**
  48892. * Exits XR mode and returns the scene to its original state
  48893. * @returns promise that resolves after xr mode has exited
  48894. */
  48895. exitXRAsync(): Promise<void>;
  48896. private _nonXRToXRCamera;
  48897. private _setState;
  48898. }
  48899. }
  48900. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48901. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48902. import { Observable } from "babylonjs/Misc/observable";
  48903. import { IDisposable } from "babylonjs/scene";
  48904. /**
  48905. * X-Y values for axes in WebXR
  48906. */
  48907. export interface IWebXRMotionControllerAxesValue {
  48908. /**
  48909. * The value of the x axis
  48910. */
  48911. x: number;
  48912. /**
  48913. * The value of the y-axis
  48914. */
  48915. y: number;
  48916. }
  48917. /**
  48918. * changed / previous values for the values of this component
  48919. */
  48920. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48921. /**
  48922. * current (this frame) value
  48923. */
  48924. current: T;
  48925. /**
  48926. * previous (last change) value
  48927. */
  48928. previous: T;
  48929. }
  48930. /**
  48931. * Represents changes in the component between current frame and last values recorded
  48932. */
  48933. export interface IWebXRMotionControllerComponentChanges {
  48934. /**
  48935. * will be populated with previous and current values if axes changed
  48936. */
  48937. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48938. /**
  48939. * will be populated with previous and current values if pressed changed
  48940. */
  48941. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48942. /**
  48943. * will be populated with previous and current values if touched changed
  48944. */
  48945. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48946. /**
  48947. * will be populated with previous and current values if value changed
  48948. */
  48949. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48950. }
  48951. /**
  48952. * This class represents a single component (for example button or thumbstick) of a motion controller
  48953. */
  48954. export class WebXRControllerComponent implements IDisposable {
  48955. /**
  48956. * the id of this component
  48957. */
  48958. id: string;
  48959. /**
  48960. * the type of the component
  48961. */
  48962. type: MotionControllerComponentType;
  48963. private _buttonIndex;
  48964. private _axesIndices;
  48965. private _axes;
  48966. private _changes;
  48967. private _currentValue;
  48968. private _hasChanges;
  48969. private _pressed;
  48970. private _touched;
  48971. /**
  48972. * button component type
  48973. */
  48974. static BUTTON_TYPE: MotionControllerComponentType;
  48975. /**
  48976. * squeeze component type
  48977. */
  48978. static SQUEEZE_TYPE: MotionControllerComponentType;
  48979. /**
  48980. * Thumbstick component type
  48981. */
  48982. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48983. /**
  48984. * Touchpad component type
  48985. */
  48986. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48987. /**
  48988. * trigger component type
  48989. */
  48990. static TRIGGER_TYPE: MotionControllerComponentType;
  48991. /**
  48992. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48993. * the axes data changes
  48994. */
  48995. onAxisValueChangedObservable: Observable<{
  48996. x: number;
  48997. y: number;
  48998. }>;
  48999. /**
  49000. * Observers registered here will be triggered when the state of a button changes
  49001. * State change is either pressed / touched / value
  49002. */
  49003. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49004. /**
  49005. * Creates a new component for a motion controller.
  49006. * It is created by the motion controller itself
  49007. *
  49008. * @param id the id of this component
  49009. * @param type the type of the component
  49010. * @param _buttonIndex index in the buttons array of the gamepad
  49011. * @param _axesIndices indices of the values in the axes array of the gamepad
  49012. */
  49013. constructor(
  49014. /**
  49015. * the id of this component
  49016. */
  49017. id: string,
  49018. /**
  49019. * the type of the component
  49020. */
  49021. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49022. /**
  49023. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49024. */
  49025. get axes(): IWebXRMotionControllerAxesValue;
  49026. /**
  49027. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49028. */
  49029. get changes(): IWebXRMotionControllerComponentChanges;
  49030. /**
  49031. * Return whether or not the component changed the last frame
  49032. */
  49033. get hasChanges(): boolean;
  49034. /**
  49035. * is the button currently pressed
  49036. */
  49037. get pressed(): boolean;
  49038. /**
  49039. * is the button currently touched
  49040. */
  49041. get touched(): boolean;
  49042. /**
  49043. * Get the current value of this component
  49044. */
  49045. get value(): number;
  49046. /**
  49047. * Dispose this component
  49048. */
  49049. dispose(): void;
  49050. /**
  49051. * Are there axes correlating to this component
  49052. * @return true is axes data is available
  49053. */
  49054. isAxes(): boolean;
  49055. /**
  49056. * Is this component a button (hence - pressable)
  49057. * @returns true if can be pressed
  49058. */
  49059. isButton(): boolean;
  49060. /**
  49061. * update this component using the gamepad object it is in. Called on every frame
  49062. * @param nativeController the native gamepad controller object
  49063. */
  49064. update(nativeController: IMinimalMotionControllerObject): void;
  49065. }
  49066. }
  49067. declare module "babylonjs/Loading/sceneLoader" {
  49068. import { Observable } from "babylonjs/Misc/observable";
  49069. import { Nullable } from "babylonjs/types";
  49070. import { Scene } from "babylonjs/scene";
  49071. import { Engine } from "babylonjs/Engines/engine";
  49072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49073. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49074. import { AssetContainer } from "babylonjs/assetContainer";
  49075. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49076. import { Skeleton } from "babylonjs/Bones/skeleton";
  49077. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49078. import { WebRequest } from "babylonjs/Misc/webRequest";
  49079. /**
  49080. * Interface used to represent data loading progression
  49081. */
  49082. export interface ISceneLoaderProgressEvent {
  49083. /**
  49084. * Defines if data length to load can be evaluated
  49085. */
  49086. readonly lengthComputable: boolean;
  49087. /**
  49088. * Defines the loaded data length
  49089. */
  49090. readonly loaded: number;
  49091. /**
  49092. * Defines the data length to load
  49093. */
  49094. readonly total: number;
  49095. }
  49096. /**
  49097. * Interface used by SceneLoader plugins to define supported file extensions
  49098. */
  49099. export interface ISceneLoaderPluginExtensions {
  49100. /**
  49101. * Defines the list of supported extensions
  49102. */
  49103. [extension: string]: {
  49104. isBinary: boolean;
  49105. };
  49106. }
  49107. /**
  49108. * Interface used by SceneLoader plugin factory
  49109. */
  49110. export interface ISceneLoaderPluginFactory {
  49111. /**
  49112. * Defines the name of the factory
  49113. */
  49114. name: string;
  49115. /**
  49116. * Function called to create a new plugin
  49117. * @return the new plugin
  49118. */
  49119. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49120. /**
  49121. * The callback that returns true if the data can be directly loaded.
  49122. * @param data string containing the file data
  49123. * @returns if the data can be loaded directly
  49124. */
  49125. canDirectLoad?(data: string): boolean;
  49126. }
  49127. /**
  49128. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49129. */
  49130. export interface ISceneLoaderPluginBase {
  49131. /**
  49132. * The friendly name of this plugin.
  49133. */
  49134. name: string;
  49135. /**
  49136. * The file extensions supported by this plugin.
  49137. */
  49138. extensions: string | ISceneLoaderPluginExtensions;
  49139. /**
  49140. * The callback called when loading from a url.
  49141. * @param scene scene loading this url
  49142. * @param url url to load
  49143. * @param onSuccess callback called when the file successfully loads
  49144. * @param onProgress callback called while file is loading (if the server supports this mode)
  49145. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49146. * @param onError callback called when the file fails to load
  49147. * @returns a file request object
  49148. */
  49149. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49150. /**
  49151. * The callback called when loading from a file object.
  49152. * @param scene scene loading this file
  49153. * @param file defines the file to load
  49154. * @param onSuccess defines the callback to call when data is loaded
  49155. * @param onProgress defines the callback to call during loading process
  49156. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49157. * @param onError defines the callback to call when an error occurs
  49158. * @returns a file request object
  49159. */
  49160. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49161. /**
  49162. * The callback that returns true if the data can be directly loaded.
  49163. * @param data string containing the file data
  49164. * @returns if the data can be loaded directly
  49165. */
  49166. canDirectLoad?(data: string): boolean;
  49167. /**
  49168. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49169. * @param scene scene loading this data
  49170. * @param data string containing the data
  49171. * @returns data to pass to the plugin
  49172. */
  49173. directLoad?(scene: Scene, data: string): any;
  49174. /**
  49175. * The callback that allows custom handling of the root url based on the response url.
  49176. * @param rootUrl the original root url
  49177. * @param responseURL the response url if available
  49178. * @returns the new root url
  49179. */
  49180. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49181. }
  49182. /**
  49183. * Interface used to define a SceneLoader plugin
  49184. */
  49185. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49186. /**
  49187. * Import meshes into a scene.
  49188. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49189. * @param scene The scene to import into
  49190. * @param data The data to import
  49191. * @param rootUrl The root url for scene and resources
  49192. * @param meshes The meshes array to import into
  49193. * @param particleSystems The particle systems array to import into
  49194. * @param skeletons The skeletons array to import into
  49195. * @param onError The callback when import fails
  49196. * @returns True if successful or false otherwise
  49197. */
  49198. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49199. /**
  49200. * Load into a scene.
  49201. * @param scene The scene to load into
  49202. * @param data The data to import
  49203. * @param rootUrl The root url for scene and resources
  49204. * @param onError The callback when import fails
  49205. * @returns True if successful or false otherwise
  49206. */
  49207. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49208. /**
  49209. * Load into an asset container.
  49210. * @param scene The scene to load into
  49211. * @param data The data to import
  49212. * @param rootUrl The root url for scene and resources
  49213. * @param onError The callback when import fails
  49214. * @returns The loaded asset container
  49215. */
  49216. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49217. }
  49218. /**
  49219. * Interface used to define an async SceneLoader plugin
  49220. */
  49221. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49222. /**
  49223. * Import meshes into a scene.
  49224. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49225. * @param scene The scene to import into
  49226. * @param data The data to import
  49227. * @param rootUrl The root url for scene and resources
  49228. * @param onProgress The callback when the load progresses
  49229. * @param fileName Defines the name of the file to load
  49230. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49231. */
  49232. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49233. meshes: AbstractMesh[];
  49234. particleSystems: IParticleSystem[];
  49235. skeletons: Skeleton[];
  49236. animationGroups: AnimationGroup[];
  49237. }>;
  49238. /**
  49239. * Load into a scene.
  49240. * @param scene The scene to load into
  49241. * @param data The data to import
  49242. * @param rootUrl The root url for scene and resources
  49243. * @param onProgress The callback when the load progresses
  49244. * @param fileName Defines the name of the file to load
  49245. * @returns Nothing
  49246. */
  49247. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49248. /**
  49249. * Load into an asset container.
  49250. * @param scene The scene to load into
  49251. * @param data The data to import
  49252. * @param rootUrl The root url for scene and resources
  49253. * @param onProgress The callback when the load progresses
  49254. * @param fileName Defines the name of the file to load
  49255. * @returns The loaded asset container
  49256. */
  49257. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49258. }
  49259. /**
  49260. * Mode that determines how to handle old animation groups before loading new ones.
  49261. */
  49262. export enum SceneLoaderAnimationGroupLoadingMode {
  49263. /**
  49264. * Reset all old animations to initial state then dispose them.
  49265. */
  49266. Clean = 0,
  49267. /**
  49268. * Stop all old animations.
  49269. */
  49270. Stop = 1,
  49271. /**
  49272. * Restart old animations from first frame.
  49273. */
  49274. Sync = 2,
  49275. /**
  49276. * Old animations remains untouched.
  49277. */
  49278. NoSync = 3
  49279. }
  49280. /**
  49281. * Defines a plugin registered by the SceneLoader
  49282. */
  49283. interface IRegisteredPlugin {
  49284. /**
  49285. * Defines the plugin to use
  49286. */
  49287. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49288. /**
  49289. * Defines if the plugin supports binary data
  49290. */
  49291. isBinary: boolean;
  49292. }
  49293. /**
  49294. * Class used to load scene from various file formats using registered plugins
  49295. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49296. */
  49297. export class SceneLoader {
  49298. /**
  49299. * No logging while loading
  49300. */
  49301. static readonly NO_LOGGING: number;
  49302. /**
  49303. * Minimal logging while loading
  49304. */
  49305. static readonly MINIMAL_LOGGING: number;
  49306. /**
  49307. * Summary logging while loading
  49308. */
  49309. static readonly SUMMARY_LOGGING: number;
  49310. /**
  49311. * Detailled logging while loading
  49312. */
  49313. static readonly DETAILED_LOGGING: number;
  49314. /**
  49315. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49316. */
  49317. static get ForceFullSceneLoadingForIncremental(): boolean;
  49318. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49319. /**
  49320. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49321. */
  49322. static get ShowLoadingScreen(): boolean;
  49323. static set ShowLoadingScreen(value: boolean);
  49324. /**
  49325. * Defines the current logging level (while loading the scene)
  49326. * @ignorenaming
  49327. */
  49328. static get loggingLevel(): number;
  49329. static set loggingLevel(value: number);
  49330. /**
  49331. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49332. */
  49333. static get CleanBoneMatrixWeights(): boolean;
  49334. static set CleanBoneMatrixWeights(value: boolean);
  49335. /**
  49336. * Event raised when a plugin is used to load a scene
  49337. */
  49338. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49339. private static _registeredPlugins;
  49340. private static _showingLoadingScreen;
  49341. /**
  49342. * Gets the default plugin (used to load Babylon files)
  49343. * @returns the .babylon plugin
  49344. */
  49345. static GetDefaultPlugin(): IRegisteredPlugin;
  49346. private static _GetPluginForExtension;
  49347. private static _GetPluginForDirectLoad;
  49348. private static _GetPluginForFilename;
  49349. private static _GetDirectLoad;
  49350. private static _LoadData;
  49351. private static _GetFileInfo;
  49352. /**
  49353. * Gets a plugin that can load the given extension
  49354. * @param extension defines the extension to load
  49355. * @returns a plugin or null if none works
  49356. */
  49357. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49358. /**
  49359. * Gets a boolean indicating that the given extension can be loaded
  49360. * @param extension defines the extension to load
  49361. * @returns true if the extension is supported
  49362. */
  49363. static IsPluginForExtensionAvailable(extension: string): boolean;
  49364. /**
  49365. * Adds a new plugin to the list of registered plugins
  49366. * @param plugin defines the plugin to add
  49367. */
  49368. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49369. /**
  49370. * Import meshes into a scene
  49371. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49372. * @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)
  49373. * @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)
  49374. * @param scene the instance of BABYLON.Scene to append to
  49375. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49376. * @param onProgress a callback with a progress event for each file being loaded
  49377. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49378. * @param pluginExtension the extension used to determine the plugin
  49379. * @returns The loaded plugin
  49380. */
  49381. 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>;
  49382. /**
  49383. * Import meshes into a scene
  49384. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49385. * @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)
  49386. * @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)
  49387. * @param scene the instance of BABYLON.Scene to append to
  49388. * @param onProgress a callback with a progress event for each file being loaded
  49389. * @param pluginExtension the extension used to determine the plugin
  49390. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49391. */
  49392. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49393. meshes: AbstractMesh[];
  49394. particleSystems: IParticleSystem[];
  49395. skeletons: Skeleton[];
  49396. animationGroups: AnimationGroup[];
  49397. }>;
  49398. /**
  49399. * Load a scene
  49400. * @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)
  49401. * @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)
  49402. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49403. * @param onSuccess a callback with the scene when import succeeds
  49404. * @param onProgress a callback with a progress event for each file being loaded
  49405. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49406. * @param pluginExtension the extension used to determine the plugin
  49407. * @returns The loaded plugin
  49408. */
  49409. 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>;
  49410. /**
  49411. * Load a scene
  49412. * @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)
  49413. * @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)
  49414. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49415. * @param onProgress a callback with a progress event for each file being loaded
  49416. * @param pluginExtension the extension used to determine the plugin
  49417. * @returns The loaded scene
  49418. */
  49419. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49420. /**
  49421. * Append a scene
  49422. * @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)
  49423. * @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)
  49424. * @param scene is the instance of BABYLON.Scene to append to
  49425. * @param onSuccess a callback with the scene when import succeeds
  49426. * @param onProgress a callback with a progress event for each file being loaded
  49427. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49428. * @param pluginExtension the extension used to determine the plugin
  49429. * @returns The loaded plugin
  49430. */
  49431. 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>;
  49432. /**
  49433. * Append a scene
  49434. * @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)
  49435. * @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)
  49436. * @param scene is the instance of BABYLON.Scene to append to
  49437. * @param onProgress a callback with a progress event for each file being loaded
  49438. * @param pluginExtension the extension used to determine the plugin
  49439. * @returns The given scene
  49440. */
  49441. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49442. /**
  49443. * Load a scene into an asset container
  49444. * @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)
  49445. * @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)
  49446. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49447. * @param onSuccess a callback with the scene when import succeeds
  49448. * @param onProgress a callback with a progress event for each file being loaded
  49449. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49450. * @param pluginExtension the extension used to determine the plugin
  49451. * @returns The loaded plugin
  49452. */
  49453. 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>;
  49454. /**
  49455. * Load a scene into an asset container
  49456. * @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)
  49457. * @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)
  49458. * @param scene is the instance of Scene to append to
  49459. * @param onProgress a callback with a progress event for each file being loaded
  49460. * @param pluginExtension the extension used to determine the plugin
  49461. * @returns The loaded asset container
  49462. */
  49463. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49464. /**
  49465. * Import animations from a file into a scene
  49466. * @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)
  49467. * @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)
  49468. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49469. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49470. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49471. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49472. * @param onSuccess a callback with the scene when import succeeds
  49473. * @param onProgress a callback with a progress event for each file being loaded
  49474. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49475. * @param pluginExtension the extension used to determine the plugin
  49476. */
  49477. 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;
  49478. /**
  49479. * Import animations from a file into a scene
  49480. * @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)
  49481. * @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)
  49482. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49483. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49484. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49485. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49486. * @param onSuccess a callback with the scene when import succeeds
  49487. * @param onProgress a callback with a progress event for each file being loaded
  49488. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49489. * @param pluginExtension the extension used to determine the plugin
  49490. * @returns the updated scene with imported animations
  49491. */
  49492. 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>;
  49493. }
  49494. }
  49495. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49496. import { IDisposable, Scene } from "babylonjs/scene";
  49497. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49498. import { Observable } from "babylonjs/Misc/observable";
  49499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49500. import { Nullable } from "babylonjs/types";
  49501. /**
  49502. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49503. */
  49504. export type MotionControllerHandedness = "none" | "left" | "right";
  49505. /**
  49506. * The type of components available in motion controllers.
  49507. * This is not the name of the component.
  49508. */
  49509. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49510. /**
  49511. * The state of a controller component
  49512. */
  49513. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49514. /**
  49515. * The schema of motion controller layout.
  49516. * No object will be initialized using this interface
  49517. * This is used just to define the profile.
  49518. */
  49519. export interface IMotionControllerLayout {
  49520. /**
  49521. * Path to load the assets. Usually relative to the base path
  49522. */
  49523. assetPath: string;
  49524. /**
  49525. * Available components (unsorted)
  49526. */
  49527. components: {
  49528. /**
  49529. * A map of component Ids
  49530. */
  49531. [componentId: string]: {
  49532. /**
  49533. * The type of input the component outputs
  49534. */
  49535. type: MotionControllerComponentType;
  49536. /**
  49537. * The indices of this component in the gamepad object
  49538. */
  49539. gamepadIndices: {
  49540. /**
  49541. * Index of button
  49542. */
  49543. button?: number;
  49544. /**
  49545. * If available, index of x-axis
  49546. */
  49547. xAxis?: number;
  49548. /**
  49549. * If available, index of y-axis
  49550. */
  49551. yAxis?: number;
  49552. };
  49553. /**
  49554. * The mesh's root node name
  49555. */
  49556. rootNodeName: string;
  49557. /**
  49558. * Animation definitions for this model
  49559. */
  49560. visualResponses: {
  49561. [stateKey: string]: {
  49562. /**
  49563. * What property will be animated
  49564. */
  49565. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49566. /**
  49567. * What states influence this visual response
  49568. */
  49569. states: MotionControllerComponentStateType[];
  49570. /**
  49571. * Type of animation - movement or visibility
  49572. */
  49573. valueNodeProperty: "transform" | "visibility";
  49574. /**
  49575. * Base node name to move. Its position will be calculated according to the min and max nodes
  49576. */
  49577. valueNodeName?: string;
  49578. /**
  49579. * Minimum movement node
  49580. */
  49581. minNodeName?: string;
  49582. /**
  49583. * Max movement node
  49584. */
  49585. maxNodeName?: string;
  49586. };
  49587. };
  49588. /**
  49589. * If touch enabled, what is the name of node to display user feedback
  49590. */
  49591. touchPointNodeName?: string;
  49592. };
  49593. };
  49594. /**
  49595. * Is it xr standard mapping or not
  49596. */
  49597. gamepadMapping: "" | "xr-standard";
  49598. /**
  49599. * Base root node of this entire model
  49600. */
  49601. rootNodeName: string;
  49602. /**
  49603. * Defines the main button component id
  49604. */
  49605. selectComponentId: string;
  49606. }
  49607. /**
  49608. * A definition for the layout map in the input profile
  49609. */
  49610. export interface IMotionControllerLayoutMap {
  49611. /**
  49612. * Layouts with handedness type as a key
  49613. */
  49614. [handedness: string]: IMotionControllerLayout;
  49615. }
  49616. /**
  49617. * The XR Input profile schema
  49618. * Profiles can be found here:
  49619. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49620. */
  49621. export interface IMotionControllerProfile {
  49622. /**
  49623. * fallback profiles for this profileId
  49624. */
  49625. fallbackProfileIds: string[];
  49626. /**
  49627. * The layout map, with handedness as key
  49628. */
  49629. layouts: IMotionControllerLayoutMap;
  49630. /**
  49631. * The id of this profile
  49632. * correlates to the profile(s) in the xrInput.profiles array
  49633. */
  49634. profileId: string;
  49635. }
  49636. /**
  49637. * A helper-interface for the 3 meshes needed for controller button animation
  49638. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49639. */
  49640. export interface IMotionControllerButtonMeshMap {
  49641. /**
  49642. * the mesh that defines the pressed value mesh position.
  49643. * This is used to find the max-position of this button
  49644. */
  49645. pressedMesh: AbstractMesh;
  49646. /**
  49647. * the mesh that defines the unpressed value mesh position.
  49648. * This is used to find the min (or initial) position of this button
  49649. */
  49650. unpressedMesh: AbstractMesh;
  49651. /**
  49652. * The mesh that will be changed when value changes
  49653. */
  49654. valueMesh: AbstractMesh;
  49655. }
  49656. /**
  49657. * A helper-interface for the 3 meshes needed for controller axis animation.
  49658. * This will be expanded when touchpad animations are fully supported
  49659. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49660. */
  49661. export interface IMotionControllerMeshMap {
  49662. /**
  49663. * the mesh that defines the maximum value mesh position.
  49664. */
  49665. maxMesh?: AbstractMesh;
  49666. /**
  49667. * the mesh that defines the minimum value mesh position.
  49668. */
  49669. minMesh?: AbstractMesh;
  49670. /**
  49671. * The mesh that will be changed when axis value changes
  49672. */
  49673. valueMesh: AbstractMesh;
  49674. }
  49675. /**
  49676. * The elements needed for change-detection of the gamepad objects in motion controllers
  49677. */
  49678. export interface IMinimalMotionControllerObject {
  49679. /**
  49680. * Available axes of this controller
  49681. */
  49682. axes: number[];
  49683. /**
  49684. * An array of available buttons
  49685. */
  49686. buttons: Array<{
  49687. /**
  49688. * Value of the button/trigger
  49689. */
  49690. value: number;
  49691. /**
  49692. * If the button/trigger is currently touched
  49693. */
  49694. touched: boolean;
  49695. /**
  49696. * If the button/trigger is currently pressed
  49697. */
  49698. pressed: boolean;
  49699. }>;
  49700. /**
  49701. * EXPERIMENTAL haptic support.
  49702. */
  49703. hapticActuators?: Array<{
  49704. pulse: (value: number, duration: number) => Promise<boolean>;
  49705. }>;
  49706. }
  49707. /**
  49708. * An Abstract Motion controller
  49709. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49710. * Each component has an observable to check for changes in value and state
  49711. */
  49712. export abstract class WebXRAbstractMotionController implements IDisposable {
  49713. protected scene: Scene;
  49714. protected layout: IMotionControllerLayout;
  49715. /**
  49716. * The gamepad object correlating to this controller
  49717. */
  49718. gamepadObject: IMinimalMotionControllerObject;
  49719. /**
  49720. * handedness (left/right/none) of this controller
  49721. */
  49722. handedness: MotionControllerHandedness;
  49723. private _initComponent;
  49724. private _modelReady;
  49725. /**
  49726. * A map of components (WebXRControllerComponent) in this motion controller
  49727. * Components have a ComponentType and can also have both button and axis definitions
  49728. */
  49729. readonly components: {
  49730. [id: string]: WebXRControllerComponent;
  49731. };
  49732. /**
  49733. * Disable the model's animation. Can be set at any time.
  49734. */
  49735. disableAnimation: boolean;
  49736. /**
  49737. * Observers registered here will be triggered when the model of this controller is done loading
  49738. */
  49739. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49740. /**
  49741. * The profile id of this motion controller
  49742. */
  49743. abstract profileId: string;
  49744. /**
  49745. * The root mesh of the model. It is null if the model was not yet initialized
  49746. */
  49747. rootMesh: Nullable<AbstractMesh>;
  49748. /**
  49749. * constructs a new abstract motion controller
  49750. * @param scene the scene to which the model of the controller will be added
  49751. * @param layout The profile layout to load
  49752. * @param gamepadObject The gamepad object correlating to this controller
  49753. * @param handedness handedness (left/right/none) of this controller
  49754. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49755. */
  49756. constructor(scene: Scene, layout: IMotionControllerLayout,
  49757. /**
  49758. * The gamepad object correlating to this controller
  49759. */
  49760. gamepadObject: IMinimalMotionControllerObject,
  49761. /**
  49762. * handedness (left/right/none) of this controller
  49763. */
  49764. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49765. /**
  49766. * Dispose this controller, the model mesh and all its components
  49767. */
  49768. dispose(): void;
  49769. /**
  49770. * Returns all components of specific type
  49771. * @param type the type to search for
  49772. * @return an array of components with this type
  49773. */
  49774. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49775. /**
  49776. * get a component based an its component id as defined in layout.components
  49777. * @param id the id of the component
  49778. * @returns the component correlates to the id or undefined if not found
  49779. */
  49780. getComponent(id: string): WebXRControllerComponent;
  49781. /**
  49782. * Get the list of components available in this motion controller
  49783. * @returns an array of strings correlating to available components
  49784. */
  49785. getComponentIds(): string[];
  49786. /**
  49787. * Get the first component of specific type
  49788. * @param type type of component to find
  49789. * @return a controller component or null if not found
  49790. */
  49791. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49792. /**
  49793. * Get the main (Select) component of this controller as defined in the layout
  49794. * @returns the main component of this controller
  49795. */
  49796. getMainComponent(): WebXRControllerComponent;
  49797. /**
  49798. * Loads the model correlating to this controller
  49799. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49800. * @returns A promise fulfilled with the result of the model loading
  49801. */
  49802. loadModel(): Promise<boolean>;
  49803. /**
  49804. * Update this model using the current XRFrame
  49805. * @param xrFrame the current xr frame to use and update the model
  49806. */
  49807. updateFromXRFrame(xrFrame: XRFrame): void;
  49808. /**
  49809. * Backwards compatibility due to a deeply-integrated typo
  49810. */
  49811. get handness(): XREye;
  49812. /**
  49813. * Pulse (vibrate) this controller
  49814. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49815. * Consecutive calls to this function will cancel the last pulse call
  49816. *
  49817. * @param value the strength of the pulse in 0.0...1.0 range
  49818. * @param duration Duration of the pulse in milliseconds
  49819. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49820. * @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
  49821. */
  49822. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49823. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49824. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49825. /**
  49826. * Moves the axis on the controller mesh based on its current state
  49827. * @param axis the index of the axis
  49828. * @param axisValue the value of the axis which determines the meshes new position
  49829. * @hidden
  49830. */
  49831. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49832. /**
  49833. * Update the model itself with the current frame data
  49834. * @param xrFrame the frame to use for updating the model mesh
  49835. */
  49836. protected updateModel(xrFrame: XRFrame): void;
  49837. /**
  49838. * Get the filename and path for this controller's model
  49839. * @returns a map of filename and path
  49840. */
  49841. protected abstract _getFilenameAndPath(): {
  49842. filename: string;
  49843. path: string;
  49844. };
  49845. /**
  49846. * This function is called before the mesh is loaded. It checks for loading constraints.
  49847. * For example, this function can check if the GLB loader is available
  49848. * If this function returns false, the generic controller will be loaded instead
  49849. * @returns Is the client ready to load the mesh
  49850. */
  49851. protected abstract _getModelLoadingConstraints(): boolean;
  49852. /**
  49853. * This function will be called after the model was successfully loaded and can be used
  49854. * for mesh transformations before it is available for the user
  49855. * @param meshes the loaded meshes
  49856. */
  49857. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49858. /**
  49859. * Set the root mesh for this controller. Important for the WebXR controller class
  49860. * @param meshes the loaded meshes
  49861. */
  49862. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49863. /**
  49864. * A function executed each frame that updates the mesh (if needed)
  49865. * @param xrFrame the current xrFrame
  49866. */
  49867. protected abstract _updateModel(xrFrame: XRFrame): void;
  49868. private _getGenericFilenameAndPath;
  49869. private _getGenericParentMesh;
  49870. }
  49871. }
  49872. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49873. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49875. import { Scene } from "babylonjs/scene";
  49876. /**
  49877. * A generic trigger-only motion controller for WebXR
  49878. */
  49879. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49880. /**
  49881. * Static version of the profile id of this controller
  49882. */
  49883. static ProfileId: string;
  49884. profileId: string;
  49885. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49886. protected _getFilenameAndPath(): {
  49887. filename: string;
  49888. path: string;
  49889. };
  49890. protected _getModelLoadingConstraints(): boolean;
  49891. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49892. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49893. protected _updateModel(): void;
  49894. }
  49895. }
  49896. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49897. import { Vector4 } from "babylonjs/Maths/math.vector";
  49898. import { Mesh } from "babylonjs/Meshes/mesh";
  49899. import { Scene } from "babylonjs/scene";
  49900. import { Nullable } from "babylonjs/types";
  49901. /**
  49902. * Class containing static functions to help procedurally build meshes
  49903. */
  49904. export class SphereBuilder {
  49905. /**
  49906. * Creates a sphere mesh
  49907. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49908. * * 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`)
  49909. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49910. * * 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
  49911. * * 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)
  49912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49915. * @param name defines the name of the mesh
  49916. * @param options defines the options used to create the mesh
  49917. * @param scene defines the hosting scene
  49918. * @returns the sphere mesh
  49919. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49920. */
  49921. static CreateSphere(name: string, options: {
  49922. segments?: number;
  49923. diameter?: number;
  49924. diameterX?: number;
  49925. diameterY?: number;
  49926. diameterZ?: number;
  49927. arc?: number;
  49928. slice?: number;
  49929. sideOrientation?: number;
  49930. frontUVs?: Vector4;
  49931. backUVs?: Vector4;
  49932. updatable?: boolean;
  49933. }, scene?: Nullable<Scene>): Mesh;
  49934. }
  49935. }
  49936. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49938. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49939. import { Scene } from "babylonjs/scene";
  49940. /**
  49941. * A profiled motion controller has its profile loaded from an online repository.
  49942. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49943. */
  49944. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49945. private _repositoryUrl;
  49946. private _buttonMeshMapping;
  49947. private _touchDots;
  49948. /**
  49949. * The profile ID of this controller. Will be populated when the controller initializes.
  49950. */
  49951. profileId: string;
  49952. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49953. dispose(): void;
  49954. protected _getFilenameAndPath(): {
  49955. filename: string;
  49956. path: string;
  49957. };
  49958. protected _getModelLoadingConstraints(): boolean;
  49959. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49960. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49961. protected _updateModel(_xrFrame: XRFrame): void;
  49962. }
  49963. }
  49964. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49965. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49966. import { Scene } from "babylonjs/scene";
  49967. /**
  49968. * A construction function type to create a new controller based on an xrInput object
  49969. */
  49970. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49971. /**
  49972. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49973. *
  49974. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49975. * it should be replaced with auto-loaded controllers.
  49976. *
  49977. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49978. */
  49979. export class WebXRMotionControllerManager {
  49980. private static _AvailableControllers;
  49981. private static _Fallbacks;
  49982. private static _ProfileLoadingPromises;
  49983. private static _ProfilesList;
  49984. /**
  49985. * The base URL of the online controller repository. Can be changed at any time.
  49986. */
  49987. static BaseRepositoryUrl: string;
  49988. /**
  49989. * Which repository gets priority - local or online
  49990. */
  49991. static PrioritizeOnlineRepository: boolean;
  49992. /**
  49993. * Use the online repository, or use only locally-defined controllers
  49994. */
  49995. static UseOnlineRepository: boolean;
  49996. /**
  49997. * Clear the cache used for profile loading and reload when requested again
  49998. */
  49999. static ClearProfilesCache(): void;
  50000. /**
  50001. * Register the default fallbacks.
  50002. * This function is called automatically when this file is imported.
  50003. */
  50004. static DefaultFallbacks(): void;
  50005. /**
  50006. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50007. * @param profileId the profile to which a fallback needs to be found
  50008. * @return an array with corresponding fallback profiles
  50009. */
  50010. static FindFallbackWithProfileId(profileId: string): string[];
  50011. /**
  50012. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50013. * The order of search:
  50014. *
  50015. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50016. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50017. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50018. * 4) return the generic trigger controller if none were found
  50019. *
  50020. * @param xrInput the xrInput to which a new controller is initialized
  50021. * @param scene the scene to which the model will be added
  50022. * @param forceProfile force a certain profile for this controller
  50023. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50024. */
  50025. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50026. /**
  50027. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50028. *
  50029. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50030. *
  50031. * @param type the profile type to register
  50032. * @param constructFunction the function to be called when loading this profile
  50033. */
  50034. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50035. /**
  50036. * Register a fallback to a specific profile.
  50037. * @param profileId the profileId that will receive the fallbacks
  50038. * @param fallbacks A list of fallback profiles
  50039. */
  50040. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50041. /**
  50042. * Will update the list of profiles available in the repository
  50043. * @return a promise that resolves to a map of profiles available online
  50044. */
  50045. static UpdateProfilesList(): Promise<{
  50046. [profile: string]: string;
  50047. }>;
  50048. private static _LoadProfileFromRepository;
  50049. private static _LoadProfilesFromAvailableControllers;
  50050. }
  50051. }
  50052. declare module "babylonjs/XR/webXRInputSource" {
  50053. import { Observable } from "babylonjs/Misc/observable";
  50054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50055. import { Ray } from "babylonjs/Culling/ray";
  50056. import { Scene } from "babylonjs/scene";
  50057. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50058. /**
  50059. * Configuration options for the WebXR controller creation
  50060. */
  50061. export interface IWebXRControllerOptions {
  50062. /**
  50063. * Should the controller mesh be animated when a user interacts with it
  50064. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50065. */
  50066. disableMotionControllerAnimation?: boolean;
  50067. /**
  50068. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50069. */
  50070. doNotLoadControllerMesh?: boolean;
  50071. /**
  50072. * Force a specific controller type for this controller.
  50073. * This can be used when creating your own profile or when testing different controllers
  50074. */
  50075. forceControllerProfile?: string;
  50076. /**
  50077. * Defines a rendering group ID for meshes that will be loaded.
  50078. * This is for the default controllers only.
  50079. */
  50080. renderingGroupId?: number;
  50081. }
  50082. /**
  50083. * Represents an XR controller
  50084. */
  50085. export class WebXRInputSource {
  50086. private _scene;
  50087. /** The underlying input source for the controller */
  50088. inputSource: XRInputSource;
  50089. private _options;
  50090. private _tmpVector;
  50091. private _uniqueId;
  50092. /**
  50093. * 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
  50094. */
  50095. grip?: AbstractMesh;
  50096. /**
  50097. * If available, this is the gamepad object related to this controller.
  50098. * Using this object it is possible to get click events and trackpad changes of the
  50099. * webxr controller that is currently being used.
  50100. */
  50101. motionController?: WebXRAbstractMotionController;
  50102. /**
  50103. * Event that fires when the controller is removed/disposed.
  50104. * The object provided as event data is this controller, after associated assets were disposed.
  50105. * uniqueId is still available.
  50106. */
  50107. onDisposeObservable: Observable<WebXRInputSource>;
  50108. /**
  50109. * Will be triggered when the mesh associated with the motion controller is done loading.
  50110. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50111. * A shortened version of controller -> motion controller -> on mesh loaded.
  50112. */
  50113. onMeshLoadedObservable: Observable<AbstractMesh>;
  50114. /**
  50115. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50116. */
  50117. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50118. /**
  50119. * Pointer which can be used to select objects or attach a visible laser to
  50120. */
  50121. pointer: AbstractMesh;
  50122. /**
  50123. * Creates the input source object
  50124. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50125. * @param _scene the scene which the controller should be associated to
  50126. * @param inputSource the underlying input source for the controller
  50127. * @param _options options for this controller creation
  50128. */
  50129. constructor(_scene: Scene,
  50130. /** The underlying input source for the controller */
  50131. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50132. /**
  50133. * Get this controllers unique id
  50134. */
  50135. get uniqueId(): string;
  50136. /**
  50137. * Disposes of the object
  50138. */
  50139. dispose(): void;
  50140. /**
  50141. * Gets a world space ray coming from the pointer or grip
  50142. * @param result the resulting ray
  50143. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50144. */
  50145. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50146. /**
  50147. * Updates the controller pose based on the given XRFrame
  50148. * @param xrFrame xr frame to update the pose with
  50149. * @param referenceSpace reference space to use
  50150. */
  50151. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50152. }
  50153. }
  50154. declare module "babylonjs/XR/webXRInput" {
  50155. import { Observable } from "babylonjs/Misc/observable";
  50156. import { IDisposable } from "babylonjs/scene";
  50157. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50158. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50159. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50160. /**
  50161. * The schema for initialization options of the XR Input class
  50162. */
  50163. export interface IWebXRInputOptions {
  50164. /**
  50165. * If set to true no model will be automatically loaded
  50166. */
  50167. doNotLoadControllerMeshes?: boolean;
  50168. /**
  50169. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50170. * If not found, the xr input profile data will be used.
  50171. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50172. */
  50173. forceInputProfile?: string;
  50174. /**
  50175. * Do not send a request to the controller repository to load the profile.
  50176. *
  50177. * Instead, use the controllers available in babylon itself.
  50178. */
  50179. disableOnlineControllerRepository?: boolean;
  50180. /**
  50181. * A custom URL for the controllers repository
  50182. */
  50183. customControllersRepositoryURL?: string;
  50184. /**
  50185. * Should the controller model's components not move according to the user input
  50186. */
  50187. disableControllerAnimation?: boolean;
  50188. /**
  50189. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50190. */
  50191. controllerOptions?: IWebXRControllerOptions;
  50192. }
  50193. /**
  50194. * XR input used to track XR inputs such as controllers/rays
  50195. */
  50196. export class WebXRInput implements IDisposable {
  50197. /**
  50198. * the xr session manager for this session
  50199. */
  50200. xrSessionManager: WebXRSessionManager;
  50201. /**
  50202. * the WebXR camera for this session. Mainly used for teleportation
  50203. */
  50204. xrCamera: WebXRCamera;
  50205. private readonly options;
  50206. /**
  50207. * XR controllers being tracked
  50208. */
  50209. controllers: Array<WebXRInputSource>;
  50210. private _frameObserver;
  50211. private _sessionEndedObserver;
  50212. private _sessionInitObserver;
  50213. /**
  50214. * Event when a controller has been connected/added
  50215. */
  50216. onControllerAddedObservable: Observable<WebXRInputSource>;
  50217. /**
  50218. * Event when a controller has been removed/disconnected
  50219. */
  50220. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50221. /**
  50222. * Initializes the WebXRInput
  50223. * @param xrSessionManager the xr session manager for this session
  50224. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50225. * @param options = initialization options for this xr input
  50226. */
  50227. constructor(
  50228. /**
  50229. * the xr session manager for this session
  50230. */
  50231. xrSessionManager: WebXRSessionManager,
  50232. /**
  50233. * the WebXR camera for this session. Mainly used for teleportation
  50234. */
  50235. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50236. private _onInputSourcesChange;
  50237. private _addAndRemoveControllers;
  50238. /**
  50239. * Disposes of the object
  50240. */
  50241. dispose(): void;
  50242. }
  50243. }
  50244. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50245. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50246. import { Observable, EventState } from "babylonjs/Misc/observable";
  50247. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50248. /**
  50249. * This is the base class for all WebXR features.
  50250. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50251. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50252. */
  50253. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50254. protected _xrSessionManager: WebXRSessionManager;
  50255. private _attached;
  50256. private _removeOnDetach;
  50257. /**
  50258. * Should auto-attach be disabled?
  50259. */
  50260. disableAutoAttach: boolean;
  50261. /**
  50262. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50263. */
  50264. xrNativeFeatureName: string;
  50265. /**
  50266. * Construct a new (abstract) WebXR feature
  50267. * @param _xrSessionManager the xr session manager for this feature
  50268. */
  50269. constructor(_xrSessionManager: WebXRSessionManager);
  50270. /**
  50271. * Is this feature attached
  50272. */
  50273. get attached(): boolean;
  50274. /**
  50275. * attach this feature
  50276. *
  50277. * @param force should attachment be forced (even when already attached)
  50278. * @returns true if successful, false is failed or already attached
  50279. */
  50280. attach(force?: boolean): boolean;
  50281. /**
  50282. * detach this feature.
  50283. *
  50284. * @returns true if successful, false if failed or already detached
  50285. */
  50286. detach(): boolean;
  50287. /**
  50288. * Dispose this feature and all of the resources attached
  50289. */
  50290. dispose(): void;
  50291. /**
  50292. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50293. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50294. *
  50295. * @returns whether or not the feature is compatible in this environment
  50296. */
  50297. isCompatible(): boolean;
  50298. /**
  50299. * This is used to register callbacks that will automatically be removed when detach is called.
  50300. * @param observable the observable to which the observer will be attached
  50301. * @param callback the callback to register
  50302. */
  50303. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50304. /**
  50305. * Code in this function will be executed on each xrFrame received from the browser.
  50306. * This function will not execute after the feature is detached.
  50307. * @param _xrFrame the current frame
  50308. */
  50309. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50310. }
  50311. }
  50312. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50313. import { IDisposable, Scene } from "babylonjs/scene";
  50314. import { Nullable } from "babylonjs/types";
  50315. import { Observable } from "babylonjs/Misc/observable";
  50316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50317. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50318. import { Camera } from "babylonjs/Cameras/camera";
  50319. /**
  50320. * Renders a layer on top of an existing scene
  50321. */
  50322. export class UtilityLayerRenderer implements IDisposable {
  50323. /** the original scene that will be rendered on top of */
  50324. originalScene: Scene;
  50325. private _pointerCaptures;
  50326. private _lastPointerEvents;
  50327. private static _DefaultUtilityLayer;
  50328. private static _DefaultKeepDepthUtilityLayer;
  50329. private _sharedGizmoLight;
  50330. private _renderCamera;
  50331. /**
  50332. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50333. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50334. * @returns the camera that is used when rendering the utility layer
  50335. */
  50336. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50337. /**
  50338. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50339. * @param cam the camera that should be used when rendering the utility layer
  50340. */
  50341. setRenderCamera(cam: Nullable<Camera>): void;
  50342. /**
  50343. * @hidden
  50344. * Light which used by gizmos to get light shading
  50345. */
  50346. _getSharedGizmoLight(): HemisphericLight;
  50347. /**
  50348. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50349. */
  50350. pickUtilitySceneFirst: boolean;
  50351. /**
  50352. * 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)
  50353. */
  50354. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50355. /**
  50356. * 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)
  50357. */
  50358. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50359. /**
  50360. * The scene that is rendered on top of the original scene
  50361. */
  50362. utilityLayerScene: Scene;
  50363. /**
  50364. * If the utility layer should automatically be rendered on top of existing scene
  50365. */
  50366. shouldRender: boolean;
  50367. /**
  50368. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50369. */
  50370. onlyCheckPointerDownEvents: boolean;
  50371. /**
  50372. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50373. */
  50374. processAllEvents: boolean;
  50375. /**
  50376. * Observable raised when the pointer move from the utility layer scene to the main scene
  50377. */
  50378. onPointerOutObservable: Observable<number>;
  50379. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50380. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50381. private _afterRenderObserver;
  50382. private _sceneDisposeObserver;
  50383. private _originalPointerObserver;
  50384. /**
  50385. * Instantiates a UtilityLayerRenderer
  50386. * @param originalScene the original scene that will be rendered on top of
  50387. * @param handleEvents boolean indicating if the utility layer should handle events
  50388. */
  50389. constructor(
  50390. /** the original scene that will be rendered on top of */
  50391. originalScene: Scene, handleEvents?: boolean);
  50392. private _notifyObservers;
  50393. /**
  50394. * Renders the utility layers scene on top of the original scene
  50395. */
  50396. render(): void;
  50397. /**
  50398. * Disposes of the renderer
  50399. */
  50400. dispose(): void;
  50401. private _updateCamera;
  50402. }
  50403. }
  50404. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50405. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50407. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50408. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50409. import { Scene } from "babylonjs/scene";
  50410. import { Nullable } from "babylonjs/types";
  50411. import { Color3 } from "babylonjs/Maths/math.color";
  50412. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50413. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50414. /**
  50415. * Options interface for the pointer selection module
  50416. */
  50417. export interface IWebXRControllerPointerSelectionOptions {
  50418. /**
  50419. * if provided, this scene will be used to render meshes.
  50420. */
  50421. customUtilityLayerScene?: Scene;
  50422. /**
  50423. * 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)
  50424. * If not disabled, the last picked point will be used to execute a pointer up event
  50425. * If disabled, pointer up event will be triggered right after the pointer down event.
  50426. * Used in screen and gaze target ray mode only
  50427. */
  50428. disablePointerUpOnTouchOut: boolean;
  50429. /**
  50430. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50431. */
  50432. forceGazeMode: boolean;
  50433. /**
  50434. * 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
  50435. * to start a new countdown to the pointer down event.
  50436. * Defaults to 1.
  50437. */
  50438. gazeModePointerMovedFactor?: number;
  50439. /**
  50440. * Different button type to use instead of the main component
  50441. */
  50442. overrideButtonId?: string;
  50443. /**
  50444. * use this rendering group id for the meshes (optional)
  50445. */
  50446. renderingGroupId?: number;
  50447. /**
  50448. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50449. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50450. * 3000 means 3 seconds between pointing at something and selecting it
  50451. */
  50452. timeToSelect?: number;
  50453. /**
  50454. * Should meshes created here be added to a utility layer or the main scene
  50455. */
  50456. useUtilityLayer?: boolean;
  50457. /**
  50458. * Optional WebXR camera to be used for gaze selection
  50459. */
  50460. gazeCamera?: WebXRCamera;
  50461. /**
  50462. * the xr input to use with this pointer selection
  50463. */
  50464. xrInput: WebXRInput;
  50465. }
  50466. /**
  50467. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50468. */
  50469. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50470. private readonly _options;
  50471. private static _idCounter;
  50472. private _attachController;
  50473. private _controllers;
  50474. private _scene;
  50475. private _tmpVectorForPickCompare;
  50476. /**
  50477. * The module's name
  50478. */
  50479. static readonly Name: string;
  50480. /**
  50481. * The (Babylon) version of this module.
  50482. * This is an integer representing the implementation version.
  50483. * This number does not correspond to the WebXR specs version
  50484. */
  50485. static readonly Version: number;
  50486. /**
  50487. * Disable lighting on the laser pointer (so it will always be visible)
  50488. */
  50489. disablePointerLighting: boolean;
  50490. /**
  50491. * Disable lighting on the selection mesh (so it will always be visible)
  50492. */
  50493. disableSelectionMeshLighting: boolean;
  50494. /**
  50495. * Should the laser pointer be displayed
  50496. */
  50497. displayLaserPointer: boolean;
  50498. /**
  50499. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50500. */
  50501. displaySelectionMesh: boolean;
  50502. /**
  50503. * This color will be set to the laser pointer when selection is triggered
  50504. */
  50505. laserPointerPickedColor: Color3;
  50506. /**
  50507. * Default color of the laser pointer
  50508. */
  50509. laserPointerDefaultColor: Color3;
  50510. /**
  50511. * default color of the selection ring
  50512. */
  50513. selectionMeshDefaultColor: Color3;
  50514. /**
  50515. * This color will be applied to the selection ring when selection is triggered
  50516. */
  50517. selectionMeshPickedColor: Color3;
  50518. /**
  50519. * Optional filter to be used for ray selection. This predicate shares behavior with
  50520. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50521. */
  50522. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50523. /**
  50524. * constructs a new background remover module
  50525. * @param _xrSessionManager the session manager for this module
  50526. * @param _options read-only options to be used in this module
  50527. */
  50528. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50529. /**
  50530. * attach this feature
  50531. * Will usually be called by the features manager
  50532. *
  50533. * @returns true if successful.
  50534. */
  50535. attach(): boolean;
  50536. /**
  50537. * detach this feature.
  50538. * Will usually be called by the features manager
  50539. *
  50540. * @returns true if successful.
  50541. */
  50542. detach(): boolean;
  50543. /**
  50544. * Will get the mesh under a specific pointer.
  50545. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50546. * @param controllerId the controllerId to check
  50547. * @returns The mesh under pointer or null if no mesh is under the pointer
  50548. */
  50549. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50550. /**
  50551. * Get the xr controller that correlates to the pointer id in the pointer event
  50552. *
  50553. * @param id the pointer id to search for
  50554. * @returns the controller that correlates to this id or null if not found
  50555. */
  50556. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50557. protected _onXRFrame(_xrFrame: XRFrame): void;
  50558. private _attachGazeMode;
  50559. private _attachScreenRayMode;
  50560. private _attachTrackedPointerRayMode;
  50561. private _convertNormalToDirectionOfRay;
  50562. private _detachController;
  50563. private _generateNewMeshPair;
  50564. private _pickingMoved;
  50565. private _updatePointerDistance;
  50566. /** @hidden */
  50567. get lasterPointerDefaultColor(): Color3;
  50568. }
  50569. }
  50570. declare module "babylonjs/XR/webXREnterExitUI" {
  50571. import { Nullable } from "babylonjs/types";
  50572. import { Observable } from "babylonjs/Misc/observable";
  50573. import { IDisposable, Scene } from "babylonjs/scene";
  50574. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50575. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50576. /**
  50577. * Button which can be used to enter a different mode of XR
  50578. */
  50579. export class WebXREnterExitUIButton {
  50580. /** button element */
  50581. element: HTMLElement;
  50582. /** XR initialization options for the button */
  50583. sessionMode: XRSessionMode;
  50584. /** Reference space type */
  50585. referenceSpaceType: XRReferenceSpaceType;
  50586. /**
  50587. * Creates a WebXREnterExitUIButton
  50588. * @param element button element
  50589. * @param sessionMode XR initialization session mode
  50590. * @param referenceSpaceType the type of reference space to be used
  50591. */
  50592. constructor(
  50593. /** button element */
  50594. element: HTMLElement,
  50595. /** XR initialization options for the button */
  50596. sessionMode: XRSessionMode,
  50597. /** Reference space type */
  50598. referenceSpaceType: XRReferenceSpaceType);
  50599. /**
  50600. * Extendable function which can be used to update the button's visuals when the state changes
  50601. * @param activeButton the current active button in the UI
  50602. */
  50603. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50604. }
  50605. /**
  50606. * Options to create the webXR UI
  50607. */
  50608. export class WebXREnterExitUIOptions {
  50609. /**
  50610. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50611. */
  50612. customButtons?: Array<WebXREnterExitUIButton>;
  50613. /**
  50614. * A reference space type to use when creating the default button.
  50615. * Default is local-floor
  50616. */
  50617. referenceSpaceType?: XRReferenceSpaceType;
  50618. /**
  50619. * Context to enter xr with
  50620. */
  50621. renderTarget?: Nullable<WebXRRenderTarget>;
  50622. /**
  50623. * A session mode to use when creating the default button.
  50624. * Default is immersive-vr
  50625. */
  50626. sessionMode?: XRSessionMode;
  50627. /**
  50628. * A list of optional features to init the session with
  50629. */
  50630. optionalFeatures?: string[];
  50631. /**
  50632. * A list of optional features to init the session with
  50633. */
  50634. requiredFeatures?: string[];
  50635. }
  50636. /**
  50637. * UI to allow the user to enter/exit XR mode
  50638. */
  50639. export class WebXREnterExitUI implements IDisposable {
  50640. private scene;
  50641. /** version of the options passed to this UI */
  50642. options: WebXREnterExitUIOptions;
  50643. private _activeButton;
  50644. private _buttons;
  50645. private _overlay;
  50646. /**
  50647. * Fired every time the active button is changed.
  50648. *
  50649. * When xr is entered via a button that launches xr that button will be the callback parameter
  50650. *
  50651. * When exiting xr the callback parameter will be null)
  50652. */
  50653. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50654. /**
  50655. *
  50656. * @param scene babylon scene object to use
  50657. * @param options (read-only) version of the options passed to this UI
  50658. */
  50659. private constructor();
  50660. /**
  50661. * Creates UI to allow the user to enter/exit XR mode
  50662. * @param scene the scene to add the ui to
  50663. * @param helper the xr experience helper to enter/exit xr with
  50664. * @param options options to configure the UI
  50665. * @returns the created ui
  50666. */
  50667. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50668. /**
  50669. * Disposes of the XR UI component
  50670. */
  50671. dispose(): void;
  50672. private _updateButtons;
  50673. }
  50674. }
  50675. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50676. import { Vector3 } from "babylonjs/Maths/math.vector";
  50677. import { Color4 } from "babylonjs/Maths/math.color";
  50678. import { Nullable } from "babylonjs/types";
  50679. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50680. import { Scene } from "babylonjs/scene";
  50681. /**
  50682. * Class containing static functions to help procedurally build meshes
  50683. */
  50684. export class LinesBuilder {
  50685. /**
  50686. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50687. * * 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
  50688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50689. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50690. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50691. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50692. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50693. * * 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
  50694. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50697. * @param name defines the name of the new line system
  50698. * @param options defines the options used to create the line system
  50699. * @param scene defines the hosting scene
  50700. * @returns a new line system mesh
  50701. */
  50702. static CreateLineSystem(name: string, options: {
  50703. lines: Vector3[][];
  50704. updatable?: boolean;
  50705. instance?: Nullable<LinesMesh>;
  50706. colors?: Nullable<Color4[][]>;
  50707. useVertexAlpha?: boolean;
  50708. }, scene: Nullable<Scene>): LinesMesh;
  50709. /**
  50710. * Creates a line mesh
  50711. * 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
  50712. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50713. * * The parameter `points` is an array successive Vector3
  50714. * * 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
  50715. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50716. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50717. * * When updating an instance, remember that only point positions can change, not the number of points
  50718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50720. * @param name defines the name of the new line system
  50721. * @param options defines the options used to create the line system
  50722. * @param scene defines the hosting scene
  50723. * @returns a new line mesh
  50724. */
  50725. static CreateLines(name: string, options: {
  50726. points: Vector3[];
  50727. updatable?: boolean;
  50728. instance?: Nullable<LinesMesh>;
  50729. colors?: Color4[];
  50730. useVertexAlpha?: boolean;
  50731. }, scene?: Nullable<Scene>): LinesMesh;
  50732. /**
  50733. * Creates a dashed line mesh
  50734. * * 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
  50735. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50736. * * The parameter `points` is an array successive Vector3
  50737. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50738. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50739. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50740. * * 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
  50741. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50742. * * When updating an instance, remember that only point positions can change, not the number of points
  50743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50744. * @param name defines the name of the mesh
  50745. * @param options defines the options used to create the mesh
  50746. * @param scene defines the hosting scene
  50747. * @returns the dashed line mesh
  50748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50749. */
  50750. static CreateDashedLines(name: string, options: {
  50751. points: Vector3[];
  50752. dashSize?: number;
  50753. gapSize?: number;
  50754. dashNb?: number;
  50755. updatable?: boolean;
  50756. instance?: LinesMesh;
  50757. useVertexAlpha?: boolean;
  50758. }, scene?: Nullable<Scene>): LinesMesh;
  50759. }
  50760. }
  50761. declare module "babylonjs/Misc/timer" {
  50762. import { Observable, Observer } from "babylonjs/Misc/observable";
  50763. import { Nullable } from "babylonjs/types";
  50764. import { IDisposable } from "babylonjs/scene";
  50765. /**
  50766. * Construction options for a timer
  50767. */
  50768. export interface ITimerOptions<T> {
  50769. /**
  50770. * Time-to-end
  50771. */
  50772. timeout: number;
  50773. /**
  50774. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50775. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50776. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50777. */
  50778. contextObservable: Observable<T>;
  50779. /**
  50780. * Optional parameters when adding an observer to the observable
  50781. */
  50782. observableParameters?: {
  50783. mask?: number;
  50784. insertFirst?: boolean;
  50785. scope?: any;
  50786. };
  50787. /**
  50788. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50789. */
  50790. breakCondition?: (data?: ITimerData<T>) => boolean;
  50791. /**
  50792. * Will be triggered when the time condition has met
  50793. */
  50794. onEnded?: (data: ITimerData<any>) => void;
  50795. /**
  50796. * Will be triggered when the break condition has met (prematurely ended)
  50797. */
  50798. onAborted?: (data: ITimerData<any>) => void;
  50799. /**
  50800. * Optional function to execute on each tick (or count)
  50801. */
  50802. onTick?: (data: ITimerData<any>) => void;
  50803. }
  50804. /**
  50805. * An interface defining the data sent by the timer
  50806. */
  50807. export interface ITimerData<T> {
  50808. /**
  50809. * When did it start
  50810. */
  50811. startTime: number;
  50812. /**
  50813. * Time now
  50814. */
  50815. currentTime: number;
  50816. /**
  50817. * Time passed since started
  50818. */
  50819. deltaTime: number;
  50820. /**
  50821. * How much is completed, in [0.0...1.0].
  50822. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50823. */
  50824. completeRate: number;
  50825. /**
  50826. * What the registered observable sent in the last count
  50827. */
  50828. payload: T;
  50829. }
  50830. /**
  50831. * The current state of the timer
  50832. */
  50833. export enum TimerState {
  50834. /**
  50835. * Timer initialized, not yet started
  50836. */
  50837. INIT = 0,
  50838. /**
  50839. * Timer started and counting
  50840. */
  50841. STARTED = 1,
  50842. /**
  50843. * Timer ended (whether aborted or time reached)
  50844. */
  50845. ENDED = 2
  50846. }
  50847. /**
  50848. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50849. *
  50850. * @param options options with which to initialize this timer
  50851. */
  50852. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50853. /**
  50854. * An advanced implementation of a timer class
  50855. */
  50856. export class AdvancedTimer<T = any> implements IDisposable {
  50857. /**
  50858. * Will notify each time the timer calculates the remaining time
  50859. */
  50860. onEachCountObservable: Observable<ITimerData<T>>;
  50861. /**
  50862. * Will trigger when the timer was aborted due to the break condition
  50863. */
  50864. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50865. /**
  50866. * Will trigger when the timer ended successfully
  50867. */
  50868. onTimerEndedObservable: Observable<ITimerData<T>>;
  50869. /**
  50870. * Will trigger when the timer state has changed
  50871. */
  50872. onStateChangedObservable: Observable<TimerState>;
  50873. private _observer;
  50874. private _contextObservable;
  50875. private _observableParameters;
  50876. private _startTime;
  50877. private _timer;
  50878. private _state;
  50879. private _breakCondition;
  50880. private _timeToEnd;
  50881. private _breakOnNextTick;
  50882. /**
  50883. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50884. * @param options construction options for this advanced timer
  50885. */
  50886. constructor(options: ITimerOptions<T>);
  50887. /**
  50888. * set a breaking condition for this timer. Default is to never break during count
  50889. * @param predicate the new break condition. Returns true to break, false otherwise
  50890. */
  50891. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50892. /**
  50893. * Reset ALL associated observables in this advanced timer
  50894. */
  50895. clearObservables(): void;
  50896. /**
  50897. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50898. *
  50899. * @param timeToEnd how much time to measure until timer ended
  50900. */
  50901. start(timeToEnd?: number): void;
  50902. /**
  50903. * Will force a stop on the next tick.
  50904. */
  50905. stop(): void;
  50906. /**
  50907. * Dispose this timer, clearing all resources
  50908. */
  50909. dispose(): void;
  50910. private _setState;
  50911. private _tick;
  50912. private _stop;
  50913. }
  50914. }
  50915. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50916. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50917. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50918. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50920. import { Vector3 } from "babylonjs/Maths/math.vector";
  50921. import { Material } from "babylonjs/Materials/material";
  50922. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50923. import { Scene } from "babylonjs/scene";
  50924. /**
  50925. * The options container for the teleportation module
  50926. */
  50927. export interface IWebXRTeleportationOptions {
  50928. /**
  50929. * if provided, this scene will be used to render meshes.
  50930. */
  50931. customUtilityLayerScene?: Scene;
  50932. /**
  50933. * Values to configure the default target mesh
  50934. */
  50935. defaultTargetMeshOptions?: {
  50936. /**
  50937. * Fill color of the teleportation area
  50938. */
  50939. teleportationFillColor?: string;
  50940. /**
  50941. * Border color for the teleportation area
  50942. */
  50943. teleportationBorderColor?: string;
  50944. /**
  50945. * Disable the mesh's animation sequence
  50946. */
  50947. disableAnimation?: boolean;
  50948. /**
  50949. * Disable lighting on the material or the ring and arrow
  50950. */
  50951. disableLighting?: boolean;
  50952. /**
  50953. * Override the default material of the torus and arrow
  50954. */
  50955. torusArrowMaterial?: Material;
  50956. };
  50957. /**
  50958. * A list of meshes to use as floor meshes.
  50959. * Meshes can be added and removed after initializing the feature using the
  50960. * addFloorMesh and removeFloorMesh functions
  50961. * If empty, rotation will still work
  50962. */
  50963. floorMeshes?: AbstractMesh[];
  50964. /**
  50965. * use this rendering group id for the meshes (optional)
  50966. */
  50967. renderingGroupId?: number;
  50968. /**
  50969. * Should teleportation move only to snap points
  50970. */
  50971. snapPointsOnly?: boolean;
  50972. /**
  50973. * An array of points to which the teleportation will snap to.
  50974. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50975. */
  50976. snapPositions?: Vector3[];
  50977. /**
  50978. * How close should the teleportation ray be in order to snap to position.
  50979. * Default to 0.8 units (meters)
  50980. */
  50981. snapToPositionRadius?: number;
  50982. /**
  50983. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50984. * If you want to support rotation, make sure your mesh has a direction indicator.
  50985. *
  50986. * When left untouched, the default mesh will be initialized.
  50987. */
  50988. teleportationTargetMesh?: AbstractMesh;
  50989. /**
  50990. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50991. */
  50992. timeToTeleport?: number;
  50993. /**
  50994. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50995. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50996. */
  50997. useMainComponentOnly?: boolean;
  50998. /**
  50999. * Should meshes created here be added to a utility layer or the main scene
  51000. */
  51001. useUtilityLayer?: boolean;
  51002. /**
  51003. * Babylon XR Input class for controller
  51004. */
  51005. xrInput: WebXRInput;
  51006. }
  51007. /**
  51008. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51009. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51010. * the input of the attached controllers.
  51011. */
  51012. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51013. private _options;
  51014. private _controllers;
  51015. private _currentTeleportationControllerId;
  51016. private _floorMeshes;
  51017. private _quadraticBezierCurve;
  51018. private _selectionFeature;
  51019. private _snapToPositions;
  51020. private _snappedToPoint;
  51021. private _teleportationRingMaterial?;
  51022. private _tmpRay;
  51023. private _tmpVector;
  51024. /**
  51025. * The module's name
  51026. */
  51027. static readonly Name: string;
  51028. /**
  51029. * The (Babylon) version of this module.
  51030. * This is an integer representing the implementation version.
  51031. * This number does not correspond to the webxr specs version
  51032. */
  51033. static readonly Version: number;
  51034. /**
  51035. * Is movement backwards enabled
  51036. */
  51037. backwardsMovementEnabled: boolean;
  51038. /**
  51039. * Distance to travel when moving backwards
  51040. */
  51041. backwardsTeleportationDistance: number;
  51042. /**
  51043. * The distance from the user to the inspection point in the direction of the controller
  51044. * A higher number will allow the user to move further
  51045. * defaults to 5 (meters, in xr units)
  51046. */
  51047. parabolicCheckRadius: number;
  51048. /**
  51049. * Should the module support parabolic ray on top of direct ray
  51050. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51051. * Very helpful when moving between floors / different heights
  51052. */
  51053. parabolicRayEnabled: boolean;
  51054. /**
  51055. * How much rotation should be applied when rotating right and left
  51056. */
  51057. rotationAngle: number;
  51058. /**
  51059. * Is rotation enabled when moving forward?
  51060. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51061. */
  51062. rotationEnabled: boolean;
  51063. /**
  51064. * constructs a new anchor system
  51065. * @param _xrSessionManager an instance of WebXRSessionManager
  51066. * @param _options configuration object for this feature
  51067. */
  51068. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51069. /**
  51070. * Get the snapPointsOnly flag
  51071. */
  51072. get snapPointsOnly(): boolean;
  51073. /**
  51074. * Sets the snapPointsOnly flag
  51075. * @param snapToPoints should teleportation be exclusively to snap points
  51076. */
  51077. set snapPointsOnly(snapToPoints: boolean);
  51078. /**
  51079. * Add a new mesh to the floor meshes array
  51080. * @param mesh the mesh to use as floor mesh
  51081. */
  51082. addFloorMesh(mesh: AbstractMesh): void;
  51083. /**
  51084. * Add a new snap-to point to fix teleportation to this position
  51085. * @param newSnapPoint The new Snap-To point
  51086. */
  51087. addSnapPoint(newSnapPoint: Vector3): void;
  51088. attach(): boolean;
  51089. detach(): boolean;
  51090. dispose(): void;
  51091. /**
  51092. * Remove a mesh from the floor meshes array
  51093. * @param mesh the mesh to remove
  51094. */
  51095. removeFloorMesh(mesh: AbstractMesh): void;
  51096. /**
  51097. * Remove a mesh from the floor meshes array using its name
  51098. * @param name the mesh name to remove
  51099. */
  51100. removeFloorMeshByName(name: string): void;
  51101. /**
  51102. * 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
  51103. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51104. * @returns was the point found and removed or not
  51105. */
  51106. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51107. /**
  51108. * This function sets a selection feature that will be disabled when
  51109. * the forward ray is shown and will be reattached when hidden.
  51110. * This is used to remove the selection rays when moving.
  51111. * @param selectionFeature the feature to disable when forward movement is enabled
  51112. */
  51113. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51114. protected _onXRFrame(_xrFrame: XRFrame): void;
  51115. private _attachController;
  51116. private _createDefaultTargetMesh;
  51117. private _detachController;
  51118. private _findClosestSnapPointWithRadius;
  51119. private _setTargetMeshPosition;
  51120. private _setTargetMeshVisibility;
  51121. private _showParabolicPath;
  51122. private _teleportForward;
  51123. }
  51124. }
  51125. declare module "babylonjs/XR/webXRDefaultExperience" {
  51126. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51127. import { Scene } from "babylonjs/scene";
  51128. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51129. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51130. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51131. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51133. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51134. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51135. /**
  51136. * Options for the default xr helper
  51137. */
  51138. export class WebXRDefaultExperienceOptions {
  51139. /**
  51140. * Enable or disable default UI to enter XR
  51141. */
  51142. disableDefaultUI?: boolean;
  51143. /**
  51144. * Should teleportation not initialize. defaults to false.
  51145. */
  51146. disableTeleportation?: boolean;
  51147. /**
  51148. * Floor meshes that will be used for teleport
  51149. */
  51150. floorMeshes?: Array<AbstractMesh>;
  51151. /**
  51152. * If set to true, the first frame will not be used to reset position
  51153. * The first frame is mainly used when copying transformation from the old camera
  51154. * Mainly used in AR
  51155. */
  51156. ignoreNativeCameraTransformation?: boolean;
  51157. /**
  51158. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51159. */
  51160. inputOptions?: IWebXRInputOptions;
  51161. /**
  51162. * optional configuration for the output canvas
  51163. */
  51164. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51165. /**
  51166. * optional UI options. This can be used among other to change session mode and reference space type
  51167. */
  51168. uiOptions?: WebXREnterExitUIOptions;
  51169. /**
  51170. * When loading teleportation and pointer select, use stable versions instead of latest.
  51171. */
  51172. useStablePlugins?: boolean;
  51173. /**
  51174. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51175. */
  51176. renderingGroupId?: number;
  51177. /**
  51178. * A list of optional features to init the session with
  51179. * If set to true, all features we support will be added
  51180. */
  51181. optionalFeatures?: boolean | string[];
  51182. }
  51183. /**
  51184. * Default experience which provides a similar setup to the previous webVRExperience
  51185. */
  51186. export class WebXRDefaultExperience {
  51187. /**
  51188. * Base experience
  51189. */
  51190. baseExperience: WebXRExperienceHelper;
  51191. /**
  51192. * Enables ui for entering/exiting xr
  51193. */
  51194. enterExitUI: WebXREnterExitUI;
  51195. /**
  51196. * Input experience extension
  51197. */
  51198. input: WebXRInput;
  51199. /**
  51200. * Enables laser pointer and selection
  51201. */
  51202. pointerSelection: WebXRControllerPointerSelection;
  51203. /**
  51204. * Default target xr should render to
  51205. */
  51206. renderTarget: WebXRRenderTarget;
  51207. /**
  51208. * Enables teleportation
  51209. */
  51210. teleportation: WebXRMotionControllerTeleportation;
  51211. private constructor();
  51212. /**
  51213. * Creates the default xr experience
  51214. * @param scene scene
  51215. * @param options options for basic configuration
  51216. * @returns resulting WebXRDefaultExperience
  51217. */
  51218. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51219. /**
  51220. * DIsposes of the experience helper
  51221. */
  51222. dispose(): void;
  51223. }
  51224. }
  51225. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51226. import { Observable } from "babylonjs/Misc/observable";
  51227. import { Nullable } from "babylonjs/types";
  51228. import { Camera } from "babylonjs/Cameras/camera";
  51229. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51230. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51231. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51232. import { Scene } from "babylonjs/scene";
  51233. import { Vector3 } from "babylonjs/Maths/math.vector";
  51234. import { Color3 } from "babylonjs/Maths/math.color";
  51235. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51237. import { Mesh } from "babylonjs/Meshes/mesh";
  51238. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51239. import { EasingFunction } from "babylonjs/Animations/easing";
  51240. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51241. import "babylonjs/Meshes/Builders/groundBuilder";
  51242. import "babylonjs/Meshes/Builders/torusBuilder";
  51243. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51244. import "babylonjs/Gamepads/gamepadSceneComponent";
  51245. import "babylonjs/Animations/animatable";
  51246. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51247. /**
  51248. * Options to modify the vr teleportation behavior.
  51249. */
  51250. export interface VRTeleportationOptions {
  51251. /**
  51252. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51253. */
  51254. floorMeshName?: string;
  51255. /**
  51256. * A list of meshes to be used as the teleportation floor. (default: empty)
  51257. */
  51258. floorMeshes?: Mesh[];
  51259. /**
  51260. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51261. */
  51262. teleportationMode?: number;
  51263. /**
  51264. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51265. */
  51266. teleportationTime?: number;
  51267. /**
  51268. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51269. */
  51270. teleportationSpeed?: number;
  51271. /**
  51272. * The easing function used in the animation or null for Linear. (default CircleEase)
  51273. */
  51274. easingFunction?: EasingFunction;
  51275. }
  51276. /**
  51277. * Options to modify the vr experience helper's behavior.
  51278. */
  51279. export interface VRExperienceHelperOptions extends WebVROptions {
  51280. /**
  51281. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51282. */
  51283. createDeviceOrientationCamera?: boolean;
  51284. /**
  51285. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51286. */
  51287. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51288. /**
  51289. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51290. */
  51291. laserToggle?: boolean;
  51292. /**
  51293. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51294. */
  51295. floorMeshes?: Mesh[];
  51296. /**
  51297. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51298. */
  51299. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51300. /**
  51301. * Defines if WebXR should be used instead of WebVR (if available)
  51302. */
  51303. useXR?: boolean;
  51304. }
  51305. /**
  51306. * Event containing information after VR has been entered
  51307. */
  51308. export class OnAfterEnteringVRObservableEvent {
  51309. /**
  51310. * If entering vr was successful
  51311. */
  51312. success: boolean;
  51313. }
  51314. /**
  51315. * Helps to quickly add VR support to an existing scene.
  51316. * See https://doc.babylonjs.com/how_to/webvr_helper
  51317. */
  51318. export class VRExperienceHelper {
  51319. /** Options to modify the vr experience helper's behavior. */
  51320. webVROptions: VRExperienceHelperOptions;
  51321. private _scene;
  51322. private _position;
  51323. private _btnVR;
  51324. private _btnVRDisplayed;
  51325. private _webVRsupported;
  51326. private _webVRready;
  51327. private _webVRrequesting;
  51328. private _webVRpresenting;
  51329. private _hasEnteredVR;
  51330. private _fullscreenVRpresenting;
  51331. private _inputElement;
  51332. private _webVRCamera;
  51333. private _vrDeviceOrientationCamera;
  51334. private _deviceOrientationCamera;
  51335. private _existingCamera;
  51336. private _onKeyDown;
  51337. private _onVrDisplayPresentChange;
  51338. private _onVRDisplayChanged;
  51339. private _onVRRequestPresentStart;
  51340. private _onVRRequestPresentComplete;
  51341. /**
  51342. * 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)
  51343. */
  51344. enableGazeEvenWhenNoPointerLock: boolean;
  51345. /**
  51346. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51347. */
  51348. exitVROnDoubleTap: boolean;
  51349. /**
  51350. * Observable raised right before entering VR.
  51351. */
  51352. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51353. /**
  51354. * Observable raised when entering VR has completed.
  51355. */
  51356. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51357. /**
  51358. * Observable raised when exiting VR.
  51359. */
  51360. onExitingVRObservable: Observable<VRExperienceHelper>;
  51361. /**
  51362. * Observable raised when controller mesh is loaded.
  51363. */
  51364. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51365. /** Return this.onEnteringVRObservable
  51366. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51367. */
  51368. get onEnteringVR(): Observable<VRExperienceHelper>;
  51369. /** Return this.onExitingVRObservable
  51370. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51371. */
  51372. get onExitingVR(): Observable<VRExperienceHelper>;
  51373. /** Return this.onControllerMeshLoadedObservable
  51374. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51375. */
  51376. get onControllerMeshLoaded(): Observable<WebVRController>;
  51377. private _rayLength;
  51378. private _useCustomVRButton;
  51379. private _teleportationRequested;
  51380. private _teleportActive;
  51381. private _floorMeshName;
  51382. private _floorMeshesCollection;
  51383. private _teleportationMode;
  51384. private _teleportationTime;
  51385. private _teleportationSpeed;
  51386. private _teleportationEasing;
  51387. private _rotationAllowed;
  51388. private _teleportBackwardsVector;
  51389. private _teleportationTarget;
  51390. private _isDefaultTeleportationTarget;
  51391. private _postProcessMove;
  51392. private _teleportationFillColor;
  51393. private _teleportationBorderColor;
  51394. private _rotationAngle;
  51395. private _haloCenter;
  51396. private _cameraGazer;
  51397. private _padSensibilityUp;
  51398. private _padSensibilityDown;
  51399. private _leftController;
  51400. private _rightController;
  51401. private _gazeColor;
  51402. private _laserColor;
  51403. private _pickedLaserColor;
  51404. private _pickedGazeColor;
  51405. /**
  51406. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51407. */
  51408. onNewMeshSelected: Observable<AbstractMesh>;
  51409. /**
  51410. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51411. * This observable will provide the mesh and the controller used to select the mesh
  51412. */
  51413. onMeshSelectedWithController: Observable<{
  51414. mesh: AbstractMesh;
  51415. controller: WebVRController;
  51416. }>;
  51417. /**
  51418. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51419. */
  51420. onNewMeshPicked: Observable<PickingInfo>;
  51421. private _circleEase;
  51422. /**
  51423. * Observable raised before camera teleportation
  51424. */
  51425. onBeforeCameraTeleport: Observable<Vector3>;
  51426. /**
  51427. * Observable raised after camera teleportation
  51428. */
  51429. onAfterCameraTeleport: Observable<Vector3>;
  51430. /**
  51431. * Observable raised when current selected mesh gets unselected
  51432. */
  51433. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51434. private _raySelectionPredicate;
  51435. /**
  51436. * To be optionaly changed by user to define custom ray selection
  51437. */
  51438. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51439. /**
  51440. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51441. */
  51442. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51443. /**
  51444. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51445. */
  51446. teleportationEnabled: boolean;
  51447. private _defaultHeight;
  51448. private _teleportationInitialized;
  51449. private _interactionsEnabled;
  51450. private _interactionsRequested;
  51451. private _displayGaze;
  51452. private _displayLaserPointer;
  51453. /**
  51454. * The mesh used to display where the user is going to teleport.
  51455. */
  51456. get teleportationTarget(): Mesh;
  51457. /**
  51458. * Sets the mesh to be used to display where the user is going to teleport.
  51459. */
  51460. set teleportationTarget(value: Mesh);
  51461. /**
  51462. * 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
  51463. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51464. * See https://doc.babylonjs.com/resources/baking_transformations
  51465. */
  51466. get gazeTrackerMesh(): Mesh;
  51467. set gazeTrackerMesh(value: Mesh);
  51468. /**
  51469. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51470. */
  51471. updateGazeTrackerScale: boolean;
  51472. /**
  51473. * If the gaze trackers color should be updated when selecting meshes
  51474. */
  51475. updateGazeTrackerColor: boolean;
  51476. /**
  51477. * If the controller laser color should be updated when selecting meshes
  51478. */
  51479. updateControllerLaserColor: boolean;
  51480. /**
  51481. * The gaze tracking mesh corresponding to the left controller
  51482. */
  51483. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51484. /**
  51485. * The gaze tracking mesh corresponding to the right controller
  51486. */
  51487. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51488. /**
  51489. * If the ray of the gaze should be displayed.
  51490. */
  51491. get displayGaze(): boolean;
  51492. /**
  51493. * Sets if the ray of the gaze should be displayed.
  51494. */
  51495. set displayGaze(value: boolean);
  51496. /**
  51497. * If the ray of the LaserPointer should be displayed.
  51498. */
  51499. get displayLaserPointer(): boolean;
  51500. /**
  51501. * Sets if the ray of the LaserPointer should be displayed.
  51502. */
  51503. set displayLaserPointer(value: boolean);
  51504. /**
  51505. * The deviceOrientationCamera used as the camera when not in VR.
  51506. */
  51507. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51508. /**
  51509. * Based on the current WebVR support, returns the current VR camera used.
  51510. */
  51511. get currentVRCamera(): Nullable<Camera>;
  51512. /**
  51513. * The webVRCamera which is used when in VR.
  51514. */
  51515. get webVRCamera(): WebVRFreeCamera;
  51516. /**
  51517. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51518. */
  51519. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51520. /**
  51521. * The html button that is used to trigger entering into VR.
  51522. */
  51523. get vrButton(): Nullable<HTMLButtonElement>;
  51524. private get _teleportationRequestInitiated();
  51525. /**
  51526. * Defines whether or not Pointer lock should be requested when switching to
  51527. * full screen.
  51528. */
  51529. requestPointerLockOnFullScreen: boolean;
  51530. /**
  51531. * If asking to force XR, this will be populated with the default xr experience
  51532. */
  51533. xr: WebXRDefaultExperience;
  51534. /**
  51535. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51536. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51537. */
  51538. xrTestDone: boolean;
  51539. /**
  51540. * Instantiates a VRExperienceHelper.
  51541. * Helps to quickly add VR support to an existing scene.
  51542. * @param scene The scene the VRExperienceHelper belongs to.
  51543. * @param webVROptions Options to modify the vr experience helper's behavior.
  51544. */
  51545. constructor(scene: Scene,
  51546. /** Options to modify the vr experience helper's behavior. */
  51547. webVROptions?: VRExperienceHelperOptions);
  51548. private completeVRInit;
  51549. private _onDefaultMeshLoaded;
  51550. private _onResize;
  51551. private _onFullscreenChange;
  51552. /**
  51553. * Gets a value indicating if we are currently in VR mode.
  51554. */
  51555. get isInVRMode(): boolean;
  51556. private onVrDisplayPresentChange;
  51557. private onVRDisplayChanged;
  51558. private moveButtonToBottomRight;
  51559. private displayVRButton;
  51560. private updateButtonVisibility;
  51561. private _cachedAngularSensibility;
  51562. /**
  51563. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51564. * Otherwise, will use the fullscreen API.
  51565. */
  51566. enterVR(): void;
  51567. /**
  51568. * Attempt to exit VR, or fullscreen.
  51569. */
  51570. exitVR(): void;
  51571. /**
  51572. * The position of the vr experience helper.
  51573. */
  51574. get position(): Vector3;
  51575. /**
  51576. * Sets the position of the vr experience helper.
  51577. */
  51578. set position(value: Vector3);
  51579. /**
  51580. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51581. */
  51582. enableInteractions(): void;
  51583. private get _noControllerIsActive();
  51584. private beforeRender;
  51585. private _isTeleportationFloor;
  51586. /**
  51587. * Adds a floor mesh to be used for teleportation.
  51588. * @param floorMesh the mesh to be used for teleportation.
  51589. */
  51590. addFloorMesh(floorMesh: Mesh): void;
  51591. /**
  51592. * Removes a floor mesh from being used for teleportation.
  51593. * @param floorMesh the mesh to be removed.
  51594. */
  51595. removeFloorMesh(floorMesh: Mesh): void;
  51596. /**
  51597. * Enables interactions and teleportation using the VR controllers and gaze.
  51598. * @param vrTeleportationOptions options to modify teleportation behavior.
  51599. */
  51600. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51601. private _onNewGamepadConnected;
  51602. private _tryEnableInteractionOnController;
  51603. private _onNewGamepadDisconnected;
  51604. private _enableInteractionOnController;
  51605. private _checkTeleportWithRay;
  51606. private _checkRotate;
  51607. private _checkTeleportBackwards;
  51608. private _enableTeleportationOnController;
  51609. private _createTeleportationCircles;
  51610. private _displayTeleportationTarget;
  51611. private _hideTeleportationTarget;
  51612. private _rotateCamera;
  51613. private _moveTeleportationSelectorTo;
  51614. private _workingVector;
  51615. private _workingQuaternion;
  51616. private _workingMatrix;
  51617. /**
  51618. * Time Constant Teleportation Mode
  51619. */
  51620. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51621. /**
  51622. * Speed Constant Teleportation Mode
  51623. */
  51624. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51625. /**
  51626. * Teleports the users feet to the desired location
  51627. * @param location The location where the user's feet should be placed
  51628. */
  51629. teleportCamera(location: Vector3): void;
  51630. private _convertNormalToDirectionOfRay;
  51631. private _castRayAndSelectObject;
  51632. private _notifySelectedMeshUnselected;
  51633. /**
  51634. * Permanently set new colors for the laser pointer
  51635. * @param color the new laser color
  51636. * @param pickedColor the new laser color when picked mesh detected
  51637. */
  51638. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51639. /**
  51640. * Set lighting enabled / disabled on the laser pointer of both controllers
  51641. * @param enabled should the lighting be enabled on the laser pointer
  51642. */
  51643. setLaserLightingState(enabled?: boolean): void;
  51644. /**
  51645. * Permanently set new colors for the gaze pointer
  51646. * @param color the new gaze color
  51647. * @param pickedColor the new gaze color when picked mesh detected
  51648. */
  51649. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51650. /**
  51651. * Sets the color of the laser ray from the vr controllers.
  51652. * @param color new color for the ray.
  51653. */
  51654. changeLaserColor(color: Color3): void;
  51655. /**
  51656. * Sets the color of the ray from the vr headsets gaze.
  51657. * @param color new color for the ray.
  51658. */
  51659. changeGazeColor(color: Color3): void;
  51660. /**
  51661. * Exits VR and disposes of the vr experience helper
  51662. */
  51663. dispose(): void;
  51664. /**
  51665. * Gets the name of the VRExperienceHelper class
  51666. * @returns "VRExperienceHelper"
  51667. */
  51668. getClassName(): string;
  51669. }
  51670. }
  51671. declare module "babylonjs/Cameras/VR/index" {
  51672. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51673. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51674. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51675. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51676. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51677. export * from "babylonjs/Cameras/VR/webVRCamera";
  51678. }
  51679. declare module "babylonjs/Cameras/RigModes/index" {
  51680. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51681. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51682. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51683. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51684. }
  51685. declare module "babylonjs/Cameras/index" {
  51686. export * from "babylonjs/Cameras/Inputs/index";
  51687. export * from "babylonjs/Cameras/cameraInputsManager";
  51688. export * from "babylonjs/Cameras/camera";
  51689. export * from "babylonjs/Cameras/targetCamera";
  51690. export * from "babylonjs/Cameras/freeCamera";
  51691. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51692. export * from "babylonjs/Cameras/touchCamera";
  51693. export * from "babylonjs/Cameras/arcRotateCamera";
  51694. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51695. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51696. export * from "babylonjs/Cameras/flyCamera";
  51697. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51698. export * from "babylonjs/Cameras/followCamera";
  51699. export * from "babylonjs/Cameras/followCameraInputsManager";
  51700. export * from "babylonjs/Cameras/gamepadCamera";
  51701. export * from "babylonjs/Cameras/Stereoscopic/index";
  51702. export * from "babylonjs/Cameras/universalCamera";
  51703. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51704. export * from "babylonjs/Cameras/VR/index";
  51705. export * from "babylonjs/Cameras/RigModes/index";
  51706. }
  51707. declare module "babylonjs/Collisions/index" {
  51708. export * from "babylonjs/Collisions/collider";
  51709. export * from "babylonjs/Collisions/collisionCoordinator";
  51710. export * from "babylonjs/Collisions/pickingInfo";
  51711. export * from "babylonjs/Collisions/intersectionInfo";
  51712. export * from "babylonjs/Collisions/meshCollisionData";
  51713. }
  51714. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51715. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51716. import { Vector3 } from "babylonjs/Maths/math.vector";
  51717. import { Ray } from "babylonjs/Culling/ray";
  51718. import { Plane } from "babylonjs/Maths/math.plane";
  51719. /**
  51720. * Contains an array of blocks representing the octree
  51721. */
  51722. export interface IOctreeContainer<T> {
  51723. /**
  51724. * Blocks within the octree
  51725. */
  51726. blocks: Array<OctreeBlock<T>>;
  51727. }
  51728. /**
  51729. * Class used to store a cell in an octree
  51730. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51731. */
  51732. export class OctreeBlock<T> {
  51733. /**
  51734. * Gets the content of the current block
  51735. */
  51736. entries: T[];
  51737. /**
  51738. * Gets the list of block children
  51739. */
  51740. blocks: Array<OctreeBlock<T>>;
  51741. private _depth;
  51742. private _maxDepth;
  51743. private _capacity;
  51744. private _minPoint;
  51745. private _maxPoint;
  51746. private _boundingVectors;
  51747. private _creationFunc;
  51748. /**
  51749. * Creates a new block
  51750. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51751. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51752. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51753. * @param depth defines the current depth of this block in the octree
  51754. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51755. * @param creationFunc defines a callback to call when an element is added to the block
  51756. */
  51757. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51758. /**
  51759. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51760. */
  51761. get capacity(): number;
  51762. /**
  51763. * Gets the minimum vector (in world space) of the block's bounding box
  51764. */
  51765. get minPoint(): Vector3;
  51766. /**
  51767. * Gets the maximum vector (in world space) of the block's bounding box
  51768. */
  51769. get maxPoint(): Vector3;
  51770. /**
  51771. * Add a new element to this block
  51772. * @param entry defines the element to add
  51773. */
  51774. addEntry(entry: T): void;
  51775. /**
  51776. * Remove an element from this block
  51777. * @param entry defines the element to remove
  51778. */
  51779. removeEntry(entry: T): void;
  51780. /**
  51781. * Add an array of elements to this block
  51782. * @param entries defines the array of elements to add
  51783. */
  51784. addEntries(entries: T[]): void;
  51785. /**
  51786. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51787. * @param frustumPlanes defines the frustum planes to test
  51788. * @param selection defines the array to store current content if selection is positive
  51789. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51790. */
  51791. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51792. /**
  51793. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51794. * @param sphereCenter defines the bounding sphere center
  51795. * @param sphereRadius defines the bounding sphere radius
  51796. * @param selection defines the array to store current content if selection is positive
  51797. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51798. */
  51799. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51800. /**
  51801. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51802. * @param ray defines the ray to test with
  51803. * @param selection defines the array to store current content if selection is positive
  51804. */
  51805. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51806. /**
  51807. * Subdivide the content into child blocks (this block will then be empty)
  51808. */
  51809. createInnerBlocks(): void;
  51810. /**
  51811. * @hidden
  51812. */
  51813. 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;
  51814. }
  51815. }
  51816. declare module "babylonjs/Culling/Octrees/octree" {
  51817. import { SmartArray } from "babylonjs/Misc/smartArray";
  51818. import { Vector3 } from "babylonjs/Maths/math.vector";
  51819. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51821. import { Ray } from "babylonjs/Culling/ray";
  51822. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51823. import { Plane } from "babylonjs/Maths/math.plane";
  51824. /**
  51825. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51826. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51827. */
  51828. export class Octree<T> {
  51829. /** 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.) */
  51830. maxDepth: number;
  51831. /**
  51832. * Blocks within the octree containing objects
  51833. */
  51834. blocks: Array<OctreeBlock<T>>;
  51835. /**
  51836. * Content stored in the octree
  51837. */
  51838. dynamicContent: T[];
  51839. private _maxBlockCapacity;
  51840. private _selectionContent;
  51841. private _creationFunc;
  51842. /**
  51843. * Creates a octree
  51844. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51845. * @param creationFunc function to be used to instatiate the octree
  51846. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51847. * @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.)
  51848. */
  51849. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51850. /** 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.) */
  51851. maxDepth?: number);
  51852. /**
  51853. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51854. * @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);
  51855. * @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);
  51856. * @param entries meshes to be added to the octree blocks
  51857. */
  51858. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51859. /**
  51860. * Adds a mesh to the octree
  51861. * @param entry Mesh to add to the octree
  51862. */
  51863. addMesh(entry: T): void;
  51864. /**
  51865. * Remove an element from the octree
  51866. * @param entry defines the element to remove
  51867. */
  51868. removeMesh(entry: T): void;
  51869. /**
  51870. * Selects an array of meshes within the frustum
  51871. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51872. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51873. * @returns array of meshes within the frustum
  51874. */
  51875. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51876. /**
  51877. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51878. * @param sphereCenter defines the bounding sphere center
  51879. * @param sphereRadius defines the bounding sphere radius
  51880. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51881. * @returns an array of objects that intersect the sphere
  51882. */
  51883. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51884. /**
  51885. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51886. * @param ray defines the ray to test with
  51887. * @returns array of intersected objects
  51888. */
  51889. intersectsRay(ray: Ray): SmartArray<T>;
  51890. /**
  51891. * Adds a mesh into the octree block if it intersects the block
  51892. */
  51893. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51894. /**
  51895. * Adds a submesh into the octree block if it intersects the block
  51896. */
  51897. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51898. }
  51899. }
  51900. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51901. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51902. import { Scene } from "babylonjs/scene";
  51903. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51905. import { Ray } from "babylonjs/Culling/ray";
  51906. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51907. import { Collider } from "babylonjs/Collisions/collider";
  51908. module "babylonjs/scene" {
  51909. interface Scene {
  51910. /**
  51911. * @hidden
  51912. * Backing Filed
  51913. */
  51914. _selectionOctree: Octree<AbstractMesh>;
  51915. /**
  51916. * Gets the octree used to boost mesh selection (picking)
  51917. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51918. */
  51919. selectionOctree: Octree<AbstractMesh>;
  51920. /**
  51921. * Creates or updates the octree used to boost selection (picking)
  51922. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51923. * @param maxCapacity defines the maximum capacity per leaf
  51924. * @param maxDepth defines the maximum depth of the octree
  51925. * @returns an octree of AbstractMesh
  51926. */
  51927. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51928. }
  51929. }
  51930. module "babylonjs/Meshes/abstractMesh" {
  51931. interface AbstractMesh {
  51932. /**
  51933. * @hidden
  51934. * Backing Field
  51935. */
  51936. _submeshesOctree: Octree<SubMesh>;
  51937. /**
  51938. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51939. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51940. * @param maxCapacity defines the maximum size of each block (64 by default)
  51941. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51942. * @returns the new octree
  51943. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51945. */
  51946. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51947. }
  51948. }
  51949. /**
  51950. * Defines the octree scene component responsible to manage any octrees
  51951. * in a given scene.
  51952. */
  51953. export class OctreeSceneComponent {
  51954. /**
  51955. * The component name help to identify the component in the list of scene components.
  51956. */
  51957. readonly name: string;
  51958. /**
  51959. * The scene the component belongs to.
  51960. */
  51961. scene: Scene;
  51962. /**
  51963. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51964. */
  51965. readonly checksIsEnabled: boolean;
  51966. /**
  51967. * Creates a new instance of the component for the given scene
  51968. * @param scene Defines the scene to register the component in
  51969. */
  51970. constructor(scene: Scene);
  51971. /**
  51972. * Registers the component in a given scene
  51973. */
  51974. register(): void;
  51975. /**
  51976. * Return the list of active meshes
  51977. * @returns the list of active meshes
  51978. */
  51979. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51980. /**
  51981. * Return the list of active sub meshes
  51982. * @param mesh The mesh to get the candidates sub meshes from
  51983. * @returns the list of active sub meshes
  51984. */
  51985. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51986. private _tempRay;
  51987. /**
  51988. * Return the list of sub meshes intersecting with a given local ray
  51989. * @param mesh defines the mesh to find the submesh for
  51990. * @param localRay defines the ray in local space
  51991. * @returns the list of intersecting sub meshes
  51992. */
  51993. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51994. /**
  51995. * Return the list of sub meshes colliding with a collider
  51996. * @param mesh defines the mesh to find the submesh for
  51997. * @param collider defines the collider to evaluate the collision against
  51998. * @returns the list of colliding sub meshes
  51999. */
  52000. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52001. /**
  52002. * Rebuilds the elements related to this component in case of
  52003. * context lost for instance.
  52004. */
  52005. rebuild(): void;
  52006. /**
  52007. * Disposes the component and the associated ressources.
  52008. */
  52009. dispose(): void;
  52010. }
  52011. }
  52012. declare module "babylonjs/Culling/Octrees/index" {
  52013. export * from "babylonjs/Culling/Octrees/octree";
  52014. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52015. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52016. }
  52017. declare module "babylonjs/Culling/index" {
  52018. export * from "babylonjs/Culling/boundingBox";
  52019. export * from "babylonjs/Culling/boundingInfo";
  52020. export * from "babylonjs/Culling/boundingSphere";
  52021. export * from "babylonjs/Culling/Octrees/index";
  52022. export * from "babylonjs/Culling/ray";
  52023. }
  52024. declare module "babylonjs/Gizmos/gizmo" {
  52025. import { Nullable } from "babylonjs/types";
  52026. import { IDisposable } from "babylonjs/scene";
  52027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52028. import { Mesh } from "babylonjs/Meshes/mesh";
  52029. import { Node } from "babylonjs/node";
  52030. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52031. /**
  52032. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52033. */
  52034. export class Gizmo implements IDisposable {
  52035. /** The utility layer the gizmo will be added to */
  52036. gizmoLayer: UtilityLayerRenderer;
  52037. /**
  52038. * The root mesh of the gizmo
  52039. */
  52040. _rootMesh: Mesh;
  52041. private _attachedMesh;
  52042. private _attachedNode;
  52043. /**
  52044. * Ratio for the scale of the gizmo (Default: 1)
  52045. */
  52046. scaleRatio: number;
  52047. /**
  52048. * If a custom mesh has been set (Default: false)
  52049. */
  52050. protected _customMeshSet: boolean;
  52051. /**
  52052. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52053. * * When set, interactions will be enabled
  52054. */
  52055. get attachedMesh(): Nullable<AbstractMesh>;
  52056. set attachedMesh(value: Nullable<AbstractMesh>);
  52057. /**
  52058. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52059. * * When set, interactions will be enabled
  52060. */
  52061. get attachedNode(): Nullable<Node>;
  52062. set attachedNode(value: Nullable<Node>);
  52063. /**
  52064. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52065. * @param mesh The mesh to replace the default mesh of the gizmo
  52066. */
  52067. setCustomMesh(mesh: Mesh): void;
  52068. /**
  52069. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52070. */
  52071. updateGizmoRotationToMatchAttachedMesh: boolean;
  52072. /**
  52073. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52074. */
  52075. updateGizmoPositionToMatchAttachedMesh: boolean;
  52076. /**
  52077. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52078. */
  52079. updateScale: boolean;
  52080. protected _interactionsEnabled: boolean;
  52081. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52082. private _beforeRenderObserver;
  52083. private _tempVector;
  52084. /**
  52085. * Creates a gizmo
  52086. * @param gizmoLayer The utility layer the gizmo will be added to
  52087. */
  52088. constructor(
  52089. /** The utility layer the gizmo will be added to */
  52090. gizmoLayer?: UtilityLayerRenderer);
  52091. /**
  52092. * Updates the gizmo to match the attached mesh's position/rotation
  52093. */
  52094. protected _update(): void;
  52095. /**
  52096. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52097. * @param value Node, TransformNode or mesh
  52098. */
  52099. protected _matrixChanged(): void;
  52100. /**
  52101. * Disposes of the gizmo
  52102. */
  52103. dispose(): void;
  52104. }
  52105. }
  52106. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52107. import { Observable } from "babylonjs/Misc/observable";
  52108. import { Nullable } from "babylonjs/types";
  52109. import { Vector3 } from "babylonjs/Maths/math.vector";
  52110. import { Color3 } from "babylonjs/Maths/math.color";
  52111. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52112. import { Node } from "babylonjs/node";
  52113. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52114. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52115. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52116. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52117. import { Scene } from "babylonjs/scene";
  52118. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52119. /**
  52120. * Single plane drag gizmo
  52121. */
  52122. export class PlaneDragGizmo extends Gizmo {
  52123. /**
  52124. * Drag behavior responsible for the gizmos dragging interactions
  52125. */
  52126. dragBehavior: PointerDragBehavior;
  52127. private _pointerObserver;
  52128. /**
  52129. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52130. */
  52131. snapDistance: number;
  52132. /**
  52133. * Event that fires each time the gizmo snaps to a new location.
  52134. * * snapDistance is the the change in distance
  52135. */
  52136. onSnapObservable: Observable<{
  52137. snapDistance: number;
  52138. }>;
  52139. private _plane;
  52140. private _coloredMaterial;
  52141. private _hoverMaterial;
  52142. private _isEnabled;
  52143. private _parent;
  52144. /** @hidden */
  52145. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52146. /** @hidden */
  52147. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52148. /**
  52149. * Creates a PlaneDragGizmo
  52150. * @param gizmoLayer The utility layer the gizmo will be added to
  52151. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52152. * @param color The color of the gizmo
  52153. */
  52154. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52155. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52156. /**
  52157. * If the gizmo is enabled
  52158. */
  52159. set isEnabled(value: boolean);
  52160. get isEnabled(): boolean;
  52161. /**
  52162. * Disposes of the gizmo
  52163. */
  52164. dispose(): void;
  52165. }
  52166. }
  52167. declare module "babylonjs/Gizmos/positionGizmo" {
  52168. import { Observable } from "babylonjs/Misc/observable";
  52169. import { Nullable } from "babylonjs/types";
  52170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52171. import { Node } from "babylonjs/node";
  52172. import { Mesh } from "babylonjs/Meshes/mesh";
  52173. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52174. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52175. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52176. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52177. /**
  52178. * Gizmo that enables dragging a mesh along 3 axis
  52179. */
  52180. export class PositionGizmo extends Gizmo {
  52181. /**
  52182. * Internal gizmo used for interactions on the x axis
  52183. */
  52184. xGizmo: AxisDragGizmo;
  52185. /**
  52186. * Internal gizmo used for interactions on the y axis
  52187. */
  52188. yGizmo: AxisDragGizmo;
  52189. /**
  52190. * Internal gizmo used for interactions on the z axis
  52191. */
  52192. zGizmo: AxisDragGizmo;
  52193. /**
  52194. * Internal gizmo used for interactions on the yz plane
  52195. */
  52196. xPlaneGizmo: PlaneDragGizmo;
  52197. /**
  52198. * Internal gizmo used for interactions on the xz plane
  52199. */
  52200. yPlaneGizmo: PlaneDragGizmo;
  52201. /**
  52202. * Internal gizmo used for interactions on the xy plane
  52203. */
  52204. zPlaneGizmo: PlaneDragGizmo;
  52205. /**
  52206. * private variables
  52207. */
  52208. private _meshAttached;
  52209. private _nodeAttached;
  52210. private _updateGizmoRotationToMatchAttachedMesh;
  52211. private _snapDistance;
  52212. private _scaleRatio;
  52213. /** Fires an event when any of it's sub gizmos are dragged */
  52214. onDragStartObservable: Observable<unknown>;
  52215. /** Fires an event when any of it's sub gizmos are released from dragging */
  52216. onDragEndObservable: Observable<unknown>;
  52217. /**
  52218. * If set to true, planar drag is enabled
  52219. */
  52220. private _planarGizmoEnabled;
  52221. get attachedMesh(): Nullable<AbstractMesh>;
  52222. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52223. get attachedNode(): Nullable<Node>;
  52224. set attachedNode(node: Nullable<Node>);
  52225. /**
  52226. * Creates a PositionGizmo
  52227. * @param gizmoLayer The utility layer the gizmo will be added to
  52228. @param thickness display gizmo axis thickness
  52229. */
  52230. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52231. /**
  52232. * If the planar drag gizmo is enabled
  52233. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52234. */
  52235. set planarGizmoEnabled(value: boolean);
  52236. get planarGizmoEnabled(): boolean;
  52237. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52238. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52239. /**
  52240. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52241. */
  52242. set snapDistance(value: number);
  52243. get snapDistance(): number;
  52244. /**
  52245. * Ratio for the scale of the gizmo (Default: 1)
  52246. */
  52247. set scaleRatio(value: number);
  52248. get scaleRatio(): number;
  52249. /**
  52250. * Disposes of the gizmo
  52251. */
  52252. dispose(): void;
  52253. /**
  52254. * CustomMeshes are not supported by this gizmo
  52255. * @param mesh The mesh to replace the default mesh of the gizmo
  52256. */
  52257. setCustomMesh(mesh: Mesh): void;
  52258. }
  52259. }
  52260. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52261. import { Observable } from "babylonjs/Misc/observable";
  52262. import { Nullable } from "babylonjs/types";
  52263. import { Vector3 } from "babylonjs/Maths/math.vector";
  52264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52265. import { Node } from "babylonjs/node";
  52266. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52267. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52269. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52270. import { Scene } from "babylonjs/scene";
  52271. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52272. import { Color3 } from "babylonjs/Maths/math.color";
  52273. /**
  52274. * Single axis drag gizmo
  52275. */
  52276. export class AxisDragGizmo extends Gizmo {
  52277. /**
  52278. * Drag behavior responsible for the gizmos dragging interactions
  52279. */
  52280. dragBehavior: PointerDragBehavior;
  52281. private _pointerObserver;
  52282. /**
  52283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52284. */
  52285. snapDistance: number;
  52286. /**
  52287. * Event that fires each time the gizmo snaps to a new location.
  52288. * * snapDistance is the the change in distance
  52289. */
  52290. onSnapObservable: Observable<{
  52291. snapDistance: number;
  52292. }>;
  52293. private _isEnabled;
  52294. private _parent;
  52295. private _arrow;
  52296. private _coloredMaterial;
  52297. private _hoverMaterial;
  52298. /** @hidden */
  52299. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52300. /** @hidden */
  52301. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52302. /**
  52303. * Creates an AxisDragGizmo
  52304. * @param gizmoLayer The utility layer the gizmo will be added to
  52305. * @param dragAxis The axis which the gizmo will be able to drag on
  52306. * @param color The color of the gizmo
  52307. * @param thickness display gizmo axis thickness
  52308. */
  52309. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52310. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52311. /**
  52312. * If the gizmo is enabled
  52313. */
  52314. set isEnabled(value: boolean);
  52315. get isEnabled(): boolean;
  52316. /**
  52317. * Disposes of the gizmo
  52318. */
  52319. dispose(): void;
  52320. }
  52321. }
  52322. declare module "babylonjs/Debug/axesViewer" {
  52323. import { Vector3 } from "babylonjs/Maths/math.vector";
  52324. import { Nullable } from "babylonjs/types";
  52325. import { Scene } from "babylonjs/scene";
  52326. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52327. /**
  52328. * The Axes viewer will show 3 axes in a specific point in space
  52329. */
  52330. export class AxesViewer {
  52331. private _xAxis;
  52332. private _yAxis;
  52333. private _zAxis;
  52334. private _scaleLinesFactor;
  52335. private _instanced;
  52336. /**
  52337. * Gets the hosting scene
  52338. */
  52339. scene: Scene;
  52340. /**
  52341. * Gets or sets a number used to scale line length
  52342. */
  52343. scaleLines: number;
  52344. /** Gets the node hierarchy used to render x-axis */
  52345. get xAxis(): TransformNode;
  52346. /** Gets the node hierarchy used to render y-axis */
  52347. get yAxis(): TransformNode;
  52348. /** Gets the node hierarchy used to render z-axis */
  52349. get zAxis(): TransformNode;
  52350. /**
  52351. * Creates a new AxesViewer
  52352. * @param scene defines the hosting scene
  52353. * @param scaleLines defines a number used to scale line length (1 by default)
  52354. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52355. * @param xAxis defines the node hierarchy used to render the x-axis
  52356. * @param yAxis defines the node hierarchy used to render the y-axis
  52357. * @param zAxis defines the node hierarchy used to render the z-axis
  52358. */
  52359. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52360. /**
  52361. * Force the viewer to update
  52362. * @param position defines the position of the viewer
  52363. * @param xaxis defines the x axis of the viewer
  52364. * @param yaxis defines the y axis of the viewer
  52365. * @param zaxis defines the z axis of the viewer
  52366. */
  52367. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52368. /**
  52369. * Creates an instance of this axes viewer.
  52370. * @returns a new axes viewer with instanced meshes
  52371. */
  52372. createInstance(): AxesViewer;
  52373. /** Releases resources */
  52374. dispose(): void;
  52375. private static _SetRenderingGroupId;
  52376. }
  52377. }
  52378. declare module "babylonjs/Debug/boneAxesViewer" {
  52379. import { Nullable } from "babylonjs/types";
  52380. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52381. import { Vector3 } from "babylonjs/Maths/math.vector";
  52382. import { Mesh } from "babylonjs/Meshes/mesh";
  52383. import { Bone } from "babylonjs/Bones/bone";
  52384. import { Scene } from "babylonjs/scene";
  52385. /**
  52386. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52387. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52388. */
  52389. export class BoneAxesViewer extends AxesViewer {
  52390. /**
  52391. * Gets or sets the target mesh where to display the axes viewer
  52392. */
  52393. mesh: Nullable<Mesh>;
  52394. /**
  52395. * Gets or sets the target bone where to display the axes viewer
  52396. */
  52397. bone: Nullable<Bone>;
  52398. /** Gets current position */
  52399. pos: Vector3;
  52400. /** Gets direction of X axis */
  52401. xaxis: Vector3;
  52402. /** Gets direction of Y axis */
  52403. yaxis: Vector3;
  52404. /** Gets direction of Z axis */
  52405. zaxis: Vector3;
  52406. /**
  52407. * Creates a new BoneAxesViewer
  52408. * @param scene defines the hosting scene
  52409. * @param bone defines the target bone
  52410. * @param mesh defines the target mesh
  52411. * @param scaleLines defines a scaling factor for line length (1 by default)
  52412. */
  52413. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52414. /**
  52415. * Force the viewer to update
  52416. */
  52417. update(): void;
  52418. /** Releases resources */
  52419. dispose(): void;
  52420. }
  52421. }
  52422. declare module "babylonjs/Debug/debugLayer" {
  52423. import { Scene } from "babylonjs/scene";
  52424. /**
  52425. * Interface used to define scene explorer extensibility option
  52426. */
  52427. export interface IExplorerExtensibilityOption {
  52428. /**
  52429. * Define the option label
  52430. */
  52431. label: string;
  52432. /**
  52433. * Defines the action to execute on click
  52434. */
  52435. action: (entity: any) => void;
  52436. }
  52437. /**
  52438. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52439. */
  52440. export interface IExplorerExtensibilityGroup {
  52441. /**
  52442. * Defines a predicate to test if a given type mut be extended
  52443. */
  52444. predicate: (entity: any) => boolean;
  52445. /**
  52446. * Gets the list of options added to a type
  52447. */
  52448. entries: IExplorerExtensibilityOption[];
  52449. }
  52450. /**
  52451. * Interface used to define the options to use to create the Inspector
  52452. */
  52453. export interface IInspectorOptions {
  52454. /**
  52455. * Display in overlay mode (default: false)
  52456. */
  52457. overlay?: boolean;
  52458. /**
  52459. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52460. */
  52461. globalRoot?: HTMLElement;
  52462. /**
  52463. * Display the Scene explorer
  52464. */
  52465. showExplorer?: boolean;
  52466. /**
  52467. * Display the property inspector
  52468. */
  52469. showInspector?: boolean;
  52470. /**
  52471. * Display in embed mode (both panes on the right)
  52472. */
  52473. embedMode?: boolean;
  52474. /**
  52475. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52476. */
  52477. handleResize?: boolean;
  52478. /**
  52479. * Allow the panes to popup (default: true)
  52480. */
  52481. enablePopup?: boolean;
  52482. /**
  52483. * Allow the panes to be closed by users (default: true)
  52484. */
  52485. enableClose?: boolean;
  52486. /**
  52487. * Optional list of extensibility entries
  52488. */
  52489. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52490. /**
  52491. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52492. */
  52493. inspectorURL?: string;
  52494. /**
  52495. * Optional initial tab (default to DebugLayerTab.Properties)
  52496. */
  52497. initialTab?: DebugLayerTab;
  52498. }
  52499. module "babylonjs/scene" {
  52500. interface Scene {
  52501. /**
  52502. * @hidden
  52503. * Backing field
  52504. */
  52505. _debugLayer: DebugLayer;
  52506. /**
  52507. * Gets the debug layer (aka Inspector) associated with the scene
  52508. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52509. */
  52510. debugLayer: DebugLayer;
  52511. }
  52512. }
  52513. /**
  52514. * Enum of inspector action tab
  52515. */
  52516. export enum DebugLayerTab {
  52517. /**
  52518. * Properties tag (default)
  52519. */
  52520. Properties = 0,
  52521. /**
  52522. * Debug tab
  52523. */
  52524. Debug = 1,
  52525. /**
  52526. * Statistics tab
  52527. */
  52528. Statistics = 2,
  52529. /**
  52530. * Tools tab
  52531. */
  52532. Tools = 3,
  52533. /**
  52534. * Settings tab
  52535. */
  52536. Settings = 4
  52537. }
  52538. /**
  52539. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52540. * what is happening in your scene
  52541. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52542. */
  52543. export class DebugLayer {
  52544. /**
  52545. * Define the url to get the inspector script from.
  52546. * By default it uses the babylonjs CDN.
  52547. * @ignoreNaming
  52548. */
  52549. static InspectorURL: string;
  52550. private _scene;
  52551. private BJSINSPECTOR;
  52552. private _onPropertyChangedObservable?;
  52553. /**
  52554. * Observable triggered when a property is changed through the inspector.
  52555. */
  52556. get onPropertyChangedObservable(): any;
  52557. /**
  52558. * Instantiates a new debug layer.
  52559. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52560. * what is happening in your scene
  52561. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52562. * @param scene Defines the scene to inspect
  52563. */
  52564. constructor(scene: Scene);
  52565. /** Creates the inspector window. */
  52566. private _createInspector;
  52567. /**
  52568. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52569. * @param entity defines the entity to select
  52570. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52571. */
  52572. select(entity: any, lineContainerTitles?: string | string[]): void;
  52573. /** Get the inspector from bundle or global */
  52574. private _getGlobalInspector;
  52575. /**
  52576. * Get if the inspector is visible or not.
  52577. * @returns true if visible otherwise, false
  52578. */
  52579. isVisible(): boolean;
  52580. /**
  52581. * Hide the inspector and close its window.
  52582. */
  52583. hide(): void;
  52584. /**
  52585. * Update the scene in the inspector
  52586. */
  52587. setAsActiveScene(): void;
  52588. /**
  52589. * Launch the debugLayer.
  52590. * @param config Define the configuration of the inspector
  52591. * @return a promise fulfilled when the debug layer is visible
  52592. */
  52593. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52594. }
  52595. }
  52596. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52597. import { Nullable } from "babylonjs/types";
  52598. import { Scene } from "babylonjs/scene";
  52599. import { Vector4 } from "babylonjs/Maths/math.vector";
  52600. import { Color4 } from "babylonjs/Maths/math.color";
  52601. import { Mesh } from "babylonjs/Meshes/mesh";
  52602. /**
  52603. * Class containing static functions to help procedurally build meshes
  52604. */
  52605. export class BoxBuilder {
  52606. /**
  52607. * Creates a box mesh
  52608. * * The parameter `size` sets the size (float) of each box side (default 1)
  52609. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52610. * * 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)
  52611. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52615. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52616. * @param name defines the name of the mesh
  52617. * @param options defines the options used to create the mesh
  52618. * @param scene defines the hosting scene
  52619. * @returns the box mesh
  52620. */
  52621. static CreateBox(name: string, options: {
  52622. size?: number;
  52623. width?: number;
  52624. height?: number;
  52625. depth?: number;
  52626. faceUV?: Vector4[];
  52627. faceColors?: Color4[];
  52628. sideOrientation?: number;
  52629. frontUVs?: Vector4;
  52630. backUVs?: Vector4;
  52631. wrap?: boolean;
  52632. topBaseAt?: number;
  52633. bottomBaseAt?: number;
  52634. updatable?: boolean;
  52635. }, scene?: Nullable<Scene>): Mesh;
  52636. }
  52637. }
  52638. declare module "babylonjs/Debug/physicsViewer" {
  52639. import { Nullable } from "babylonjs/types";
  52640. import { Scene } from "babylonjs/scene";
  52641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52642. import { Mesh } from "babylonjs/Meshes/mesh";
  52643. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52644. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52645. /**
  52646. * Used to show the physics impostor around the specific mesh
  52647. */
  52648. export class PhysicsViewer {
  52649. /** @hidden */
  52650. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52651. /** @hidden */
  52652. protected _meshes: Array<Nullable<AbstractMesh>>;
  52653. /** @hidden */
  52654. protected _scene: Nullable<Scene>;
  52655. /** @hidden */
  52656. protected _numMeshes: number;
  52657. /** @hidden */
  52658. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52659. private _renderFunction;
  52660. private _utilityLayer;
  52661. private _debugBoxMesh;
  52662. private _debugSphereMesh;
  52663. private _debugCylinderMesh;
  52664. private _debugMaterial;
  52665. private _debugMeshMeshes;
  52666. /**
  52667. * Creates a new PhysicsViewer
  52668. * @param scene defines the hosting scene
  52669. */
  52670. constructor(scene: Scene);
  52671. /** @hidden */
  52672. protected _updateDebugMeshes(): void;
  52673. /**
  52674. * Renders a specified physic impostor
  52675. * @param impostor defines the impostor to render
  52676. * @param targetMesh defines the mesh represented by the impostor
  52677. * @returns the new debug mesh used to render the impostor
  52678. */
  52679. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52680. /**
  52681. * Hides a specified physic impostor
  52682. * @param impostor defines the impostor to hide
  52683. */
  52684. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52685. private _getDebugMaterial;
  52686. private _getDebugBoxMesh;
  52687. private _getDebugSphereMesh;
  52688. private _getDebugCylinderMesh;
  52689. private _getDebugMeshMesh;
  52690. private _getDebugMesh;
  52691. /** Releases all resources */
  52692. dispose(): void;
  52693. }
  52694. }
  52695. declare module "babylonjs/Debug/rayHelper" {
  52696. import { Nullable } from "babylonjs/types";
  52697. import { Ray } from "babylonjs/Culling/ray";
  52698. import { Vector3 } from "babylonjs/Maths/math.vector";
  52699. import { Color3 } from "babylonjs/Maths/math.color";
  52700. import { Scene } from "babylonjs/scene";
  52701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52702. import "babylonjs/Meshes/Builders/linesBuilder";
  52703. /**
  52704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52705. * in order to better appreciate the issue one might have.
  52706. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52707. */
  52708. export class RayHelper {
  52709. /**
  52710. * Defines the ray we are currently tryin to visualize.
  52711. */
  52712. ray: Nullable<Ray>;
  52713. private _renderPoints;
  52714. private _renderLine;
  52715. private _renderFunction;
  52716. private _scene;
  52717. private _updateToMeshFunction;
  52718. private _attachedToMesh;
  52719. private _meshSpaceDirection;
  52720. private _meshSpaceOrigin;
  52721. /**
  52722. * Helper function to create a colored helper in a scene in one line.
  52723. * @param ray Defines the ray we are currently tryin to visualize
  52724. * @param scene Defines the scene the ray is used in
  52725. * @param color Defines the color we want to see the ray in
  52726. * @returns The newly created ray helper.
  52727. */
  52728. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52729. /**
  52730. * Instantiate a new ray helper.
  52731. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52732. * in order to better appreciate the issue one might have.
  52733. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52734. * @param ray Defines the ray we are currently tryin to visualize
  52735. */
  52736. constructor(ray: Ray);
  52737. /**
  52738. * Shows the ray we are willing to debug.
  52739. * @param scene Defines the scene the ray needs to be rendered in
  52740. * @param color Defines the color the ray needs to be rendered in
  52741. */
  52742. show(scene: Scene, color?: Color3): void;
  52743. /**
  52744. * Hides the ray we are debugging.
  52745. */
  52746. hide(): void;
  52747. private _render;
  52748. /**
  52749. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52750. * @param mesh Defines the mesh we want the helper attached to
  52751. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52752. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52753. * @param length Defines the length of the ray
  52754. */
  52755. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52756. /**
  52757. * Detach the ray helper from the mesh it has previously been attached to.
  52758. */
  52759. detachFromMesh(): void;
  52760. private _updateToMesh;
  52761. /**
  52762. * Dispose the helper and release its associated resources.
  52763. */
  52764. dispose(): void;
  52765. }
  52766. }
  52767. declare module "babylonjs/Debug/ISkeletonViewer" {
  52768. /**
  52769. * Defines the options associated with the creation of a SkeletonViewer.
  52770. */
  52771. export interface ISkeletonViewerOptions {
  52772. /** Should the system pause animations before building the Viewer? */
  52773. pauseAnimations: boolean;
  52774. /** Should the system return the skeleton to rest before building? */
  52775. returnToRest: boolean;
  52776. /** public Display Mode of the Viewer */
  52777. displayMode: number;
  52778. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52779. displayOptions: ISkeletonViewerDisplayOptions;
  52780. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52781. computeBonesUsingShaders: boolean;
  52782. }
  52783. /**
  52784. * Defines how to display the various bone meshes for the viewer.
  52785. */
  52786. export interface ISkeletonViewerDisplayOptions {
  52787. /** How far down to start tapering the bone spurs */
  52788. midStep?: number;
  52789. /** How big is the midStep? */
  52790. midStepFactor?: number;
  52791. /** Base for the Sphere Size */
  52792. sphereBaseSize?: number;
  52793. /** The ratio of the sphere to the longest bone in units */
  52794. sphereScaleUnit?: number;
  52795. /** Ratio for the Sphere Size */
  52796. sphereFactor?: number;
  52797. }
  52798. }
  52799. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52800. import { Nullable } from "babylonjs/types";
  52801. import { Scene } from "babylonjs/scene";
  52802. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52803. import { Color4 } from "babylonjs/Maths/math.color";
  52804. import { Mesh } from "babylonjs/Meshes/mesh";
  52805. /**
  52806. * Class containing static functions to help procedurally build meshes
  52807. */
  52808. export class RibbonBuilder {
  52809. /**
  52810. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52811. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52812. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52813. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52814. * * 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
  52815. * * 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
  52816. * * 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
  52817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52820. * * 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
  52821. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52822. * * 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
  52823. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52825. * @param name defines the name of the mesh
  52826. * @param options defines the options used to create the mesh
  52827. * @param scene defines the hosting scene
  52828. * @returns the ribbon mesh
  52829. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52830. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52831. */
  52832. static CreateRibbon(name: string, options: {
  52833. pathArray: Vector3[][];
  52834. closeArray?: boolean;
  52835. closePath?: boolean;
  52836. offset?: number;
  52837. updatable?: boolean;
  52838. sideOrientation?: number;
  52839. frontUVs?: Vector4;
  52840. backUVs?: Vector4;
  52841. instance?: Mesh;
  52842. invertUV?: boolean;
  52843. uvs?: Vector2[];
  52844. colors?: Color4[];
  52845. }, scene?: Nullable<Scene>): Mesh;
  52846. }
  52847. }
  52848. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52849. import { Nullable } from "babylonjs/types";
  52850. import { Scene } from "babylonjs/scene";
  52851. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52852. import { Mesh } from "babylonjs/Meshes/mesh";
  52853. /**
  52854. * Class containing static functions to help procedurally build meshes
  52855. */
  52856. export class ShapeBuilder {
  52857. /**
  52858. * 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.
  52859. * * 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.
  52860. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52861. * * 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.
  52862. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52863. * * 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
  52864. * * 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
  52865. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52870. * @param name defines the name of the mesh
  52871. * @param options defines the options used to create the mesh
  52872. * @param scene defines the hosting scene
  52873. * @returns the extruded shape mesh
  52874. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52876. */
  52877. static ExtrudeShape(name: string, options: {
  52878. shape: Vector3[];
  52879. path: Vector3[];
  52880. scale?: number;
  52881. rotation?: number;
  52882. cap?: number;
  52883. updatable?: boolean;
  52884. sideOrientation?: number;
  52885. frontUVs?: Vector4;
  52886. backUVs?: Vector4;
  52887. instance?: Mesh;
  52888. invertUV?: boolean;
  52889. }, scene?: Nullable<Scene>): Mesh;
  52890. /**
  52891. * Creates an custom extruded shape mesh.
  52892. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52893. * * 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.
  52894. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52895. * * 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
  52896. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52897. * * 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
  52898. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52899. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52900. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52901. * * 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
  52902. * * 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
  52903. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52908. * @param name defines the name of the mesh
  52909. * @param options defines the options used to create the mesh
  52910. * @param scene defines the hosting scene
  52911. * @returns the custom extruded shape mesh
  52912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52915. */
  52916. static ExtrudeShapeCustom(name: string, options: {
  52917. shape: Vector3[];
  52918. path: Vector3[];
  52919. scaleFunction?: any;
  52920. rotationFunction?: any;
  52921. ribbonCloseArray?: boolean;
  52922. ribbonClosePath?: boolean;
  52923. cap?: number;
  52924. updatable?: boolean;
  52925. sideOrientation?: number;
  52926. frontUVs?: Vector4;
  52927. backUVs?: Vector4;
  52928. instance?: Mesh;
  52929. invertUV?: boolean;
  52930. }, scene?: Nullable<Scene>): Mesh;
  52931. private static _ExtrudeShapeGeneric;
  52932. }
  52933. }
  52934. declare module "babylonjs/Debug/skeletonViewer" {
  52935. import { Color3 } from "babylonjs/Maths/math.color";
  52936. import { Scene } from "babylonjs/scene";
  52937. import { Nullable } from "babylonjs/types";
  52938. import { Skeleton } from "babylonjs/Bones/skeleton";
  52939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52940. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52941. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52942. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52943. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  52944. /**
  52945. * Class used to render a debug view of a given skeleton
  52946. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52947. */
  52948. export class SkeletonViewer {
  52949. /** defines the skeleton to render */
  52950. skeleton: Skeleton;
  52951. /** defines the mesh attached to the skeleton */
  52952. mesh: AbstractMesh;
  52953. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52954. autoUpdateBonesMatrices: boolean;
  52955. /** defines the rendering group id to use with the viewer */
  52956. renderingGroupId: number;
  52957. /** is the options for the viewer */
  52958. options: Partial<ISkeletonViewerOptions>;
  52959. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  52960. static readonly DISPLAY_LINES: number;
  52961. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  52962. static readonly DISPLAY_SPHERES: number;
  52963. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  52964. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  52965. /** If SkeletonViewer scene scope. */
  52966. private _scene;
  52967. /** Gets or sets the color used to render the skeleton */
  52968. color: Color3;
  52969. /** Array of the points of the skeleton fo the line view. */
  52970. private _debugLines;
  52971. /** The SkeletonViewers Mesh. */
  52972. private _debugMesh;
  52973. /** If SkeletonViewer is enabled. */
  52974. private _isEnabled;
  52975. /** If SkeletonViewer is ready. */
  52976. private _ready;
  52977. /** SkeletonViewer render observable. */
  52978. private _obs;
  52979. /** The Utility Layer to render the gizmos in. */
  52980. private _utilityLayer;
  52981. /** Gets the Scene. */
  52982. get scene(): Scene;
  52983. /** Gets the utilityLayer. */
  52984. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  52985. /** Checks Ready Status. */
  52986. get isReady(): Boolean;
  52987. /** Sets Ready Status. */
  52988. set ready(value: boolean);
  52989. /** Gets the debugMesh */
  52990. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  52991. /** Sets the debugMesh */
  52992. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  52993. /** Gets the material */
  52994. get material(): StandardMaterial;
  52995. /** Sets the material */
  52996. set material(value: StandardMaterial);
  52997. /**
  52998. * Creates a new SkeletonViewer
  52999. * @param skeleton defines the skeleton to render
  53000. * @param mesh defines the mesh attached to the skeleton
  53001. * @param scene defines the hosting scene
  53002. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53003. * @param renderingGroupId defines the rendering group id to use with the viewer
  53004. * @param options All of the extra constructor options for the SkeletonViewer
  53005. */
  53006. constructor(
  53007. /** defines the skeleton to render */
  53008. skeleton: Skeleton,
  53009. /** defines the mesh attached to the skeleton */
  53010. mesh: AbstractMesh,
  53011. /** The Scene scope*/
  53012. scene: Scene,
  53013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53014. autoUpdateBonesMatrices?: boolean,
  53015. /** defines the rendering group id to use with the viewer */
  53016. renderingGroupId?: number,
  53017. /** is the options for the viewer */
  53018. options?: Partial<ISkeletonViewerOptions>);
  53019. /** The Dynamic bindings for the update functions */
  53020. private _bindObs;
  53021. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53022. update(): void;
  53023. /** Gets or sets a boolean indicating if the viewer is enabled */
  53024. set isEnabled(value: boolean);
  53025. get isEnabled(): boolean;
  53026. private _getBonePosition;
  53027. private _getLinesForBonesWithLength;
  53028. private _getLinesForBonesNoLength;
  53029. /** function to revert the mesh and scene back to the initial state. */
  53030. private _revert;
  53031. /** function to build and bind sphere joint points and spur bone representations. */
  53032. private _buildSpheresAndSpurs;
  53033. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53034. private _displayLinesUpdate;
  53035. /** Release associated resources */
  53036. dispose(): void;
  53037. }
  53038. }
  53039. declare module "babylonjs/Debug/index" {
  53040. export * from "babylonjs/Debug/axesViewer";
  53041. export * from "babylonjs/Debug/boneAxesViewer";
  53042. export * from "babylonjs/Debug/debugLayer";
  53043. export * from "babylonjs/Debug/physicsViewer";
  53044. export * from "babylonjs/Debug/rayHelper";
  53045. export * from "babylonjs/Debug/skeletonViewer";
  53046. export * from "babylonjs/Debug/ISkeletonViewer";
  53047. }
  53048. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53049. /**
  53050. * Enum for Device Types
  53051. */
  53052. export enum DeviceType {
  53053. /** Generic */
  53054. Generic = 0,
  53055. /** Keyboard */
  53056. Keyboard = 1,
  53057. /** Mouse */
  53058. Mouse = 2,
  53059. /** Touch Pointers */
  53060. Touch = 3,
  53061. /** PS4 Dual Shock */
  53062. DualShock = 4,
  53063. /** Xbox */
  53064. Xbox = 5,
  53065. /** Switch Controller */
  53066. Switch = 6
  53067. }
  53068. /**
  53069. * Enum for All Pointers (Touch/Mouse)
  53070. */
  53071. export enum PointerInput {
  53072. /** Horizontal Axis */
  53073. Horizontal = 0,
  53074. /** Vertical Axis */
  53075. Vertical = 1,
  53076. /** Left Click or Touch */
  53077. LeftClick = 2,
  53078. /** Middle Click */
  53079. MiddleClick = 3,
  53080. /** Right Click */
  53081. RightClick = 4,
  53082. /** Browser Back */
  53083. BrowserBack = 5,
  53084. /** Browser Forward */
  53085. BrowserForward = 6
  53086. }
  53087. /**
  53088. * Enum for Dual Shock Gamepad
  53089. */
  53090. export enum DualShockInput {
  53091. /** Cross */
  53092. Cross = 0,
  53093. /** Circle */
  53094. Circle = 1,
  53095. /** Square */
  53096. Square = 2,
  53097. /** Triangle */
  53098. Triangle = 3,
  53099. /** L1 */
  53100. L1 = 4,
  53101. /** R1 */
  53102. R1 = 5,
  53103. /** L2 */
  53104. L2 = 6,
  53105. /** R2 */
  53106. R2 = 7,
  53107. /** Share */
  53108. Share = 8,
  53109. /** Options */
  53110. Options = 9,
  53111. /** L3 */
  53112. L3 = 10,
  53113. /** R3 */
  53114. R3 = 11,
  53115. /** DPadUp */
  53116. DPadUp = 12,
  53117. /** DPadDown */
  53118. DPadDown = 13,
  53119. /** DPadLeft */
  53120. DPadLeft = 14,
  53121. /** DRight */
  53122. DPadRight = 15,
  53123. /** Home */
  53124. Home = 16,
  53125. /** TouchPad */
  53126. TouchPad = 17,
  53127. /** LStickXAxis */
  53128. LStickXAxis = 18,
  53129. /** LStickYAxis */
  53130. LStickYAxis = 19,
  53131. /** RStickXAxis */
  53132. RStickXAxis = 20,
  53133. /** RStickYAxis */
  53134. RStickYAxis = 21
  53135. }
  53136. /**
  53137. * Enum for Xbox Gamepad
  53138. */
  53139. export enum XboxInput {
  53140. /** A */
  53141. A = 0,
  53142. /** B */
  53143. B = 1,
  53144. /** X */
  53145. X = 2,
  53146. /** Y */
  53147. Y = 3,
  53148. /** LB */
  53149. LB = 4,
  53150. /** RB */
  53151. RB = 5,
  53152. /** LT */
  53153. LT = 6,
  53154. /** RT */
  53155. RT = 7,
  53156. /** Back */
  53157. Back = 8,
  53158. /** Start */
  53159. Start = 9,
  53160. /** LS */
  53161. LS = 10,
  53162. /** RS */
  53163. RS = 11,
  53164. /** DPadUp */
  53165. DPadUp = 12,
  53166. /** DPadDown */
  53167. DPadDown = 13,
  53168. /** DPadLeft */
  53169. DPadLeft = 14,
  53170. /** DRight */
  53171. DPadRight = 15,
  53172. /** Home */
  53173. Home = 16,
  53174. /** LStickXAxis */
  53175. LStickXAxis = 17,
  53176. /** LStickYAxis */
  53177. LStickYAxis = 18,
  53178. /** RStickXAxis */
  53179. RStickXAxis = 19,
  53180. /** RStickYAxis */
  53181. RStickYAxis = 20
  53182. }
  53183. /**
  53184. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53185. */
  53186. export enum SwitchInput {
  53187. /** B */
  53188. B = 0,
  53189. /** A */
  53190. A = 1,
  53191. /** Y */
  53192. Y = 2,
  53193. /** X */
  53194. X = 3,
  53195. /** L */
  53196. L = 4,
  53197. /** R */
  53198. R = 5,
  53199. /** ZL */
  53200. ZL = 6,
  53201. /** ZR */
  53202. ZR = 7,
  53203. /** Minus */
  53204. Minus = 8,
  53205. /** Plus */
  53206. Plus = 9,
  53207. /** LS */
  53208. LS = 10,
  53209. /** RS */
  53210. RS = 11,
  53211. /** DPadUp */
  53212. DPadUp = 12,
  53213. /** DPadDown */
  53214. DPadDown = 13,
  53215. /** DPadLeft */
  53216. DPadLeft = 14,
  53217. /** DRight */
  53218. DPadRight = 15,
  53219. /** Home */
  53220. Home = 16,
  53221. /** Capture */
  53222. Capture = 17,
  53223. /** LStickXAxis */
  53224. LStickXAxis = 18,
  53225. /** LStickYAxis */
  53226. LStickYAxis = 19,
  53227. /** RStickXAxis */
  53228. RStickXAxis = 20,
  53229. /** RStickYAxis */
  53230. RStickYAxis = 21
  53231. }
  53232. }
  53233. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53234. import { Engine } from "babylonjs/Engines/engine";
  53235. import { IDisposable } from "babylonjs/scene";
  53236. import { Nullable } from "babylonjs/types";
  53237. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53238. /**
  53239. * This class will take all inputs from Keyboard, Pointer, and
  53240. * any Gamepads and provide a polling system that all devices
  53241. * will use. This class assumes that there will only be one
  53242. * pointer device and one keyboard.
  53243. */
  53244. export class DeviceInputSystem implements IDisposable {
  53245. /**
  53246. * Callback to be triggered when a device is connected
  53247. */
  53248. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53249. /**
  53250. * Callback to be triggered when a device is disconnected
  53251. */
  53252. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53253. /**
  53254. * Callback to be triggered when event driven input is updated
  53255. */
  53256. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53257. private _inputs;
  53258. private _gamepads;
  53259. private _keyboardActive;
  53260. private _pointerActive;
  53261. private _elementToAttachTo;
  53262. private _keyboardDownEvent;
  53263. private _keyboardUpEvent;
  53264. private _pointerMoveEvent;
  53265. private _pointerDownEvent;
  53266. private _pointerUpEvent;
  53267. private _gamepadConnectedEvent;
  53268. private _gamepadDisconnectedEvent;
  53269. private static _MAX_KEYCODES;
  53270. private static _MAX_POINTER_INPUTS;
  53271. private constructor();
  53272. /**
  53273. * Creates a new DeviceInputSystem instance
  53274. * @param engine Engine to pull input element from
  53275. * @returns The new instance
  53276. */
  53277. static Create(engine: Engine): DeviceInputSystem;
  53278. /**
  53279. * Checks for current device input value, given an id and input index
  53280. * @param deviceName Id of connected device
  53281. * @param inputIndex Index of device input
  53282. * @returns Current value of input
  53283. */
  53284. /**
  53285. * Checks for current device input value, given an id and input index
  53286. * @param deviceType Enum specifiying device type
  53287. * @param deviceSlot "Slot" or index that device is referenced in
  53288. * @param inputIndex Id of input to be checked
  53289. * @returns Current value of input
  53290. */
  53291. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53292. /**
  53293. * Dispose of all the eventlisteners
  53294. */
  53295. dispose(): void;
  53296. /**
  53297. * Add device and inputs to device array
  53298. * @param deviceType Enum specifiying device type
  53299. * @param deviceSlot "Slot" or index that device is referenced in
  53300. * @param numberOfInputs Number of input entries to create for given device
  53301. */
  53302. private _registerDevice;
  53303. /**
  53304. * Given a specific device name, remove that device from the device map
  53305. * @param deviceType Enum specifiying device type
  53306. * @param deviceSlot "Slot" or index that device is referenced in
  53307. */
  53308. private _unregisterDevice;
  53309. /**
  53310. * Handle all actions that come from keyboard interaction
  53311. */
  53312. private _handleKeyActions;
  53313. /**
  53314. * Handle all actions that come from pointer interaction
  53315. */
  53316. private _handlePointerActions;
  53317. /**
  53318. * Handle all actions that come from gamepad interaction
  53319. */
  53320. private _handleGamepadActions;
  53321. /**
  53322. * Update all non-event based devices with each frame
  53323. * @param deviceType Enum specifiying device type
  53324. * @param deviceSlot "Slot" or index that device is referenced in
  53325. * @param inputIndex Id of input to be checked
  53326. */
  53327. private _updateDevice;
  53328. /**
  53329. * Gets DeviceType from the device name
  53330. * @param deviceName Name of Device from DeviceInputSystem
  53331. * @returns DeviceType enum value
  53332. */
  53333. private _getGamepadDeviceType;
  53334. }
  53335. }
  53336. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53337. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53338. /**
  53339. * Type to handle enforcement of inputs
  53340. */
  53341. 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;
  53342. }
  53343. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53344. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53345. import { Engine } from "babylonjs/Engines/engine";
  53346. import { IDisposable } from "babylonjs/scene";
  53347. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53348. import { Nullable } from "babylonjs/types";
  53349. import { Observable } from "babylonjs/Misc/observable";
  53350. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53351. /**
  53352. * Class that handles all input for a specific device
  53353. */
  53354. export class DeviceSource<T extends DeviceType> {
  53355. /** Type of device */
  53356. readonly deviceType: DeviceType;
  53357. /** "Slot" or index that device is referenced in */
  53358. readonly deviceSlot: number;
  53359. /**
  53360. * Observable to handle device input changes per device
  53361. */
  53362. readonly onInputChangedObservable: Observable<{
  53363. inputIndex: DeviceInput<T>;
  53364. previousState: Nullable<number>;
  53365. currentState: Nullable<number>;
  53366. }>;
  53367. private readonly _deviceInputSystem;
  53368. /**
  53369. * Default Constructor
  53370. * @param deviceInputSystem Reference to DeviceInputSystem
  53371. * @param deviceType Type of device
  53372. * @param deviceSlot "Slot" or index that device is referenced in
  53373. */
  53374. constructor(deviceInputSystem: DeviceInputSystem,
  53375. /** Type of device */
  53376. deviceType: DeviceType,
  53377. /** "Slot" or index that device is referenced in */
  53378. deviceSlot?: number);
  53379. /**
  53380. * Get input for specific input
  53381. * @param inputIndex index of specific input on device
  53382. * @returns Input value from DeviceInputSystem
  53383. */
  53384. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53385. }
  53386. /**
  53387. * Class to keep track of devices
  53388. */
  53389. export class DeviceSourceManager implements IDisposable {
  53390. /**
  53391. * Observable to be triggered when before a device is connected
  53392. */
  53393. readonly onBeforeDeviceConnectedObservable: Observable<{
  53394. deviceType: DeviceType;
  53395. deviceSlot: number;
  53396. }>;
  53397. /**
  53398. * Observable to be triggered when before a device is disconnected
  53399. */
  53400. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53401. deviceType: DeviceType;
  53402. deviceSlot: number;
  53403. }>;
  53404. /**
  53405. * Observable to be triggered when after a device is connected
  53406. */
  53407. readonly onAfterDeviceConnectedObservable: Observable<{
  53408. deviceType: DeviceType;
  53409. deviceSlot: number;
  53410. }>;
  53411. /**
  53412. * Observable to be triggered when after a device is disconnected
  53413. */
  53414. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53415. deviceType: DeviceType;
  53416. deviceSlot: number;
  53417. }>;
  53418. private readonly _devices;
  53419. private readonly _firstDevice;
  53420. private readonly _deviceInputSystem;
  53421. /**
  53422. * Default Constructor
  53423. * @param engine engine to pull input element from
  53424. */
  53425. constructor(engine: Engine);
  53426. /**
  53427. * Gets a DeviceSource, given a type and slot
  53428. * @param deviceType Enum specifying device type
  53429. * @param deviceSlot "Slot" or index that device is referenced in
  53430. * @returns DeviceSource object
  53431. */
  53432. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53433. /**
  53434. * Gets an array of DeviceSource objects for a given device type
  53435. * @param deviceType Enum specifying device type
  53436. * @returns Array of DeviceSource objects
  53437. */
  53438. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53439. /**
  53440. * Dispose of DeviceInputSystem and other parts
  53441. */
  53442. dispose(): void;
  53443. /**
  53444. * Function to add device name to device list
  53445. * @param deviceType Enum specifying device type
  53446. * @param deviceSlot "Slot" or index that device is referenced in
  53447. */
  53448. private _addDevice;
  53449. /**
  53450. * Function to remove device name to device list
  53451. * @param deviceType Enum specifying device type
  53452. * @param deviceSlot "Slot" or index that device is referenced in
  53453. */
  53454. private _removeDevice;
  53455. /**
  53456. * Updates array storing first connected device of each type
  53457. * @param type Type of Device
  53458. */
  53459. private _updateFirstDevices;
  53460. }
  53461. }
  53462. declare module "babylonjs/DeviceInput/index" {
  53463. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53464. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53465. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53466. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53467. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53468. }
  53469. declare module "babylonjs/Engines/nullEngine" {
  53470. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53471. import { Engine } from "babylonjs/Engines/engine";
  53472. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53473. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53475. import { Effect } from "babylonjs/Materials/effect";
  53476. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53477. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53478. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53479. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53480. /**
  53481. * Options to create the null engine
  53482. */
  53483. export class NullEngineOptions {
  53484. /**
  53485. * Render width (Default: 512)
  53486. */
  53487. renderWidth: number;
  53488. /**
  53489. * Render height (Default: 256)
  53490. */
  53491. renderHeight: number;
  53492. /**
  53493. * Texture size (Default: 512)
  53494. */
  53495. textureSize: number;
  53496. /**
  53497. * If delta time between frames should be constant
  53498. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53499. */
  53500. deterministicLockstep: boolean;
  53501. /**
  53502. * Maximum about of steps between frames (Default: 4)
  53503. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53504. */
  53505. lockstepMaxSteps: number;
  53506. /**
  53507. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53508. */
  53509. useHighPrecisionMatrix?: boolean;
  53510. }
  53511. /**
  53512. * The null engine class provides support for headless version of babylon.js.
  53513. * This can be used in server side scenario or for testing purposes
  53514. */
  53515. export class NullEngine extends Engine {
  53516. private _options;
  53517. /**
  53518. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53519. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53520. * @returns true if engine is in deterministic lock step mode
  53521. */
  53522. isDeterministicLockStep(): boolean;
  53523. /**
  53524. * Gets the max steps when engine is running in deterministic lock step
  53525. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53526. * @returns the max steps
  53527. */
  53528. getLockstepMaxSteps(): number;
  53529. /**
  53530. * Gets the current hardware scaling level.
  53531. * By default the hardware scaling level is computed from the window device ratio.
  53532. * 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.
  53533. * @returns a number indicating the current hardware scaling level
  53534. */
  53535. getHardwareScalingLevel(): number;
  53536. constructor(options?: NullEngineOptions);
  53537. /**
  53538. * Creates a vertex buffer
  53539. * @param vertices the data for the vertex buffer
  53540. * @returns the new WebGL static buffer
  53541. */
  53542. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53543. /**
  53544. * Creates a new index buffer
  53545. * @param indices defines the content of the index buffer
  53546. * @param updatable defines if the index buffer must be updatable
  53547. * @returns a new webGL buffer
  53548. */
  53549. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53550. /**
  53551. * Clear the current render buffer or the current render target (if any is set up)
  53552. * @param color defines the color to use
  53553. * @param backBuffer defines if the back buffer must be cleared
  53554. * @param depth defines if the depth buffer must be cleared
  53555. * @param stencil defines if the stencil buffer must be cleared
  53556. */
  53557. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53558. /**
  53559. * Gets the current render width
  53560. * @param useScreen defines if screen size must be used (or the current render target if any)
  53561. * @returns a number defining the current render width
  53562. */
  53563. getRenderWidth(useScreen?: boolean): number;
  53564. /**
  53565. * Gets the current render height
  53566. * @param useScreen defines if screen size must be used (or the current render target if any)
  53567. * @returns a number defining the current render height
  53568. */
  53569. getRenderHeight(useScreen?: boolean): number;
  53570. /**
  53571. * Set the WebGL's viewport
  53572. * @param viewport defines the viewport element to be used
  53573. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53574. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53575. */
  53576. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53577. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53578. /**
  53579. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53580. * @param pipelineContext defines the pipeline context to use
  53581. * @param uniformsNames defines the list of uniform names
  53582. * @returns an array of webGL uniform locations
  53583. */
  53584. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53585. /**
  53586. * Gets the lsit of active attributes for a given webGL program
  53587. * @param pipelineContext defines the pipeline context to use
  53588. * @param attributesNames defines the list of attribute names to get
  53589. * @returns an array of indices indicating the offset of each attribute
  53590. */
  53591. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53592. /**
  53593. * Binds an effect to the webGL context
  53594. * @param effect defines the effect to bind
  53595. */
  53596. bindSamplers(effect: Effect): void;
  53597. /**
  53598. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53599. * @param effect defines the effect to activate
  53600. */
  53601. enableEffect(effect: Effect): void;
  53602. /**
  53603. * Set various states to the webGL context
  53604. * @param culling defines backface culling state
  53605. * @param zOffset defines the value to apply to zOffset (0 by default)
  53606. * @param force defines if states must be applied even if cache is up to date
  53607. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53608. */
  53609. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53610. /**
  53611. * Set the value of an uniform to an array of int32
  53612. * @param uniform defines the webGL uniform location where to store the value
  53613. * @param array defines the array of int32 to store
  53614. */
  53615. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53616. /**
  53617. * Set the value of an uniform to an array of int32 (stored as vec2)
  53618. * @param uniform defines the webGL uniform location where to store the value
  53619. * @param array defines the array of int32 to store
  53620. */
  53621. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53622. /**
  53623. * Set the value of an uniform to an array of int32 (stored as vec3)
  53624. * @param uniform defines the webGL uniform location where to store the value
  53625. * @param array defines the array of int32 to store
  53626. */
  53627. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53628. /**
  53629. * Set the value of an uniform to an array of int32 (stored as vec4)
  53630. * @param uniform defines the webGL uniform location where to store the value
  53631. * @param array defines the array of int32 to store
  53632. */
  53633. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53634. /**
  53635. * Set the value of an uniform to an array of float32
  53636. * @param uniform defines the webGL uniform location where to store the value
  53637. * @param array defines the array of float32 to store
  53638. */
  53639. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53640. /**
  53641. * Set the value of an uniform to an array of float32 (stored as vec2)
  53642. * @param uniform defines the webGL uniform location where to store the value
  53643. * @param array defines the array of float32 to store
  53644. */
  53645. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53646. /**
  53647. * Set the value of an uniform to an array of float32 (stored as vec3)
  53648. * @param uniform defines the webGL uniform location where to store the value
  53649. * @param array defines the array of float32 to store
  53650. */
  53651. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53652. /**
  53653. * Set the value of an uniform to an array of float32 (stored as vec4)
  53654. * @param uniform defines the webGL uniform location where to store the value
  53655. * @param array defines the array of float32 to store
  53656. */
  53657. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53658. /**
  53659. * Set the value of an uniform to an array of number
  53660. * @param uniform defines the webGL uniform location where to store the value
  53661. * @param array defines the array of number to store
  53662. */
  53663. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53664. /**
  53665. * Set the value of an uniform to an array of number (stored as vec2)
  53666. * @param uniform defines the webGL uniform location where to store the value
  53667. * @param array defines the array of number to store
  53668. */
  53669. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53670. /**
  53671. * Set the value of an uniform to an array of number (stored as vec3)
  53672. * @param uniform defines the webGL uniform location where to store the value
  53673. * @param array defines the array of number to store
  53674. */
  53675. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53676. /**
  53677. * Set the value of an uniform to an array of number (stored as vec4)
  53678. * @param uniform defines the webGL uniform location where to store the value
  53679. * @param array defines the array of number to store
  53680. */
  53681. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53682. /**
  53683. * Set the value of an uniform to an array of float32 (stored as matrices)
  53684. * @param uniform defines the webGL uniform location where to store the value
  53685. * @param matrices defines the array of float32 to store
  53686. */
  53687. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53688. /**
  53689. * Set the value of an uniform to a matrix (3x3)
  53690. * @param uniform defines the webGL uniform location where to store the value
  53691. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53692. */
  53693. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53694. /**
  53695. * Set the value of an uniform to a matrix (2x2)
  53696. * @param uniform defines the webGL uniform location where to store the value
  53697. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53698. */
  53699. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53700. /**
  53701. * Set the value of an uniform to a number (float)
  53702. * @param uniform defines the webGL uniform location where to store the value
  53703. * @param value defines the float number to store
  53704. */
  53705. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53706. /**
  53707. * Set the value of an uniform to a vec2
  53708. * @param uniform defines the webGL uniform location where to store the value
  53709. * @param x defines the 1st component of the value
  53710. * @param y defines the 2nd component of the value
  53711. */
  53712. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53713. /**
  53714. * Set the value of an uniform to a vec3
  53715. * @param uniform defines the webGL uniform location where to store the value
  53716. * @param x defines the 1st component of the value
  53717. * @param y defines the 2nd component of the value
  53718. * @param z defines the 3rd component of the value
  53719. */
  53720. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53721. /**
  53722. * Set the value of an uniform to a boolean
  53723. * @param uniform defines the webGL uniform location where to store the value
  53724. * @param bool defines the boolean to store
  53725. */
  53726. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53727. /**
  53728. * Set the value of an uniform to a vec4
  53729. * @param uniform defines the webGL uniform location where to store the value
  53730. * @param x defines the 1st component of the value
  53731. * @param y defines the 2nd component of the value
  53732. * @param z defines the 3rd component of the value
  53733. * @param w defines the 4th component of the value
  53734. */
  53735. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53736. /**
  53737. * Sets the current alpha mode
  53738. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53739. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53740. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53741. */
  53742. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53743. /**
  53744. * Bind webGl buffers directly to the webGL context
  53745. * @param vertexBuffers defines the vertex buffer to bind
  53746. * @param indexBuffer defines the index buffer to bind
  53747. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53748. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53749. * @param effect defines the effect associated with the vertex buffer
  53750. */
  53751. bindBuffers(vertexBuffers: {
  53752. [key: string]: VertexBuffer;
  53753. }, indexBuffer: DataBuffer, effect: Effect): void;
  53754. /**
  53755. * Force the entire cache to be cleared
  53756. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53757. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53758. */
  53759. wipeCaches(bruteForce?: boolean): void;
  53760. /**
  53761. * Send a draw order
  53762. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53763. * @param indexStart defines the starting index
  53764. * @param indexCount defines the number of index to draw
  53765. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53766. */
  53767. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53768. /**
  53769. * Draw a list of indexed primitives
  53770. * @param fillMode defines the primitive to use
  53771. * @param indexStart defines the starting index
  53772. * @param indexCount defines the number of index to draw
  53773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53774. */
  53775. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53776. /**
  53777. * Draw a list of unindexed primitives
  53778. * @param fillMode defines the primitive to use
  53779. * @param verticesStart defines the index of first vertex to draw
  53780. * @param verticesCount defines the count of vertices to draw
  53781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53782. */
  53783. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53784. /** @hidden */
  53785. _createTexture(): WebGLTexture;
  53786. /** @hidden */
  53787. _releaseTexture(texture: InternalTexture): void;
  53788. /**
  53789. * Usually called from Texture.ts.
  53790. * Passed information to create a WebGLTexture
  53791. * @param urlArg defines a value which contains one of the following:
  53792. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53793. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53794. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53795. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53796. * @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)
  53797. * @param scene needed for loading to the correct scene
  53798. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53799. * @param onLoad optional callback to be called upon successful completion
  53800. * @param onError optional callback to be called upon failure
  53801. * @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
  53802. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53803. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53804. * @param forcedExtension defines the extension to use to pick the right loader
  53805. * @param mimeType defines an optional mime type
  53806. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53807. */
  53808. 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;
  53809. /**
  53810. * Creates a new render target texture
  53811. * @param size defines the size of the texture
  53812. * @param options defines the options used to create the texture
  53813. * @returns a new render target texture stored in an InternalTexture
  53814. */
  53815. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53816. /**
  53817. * Update the sampling mode of a given texture
  53818. * @param samplingMode defines the required sampling mode
  53819. * @param texture defines the texture to update
  53820. */
  53821. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53822. /**
  53823. * Binds the frame buffer to the specified texture.
  53824. * @param texture The texture to render to or null for the default canvas
  53825. * @param faceIndex The face of the texture to render to in case of cube texture
  53826. * @param requiredWidth The width of the target to render to
  53827. * @param requiredHeight The height of the target to render to
  53828. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53829. * @param lodLevel defines le lod level to bind to the frame buffer
  53830. */
  53831. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53832. /**
  53833. * Unbind the current render target texture from the webGL context
  53834. * @param texture defines the render target texture to unbind
  53835. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53836. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53837. */
  53838. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53839. /**
  53840. * Creates a dynamic vertex buffer
  53841. * @param vertices the data for the dynamic vertex buffer
  53842. * @returns the new WebGL dynamic buffer
  53843. */
  53844. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53845. /**
  53846. * Update the content of a dynamic texture
  53847. * @param texture defines the texture to update
  53848. * @param canvas defines the canvas containing the source
  53849. * @param invertY defines if data must be stored with Y axis inverted
  53850. * @param premulAlpha defines if alpha is stored as premultiplied
  53851. * @param format defines the format of the data
  53852. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53853. */
  53854. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53855. /**
  53856. * Gets a boolean indicating if all created effects are ready
  53857. * @returns true if all effects are ready
  53858. */
  53859. areAllEffectsReady(): boolean;
  53860. /**
  53861. * @hidden
  53862. * Get the current error code of the webGL context
  53863. * @returns the error code
  53864. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53865. */
  53866. getError(): number;
  53867. /** @hidden */
  53868. _getUnpackAlignement(): number;
  53869. /** @hidden */
  53870. _unpackFlipY(value: boolean): void;
  53871. /**
  53872. * Update a dynamic index buffer
  53873. * @param indexBuffer defines the target index buffer
  53874. * @param indices defines the data to update
  53875. * @param offset defines the offset in the target index buffer where update should start
  53876. */
  53877. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53878. /**
  53879. * Updates a dynamic vertex buffer.
  53880. * @param vertexBuffer the vertex buffer to update
  53881. * @param vertices the data used to update the vertex buffer
  53882. * @param byteOffset the byte offset of the data (optional)
  53883. * @param byteLength the byte length of the data (optional)
  53884. */
  53885. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53886. /** @hidden */
  53887. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53888. /** @hidden */
  53889. _bindTexture(channel: number, texture: InternalTexture): void;
  53890. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53891. /**
  53892. * 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
  53893. */
  53894. releaseEffects(): void;
  53895. displayLoadingUI(): void;
  53896. hideLoadingUI(): void;
  53897. /** @hidden */
  53898. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53899. /** @hidden */
  53900. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53901. /** @hidden */
  53902. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53903. /** @hidden */
  53904. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53905. }
  53906. }
  53907. declare module "babylonjs/Instrumentation/timeToken" {
  53908. import { Nullable } from "babylonjs/types";
  53909. /**
  53910. * @hidden
  53911. **/
  53912. export class _TimeToken {
  53913. _startTimeQuery: Nullable<WebGLQuery>;
  53914. _endTimeQuery: Nullable<WebGLQuery>;
  53915. _timeElapsedQuery: Nullable<WebGLQuery>;
  53916. _timeElapsedQueryEnded: boolean;
  53917. }
  53918. }
  53919. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53920. import { Nullable, int } from "babylonjs/types";
  53921. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53922. /** @hidden */
  53923. export class _OcclusionDataStorage {
  53924. /** @hidden */
  53925. occlusionInternalRetryCounter: number;
  53926. /** @hidden */
  53927. isOcclusionQueryInProgress: boolean;
  53928. /** @hidden */
  53929. isOccluded: boolean;
  53930. /** @hidden */
  53931. occlusionRetryCount: number;
  53932. /** @hidden */
  53933. occlusionType: number;
  53934. /** @hidden */
  53935. occlusionQueryAlgorithmType: number;
  53936. }
  53937. module "babylonjs/Engines/engine" {
  53938. interface Engine {
  53939. /**
  53940. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53941. * @return the new query
  53942. */
  53943. createQuery(): WebGLQuery;
  53944. /**
  53945. * Delete and release a webGL query
  53946. * @param query defines the query to delete
  53947. * @return the current engine
  53948. */
  53949. deleteQuery(query: WebGLQuery): Engine;
  53950. /**
  53951. * Check if a given query has resolved and got its value
  53952. * @param query defines the query to check
  53953. * @returns true if the query got its value
  53954. */
  53955. isQueryResultAvailable(query: WebGLQuery): boolean;
  53956. /**
  53957. * Gets the value of a given query
  53958. * @param query defines the query to check
  53959. * @returns the value of the query
  53960. */
  53961. getQueryResult(query: WebGLQuery): number;
  53962. /**
  53963. * Initiates an occlusion query
  53964. * @param algorithmType defines the algorithm to use
  53965. * @param query defines the query to use
  53966. * @returns the current engine
  53967. * @see https://doc.babylonjs.com/features/occlusionquery
  53968. */
  53969. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53970. /**
  53971. * Ends an occlusion query
  53972. * @see https://doc.babylonjs.com/features/occlusionquery
  53973. * @param algorithmType defines the algorithm to use
  53974. * @returns the current engine
  53975. */
  53976. endOcclusionQuery(algorithmType: number): Engine;
  53977. /**
  53978. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53979. * Please note that only one query can be issued at a time
  53980. * @returns a time token used to track the time span
  53981. */
  53982. startTimeQuery(): Nullable<_TimeToken>;
  53983. /**
  53984. * Ends a time query
  53985. * @param token defines the token used to measure the time span
  53986. * @returns the time spent (in ns)
  53987. */
  53988. endTimeQuery(token: _TimeToken): int;
  53989. /** @hidden */
  53990. _currentNonTimestampToken: Nullable<_TimeToken>;
  53991. /** @hidden */
  53992. _createTimeQuery(): WebGLQuery;
  53993. /** @hidden */
  53994. _deleteTimeQuery(query: WebGLQuery): void;
  53995. /** @hidden */
  53996. _getGlAlgorithmType(algorithmType: number): number;
  53997. /** @hidden */
  53998. _getTimeQueryResult(query: WebGLQuery): any;
  53999. /** @hidden */
  54000. _getTimeQueryAvailability(query: WebGLQuery): any;
  54001. }
  54002. }
  54003. module "babylonjs/Meshes/abstractMesh" {
  54004. interface AbstractMesh {
  54005. /**
  54006. * Backing filed
  54007. * @hidden
  54008. */
  54009. __occlusionDataStorage: _OcclusionDataStorage;
  54010. /**
  54011. * Access property
  54012. * @hidden
  54013. */
  54014. _occlusionDataStorage: _OcclusionDataStorage;
  54015. /**
  54016. * 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.
  54017. * The default value is -1 which means don't break the query and wait till the result
  54018. * @see https://doc.babylonjs.com/features/occlusionquery
  54019. */
  54020. occlusionRetryCount: number;
  54021. /**
  54022. * 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:
  54023. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54024. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54025. * * 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.
  54026. * @see https://doc.babylonjs.com/features/occlusionquery
  54027. */
  54028. occlusionType: number;
  54029. /**
  54030. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54031. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54032. * * 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.
  54033. * @see https://doc.babylonjs.com/features/occlusionquery
  54034. */
  54035. occlusionQueryAlgorithmType: number;
  54036. /**
  54037. * 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
  54038. * @see https://doc.babylonjs.com/features/occlusionquery
  54039. */
  54040. isOccluded: boolean;
  54041. /**
  54042. * Flag to check the progress status of the query
  54043. * @see https://doc.babylonjs.com/features/occlusionquery
  54044. */
  54045. isOcclusionQueryInProgress: boolean;
  54046. }
  54047. }
  54048. }
  54049. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54050. import { Nullable } from "babylonjs/types";
  54051. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54052. /** @hidden */
  54053. export var _forceTransformFeedbackToBundle: boolean;
  54054. module "babylonjs/Engines/engine" {
  54055. interface Engine {
  54056. /**
  54057. * Creates a webGL transform feedback object
  54058. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54059. * @returns the webGL transform feedback object
  54060. */
  54061. createTransformFeedback(): WebGLTransformFeedback;
  54062. /**
  54063. * Delete a webGL transform feedback object
  54064. * @param value defines the webGL transform feedback object to delete
  54065. */
  54066. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54067. /**
  54068. * Bind a webGL transform feedback object to the webgl context
  54069. * @param value defines the webGL transform feedback object to bind
  54070. */
  54071. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54072. /**
  54073. * Begins a transform feedback operation
  54074. * @param usePoints defines if points or triangles must be used
  54075. */
  54076. beginTransformFeedback(usePoints: boolean): void;
  54077. /**
  54078. * Ends a transform feedback operation
  54079. */
  54080. endTransformFeedback(): void;
  54081. /**
  54082. * Specify the varyings to use with transform feedback
  54083. * @param program defines the associated webGL program
  54084. * @param value defines the list of strings representing the varying names
  54085. */
  54086. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54087. /**
  54088. * Bind a webGL buffer for a transform feedback operation
  54089. * @param value defines the webGL buffer to bind
  54090. */
  54091. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54092. }
  54093. }
  54094. }
  54095. declare module "babylonjs/Engines/Extensions/engine.views" {
  54096. import { Camera } from "babylonjs/Cameras/camera";
  54097. import { Nullable } from "babylonjs/types";
  54098. /**
  54099. * Class used to define an additional view for the engine
  54100. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54101. */
  54102. export class EngineView {
  54103. /** Defines the canvas where to render the view */
  54104. target: HTMLCanvasElement;
  54105. /** Defines an optional camera used to render the view (will use active camera else) */
  54106. camera?: Camera;
  54107. }
  54108. module "babylonjs/Engines/engine" {
  54109. interface Engine {
  54110. /**
  54111. * Gets or sets the HTML element to use for attaching events
  54112. */
  54113. inputElement: Nullable<HTMLElement>;
  54114. /**
  54115. * Gets the current engine view
  54116. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54117. */
  54118. activeView: Nullable<EngineView>;
  54119. /** Gets or sets the list of views */
  54120. views: EngineView[];
  54121. /**
  54122. * Register a new child canvas
  54123. * @param canvas defines the canvas to register
  54124. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54125. * @returns the associated view
  54126. */
  54127. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54128. /**
  54129. * Remove a registered child canvas
  54130. * @param canvas defines the canvas to remove
  54131. * @returns the current engine
  54132. */
  54133. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54134. }
  54135. }
  54136. }
  54137. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54138. import { Nullable } from "babylonjs/types";
  54139. module "babylonjs/Engines/engine" {
  54140. interface Engine {
  54141. /** @hidden */
  54142. _excludedCompressedTextures: string[];
  54143. /** @hidden */
  54144. _textureFormatInUse: string;
  54145. /**
  54146. * Gets the list of texture formats supported
  54147. */
  54148. readonly texturesSupported: Array<string>;
  54149. /**
  54150. * Gets the texture format in use
  54151. */
  54152. readonly textureFormatInUse: Nullable<string>;
  54153. /**
  54154. * Set the compressed texture extensions or file names to skip.
  54155. *
  54156. * @param skippedFiles defines the list of those texture files you want to skip
  54157. * Example: [".dds", ".env", "myfile.png"]
  54158. */
  54159. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54160. /**
  54161. * Set the compressed texture format to use, based on the formats you have, and the formats
  54162. * supported by the hardware / browser.
  54163. *
  54164. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54165. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54166. * to API arguments needed to compressed textures. This puts the burden on the container
  54167. * generator to house the arcane code for determining these for current & future formats.
  54168. *
  54169. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54170. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54171. *
  54172. * Note: The result of this call is not taken into account when a texture is base64.
  54173. *
  54174. * @param formatsAvailable defines the list of those format families you have created
  54175. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54176. *
  54177. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54178. * @returns The extension selected.
  54179. */
  54180. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54181. }
  54182. }
  54183. }
  54184. declare module "babylonjs/Engines/Extensions/index" {
  54185. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54186. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54187. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54188. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54189. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54190. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54191. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54192. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54193. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54194. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54195. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54196. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54197. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54198. export * from "babylonjs/Engines/Extensions/engine.views";
  54199. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54200. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54201. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54202. }
  54203. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54204. import { Nullable } from "babylonjs/types";
  54205. /**
  54206. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54207. */
  54208. export interface CubeMapInfo {
  54209. /**
  54210. * The pixel array for the front face.
  54211. * This is stored in format, left to right, up to down format.
  54212. */
  54213. front: Nullable<ArrayBufferView>;
  54214. /**
  54215. * The pixel array for the back face.
  54216. * This is stored in format, left to right, up to down format.
  54217. */
  54218. back: Nullable<ArrayBufferView>;
  54219. /**
  54220. * The pixel array for the left face.
  54221. * This is stored in format, left to right, up to down format.
  54222. */
  54223. left: Nullable<ArrayBufferView>;
  54224. /**
  54225. * The pixel array for the right face.
  54226. * This is stored in format, left to right, up to down format.
  54227. */
  54228. right: Nullable<ArrayBufferView>;
  54229. /**
  54230. * The pixel array for the up face.
  54231. * This is stored in format, left to right, up to down format.
  54232. */
  54233. up: Nullable<ArrayBufferView>;
  54234. /**
  54235. * The pixel array for the down face.
  54236. * This is stored in format, left to right, up to down format.
  54237. */
  54238. down: Nullable<ArrayBufferView>;
  54239. /**
  54240. * The size of the cubemap stored.
  54241. *
  54242. * Each faces will be size * size pixels.
  54243. */
  54244. size: number;
  54245. /**
  54246. * The format of the texture.
  54247. *
  54248. * RGBA, RGB.
  54249. */
  54250. format: number;
  54251. /**
  54252. * The type of the texture data.
  54253. *
  54254. * UNSIGNED_INT, FLOAT.
  54255. */
  54256. type: number;
  54257. /**
  54258. * Specifies whether the texture is in gamma space.
  54259. */
  54260. gammaSpace: boolean;
  54261. }
  54262. /**
  54263. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54264. */
  54265. export class PanoramaToCubeMapTools {
  54266. private static FACE_LEFT;
  54267. private static FACE_RIGHT;
  54268. private static FACE_FRONT;
  54269. private static FACE_BACK;
  54270. private static FACE_DOWN;
  54271. private static FACE_UP;
  54272. /**
  54273. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54274. *
  54275. * @param float32Array The source data.
  54276. * @param inputWidth The width of the input panorama.
  54277. * @param inputHeight The height of the input panorama.
  54278. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54279. * @return The cubemap data
  54280. */
  54281. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54282. private static CreateCubemapTexture;
  54283. private static CalcProjectionSpherical;
  54284. }
  54285. }
  54286. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54287. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54289. import { Nullable } from "babylonjs/types";
  54290. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54291. /**
  54292. * Helper class dealing with the extraction of spherical polynomial dataArray
  54293. * from a cube map.
  54294. */
  54295. export class CubeMapToSphericalPolynomialTools {
  54296. private static FileFaces;
  54297. /**
  54298. * Converts a texture to the according Spherical Polynomial data.
  54299. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54300. *
  54301. * @param texture The texture to extract the information from.
  54302. * @return The Spherical Polynomial data.
  54303. */
  54304. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54305. /**
  54306. * Converts a cubemap to the according Spherical Polynomial data.
  54307. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54308. *
  54309. * @param cubeInfo The Cube map to extract the information from.
  54310. * @return The Spherical Polynomial data.
  54311. */
  54312. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54313. }
  54314. }
  54315. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54316. import { Nullable } from "babylonjs/types";
  54317. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54318. module "babylonjs/Materials/Textures/baseTexture" {
  54319. interface BaseTexture {
  54320. /**
  54321. * Get the polynomial representation of the texture data.
  54322. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54323. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54324. */
  54325. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54326. }
  54327. }
  54328. }
  54329. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54330. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54331. /** @hidden */
  54332. export var rgbdEncodePixelShader: {
  54333. name: string;
  54334. shader: string;
  54335. };
  54336. }
  54337. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54338. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54339. /** @hidden */
  54340. export var rgbdDecodePixelShader: {
  54341. name: string;
  54342. shader: string;
  54343. };
  54344. }
  54345. declare module "babylonjs/Misc/environmentTextureTools" {
  54346. import { Nullable } from "babylonjs/types";
  54347. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54350. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54351. import "babylonjs/Engines/Extensions/engine.readTexture";
  54352. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54353. import "babylonjs/Shaders/rgbdEncode.fragment";
  54354. import "babylonjs/Shaders/rgbdDecode.fragment";
  54355. /**
  54356. * Raw texture data and descriptor sufficient for WebGL texture upload
  54357. */
  54358. export interface EnvironmentTextureInfo {
  54359. /**
  54360. * Version of the environment map
  54361. */
  54362. version: number;
  54363. /**
  54364. * Width of image
  54365. */
  54366. width: number;
  54367. /**
  54368. * Irradiance information stored in the file.
  54369. */
  54370. irradiance: any;
  54371. /**
  54372. * Specular information stored in the file.
  54373. */
  54374. specular: any;
  54375. }
  54376. /**
  54377. * Defines One Image in the file. It requires only the position in the file
  54378. * as well as the length.
  54379. */
  54380. interface BufferImageData {
  54381. /**
  54382. * Length of the image data.
  54383. */
  54384. length: number;
  54385. /**
  54386. * Position of the data from the null terminator delimiting the end of the JSON.
  54387. */
  54388. position: number;
  54389. }
  54390. /**
  54391. * Defines the specular data enclosed in the file.
  54392. * This corresponds to the version 1 of the data.
  54393. */
  54394. export interface EnvironmentTextureSpecularInfoV1 {
  54395. /**
  54396. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54397. */
  54398. specularDataPosition?: number;
  54399. /**
  54400. * This contains all the images data needed to reconstruct the cubemap.
  54401. */
  54402. mipmaps: Array<BufferImageData>;
  54403. /**
  54404. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54405. */
  54406. lodGenerationScale: number;
  54407. }
  54408. /**
  54409. * Sets of helpers addressing the serialization and deserialization of environment texture
  54410. * stored in a BabylonJS env file.
  54411. * Those files are usually stored as .env files.
  54412. */
  54413. export class EnvironmentTextureTools {
  54414. /**
  54415. * Magic number identifying the env file.
  54416. */
  54417. private static _MagicBytes;
  54418. /**
  54419. * Gets the environment info from an env file.
  54420. * @param data The array buffer containing the .env bytes.
  54421. * @returns the environment file info (the json header) if successfully parsed.
  54422. */
  54423. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54424. /**
  54425. * Creates an environment texture from a loaded cube texture.
  54426. * @param texture defines the cube texture to convert in env file
  54427. * @return a promise containing the environment data if succesfull.
  54428. */
  54429. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54430. /**
  54431. * Creates a JSON representation of the spherical data.
  54432. * @param texture defines the texture containing the polynomials
  54433. * @return the JSON representation of the spherical info
  54434. */
  54435. private static _CreateEnvTextureIrradiance;
  54436. /**
  54437. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54438. * @param data the image data
  54439. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54440. * @return the views described by info providing access to the underlying buffer
  54441. */
  54442. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54443. /**
  54444. * Uploads the texture info contained in the env file to the GPU.
  54445. * @param texture defines the internal texture to upload to
  54446. * @param data defines the data to load
  54447. * @param info defines the texture info retrieved through the GetEnvInfo method
  54448. * @returns a promise
  54449. */
  54450. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54451. private static _OnImageReadyAsync;
  54452. /**
  54453. * Uploads the levels of image data to the GPU.
  54454. * @param texture defines the internal texture to upload to
  54455. * @param imageData defines the array buffer views of image data [mipmap][face]
  54456. * @returns a promise
  54457. */
  54458. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54459. /**
  54460. * Uploads spherical polynomials information to the texture.
  54461. * @param texture defines the texture we are trying to upload the information to
  54462. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54463. */
  54464. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54465. /** @hidden */
  54466. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54467. }
  54468. }
  54469. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54470. /**
  54471. * Class used to inline functions in shader code
  54472. */
  54473. export class ShaderCodeInliner {
  54474. private static readonly _RegexpFindFunctionNameAndType;
  54475. private _sourceCode;
  54476. private _functionDescr;
  54477. private _numMaxIterations;
  54478. /** Gets or sets the token used to mark the functions to inline */
  54479. inlineToken: string;
  54480. /** Gets or sets the debug mode */
  54481. debug: boolean;
  54482. /** Gets the code after the inlining process */
  54483. get code(): string;
  54484. /**
  54485. * Initializes the inliner
  54486. * @param sourceCode shader code source to inline
  54487. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54488. */
  54489. constructor(sourceCode: string, numMaxIterations?: number);
  54490. /**
  54491. * Start the processing of the shader code
  54492. */
  54493. processCode(): void;
  54494. private _collectFunctions;
  54495. private _processInlining;
  54496. private _extractBetweenMarkers;
  54497. private _skipWhitespaces;
  54498. private _removeComments;
  54499. private _replaceFunctionCallsByCode;
  54500. private _findBackward;
  54501. private _escapeRegExp;
  54502. private _replaceNames;
  54503. }
  54504. }
  54505. declare module "babylonjs/Engines/nativeEngine" {
  54506. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54507. import { Engine } from "babylonjs/Engines/engine";
  54508. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54509. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54511. import { Effect } from "babylonjs/Materials/effect";
  54512. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54513. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54514. import { IColor4Like } from "babylonjs/Maths/math.like";
  54515. import { Scene } from "babylonjs/scene";
  54516. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54517. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54518. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54519. /**
  54520. * Container for accessors for natively-stored mesh data buffers.
  54521. */
  54522. class NativeDataBuffer extends DataBuffer {
  54523. /**
  54524. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54525. */
  54526. nativeIndexBuffer?: any;
  54527. /**
  54528. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54529. */
  54530. nativeVertexBuffer?: any;
  54531. }
  54532. /** @hidden */
  54533. class NativeTexture extends InternalTexture {
  54534. getInternalTexture(): InternalTexture;
  54535. getViewCount(): number;
  54536. }
  54537. /** @hidden */
  54538. export class NativeEngine extends Engine {
  54539. private readonly _native;
  54540. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54541. private readonly INVALID_HANDLE;
  54542. getHardwareScalingLevel(): number;
  54543. constructor();
  54544. dispose(): void;
  54545. /**
  54546. * Can be used to override the current requestAnimationFrame requester.
  54547. * @hidden
  54548. */
  54549. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54550. /**
  54551. * Override default engine behavior.
  54552. * @param color
  54553. * @param backBuffer
  54554. * @param depth
  54555. * @param stencil
  54556. */
  54557. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54558. /**
  54559. * Gets host document
  54560. * @returns the host document object
  54561. */
  54562. getHostDocument(): Nullable<Document>;
  54563. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54564. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54565. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54566. recordVertexArrayObject(vertexBuffers: {
  54567. [key: string]: VertexBuffer;
  54568. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54569. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54570. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54571. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54572. /**
  54573. * Draw a list of indexed primitives
  54574. * @param fillMode defines the primitive to use
  54575. * @param indexStart defines the starting index
  54576. * @param indexCount defines the number of index to draw
  54577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54578. */
  54579. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54580. /**
  54581. * Draw a list of unindexed primitives
  54582. * @param fillMode defines the primitive to use
  54583. * @param verticesStart defines the index of first vertex to draw
  54584. * @param verticesCount defines the count of vertices to draw
  54585. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54586. */
  54587. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54588. createPipelineContext(): IPipelineContext;
  54589. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54590. /** @hidden */
  54591. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54592. /** @hidden */
  54593. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54594. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54595. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54596. protected _setProgram(program: WebGLProgram): void;
  54597. _releaseEffect(effect: Effect): void;
  54598. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54599. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54600. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54601. bindSamplers(effect: Effect): void;
  54602. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54603. getRenderWidth(useScreen?: boolean): number;
  54604. getRenderHeight(useScreen?: boolean): number;
  54605. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54606. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54607. /**
  54608. * Set the z offset to apply to current rendering
  54609. * @param value defines the offset to apply
  54610. */
  54611. setZOffset(value: number): void;
  54612. /**
  54613. * Gets the current value of the zOffset
  54614. * @returns the current zOffset state
  54615. */
  54616. getZOffset(): number;
  54617. /**
  54618. * Enable or disable depth buffering
  54619. * @param enable defines the state to set
  54620. */
  54621. setDepthBuffer(enable: boolean): void;
  54622. /**
  54623. * Gets a boolean indicating if depth writing is enabled
  54624. * @returns the current depth writing state
  54625. */
  54626. getDepthWrite(): boolean;
  54627. /**
  54628. * Enable or disable depth writing
  54629. * @param enable defines the state to set
  54630. */
  54631. setDepthWrite(enable: boolean): void;
  54632. /**
  54633. * Enable or disable color writing
  54634. * @param enable defines the state to set
  54635. */
  54636. setColorWrite(enable: boolean): void;
  54637. /**
  54638. * Gets a boolean indicating if color writing is enabled
  54639. * @returns the current color writing state
  54640. */
  54641. getColorWrite(): boolean;
  54642. /**
  54643. * Sets alpha constants used by some alpha blending modes
  54644. * @param r defines the red component
  54645. * @param g defines the green component
  54646. * @param b defines the blue component
  54647. * @param a defines the alpha component
  54648. */
  54649. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54650. /**
  54651. * Sets the current alpha mode
  54652. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54653. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54654. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54655. */
  54656. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54657. /**
  54658. * Gets the current alpha mode
  54659. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54660. * @returns the current alpha mode
  54661. */
  54662. getAlphaMode(): number;
  54663. setInt(uniform: WebGLUniformLocation, int: number): void;
  54664. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54665. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54666. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54667. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54668. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54669. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54670. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54671. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54672. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54673. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54674. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54675. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54676. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54677. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54678. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54679. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54680. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54681. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54682. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54683. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54684. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54685. wipeCaches(bruteForce?: boolean): void;
  54686. _createTexture(): WebGLTexture;
  54687. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54688. /**
  54689. * Usually called from Texture.ts.
  54690. * Passed information to create a WebGLTexture
  54691. * @param url defines a value which contains one of the following:
  54692. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54693. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54694. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54695. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54696. * @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)
  54697. * @param scene needed for loading to the correct scene
  54698. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54699. * @param onLoad optional callback to be called upon successful completion
  54700. * @param onError optional callback to be called upon failure
  54701. * @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
  54702. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54703. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54704. * @param forcedExtension defines the extension to use to pick the right loader
  54705. * @param mimeType defines an optional mime type
  54706. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54707. */
  54708. 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;
  54709. /**
  54710. * Creates a cube texture
  54711. * @param rootUrl defines the url where the files to load is located
  54712. * @param scene defines the current scene
  54713. * @param files defines the list of files to load (1 per face)
  54714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54715. * @param onLoad defines an optional callback raised when the texture is loaded
  54716. * @param onError defines an optional callback raised if there is an issue to load the texture
  54717. * @param format defines the format of the data
  54718. * @param forcedExtension defines the extension to use to pick the right loader
  54719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54722. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54723. * @returns the cube texture as an InternalTexture
  54724. */
  54725. 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;
  54726. private _getSamplingFilter;
  54727. private static _GetNativeTextureFormat;
  54728. createRenderTargetTexture(size: number | {
  54729. width: number;
  54730. height: number;
  54731. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54732. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54733. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54734. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54735. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54736. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54737. /**
  54738. * Updates a dynamic vertex buffer.
  54739. * @param vertexBuffer the vertex buffer to update
  54740. * @param data the data used to update the vertex buffer
  54741. * @param byteOffset the byte offset of the data (optional)
  54742. * @param byteLength the byte length of the data (optional)
  54743. */
  54744. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54745. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54746. private _updateAnisotropicLevel;
  54747. private _getAddressMode;
  54748. /** @hidden */
  54749. _bindTexture(channel: number, texture: InternalTexture): void;
  54750. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54751. releaseEffects(): void;
  54752. /** @hidden */
  54753. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54754. /** @hidden */
  54755. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54756. /** @hidden */
  54757. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54758. /** @hidden */
  54759. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54760. }
  54761. }
  54762. declare module "babylonjs/Engines/index" {
  54763. export * from "babylonjs/Engines/constants";
  54764. export * from "babylonjs/Engines/engineCapabilities";
  54765. export * from "babylonjs/Engines/instancingAttributeInfo";
  54766. export * from "babylonjs/Engines/thinEngine";
  54767. export * from "babylonjs/Engines/engine";
  54768. export * from "babylonjs/Engines/engineStore";
  54769. export * from "babylonjs/Engines/nullEngine";
  54770. export * from "babylonjs/Engines/Extensions/index";
  54771. export * from "babylonjs/Engines/IPipelineContext";
  54772. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54773. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54774. export * from "babylonjs/Engines/nativeEngine";
  54775. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54776. export * from "babylonjs/Engines/performanceConfigurator";
  54777. }
  54778. declare module "babylonjs/Events/clipboardEvents" {
  54779. /**
  54780. * Gather the list of clipboard event types as constants.
  54781. */
  54782. export class ClipboardEventTypes {
  54783. /**
  54784. * The clipboard event is fired when a copy command is active (pressed).
  54785. */
  54786. static readonly COPY: number;
  54787. /**
  54788. * The clipboard event is fired when a cut command is active (pressed).
  54789. */
  54790. static readonly CUT: number;
  54791. /**
  54792. * The clipboard event is fired when a paste command is active (pressed).
  54793. */
  54794. static readonly PASTE: number;
  54795. }
  54796. /**
  54797. * This class is used to store clipboard related info for the onClipboardObservable event.
  54798. */
  54799. export class ClipboardInfo {
  54800. /**
  54801. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54802. */
  54803. type: number;
  54804. /**
  54805. * Defines the related dom event
  54806. */
  54807. event: ClipboardEvent;
  54808. /**
  54809. *Creates an instance of ClipboardInfo.
  54810. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54811. * @param event Defines the related dom event
  54812. */
  54813. constructor(
  54814. /**
  54815. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54816. */
  54817. type: number,
  54818. /**
  54819. * Defines the related dom event
  54820. */
  54821. event: ClipboardEvent);
  54822. /**
  54823. * Get the clipboard event's type from the keycode.
  54824. * @param keyCode Defines the keyCode for the current keyboard event.
  54825. * @return {number}
  54826. */
  54827. static GetTypeFromCharacter(keyCode: number): number;
  54828. }
  54829. }
  54830. declare module "babylonjs/Events/index" {
  54831. export * from "babylonjs/Events/keyboardEvents";
  54832. export * from "babylonjs/Events/pointerEvents";
  54833. export * from "babylonjs/Events/clipboardEvents";
  54834. }
  54835. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54836. import { Scene } from "babylonjs/scene";
  54837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54838. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54839. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54840. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54841. /**
  54842. * Google Daydream controller
  54843. */
  54844. export class DaydreamController extends WebVRController {
  54845. /**
  54846. * Base Url for the controller model.
  54847. */
  54848. static MODEL_BASE_URL: string;
  54849. /**
  54850. * File name for the controller model.
  54851. */
  54852. static MODEL_FILENAME: string;
  54853. /**
  54854. * Gamepad Id prefix used to identify Daydream Controller.
  54855. */
  54856. static readonly GAMEPAD_ID_PREFIX: string;
  54857. /**
  54858. * Creates a new DaydreamController from a gamepad
  54859. * @param vrGamepad the gamepad that the controller should be created from
  54860. */
  54861. constructor(vrGamepad: any);
  54862. /**
  54863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54864. * @param scene scene in which to add meshes
  54865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54866. */
  54867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54868. /**
  54869. * Called once for each button that changed state since the last frame
  54870. * @param buttonIdx Which button index changed
  54871. * @param state New state of the button
  54872. * @param changes Which properties on the state changed since last frame
  54873. */
  54874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54875. }
  54876. }
  54877. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54878. import { Scene } from "babylonjs/scene";
  54879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54880. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54881. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54882. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54883. /**
  54884. * Gear VR Controller
  54885. */
  54886. export class GearVRController extends WebVRController {
  54887. /**
  54888. * Base Url for the controller model.
  54889. */
  54890. static MODEL_BASE_URL: string;
  54891. /**
  54892. * File name for the controller model.
  54893. */
  54894. static MODEL_FILENAME: string;
  54895. /**
  54896. * Gamepad Id prefix used to identify this controller.
  54897. */
  54898. static readonly GAMEPAD_ID_PREFIX: string;
  54899. private readonly _buttonIndexToObservableNameMap;
  54900. /**
  54901. * Creates a new GearVRController from a gamepad
  54902. * @param vrGamepad the gamepad that the controller should be created from
  54903. */
  54904. constructor(vrGamepad: any);
  54905. /**
  54906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54907. * @param scene scene in which to add meshes
  54908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54909. */
  54910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54911. /**
  54912. * Called once for each button that changed state since the last frame
  54913. * @param buttonIdx Which button index changed
  54914. * @param state New state of the button
  54915. * @param changes Which properties on the state changed since last frame
  54916. */
  54917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54918. }
  54919. }
  54920. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54921. import { Scene } from "babylonjs/scene";
  54922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54923. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54924. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54925. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54926. /**
  54927. * Generic Controller
  54928. */
  54929. export class GenericController extends WebVRController {
  54930. /**
  54931. * Base Url for the controller model.
  54932. */
  54933. static readonly MODEL_BASE_URL: string;
  54934. /**
  54935. * File name for the controller model.
  54936. */
  54937. static readonly MODEL_FILENAME: string;
  54938. /**
  54939. * Creates a new GenericController from a gamepad
  54940. * @param vrGamepad the gamepad that the controller should be created from
  54941. */
  54942. constructor(vrGamepad: any);
  54943. /**
  54944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54945. * @param scene scene in which to add meshes
  54946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54947. */
  54948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54949. /**
  54950. * Called once for each button that changed state since the last frame
  54951. * @param buttonIdx Which button index changed
  54952. * @param state New state of the button
  54953. * @param changes Which properties on the state changed since last frame
  54954. */
  54955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54956. }
  54957. }
  54958. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54959. import { Observable } from "babylonjs/Misc/observable";
  54960. import { Scene } from "babylonjs/scene";
  54961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54962. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54963. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54964. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54965. /**
  54966. * Oculus Touch Controller
  54967. */
  54968. export class OculusTouchController extends WebVRController {
  54969. /**
  54970. * Base Url for the controller model.
  54971. */
  54972. static MODEL_BASE_URL: string;
  54973. /**
  54974. * File name for the left controller model.
  54975. */
  54976. static MODEL_LEFT_FILENAME: string;
  54977. /**
  54978. * File name for the right controller model.
  54979. */
  54980. static MODEL_RIGHT_FILENAME: string;
  54981. /**
  54982. * Base Url for the Quest controller model.
  54983. */
  54984. static QUEST_MODEL_BASE_URL: string;
  54985. /**
  54986. * @hidden
  54987. * If the controllers are running on a device that needs the updated Quest controller models
  54988. */
  54989. static _IsQuest: boolean;
  54990. /**
  54991. * Fired when the secondary trigger on this controller is modified
  54992. */
  54993. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54994. /**
  54995. * Fired when the thumb rest on this controller is modified
  54996. */
  54997. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54998. /**
  54999. * Creates a new OculusTouchController from a gamepad
  55000. * @param vrGamepad the gamepad that the controller should be created from
  55001. */
  55002. constructor(vrGamepad: any);
  55003. /**
  55004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55005. * @param scene scene in which to add meshes
  55006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55007. */
  55008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55009. /**
  55010. * Fired when the A button on this controller is modified
  55011. */
  55012. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55013. /**
  55014. * Fired when the B button on this controller is modified
  55015. */
  55016. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55017. /**
  55018. * Fired when the X button on this controller is modified
  55019. */
  55020. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55021. /**
  55022. * Fired when the Y button on this controller is modified
  55023. */
  55024. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55025. /**
  55026. * Called once for each button that changed state since the last frame
  55027. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55028. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55029. * 2) secondary trigger (same)
  55030. * 3) A (right) X (left), touch, pressed = value
  55031. * 4) B / Y
  55032. * 5) thumb rest
  55033. * @param buttonIdx Which button index changed
  55034. * @param state New state of the button
  55035. * @param changes Which properties on the state changed since last frame
  55036. */
  55037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55038. }
  55039. }
  55040. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55041. import { Scene } from "babylonjs/scene";
  55042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55043. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55044. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55045. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55046. import { Observable } from "babylonjs/Misc/observable";
  55047. /**
  55048. * Vive Controller
  55049. */
  55050. export class ViveController extends WebVRController {
  55051. /**
  55052. * Base Url for the controller model.
  55053. */
  55054. static MODEL_BASE_URL: string;
  55055. /**
  55056. * File name for the controller model.
  55057. */
  55058. static MODEL_FILENAME: string;
  55059. /**
  55060. * Creates a new ViveController from a gamepad
  55061. * @param vrGamepad the gamepad that the controller should be created from
  55062. */
  55063. constructor(vrGamepad: any);
  55064. /**
  55065. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55066. * @param scene scene in which to add meshes
  55067. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55068. */
  55069. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55070. /**
  55071. * Fired when the left button on this controller is modified
  55072. */
  55073. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55074. /**
  55075. * Fired when the right button on this controller is modified
  55076. */
  55077. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55078. /**
  55079. * Fired when the menu button on this controller is modified
  55080. */
  55081. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55082. /**
  55083. * Called once for each button that changed state since the last frame
  55084. * Vive mapping:
  55085. * 0: touchpad
  55086. * 1: trigger
  55087. * 2: left AND right buttons
  55088. * 3: menu button
  55089. * @param buttonIdx Which button index changed
  55090. * @param state New state of the button
  55091. * @param changes Which properties on the state changed since last frame
  55092. */
  55093. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55094. }
  55095. }
  55096. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55097. import { Observable } from "babylonjs/Misc/observable";
  55098. import { Scene } from "babylonjs/scene";
  55099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55100. import { Ray } from "babylonjs/Culling/ray";
  55101. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55102. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55103. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55104. /**
  55105. * Defines the WindowsMotionController object that the state of the windows motion controller
  55106. */
  55107. export class WindowsMotionController extends WebVRController {
  55108. /**
  55109. * The base url used to load the left and right controller models
  55110. */
  55111. static MODEL_BASE_URL: string;
  55112. /**
  55113. * The name of the left controller model file
  55114. */
  55115. static MODEL_LEFT_FILENAME: string;
  55116. /**
  55117. * The name of the right controller model file
  55118. */
  55119. static MODEL_RIGHT_FILENAME: string;
  55120. /**
  55121. * The controller name prefix for this controller type
  55122. */
  55123. static readonly GAMEPAD_ID_PREFIX: string;
  55124. /**
  55125. * The controller id pattern for this controller type
  55126. */
  55127. private static readonly GAMEPAD_ID_PATTERN;
  55128. private _loadedMeshInfo;
  55129. protected readonly _mapping: {
  55130. buttons: string[];
  55131. buttonMeshNames: {
  55132. trigger: string;
  55133. menu: string;
  55134. grip: string;
  55135. thumbstick: string;
  55136. trackpad: string;
  55137. };
  55138. buttonObservableNames: {
  55139. trigger: string;
  55140. menu: string;
  55141. grip: string;
  55142. thumbstick: string;
  55143. trackpad: string;
  55144. };
  55145. axisMeshNames: string[];
  55146. pointingPoseMeshName: string;
  55147. };
  55148. /**
  55149. * Fired when the trackpad on this controller is clicked
  55150. */
  55151. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55152. /**
  55153. * Fired when the trackpad on this controller is modified
  55154. */
  55155. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55156. /**
  55157. * The current x and y values of this controller's trackpad
  55158. */
  55159. trackpad: StickValues;
  55160. /**
  55161. * Creates a new WindowsMotionController from a gamepad
  55162. * @param vrGamepad the gamepad that the controller should be created from
  55163. */
  55164. constructor(vrGamepad: any);
  55165. /**
  55166. * Fired when the trigger on this controller is modified
  55167. */
  55168. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55169. /**
  55170. * Fired when the menu button on this controller is modified
  55171. */
  55172. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55173. /**
  55174. * Fired when the grip button on this controller is modified
  55175. */
  55176. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55177. /**
  55178. * Fired when the thumbstick button on this controller is modified
  55179. */
  55180. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55181. /**
  55182. * Fired when the touchpad button on this controller is modified
  55183. */
  55184. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55185. /**
  55186. * Fired when the touchpad values on this controller are modified
  55187. */
  55188. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55189. protected _updateTrackpad(): void;
  55190. /**
  55191. * Called once per frame by the engine.
  55192. */
  55193. update(): void;
  55194. /**
  55195. * Called once for each button that changed state since the last frame
  55196. * @param buttonIdx Which button index changed
  55197. * @param state New state of the button
  55198. * @param changes Which properties on the state changed since last frame
  55199. */
  55200. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55201. /**
  55202. * Moves the buttons on the controller mesh based on their current state
  55203. * @param buttonName the name of the button to move
  55204. * @param buttonValue the value of the button which determines the buttons new position
  55205. */
  55206. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55207. /**
  55208. * Moves the axis on the controller mesh based on its current state
  55209. * @param axis the index of the axis
  55210. * @param axisValue the value of the axis which determines the meshes new position
  55211. * @hidden
  55212. */
  55213. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55214. /**
  55215. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55216. * @param scene scene in which to add meshes
  55217. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55218. */
  55219. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55220. /**
  55221. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55222. * can be transformed by button presses and axes values, based on this._mapping.
  55223. *
  55224. * @param scene scene in which the meshes exist
  55225. * @param meshes list of meshes that make up the controller model to process
  55226. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55227. */
  55228. private processModel;
  55229. private createMeshInfo;
  55230. /**
  55231. * Gets the ray of the controller in the direction the controller is pointing
  55232. * @param length the length the resulting ray should be
  55233. * @returns a ray in the direction the controller is pointing
  55234. */
  55235. getForwardRay(length?: number): Ray;
  55236. /**
  55237. * Disposes of the controller
  55238. */
  55239. dispose(): void;
  55240. }
  55241. /**
  55242. * This class represents a new windows motion controller in XR.
  55243. */
  55244. export class XRWindowsMotionController extends WindowsMotionController {
  55245. /**
  55246. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55247. */
  55248. protected readonly _mapping: {
  55249. buttons: string[];
  55250. buttonMeshNames: {
  55251. trigger: string;
  55252. menu: string;
  55253. grip: string;
  55254. thumbstick: string;
  55255. trackpad: string;
  55256. };
  55257. buttonObservableNames: {
  55258. trigger: string;
  55259. menu: string;
  55260. grip: string;
  55261. thumbstick: string;
  55262. trackpad: string;
  55263. };
  55264. axisMeshNames: string[];
  55265. pointingPoseMeshName: string;
  55266. };
  55267. /**
  55268. * Construct a new XR-Based windows motion controller
  55269. *
  55270. * @param gamepadInfo the gamepad object from the browser
  55271. */
  55272. constructor(gamepadInfo: any);
  55273. /**
  55274. * holds the thumbstick values (X,Y)
  55275. */
  55276. thumbstickValues: StickValues;
  55277. /**
  55278. * Fired when the thumbstick on this controller is clicked
  55279. */
  55280. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55281. /**
  55282. * Fired when the thumbstick on this controller is modified
  55283. */
  55284. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55285. /**
  55286. * Fired when the touchpad button on this controller is modified
  55287. */
  55288. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55289. /**
  55290. * Fired when the touchpad values on this controller are modified
  55291. */
  55292. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55293. /**
  55294. * Fired when the thumbstick button on this controller is modified
  55295. * here to prevent breaking changes
  55296. */
  55297. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55298. /**
  55299. * updating the thumbstick(!) and not the trackpad.
  55300. * This is named this way due to the difference between WebVR and XR and to avoid
  55301. * changing the parent class.
  55302. */
  55303. protected _updateTrackpad(): void;
  55304. /**
  55305. * Disposes the class with joy
  55306. */
  55307. dispose(): void;
  55308. }
  55309. }
  55310. declare module "babylonjs/Gamepads/Controllers/index" {
  55311. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55312. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55313. export * from "babylonjs/Gamepads/Controllers/genericController";
  55314. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55315. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55316. export * from "babylonjs/Gamepads/Controllers/viveController";
  55317. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55318. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55319. }
  55320. declare module "babylonjs/Gamepads/index" {
  55321. export * from "babylonjs/Gamepads/Controllers/index";
  55322. export * from "babylonjs/Gamepads/gamepad";
  55323. export * from "babylonjs/Gamepads/gamepadManager";
  55324. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55325. export * from "babylonjs/Gamepads/xboxGamepad";
  55326. export * from "babylonjs/Gamepads/dualShockGamepad";
  55327. }
  55328. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55329. import { Scene } from "babylonjs/scene";
  55330. import { Vector4 } from "babylonjs/Maths/math.vector";
  55331. import { Color4 } from "babylonjs/Maths/math.color";
  55332. import { Mesh } from "babylonjs/Meshes/mesh";
  55333. import { Nullable } from "babylonjs/types";
  55334. /**
  55335. * Class containing static functions to help procedurally build meshes
  55336. */
  55337. export class PolyhedronBuilder {
  55338. /**
  55339. * Creates a polyhedron mesh
  55340. * * 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
  55341. * * The parameter `size` (positive float, default 1) sets the polygon size
  55342. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55343. * * 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`
  55344. * * 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
  55345. * * 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)`)
  55346. * * 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
  55347. * * 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
  55348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55351. * @param name defines the name of the mesh
  55352. * @param options defines the options used to create the mesh
  55353. * @param scene defines the hosting scene
  55354. * @returns the polyhedron mesh
  55355. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55356. */
  55357. static CreatePolyhedron(name: string, options: {
  55358. type?: number;
  55359. size?: number;
  55360. sizeX?: number;
  55361. sizeY?: number;
  55362. sizeZ?: number;
  55363. custom?: any;
  55364. faceUV?: Vector4[];
  55365. faceColors?: Color4[];
  55366. flat?: boolean;
  55367. updatable?: boolean;
  55368. sideOrientation?: number;
  55369. frontUVs?: Vector4;
  55370. backUVs?: Vector4;
  55371. }, scene?: Nullable<Scene>): Mesh;
  55372. }
  55373. }
  55374. declare module "babylonjs/Gizmos/scaleGizmo" {
  55375. import { Observable } from "babylonjs/Misc/observable";
  55376. import { Nullable } from "babylonjs/types";
  55377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55378. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55379. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55380. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55381. import { Node } from "babylonjs/node";
  55382. /**
  55383. * Gizmo that enables scaling a mesh along 3 axis
  55384. */
  55385. export class ScaleGizmo extends Gizmo {
  55386. /**
  55387. * Internal gizmo used for interactions on the x axis
  55388. */
  55389. xGizmo: AxisScaleGizmo;
  55390. /**
  55391. * Internal gizmo used for interactions on the y axis
  55392. */
  55393. yGizmo: AxisScaleGizmo;
  55394. /**
  55395. * Internal gizmo used for interactions on the z axis
  55396. */
  55397. zGizmo: AxisScaleGizmo;
  55398. /**
  55399. * Internal gizmo used to scale all axis equally
  55400. */
  55401. uniformScaleGizmo: AxisScaleGizmo;
  55402. private _meshAttached;
  55403. private _nodeAttached;
  55404. private _updateGizmoRotationToMatchAttachedMesh;
  55405. private _snapDistance;
  55406. private _scaleRatio;
  55407. private _uniformScalingMesh;
  55408. private _octahedron;
  55409. private _sensitivity;
  55410. /** Fires an event when any of it's sub gizmos are dragged */
  55411. onDragStartObservable: Observable<unknown>;
  55412. /** Fires an event when any of it's sub gizmos are released from dragging */
  55413. onDragEndObservable: Observable<unknown>;
  55414. get attachedMesh(): Nullable<AbstractMesh>;
  55415. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55416. get attachedNode(): Nullable<Node>;
  55417. set attachedNode(node: Nullable<Node>);
  55418. /**
  55419. * Creates a ScaleGizmo
  55420. * @param gizmoLayer The utility layer the gizmo will be added to
  55421. * @param thickness display gizmo axis thickness
  55422. */
  55423. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55424. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55425. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55426. /**
  55427. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55428. */
  55429. set snapDistance(value: number);
  55430. get snapDistance(): number;
  55431. /**
  55432. * Ratio for the scale of the gizmo (Default: 1)
  55433. */
  55434. set scaleRatio(value: number);
  55435. get scaleRatio(): number;
  55436. /**
  55437. * Sensitivity factor for dragging (Default: 1)
  55438. */
  55439. set sensitivity(value: number);
  55440. get sensitivity(): number;
  55441. /**
  55442. * Disposes of the gizmo
  55443. */
  55444. dispose(): void;
  55445. }
  55446. }
  55447. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55448. import { Observable } from "babylonjs/Misc/observable";
  55449. import { Nullable } from "babylonjs/types";
  55450. import { Vector3 } from "babylonjs/Maths/math.vector";
  55451. import { Node } from "babylonjs/node";
  55452. import { Mesh } from "babylonjs/Meshes/mesh";
  55453. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55454. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55455. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55456. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55457. import { Color3 } from "babylonjs/Maths/math.color";
  55458. /**
  55459. * Single axis scale gizmo
  55460. */
  55461. export class AxisScaleGizmo extends Gizmo {
  55462. /**
  55463. * Drag behavior responsible for the gizmos dragging interactions
  55464. */
  55465. dragBehavior: PointerDragBehavior;
  55466. private _pointerObserver;
  55467. /**
  55468. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55469. */
  55470. snapDistance: number;
  55471. /**
  55472. * Event that fires each time the gizmo snaps to a new location.
  55473. * * snapDistance is the the change in distance
  55474. */
  55475. onSnapObservable: Observable<{
  55476. snapDistance: number;
  55477. }>;
  55478. /**
  55479. * If the scaling operation should be done on all axis (default: false)
  55480. */
  55481. uniformScaling: boolean;
  55482. /**
  55483. * Custom sensitivity value for the drag strength
  55484. */
  55485. sensitivity: number;
  55486. private _isEnabled;
  55487. private _parent;
  55488. private _arrow;
  55489. private _coloredMaterial;
  55490. private _hoverMaterial;
  55491. /**
  55492. * Creates an AxisScaleGizmo
  55493. * @param gizmoLayer The utility layer the gizmo will be added to
  55494. * @param dragAxis The axis which the gizmo will be able to scale on
  55495. * @param color The color of the gizmo
  55496. * @param thickness display gizmo axis thickness
  55497. */
  55498. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55499. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55500. /**
  55501. * If the gizmo is enabled
  55502. */
  55503. set isEnabled(value: boolean);
  55504. get isEnabled(): boolean;
  55505. /**
  55506. * Disposes of the gizmo
  55507. */
  55508. dispose(): void;
  55509. /**
  55510. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55511. * @param mesh The mesh to replace the default mesh of the gizmo
  55512. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55513. */
  55514. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55515. }
  55516. }
  55517. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55518. import { Observable } from "babylonjs/Misc/observable";
  55519. import { Nullable } from "babylonjs/types";
  55520. import { Vector3 } from "babylonjs/Maths/math.vector";
  55521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55522. import { Mesh } from "babylonjs/Meshes/mesh";
  55523. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55524. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55525. import { Color3 } from "babylonjs/Maths/math.color";
  55526. import "babylonjs/Meshes/Builders/boxBuilder";
  55527. /**
  55528. * Bounding box gizmo
  55529. */
  55530. export class BoundingBoxGizmo extends Gizmo {
  55531. private _lineBoundingBox;
  55532. private _rotateSpheresParent;
  55533. private _scaleBoxesParent;
  55534. private _boundingDimensions;
  55535. private _renderObserver;
  55536. private _pointerObserver;
  55537. private _scaleDragSpeed;
  55538. private _tmpQuaternion;
  55539. private _tmpVector;
  55540. private _tmpRotationMatrix;
  55541. /**
  55542. * 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)
  55543. */
  55544. ignoreChildren: boolean;
  55545. /**
  55546. * 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)
  55547. */
  55548. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55549. /**
  55550. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55551. */
  55552. rotationSphereSize: number;
  55553. /**
  55554. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55555. */
  55556. scaleBoxSize: number;
  55557. /**
  55558. * 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)
  55559. */
  55560. fixedDragMeshScreenSize: boolean;
  55561. /**
  55562. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55563. */
  55564. fixedDragMeshScreenSizeDistanceFactor: number;
  55565. /**
  55566. * Fired when a rotation sphere or scale box is dragged
  55567. */
  55568. onDragStartObservable: Observable<{}>;
  55569. /**
  55570. * Fired when a scale box is dragged
  55571. */
  55572. onScaleBoxDragObservable: Observable<{}>;
  55573. /**
  55574. * Fired when a scale box drag is ended
  55575. */
  55576. onScaleBoxDragEndObservable: Observable<{}>;
  55577. /**
  55578. * Fired when a rotation sphere is dragged
  55579. */
  55580. onRotationSphereDragObservable: Observable<{}>;
  55581. /**
  55582. * Fired when a rotation sphere drag is ended
  55583. */
  55584. onRotationSphereDragEndObservable: Observable<{}>;
  55585. /**
  55586. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  55587. */
  55588. scalePivot: Nullable<Vector3>;
  55589. /**
  55590. * Mesh used as a pivot to rotate the attached node
  55591. */
  55592. private _anchorMesh;
  55593. private _existingMeshScale;
  55594. private _dragMesh;
  55595. private pointerDragBehavior;
  55596. private coloredMaterial;
  55597. private hoverColoredMaterial;
  55598. /**
  55599. * Sets the color of the bounding box gizmo
  55600. * @param color the color to set
  55601. */
  55602. setColor(color: Color3): void;
  55603. /**
  55604. * Creates an BoundingBoxGizmo
  55605. * @param gizmoLayer The utility layer the gizmo will be added to
  55606. * @param color The color of the gizmo
  55607. */
  55608. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55609. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55610. private _selectNode;
  55611. /**
  55612. * Updates the bounding box information for the Gizmo
  55613. */
  55614. updateBoundingBox(): void;
  55615. private _updateRotationSpheres;
  55616. private _updateScaleBoxes;
  55617. /**
  55618. * Enables rotation on the specified axis and disables rotation on the others
  55619. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55620. */
  55621. setEnabledRotationAxis(axis: string): void;
  55622. /**
  55623. * Enables/disables scaling
  55624. * @param enable if scaling should be enabled
  55625. * @param homogeneousScaling defines if scaling should only be homogeneous
  55626. */
  55627. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55628. private _updateDummy;
  55629. /**
  55630. * Enables a pointer drag behavior on the bounding box of the gizmo
  55631. */
  55632. enableDragBehavior(): void;
  55633. /**
  55634. * Disposes of the gizmo
  55635. */
  55636. dispose(): void;
  55637. /**
  55638. * 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)
  55639. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55640. * @returns the bounding box mesh with the passed in mesh as a child
  55641. */
  55642. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55643. /**
  55644. * CustomMeshes are not supported by this gizmo
  55645. * @param mesh The mesh to replace the default mesh of the gizmo
  55646. */
  55647. setCustomMesh(mesh: Mesh): void;
  55648. }
  55649. }
  55650. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55651. import { Observable } from "babylonjs/Misc/observable";
  55652. import { Nullable } from "babylonjs/types";
  55653. import { Vector3 } from "babylonjs/Maths/math.vector";
  55654. import { Color3 } from "babylonjs/Maths/math.color";
  55655. import { Node } from "babylonjs/node";
  55656. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55657. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55658. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55659. import "babylonjs/Meshes/Builders/linesBuilder";
  55660. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55661. /**
  55662. * Single plane rotation gizmo
  55663. */
  55664. export class PlaneRotationGizmo extends Gizmo {
  55665. /**
  55666. * Drag behavior responsible for the gizmos dragging interactions
  55667. */
  55668. dragBehavior: PointerDragBehavior;
  55669. private _pointerObserver;
  55670. /**
  55671. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55672. */
  55673. snapDistance: number;
  55674. /**
  55675. * Event that fires each time the gizmo snaps to a new location.
  55676. * * snapDistance is the the change in distance
  55677. */
  55678. onSnapObservable: Observable<{
  55679. snapDistance: number;
  55680. }>;
  55681. private _isEnabled;
  55682. private _parent;
  55683. /**
  55684. * Creates a PlaneRotationGizmo
  55685. * @param gizmoLayer The utility layer the gizmo will be added to
  55686. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55687. * @param color The color of the gizmo
  55688. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55689. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55690. * @param thickness display gizmo axis thickness
  55691. */
  55692. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55693. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55694. /**
  55695. * If the gizmo is enabled
  55696. */
  55697. set isEnabled(value: boolean);
  55698. get isEnabled(): boolean;
  55699. /**
  55700. * Disposes of the gizmo
  55701. */
  55702. dispose(): void;
  55703. }
  55704. }
  55705. declare module "babylonjs/Gizmos/rotationGizmo" {
  55706. import { Observable } from "babylonjs/Misc/observable";
  55707. import { Nullable } from "babylonjs/types";
  55708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55709. import { Mesh } from "babylonjs/Meshes/mesh";
  55710. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55711. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55712. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55713. import { Node } from "babylonjs/node";
  55714. /**
  55715. * Gizmo that enables rotating a mesh along 3 axis
  55716. */
  55717. export class RotationGizmo extends Gizmo {
  55718. /**
  55719. * Internal gizmo used for interactions on the x axis
  55720. */
  55721. xGizmo: PlaneRotationGizmo;
  55722. /**
  55723. * Internal gizmo used for interactions on the y axis
  55724. */
  55725. yGizmo: PlaneRotationGizmo;
  55726. /**
  55727. * Internal gizmo used for interactions on the z axis
  55728. */
  55729. zGizmo: PlaneRotationGizmo;
  55730. /** Fires an event when any of it's sub gizmos are dragged */
  55731. onDragStartObservable: Observable<unknown>;
  55732. /** Fires an event when any of it's sub gizmos are released from dragging */
  55733. onDragEndObservable: Observable<unknown>;
  55734. private _meshAttached;
  55735. private _nodeAttached;
  55736. get attachedMesh(): Nullable<AbstractMesh>;
  55737. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55738. get attachedNode(): Nullable<Node>;
  55739. set attachedNode(node: Nullable<Node>);
  55740. /**
  55741. * Creates a RotationGizmo
  55742. * @param gizmoLayer The utility layer the gizmo will be added to
  55743. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55744. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55745. * @param thickness display gizmo axis thickness
  55746. */
  55747. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55748. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55749. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55750. /**
  55751. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55752. */
  55753. set snapDistance(value: number);
  55754. get snapDistance(): number;
  55755. /**
  55756. * Ratio for the scale of the gizmo (Default: 1)
  55757. */
  55758. set scaleRatio(value: number);
  55759. get scaleRatio(): number;
  55760. /**
  55761. * Disposes of the gizmo
  55762. */
  55763. dispose(): void;
  55764. /**
  55765. * CustomMeshes are not supported by this gizmo
  55766. * @param mesh The mesh to replace the default mesh of the gizmo
  55767. */
  55768. setCustomMesh(mesh: Mesh): void;
  55769. }
  55770. }
  55771. declare module "babylonjs/Gizmos/gizmoManager" {
  55772. import { Observable } from "babylonjs/Misc/observable";
  55773. import { Nullable } from "babylonjs/types";
  55774. import { Scene, IDisposable } from "babylonjs/scene";
  55775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55776. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55777. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55778. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55779. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55780. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55781. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55782. /**
  55783. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55784. */
  55785. export class GizmoManager implements IDisposable {
  55786. private scene;
  55787. /**
  55788. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55789. */
  55790. gizmos: {
  55791. positionGizmo: Nullable<PositionGizmo>;
  55792. rotationGizmo: Nullable<RotationGizmo>;
  55793. scaleGizmo: Nullable<ScaleGizmo>;
  55794. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55795. };
  55796. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55797. clearGizmoOnEmptyPointerEvent: boolean;
  55798. /** Fires an event when the manager is attached to a mesh */
  55799. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55800. private _gizmosEnabled;
  55801. private _pointerObserver;
  55802. private _attachedMesh;
  55803. private _boundingBoxColor;
  55804. private _defaultUtilityLayer;
  55805. private _defaultKeepDepthUtilityLayer;
  55806. private _thickness;
  55807. /**
  55808. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55809. */
  55810. boundingBoxDragBehavior: SixDofDragBehavior;
  55811. /**
  55812. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55813. */
  55814. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55815. /**
  55816. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55817. */
  55818. usePointerToAttachGizmos: boolean;
  55819. /**
  55820. * Utility layer that the bounding box gizmo belongs to
  55821. */
  55822. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55823. /**
  55824. * Utility layer that all gizmos besides bounding box belong to
  55825. */
  55826. get utilityLayer(): UtilityLayerRenderer;
  55827. /**
  55828. * Instatiates a gizmo manager
  55829. * @param scene the scene to overlay the gizmos on top of
  55830. * @param thickness display gizmo axis thickness
  55831. */
  55832. constructor(scene: Scene, thickness?: number);
  55833. /**
  55834. * Attaches a set of gizmos to the specified mesh
  55835. * @param mesh The mesh the gizmo's should be attached to
  55836. */
  55837. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55838. /**
  55839. * If the position gizmo is enabled
  55840. */
  55841. set positionGizmoEnabled(value: boolean);
  55842. get positionGizmoEnabled(): boolean;
  55843. /**
  55844. * If the rotation gizmo is enabled
  55845. */
  55846. set rotationGizmoEnabled(value: boolean);
  55847. get rotationGizmoEnabled(): boolean;
  55848. /**
  55849. * If the scale gizmo is enabled
  55850. */
  55851. set scaleGizmoEnabled(value: boolean);
  55852. get scaleGizmoEnabled(): boolean;
  55853. /**
  55854. * If the boundingBox gizmo is enabled
  55855. */
  55856. set boundingBoxGizmoEnabled(value: boolean);
  55857. get boundingBoxGizmoEnabled(): boolean;
  55858. /**
  55859. * Disposes of the gizmo manager
  55860. */
  55861. dispose(): void;
  55862. }
  55863. }
  55864. declare module "babylonjs/Lights/directionalLight" {
  55865. import { Camera } from "babylonjs/Cameras/camera";
  55866. import { Scene } from "babylonjs/scene";
  55867. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55869. import { Light } from "babylonjs/Lights/light";
  55870. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55871. import { Effect } from "babylonjs/Materials/effect";
  55872. /**
  55873. * A directional light is defined by a direction (what a surprise!).
  55874. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55875. * 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.
  55876. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55877. */
  55878. export class DirectionalLight extends ShadowLight {
  55879. private _shadowFrustumSize;
  55880. /**
  55881. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55882. */
  55883. get shadowFrustumSize(): number;
  55884. /**
  55885. * Specifies a fix frustum size for the shadow generation.
  55886. */
  55887. set shadowFrustumSize(value: number);
  55888. private _shadowOrthoScale;
  55889. /**
  55890. * Gets the shadow projection scale against the optimal computed one.
  55891. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55892. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55893. */
  55894. get shadowOrthoScale(): number;
  55895. /**
  55896. * Sets the shadow projection scale against the optimal computed one.
  55897. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55898. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55899. */
  55900. set shadowOrthoScale(value: number);
  55901. /**
  55902. * Automatically compute the projection matrix to best fit (including all the casters)
  55903. * on each frame.
  55904. */
  55905. autoUpdateExtends: boolean;
  55906. /**
  55907. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55908. * on each frame. autoUpdateExtends must be set to true for this to work
  55909. */
  55910. autoCalcShadowZBounds: boolean;
  55911. private _orthoLeft;
  55912. private _orthoRight;
  55913. private _orthoTop;
  55914. private _orthoBottom;
  55915. /**
  55916. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55917. * The directional light is emitted from everywhere in the given direction.
  55918. * It can cast shadows.
  55919. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55920. * @param name The friendly name of the light
  55921. * @param direction The direction of the light
  55922. * @param scene The scene the light belongs to
  55923. */
  55924. constructor(name: string, direction: Vector3, scene: Scene);
  55925. /**
  55926. * Returns the string "DirectionalLight".
  55927. * @return The class name
  55928. */
  55929. getClassName(): string;
  55930. /**
  55931. * Returns the integer 1.
  55932. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55933. */
  55934. getTypeID(): number;
  55935. /**
  55936. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55937. * Returns the DirectionalLight Shadow projection matrix.
  55938. */
  55939. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55940. /**
  55941. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55942. * Returns the DirectionalLight Shadow projection matrix.
  55943. */
  55944. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55945. /**
  55946. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55947. * Returns the DirectionalLight Shadow projection matrix.
  55948. */
  55949. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55950. protected _buildUniformLayout(): void;
  55951. /**
  55952. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55953. * @param effect The effect to update
  55954. * @param lightIndex The index of the light in the effect to update
  55955. * @returns The directional light
  55956. */
  55957. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55958. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55959. /**
  55960. * Gets the minZ used for shadow according to both the scene and the light.
  55961. *
  55962. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55963. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55964. * @param activeCamera The camera we are returning the min for
  55965. * @returns the depth min z
  55966. */
  55967. getDepthMinZ(activeCamera: Camera): number;
  55968. /**
  55969. * Gets the maxZ used for shadow according to both the scene and the light.
  55970. *
  55971. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55972. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55973. * @param activeCamera The camera we are returning the max for
  55974. * @returns the depth max z
  55975. */
  55976. getDepthMaxZ(activeCamera: Camera): number;
  55977. /**
  55978. * Prepares the list of defines specific to the light type.
  55979. * @param defines the list of defines
  55980. * @param lightIndex defines the index of the light for the effect
  55981. */
  55982. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55983. }
  55984. }
  55985. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55986. import { Mesh } from "babylonjs/Meshes/mesh";
  55987. /**
  55988. * Class containing static functions to help procedurally build meshes
  55989. */
  55990. export class HemisphereBuilder {
  55991. /**
  55992. * Creates a hemisphere mesh
  55993. * @param name defines the name of the mesh
  55994. * @param options defines the options used to create the mesh
  55995. * @param scene defines the hosting scene
  55996. * @returns the hemisphere mesh
  55997. */
  55998. static CreateHemisphere(name: string, options: {
  55999. segments?: number;
  56000. diameter?: number;
  56001. sideOrientation?: number;
  56002. }, scene: any): Mesh;
  56003. }
  56004. }
  56005. declare module "babylonjs/Lights/spotLight" {
  56006. import { Nullable } from "babylonjs/types";
  56007. import { Scene } from "babylonjs/scene";
  56008. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56010. import { Effect } from "babylonjs/Materials/effect";
  56011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56012. import { Light } from "babylonjs/Lights/light";
  56013. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56014. /**
  56015. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56016. * These values define a cone of light starting from the position, emitting toward the direction.
  56017. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56018. * and the exponent defines the speed of the decay of the light with distance (reach).
  56019. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56020. */
  56021. export class SpotLight extends ShadowLight {
  56022. private _angle;
  56023. private _innerAngle;
  56024. private _cosHalfAngle;
  56025. private _lightAngleScale;
  56026. private _lightAngleOffset;
  56027. /**
  56028. * Gets the cone angle of the spot light in Radians.
  56029. */
  56030. get angle(): number;
  56031. /**
  56032. * Sets the cone angle of the spot light in Radians.
  56033. */
  56034. set angle(value: number);
  56035. /**
  56036. * Only used in gltf falloff mode, this defines the angle where
  56037. * the directional falloff will start before cutting at angle which could be seen
  56038. * as outer angle.
  56039. */
  56040. get innerAngle(): number;
  56041. /**
  56042. * Only used in gltf falloff mode, this defines the angle where
  56043. * the directional falloff will start before cutting at angle which could be seen
  56044. * as outer angle.
  56045. */
  56046. set innerAngle(value: number);
  56047. private _shadowAngleScale;
  56048. /**
  56049. * Allows scaling the angle of the light for shadow generation only.
  56050. */
  56051. get shadowAngleScale(): number;
  56052. /**
  56053. * Allows scaling the angle of the light for shadow generation only.
  56054. */
  56055. set shadowAngleScale(value: number);
  56056. /**
  56057. * The light decay speed with the distance from the emission spot.
  56058. */
  56059. exponent: number;
  56060. private _projectionTextureMatrix;
  56061. /**
  56062. * Allows reading the projecton texture
  56063. */
  56064. get projectionTextureMatrix(): Matrix;
  56065. protected _projectionTextureLightNear: number;
  56066. /**
  56067. * Gets the near clip of the Spotlight for texture projection.
  56068. */
  56069. get projectionTextureLightNear(): number;
  56070. /**
  56071. * Sets the near clip of the Spotlight for texture projection.
  56072. */
  56073. set projectionTextureLightNear(value: number);
  56074. protected _projectionTextureLightFar: number;
  56075. /**
  56076. * Gets the far clip of the Spotlight for texture projection.
  56077. */
  56078. get projectionTextureLightFar(): number;
  56079. /**
  56080. * Sets the far clip of the Spotlight for texture projection.
  56081. */
  56082. set projectionTextureLightFar(value: number);
  56083. protected _projectionTextureUpDirection: Vector3;
  56084. /**
  56085. * Gets the Up vector of the Spotlight for texture projection.
  56086. */
  56087. get projectionTextureUpDirection(): Vector3;
  56088. /**
  56089. * Sets the Up vector of the Spotlight for texture projection.
  56090. */
  56091. set projectionTextureUpDirection(value: Vector3);
  56092. private _projectionTexture;
  56093. /**
  56094. * Gets the projection texture of the light.
  56095. */
  56096. get projectionTexture(): Nullable<BaseTexture>;
  56097. /**
  56098. * Sets the projection texture of the light.
  56099. */
  56100. set projectionTexture(value: Nullable<BaseTexture>);
  56101. private _projectionTextureViewLightDirty;
  56102. private _projectionTextureProjectionLightDirty;
  56103. private _projectionTextureDirty;
  56104. private _projectionTextureViewTargetVector;
  56105. private _projectionTextureViewLightMatrix;
  56106. private _projectionTextureProjectionLightMatrix;
  56107. private _projectionTextureScalingMatrix;
  56108. /**
  56109. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56110. * It can cast shadows.
  56111. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56112. * @param name The light friendly name
  56113. * @param position The position of the spot light in the scene
  56114. * @param direction The direction of the light in the scene
  56115. * @param angle The cone angle of the light in Radians
  56116. * @param exponent The light decay speed with the distance from the emission spot
  56117. * @param scene The scene the lights belongs to
  56118. */
  56119. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56120. /**
  56121. * Returns the string "SpotLight".
  56122. * @returns the class name
  56123. */
  56124. getClassName(): string;
  56125. /**
  56126. * Returns the integer 2.
  56127. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56128. */
  56129. getTypeID(): number;
  56130. /**
  56131. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56132. */
  56133. protected _setDirection(value: Vector3): void;
  56134. /**
  56135. * Overrides the position setter to recompute the projection texture view light Matrix.
  56136. */
  56137. protected _setPosition(value: Vector3): void;
  56138. /**
  56139. * 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.
  56140. * Returns the SpotLight.
  56141. */
  56142. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56143. protected _computeProjectionTextureViewLightMatrix(): void;
  56144. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56145. /**
  56146. * Main function for light texture projection matrix computing.
  56147. */
  56148. protected _computeProjectionTextureMatrix(): void;
  56149. protected _buildUniformLayout(): void;
  56150. private _computeAngleValues;
  56151. /**
  56152. * Sets the passed Effect "effect" with the Light textures.
  56153. * @param effect The effect to update
  56154. * @param lightIndex The index of the light in the effect to update
  56155. * @returns The light
  56156. */
  56157. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56158. /**
  56159. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56160. * @param effect The effect to update
  56161. * @param lightIndex The index of the light in the effect to update
  56162. * @returns The spot light
  56163. */
  56164. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56165. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56166. /**
  56167. * Disposes the light and the associated resources.
  56168. */
  56169. dispose(): void;
  56170. /**
  56171. * Prepares the list of defines specific to the light type.
  56172. * @param defines the list of defines
  56173. * @param lightIndex defines the index of the light for the effect
  56174. */
  56175. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56176. }
  56177. }
  56178. declare module "babylonjs/Gizmos/lightGizmo" {
  56179. import { Nullable } from "babylonjs/types";
  56180. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56181. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56182. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56183. import { Light } from "babylonjs/Lights/light";
  56184. /**
  56185. * Gizmo that enables viewing a light
  56186. */
  56187. export class LightGizmo extends Gizmo {
  56188. private _lightMesh;
  56189. private _material;
  56190. private _cachedPosition;
  56191. private _cachedForward;
  56192. private _attachedMeshParent;
  56193. /**
  56194. * Creates a LightGizmo
  56195. * @param gizmoLayer The utility layer the gizmo will be added to
  56196. */
  56197. constructor(gizmoLayer?: UtilityLayerRenderer);
  56198. private _light;
  56199. /**
  56200. * The light that the gizmo is attached to
  56201. */
  56202. set light(light: Nullable<Light>);
  56203. get light(): Nullable<Light>;
  56204. /**
  56205. * Gets the material used to render the light gizmo
  56206. */
  56207. get material(): StandardMaterial;
  56208. /**
  56209. * @hidden
  56210. * Updates the gizmo to match the attached mesh's position/rotation
  56211. */
  56212. protected _update(): void;
  56213. private static _Scale;
  56214. /**
  56215. * Creates the lines for a light mesh
  56216. */
  56217. private static _CreateLightLines;
  56218. /**
  56219. * Disposes of the light gizmo
  56220. */
  56221. dispose(): void;
  56222. private static _CreateHemisphericLightMesh;
  56223. private static _CreatePointLightMesh;
  56224. private static _CreateSpotLightMesh;
  56225. private static _CreateDirectionalLightMesh;
  56226. }
  56227. }
  56228. declare module "babylonjs/Gizmos/index" {
  56229. export * from "babylonjs/Gizmos/axisDragGizmo";
  56230. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56231. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56232. export * from "babylonjs/Gizmos/gizmo";
  56233. export * from "babylonjs/Gizmos/gizmoManager";
  56234. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56235. export * from "babylonjs/Gizmos/positionGizmo";
  56236. export * from "babylonjs/Gizmos/rotationGizmo";
  56237. export * from "babylonjs/Gizmos/scaleGizmo";
  56238. export * from "babylonjs/Gizmos/lightGizmo";
  56239. export * from "babylonjs/Gizmos/planeDragGizmo";
  56240. }
  56241. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56242. /** @hidden */
  56243. export var backgroundFragmentDeclaration: {
  56244. name: string;
  56245. shader: string;
  56246. };
  56247. }
  56248. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56249. /** @hidden */
  56250. export var backgroundUboDeclaration: {
  56251. name: string;
  56252. shader: string;
  56253. };
  56254. }
  56255. declare module "babylonjs/Shaders/background.fragment" {
  56256. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56257. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56258. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56259. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56260. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56261. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56262. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56263. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56264. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56265. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56266. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56267. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56268. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56269. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56270. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56271. /** @hidden */
  56272. export var backgroundPixelShader: {
  56273. name: string;
  56274. shader: string;
  56275. };
  56276. }
  56277. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56278. /** @hidden */
  56279. export var backgroundVertexDeclaration: {
  56280. name: string;
  56281. shader: string;
  56282. };
  56283. }
  56284. declare module "babylonjs/Shaders/background.vertex" {
  56285. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56286. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56287. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56288. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56289. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56291. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56292. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56293. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56294. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56295. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56296. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56297. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56298. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56299. /** @hidden */
  56300. export var backgroundVertexShader: {
  56301. name: string;
  56302. shader: string;
  56303. };
  56304. }
  56305. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56306. import { Nullable, int, float } from "babylonjs/types";
  56307. import { Scene } from "babylonjs/scene";
  56308. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56309. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56311. import { Mesh } from "babylonjs/Meshes/mesh";
  56312. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56314. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56316. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56317. import { Color3 } from "babylonjs/Maths/math.color";
  56318. import "babylonjs/Shaders/background.fragment";
  56319. import "babylonjs/Shaders/background.vertex";
  56320. /**
  56321. * Background material used to create an efficient environement around your scene.
  56322. */
  56323. export class BackgroundMaterial extends PushMaterial {
  56324. /**
  56325. * Standard reflectance value at parallel view angle.
  56326. */
  56327. static StandardReflectance0: number;
  56328. /**
  56329. * Standard reflectance value at grazing angle.
  56330. */
  56331. static StandardReflectance90: number;
  56332. protected _primaryColor: Color3;
  56333. /**
  56334. * Key light Color (multiply against the environement texture)
  56335. */
  56336. primaryColor: Color3;
  56337. protected __perceptualColor: Nullable<Color3>;
  56338. /**
  56339. * Experimental Internal Use Only.
  56340. *
  56341. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56342. * This acts as a helper to set the primary color to a more "human friendly" value.
  56343. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56344. * output color as close as possible from the chosen value.
  56345. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56346. * part of lighting setup.)
  56347. */
  56348. get _perceptualColor(): Nullable<Color3>;
  56349. set _perceptualColor(value: Nullable<Color3>);
  56350. protected _primaryColorShadowLevel: float;
  56351. /**
  56352. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56353. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56354. */
  56355. get primaryColorShadowLevel(): float;
  56356. set primaryColorShadowLevel(value: float);
  56357. protected _primaryColorHighlightLevel: float;
  56358. /**
  56359. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56360. * The primary color is used at the level chosen to define what the white area would look.
  56361. */
  56362. get primaryColorHighlightLevel(): float;
  56363. set primaryColorHighlightLevel(value: float);
  56364. protected _reflectionTexture: Nullable<BaseTexture>;
  56365. /**
  56366. * Reflection Texture used in the material.
  56367. * Should be author in a specific way for the best result (refer to the documentation).
  56368. */
  56369. reflectionTexture: Nullable<BaseTexture>;
  56370. protected _reflectionBlur: float;
  56371. /**
  56372. * Reflection Texture level of blur.
  56373. *
  56374. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56375. * texture twice.
  56376. */
  56377. reflectionBlur: float;
  56378. protected _diffuseTexture: Nullable<BaseTexture>;
  56379. /**
  56380. * Diffuse Texture used in the material.
  56381. * Should be author in a specific way for the best result (refer to the documentation).
  56382. */
  56383. diffuseTexture: Nullable<BaseTexture>;
  56384. protected _shadowLights: Nullable<IShadowLight[]>;
  56385. /**
  56386. * Specify the list of lights casting shadow on the material.
  56387. * All scene shadow lights will be included if null.
  56388. */
  56389. shadowLights: Nullable<IShadowLight[]>;
  56390. protected _shadowLevel: float;
  56391. /**
  56392. * Helps adjusting the shadow to a softer level if required.
  56393. * 0 means black shadows and 1 means no shadows.
  56394. */
  56395. shadowLevel: float;
  56396. protected _sceneCenter: Vector3;
  56397. /**
  56398. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56399. * It is usually zero but might be interesting to modify according to your setup.
  56400. */
  56401. sceneCenter: Vector3;
  56402. protected _opacityFresnel: boolean;
  56403. /**
  56404. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56405. * This helps ensuring a nice transition when the camera goes under the ground.
  56406. */
  56407. opacityFresnel: boolean;
  56408. protected _reflectionFresnel: boolean;
  56409. /**
  56410. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56411. * This helps adding a mirror texture on the ground.
  56412. */
  56413. reflectionFresnel: boolean;
  56414. protected _reflectionFalloffDistance: number;
  56415. /**
  56416. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56417. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56418. */
  56419. reflectionFalloffDistance: number;
  56420. protected _reflectionAmount: number;
  56421. /**
  56422. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56423. */
  56424. reflectionAmount: number;
  56425. protected _reflectionReflectance0: number;
  56426. /**
  56427. * This specifies the weight of the reflection at grazing angle.
  56428. */
  56429. reflectionReflectance0: number;
  56430. protected _reflectionReflectance90: number;
  56431. /**
  56432. * This specifies the weight of the reflection at a perpendicular point of view.
  56433. */
  56434. reflectionReflectance90: number;
  56435. /**
  56436. * Sets the reflection reflectance fresnel values according to the default standard
  56437. * empirically know to work well :-)
  56438. */
  56439. set reflectionStandardFresnelWeight(value: number);
  56440. protected _useRGBColor: boolean;
  56441. /**
  56442. * Helps to directly use the maps channels instead of their level.
  56443. */
  56444. useRGBColor: boolean;
  56445. protected _enableNoise: boolean;
  56446. /**
  56447. * This helps reducing the banding effect that could occur on the background.
  56448. */
  56449. enableNoise: boolean;
  56450. /**
  56451. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56452. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56453. * Recommended to be keep at 1.0 except for special cases.
  56454. */
  56455. get fovMultiplier(): number;
  56456. set fovMultiplier(value: number);
  56457. private _fovMultiplier;
  56458. /**
  56459. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56460. */
  56461. useEquirectangularFOV: boolean;
  56462. private _maxSimultaneousLights;
  56463. /**
  56464. * Number of Simultaneous lights allowed on the material.
  56465. */
  56466. maxSimultaneousLights: int;
  56467. private _shadowOnly;
  56468. /**
  56469. * Make the material only render shadows
  56470. */
  56471. shadowOnly: boolean;
  56472. /**
  56473. * Default configuration related to image processing available in the Background Material.
  56474. */
  56475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56476. /**
  56477. * Keep track of the image processing observer to allow dispose and replace.
  56478. */
  56479. private _imageProcessingObserver;
  56480. /**
  56481. * Attaches a new image processing configuration to the PBR Material.
  56482. * @param configuration (if null the scene configuration will be use)
  56483. */
  56484. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56485. /**
  56486. * Gets the image processing configuration used either in this material.
  56487. */
  56488. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56489. /**
  56490. * Sets the Default image processing configuration used either in the this material.
  56491. *
  56492. * If sets to null, the scene one is in use.
  56493. */
  56494. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56495. /**
  56496. * Gets wether the color curves effect is enabled.
  56497. */
  56498. get cameraColorCurvesEnabled(): boolean;
  56499. /**
  56500. * Sets wether the color curves effect is enabled.
  56501. */
  56502. set cameraColorCurvesEnabled(value: boolean);
  56503. /**
  56504. * Gets wether the color grading effect is enabled.
  56505. */
  56506. get cameraColorGradingEnabled(): boolean;
  56507. /**
  56508. * Gets wether the color grading effect is enabled.
  56509. */
  56510. set cameraColorGradingEnabled(value: boolean);
  56511. /**
  56512. * Gets wether tonemapping is enabled or not.
  56513. */
  56514. get cameraToneMappingEnabled(): boolean;
  56515. /**
  56516. * Sets wether tonemapping is enabled or not
  56517. */
  56518. set cameraToneMappingEnabled(value: boolean);
  56519. /**
  56520. * The camera exposure used on this material.
  56521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56522. * This corresponds to a photographic exposure.
  56523. */
  56524. get cameraExposure(): float;
  56525. /**
  56526. * The camera exposure used on this material.
  56527. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56528. * This corresponds to a photographic exposure.
  56529. */
  56530. set cameraExposure(value: float);
  56531. /**
  56532. * Gets The camera contrast used on this material.
  56533. */
  56534. get cameraContrast(): float;
  56535. /**
  56536. * Sets The camera contrast used on this material.
  56537. */
  56538. set cameraContrast(value: float);
  56539. /**
  56540. * Gets the Color Grading 2D Lookup Texture.
  56541. */
  56542. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56543. /**
  56544. * Sets the Color Grading 2D Lookup Texture.
  56545. */
  56546. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56547. /**
  56548. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56549. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56550. * 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;
  56551. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56552. */
  56553. get cameraColorCurves(): Nullable<ColorCurves>;
  56554. /**
  56555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56557. * 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;
  56558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56559. */
  56560. set cameraColorCurves(value: Nullable<ColorCurves>);
  56561. /**
  56562. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56563. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56564. */
  56565. switchToBGR: boolean;
  56566. private _renderTargets;
  56567. private _reflectionControls;
  56568. private _white;
  56569. private _primaryShadowColor;
  56570. private _primaryHighlightColor;
  56571. /**
  56572. * Instantiates a Background Material in the given scene
  56573. * @param name The friendly name of the material
  56574. * @param scene The scene to add the material to
  56575. */
  56576. constructor(name: string, scene: Scene);
  56577. /**
  56578. * Gets a boolean indicating that current material needs to register RTT
  56579. */
  56580. get hasRenderTargetTextures(): boolean;
  56581. /**
  56582. * The entire material has been created in order to prevent overdraw.
  56583. * @returns false
  56584. */
  56585. needAlphaTesting(): boolean;
  56586. /**
  56587. * The entire material has been created in order to prevent overdraw.
  56588. * @returns true if blending is enable
  56589. */
  56590. needAlphaBlending(): boolean;
  56591. /**
  56592. * Checks wether the material is ready to be rendered for a given mesh.
  56593. * @param mesh The mesh to render
  56594. * @param subMesh The submesh to check against
  56595. * @param useInstances Specify wether or not the material is used with instances
  56596. * @returns true if all the dependencies are ready (Textures, Effects...)
  56597. */
  56598. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56599. /**
  56600. * Compute the primary color according to the chosen perceptual color.
  56601. */
  56602. private _computePrimaryColorFromPerceptualColor;
  56603. /**
  56604. * Compute the highlights and shadow colors according to their chosen levels.
  56605. */
  56606. private _computePrimaryColors;
  56607. /**
  56608. * Build the uniform buffer used in the material.
  56609. */
  56610. buildUniformLayout(): void;
  56611. /**
  56612. * Unbind the material.
  56613. */
  56614. unbind(): void;
  56615. /**
  56616. * Bind only the world matrix to the material.
  56617. * @param world The world matrix to bind.
  56618. */
  56619. bindOnlyWorldMatrix(world: Matrix): void;
  56620. /**
  56621. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56622. * @param world The world matrix to bind.
  56623. * @param subMesh The submesh to bind for.
  56624. */
  56625. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56626. /**
  56627. * Checks to see if a texture is used in the material.
  56628. * @param texture - Base texture to use.
  56629. * @returns - Boolean specifying if a texture is used in the material.
  56630. */
  56631. hasTexture(texture: BaseTexture): boolean;
  56632. /**
  56633. * Dispose the material.
  56634. * @param forceDisposeEffect Force disposal of the associated effect.
  56635. * @param forceDisposeTextures Force disposal of the associated textures.
  56636. */
  56637. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56638. /**
  56639. * Clones the material.
  56640. * @param name The cloned name.
  56641. * @returns The cloned material.
  56642. */
  56643. clone(name: string): BackgroundMaterial;
  56644. /**
  56645. * Serializes the current material to its JSON representation.
  56646. * @returns The JSON representation.
  56647. */
  56648. serialize(): any;
  56649. /**
  56650. * Gets the class name of the material
  56651. * @returns "BackgroundMaterial"
  56652. */
  56653. getClassName(): string;
  56654. /**
  56655. * Parse a JSON input to create back a background material.
  56656. * @param source The JSON data to parse
  56657. * @param scene The scene to create the parsed material in
  56658. * @param rootUrl The root url of the assets the material depends upon
  56659. * @returns the instantiated BackgroundMaterial.
  56660. */
  56661. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56662. }
  56663. }
  56664. declare module "babylonjs/Helpers/environmentHelper" {
  56665. import { Observable } from "babylonjs/Misc/observable";
  56666. import { Nullable } from "babylonjs/types";
  56667. import { Scene } from "babylonjs/scene";
  56668. import { Vector3 } from "babylonjs/Maths/math.vector";
  56669. import { Color3 } from "babylonjs/Maths/math.color";
  56670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56671. import { Mesh } from "babylonjs/Meshes/mesh";
  56672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56673. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56674. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56675. import "babylonjs/Meshes/Builders/planeBuilder";
  56676. import "babylonjs/Meshes/Builders/boxBuilder";
  56677. /**
  56678. * Represents the different options available during the creation of
  56679. * a Environment helper.
  56680. *
  56681. * This can control the default ground, skybox and image processing setup of your scene.
  56682. */
  56683. export interface IEnvironmentHelperOptions {
  56684. /**
  56685. * Specifies whether or not to create a ground.
  56686. * True by default.
  56687. */
  56688. createGround: boolean;
  56689. /**
  56690. * Specifies the ground size.
  56691. * 15 by default.
  56692. */
  56693. groundSize: number;
  56694. /**
  56695. * The texture used on the ground for the main color.
  56696. * Comes from the BabylonJS CDN by default.
  56697. *
  56698. * Remarks: Can be either a texture or a url.
  56699. */
  56700. groundTexture: string | BaseTexture;
  56701. /**
  56702. * The color mixed in the ground texture by default.
  56703. * BabylonJS clearColor by default.
  56704. */
  56705. groundColor: Color3;
  56706. /**
  56707. * Specifies the ground opacity.
  56708. * 1 by default.
  56709. */
  56710. groundOpacity: number;
  56711. /**
  56712. * Enables the ground to receive shadows.
  56713. * True by default.
  56714. */
  56715. enableGroundShadow: boolean;
  56716. /**
  56717. * Helps preventing the shadow to be fully black on the ground.
  56718. * 0.5 by default.
  56719. */
  56720. groundShadowLevel: number;
  56721. /**
  56722. * Creates a mirror texture attach to the ground.
  56723. * false by default.
  56724. */
  56725. enableGroundMirror: boolean;
  56726. /**
  56727. * Specifies the ground mirror size ratio.
  56728. * 0.3 by default as the default kernel is 64.
  56729. */
  56730. groundMirrorSizeRatio: number;
  56731. /**
  56732. * Specifies the ground mirror blur kernel size.
  56733. * 64 by default.
  56734. */
  56735. groundMirrorBlurKernel: number;
  56736. /**
  56737. * Specifies the ground mirror visibility amount.
  56738. * 1 by default
  56739. */
  56740. groundMirrorAmount: number;
  56741. /**
  56742. * Specifies the ground mirror reflectance weight.
  56743. * This uses the standard weight of the background material to setup the fresnel effect
  56744. * of the mirror.
  56745. * 1 by default.
  56746. */
  56747. groundMirrorFresnelWeight: number;
  56748. /**
  56749. * Specifies the ground mirror Falloff distance.
  56750. * This can helps reducing the size of the reflection.
  56751. * 0 by Default.
  56752. */
  56753. groundMirrorFallOffDistance: number;
  56754. /**
  56755. * Specifies the ground mirror texture type.
  56756. * Unsigned Int by Default.
  56757. */
  56758. groundMirrorTextureType: number;
  56759. /**
  56760. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56761. * the shown objects.
  56762. */
  56763. groundYBias: number;
  56764. /**
  56765. * Specifies whether or not to create a skybox.
  56766. * True by default.
  56767. */
  56768. createSkybox: boolean;
  56769. /**
  56770. * Specifies the skybox size.
  56771. * 20 by default.
  56772. */
  56773. skyboxSize: number;
  56774. /**
  56775. * The texture used on the skybox for the main color.
  56776. * Comes from the BabylonJS CDN by default.
  56777. *
  56778. * Remarks: Can be either a texture or a url.
  56779. */
  56780. skyboxTexture: string | BaseTexture;
  56781. /**
  56782. * The color mixed in the skybox texture by default.
  56783. * BabylonJS clearColor by default.
  56784. */
  56785. skyboxColor: Color3;
  56786. /**
  56787. * The background rotation around the Y axis of the scene.
  56788. * This helps aligning the key lights of your scene with the background.
  56789. * 0 by default.
  56790. */
  56791. backgroundYRotation: number;
  56792. /**
  56793. * Compute automatically the size of the elements to best fit with the scene.
  56794. */
  56795. sizeAuto: boolean;
  56796. /**
  56797. * Default position of the rootMesh if autoSize is not true.
  56798. */
  56799. rootPosition: Vector3;
  56800. /**
  56801. * Sets up the image processing in the scene.
  56802. * true by default.
  56803. */
  56804. setupImageProcessing: boolean;
  56805. /**
  56806. * The texture used as your environment texture in the scene.
  56807. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56808. *
  56809. * Remarks: Can be either a texture or a url.
  56810. */
  56811. environmentTexture: string | BaseTexture;
  56812. /**
  56813. * The value of the exposure to apply to the scene.
  56814. * 0.6 by default if setupImageProcessing is true.
  56815. */
  56816. cameraExposure: number;
  56817. /**
  56818. * The value of the contrast to apply to the scene.
  56819. * 1.6 by default if setupImageProcessing is true.
  56820. */
  56821. cameraContrast: number;
  56822. /**
  56823. * Specifies whether or not tonemapping should be enabled in the scene.
  56824. * true by default if setupImageProcessing is true.
  56825. */
  56826. toneMappingEnabled: boolean;
  56827. }
  56828. /**
  56829. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56830. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56831. * It also helps with the default setup of your imageProcessing configuration.
  56832. */
  56833. export class EnvironmentHelper {
  56834. /**
  56835. * Default ground texture URL.
  56836. */
  56837. private static _groundTextureCDNUrl;
  56838. /**
  56839. * Default skybox texture URL.
  56840. */
  56841. private static _skyboxTextureCDNUrl;
  56842. /**
  56843. * Default environment texture URL.
  56844. */
  56845. private static _environmentTextureCDNUrl;
  56846. /**
  56847. * Creates the default options for the helper.
  56848. */
  56849. private static _getDefaultOptions;
  56850. private _rootMesh;
  56851. /**
  56852. * Gets the root mesh created by the helper.
  56853. */
  56854. get rootMesh(): Mesh;
  56855. private _skybox;
  56856. /**
  56857. * Gets the skybox created by the helper.
  56858. */
  56859. get skybox(): Nullable<Mesh>;
  56860. private _skyboxTexture;
  56861. /**
  56862. * Gets the skybox texture created by the helper.
  56863. */
  56864. get skyboxTexture(): Nullable<BaseTexture>;
  56865. private _skyboxMaterial;
  56866. /**
  56867. * Gets the skybox material created by the helper.
  56868. */
  56869. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56870. private _ground;
  56871. /**
  56872. * Gets the ground mesh created by the helper.
  56873. */
  56874. get ground(): Nullable<Mesh>;
  56875. private _groundTexture;
  56876. /**
  56877. * Gets the ground texture created by the helper.
  56878. */
  56879. get groundTexture(): Nullable<BaseTexture>;
  56880. private _groundMirror;
  56881. /**
  56882. * Gets the ground mirror created by the helper.
  56883. */
  56884. get groundMirror(): Nullable<MirrorTexture>;
  56885. /**
  56886. * Gets the ground mirror render list to helps pushing the meshes
  56887. * you wish in the ground reflection.
  56888. */
  56889. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56890. private _groundMaterial;
  56891. /**
  56892. * Gets the ground material created by the helper.
  56893. */
  56894. get groundMaterial(): Nullable<BackgroundMaterial>;
  56895. /**
  56896. * Stores the creation options.
  56897. */
  56898. private readonly _scene;
  56899. private _options;
  56900. /**
  56901. * This observable will be notified with any error during the creation of the environment,
  56902. * mainly texture creation errors.
  56903. */
  56904. onErrorObservable: Observable<{
  56905. message?: string;
  56906. exception?: any;
  56907. }>;
  56908. /**
  56909. * constructor
  56910. * @param options Defines the options we want to customize the helper
  56911. * @param scene The scene to add the material to
  56912. */
  56913. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56914. /**
  56915. * Updates the background according to the new options
  56916. * @param options
  56917. */
  56918. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56919. /**
  56920. * Sets the primary color of all the available elements.
  56921. * @param color the main color to affect to the ground and the background
  56922. */
  56923. setMainColor(color: Color3): void;
  56924. /**
  56925. * Setup the image processing according to the specified options.
  56926. */
  56927. private _setupImageProcessing;
  56928. /**
  56929. * Setup the environment texture according to the specified options.
  56930. */
  56931. private _setupEnvironmentTexture;
  56932. /**
  56933. * Setup the background according to the specified options.
  56934. */
  56935. private _setupBackground;
  56936. /**
  56937. * Get the scene sizes according to the setup.
  56938. */
  56939. private _getSceneSize;
  56940. /**
  56941. * Setup the ground according to the specified options.
  56942. */
  56943. private _setupGround;
  56944. /**
  56945. * Setup the ground material according to the specified options.
  56946. */
  56947. private _setupGroundMaterial;
  56948. /**
  56949. * Setup the ground diffuse texture according to the specified options.
  56950. */
  56951. private _setupGroundDiffuseTexture;
  56952. /**
  56953. * Setup the ground mirror texture according to the specified options.
  56954. */
  56955. private _setupGroundMirrorTexture;
  56956. /**
  56957. * Setup the ground to receive the mirror texture.
  56958. */
  56959. private _setupMirrorInGroundMaterial;
  56960. /**
  56961. * Setup the skybox according to the specified options.
  56962. */
  56963. private _setupSkybox;
  56964. /**
  56965. * Setup the skybox material according to the specified options.
  56966. */
  56967. private _setupSkyboxMaterial;
  56968. /**
  56969. * Setup the skybox reflection texture according to the specified options.
  56970. */
  56971. private _setupSkyboxReflectionTexture;
  56972. private _errorHandler;
  56973. /**
  56974. * Dispose all the elements created by the Helper.
  56975. */
  56976. dispose(): void;
  56977. }
  56978. }
  56979. declare module "babylonjs/Helpers/photoDome" {
  56980. import { Observable } from "babylonjs/Misc/observable";
  56981. import { Nullable } from "babylonjs/types";
  56982. import { Scene } from "babylonjs/scene";
  56983. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56984. import { Mesh } from "babylonjs/Meshes/mesh";
  56985. import { Texture } from "babylonjs/Materials/Textures/texture";
  56986. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56987. import "babylonjs/Meshes/Builders/sphereBuilder";
  56988. /**
  56989. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56990. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56991. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56992. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56993. */
  56994. export class PhotoDome extends TransformNode {
  56995. /**
  56996. * Define the image as a Monoscopic panoramic 360 image.
  56997. */
  56998. static readonly MODE_MONOSCOPIC: number;
  56999. /**
  57000. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57001. */
  57002. static readonly MODE_TOPBOTTOM: number;
  57003. /**
  57004. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57005. */
  57006. static readonly MODE_SIDEBYSIDE: number;
  57007. private _useDirectMapping;
  57008. /**
  57009. * The texture being displayed on the sphere
  57010. */
  57011. protected _photoTexture: Texture;
  57012. /**
  57013. * Gets or sets the texture being displayed on the sphere
  57014. */
  57015. get photoTexture(): Texture;
  57016. set photoTexture(value: Texture);
  57017. /**
  57018. * Observable raised when an error occured while loading the 360 image
  57019. */
  57020. onLoadErrorObservable: Observable<string>;
  57021. /**
  57022. * The skybox material
  57023. */
  57024. protected _material: BackgroundMaterial;
  57025. /**
  57026. * The surface used for the skybox
  57027. */
  57028. protected _mesh: Mesh;
  57029. /**
  57030. * Gets the mesh used for the skybox.
  57031. */
  57032. get mesh(): Mesh;
  57033. /**
  57034. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57035. * Also see the options.resolution property.
  57036. */
  57037. get fovMultiplier(): number;
  57038. set fovMultiplier(value: number);
  57039. private _imageMode;
  57040. /**
  57041. * Gets or set the current video mode for the video. It can be:
  57042. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57043. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57044. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57045. */
  57046. get imageMode(): number;
  57047. set imageMode(value: number);
  57048. /**
  57049. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57050. * @param name Element's name, child elements will append suffixes for their own names.
  57051. * @param urlsOfPhoto defines the url of the photo to display
  57052. * @param options defines an object containing optional or exposed sub element properties
  57053. * @param onError defines a callback called when an error occured while loading the texture
  57054. */
  57055. constructor(name: string, urlOfPhoto: string, options: {
  57056. resolution?: number;
  57057. size?: number;
  57058. useDirectMapping?: boolean;
  57059. faceForward?: boolean;
  57060. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57061. private _onBeforeCameraRenderObserver;
  57062. private _changeImageMode;
  57063. /**
  57064. * Releases resources associated with this node.
  57065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57067. */
  57068. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57069. }
  57070. }
  57071. declare module "babylonjs/Misc/rgbdTextureTools" {
  57072. import "babylonjs/Shaders/rgbdDecode.fragment";
  57073. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57074. import { Texture } from "babylonjs/Materials/Textures/texture";
  57075. /**
  57076. * Class used to host RGBD texture specific utilities
  57077. */
  57078. export class RGBDTextureTools {
  57079. /**
  57080. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57081. * @param texture the texture to expand.
  57082. */
  57083. static ExpandRGBDTexture(texture: Texture): void;
  57084. }
  57085. }
  57086. declare module "babylonjs/Misc/brdfTextureTools" {
  57087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57088. import { Scene } from "babylonjs/scene";
  57089. /**
  57090. * Class used to host texture specific utilities
  57091. */
  57092. export class BRDFTextureTools {
  57093. /**
  57094. * Prevents texture cache collision
  57095. */
  57096. private static _instanceNumber;
  57097. /**
  57098. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57099. * @param scene defines the hosting scene
  57100. * @returns the environment BRDF texture
  57101. */
  57102. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57103. private static _environmentBRDFBase64Texture;
  57104. }
  57105. }
  57106. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57107. import { Nullable } from "babylonjs/types";
  57108. import { Color3 } from "babylonjs/Maths/math.color";
  57109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57110. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57111. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57112. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57113. import { Engine } from "babylonjs/Engines/engine";
  57114. import { Scene } from "babylonjs/scene";
  57115. /**
  57116. * @hidden
  57117. */
  57118. export interface IMaterialClearCoatDefines {
  57119. CLEARCOAT: boolean;
  57120. CLEARCOAT_DEFAULTIOR: boolean;
  57121. CLEARCOAT_TEXTURE: boolean;
  57122. CLEARCOAT_TEXTUREDIRECTUV: number;
  57123. CLEARCOAT_BUMP: boolean;
  57124. CLEARCOAT_BUMPDIRECTUV: number;
  57125. CLEARCOAT_TINT: boolean;
  57126. CLEARCOAT_TINT_TEXTURE: boolean;
  57127. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57128. /** @hidden */
  57129. _areTexturesDirty: boolean;
  57130. }
  57131. /**
  57132. * Define the code related to the clear coat parameters of the pbr material.
  57133. */
  57134. export class PBRClearCoatConfiguration {
  57135. /**
  57136. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57137. * The default fits with a polyurethane material.
  57138. */
  57139. private static readonly _DefaultIndexOfRefraction;
  57140. private _isEnabled;
  57141. /**
  57142. * Defines if the clear coat is enabled in the material.
  57143. */
  57144. isEnabled: boolean;
  57145. /**
  57146. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57147. */
  57148. intensity: number;
  57149. /**
  57150. * Defines the clear coat layer roughness.
  57151. */
  57152. roughness: number;
  57153. private _indexOfRefraction;
  57154. /**
  57155. * Defines the index of refraction of the clear coat.
  57156. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57157. * The default fits with a polyurethane material.
  57158. * Changing the default value is more performance intensive.
  57159. */
  57160. indexOfRefraction: number;
  57161. private _texture;
  57162. /**
  57163. * Stores the clear coat values in a texture.
  57164. */
  57165. texture: Nullable<BaseTexture>;
  57166. private _bumpTexture;
  57167. /**
  57168. * Define the clear coat specific bump texture.
  57169. */
  57170. bumpTexture: Nullable<BaseTexture>;
  57171. private _isTintEnabled;
  57172. /**
  57173. * Defines if the clear coat tint is enabled in the material.
  57174. */
  57175. isTintEnabled: boolean;
  57176. /**
  57177. * Defines the clear coat tint of the material.
  57178. * This is only use if tint is enabled
  57179. */
  57180. tintColor: Color3;
  57181. /**
  57182. * Defines the distance at which the tint color should be found in the
  57183. * clear coat media.
  57184. * This is only use if tint is enabled
  57185. */
  57186. tintColorAtDistance: number;
  57187. /**
  57188. * Defines the clear coat layer thickness.
  57189. * This is only use if tint is enabled
  57190. */
  57191. tintThickness: number;
  57192. private _tintTexture;
  57193. /**
  57194. * Stores the clear tint values in a texture.
  57195. * rgb is tint
  57196. * a is a thickness factor
  57197. */
  57198. tintTexture: Nullable<BaseTexture>;
  57199. /** @hidden */
  57200. private _internalMarkAllSubMeshesAsTexturesDirty;
  57201. /** @hidden */
  57202. _markAllSubMeshesAsTexturesDirty(): void;
  57203. /**
  57204. * Instantiate a new istance of clear coat configuration.
  57205. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57206. */
  57207. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57208. /**
  57209. * Gets wehter the submesh is ready to be used or not.
  57210. * @param defines the list of "defines" to update.
  57211. * @param scene defines the scene the material belongs to.
  57212. * @param engine defines the engine the material belongs to.
  57213. * @param disableBumpMap defines wether the material disables bump or not.
  57214. * @returns - boolean indicating that the submesh is ready or not.
  57215. */
  57216. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57217. /**
  57218. * Checks to see if a texture is used in the material.
  57219. * @param defines the list of "defines" to update.
  57220. * @param scene defines the scene to the material belongs to.
  57221. */
  57222. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57223. /**
  57224. * Binds the material data.
  57225. * @param uniformBuffer defines the Uniform buffer to fill in.
  57226. * @param scene defines the scene the material belongs to.
  57227. * @param engine defines the engine the material belongs to.
  57228. * @param disableBumpMap defines wether the material disables bump or not.
  57229. * @param isFrozen defines wether the material is frozen or not.
  57230. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57231. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57232. */
  57233. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57234. /**
  57235. * Checks to see if a texture is used in the material.
  57236. * @param texture - Base texture to use.
  57237. * @returns - Boolean specifying if a texture is used in the material.
  57238. */
  57239. hasTexture(texture: BaseTexture): boolean;
  57240. /**
  57241. * Returns an array of the actively used textures.
  57242. * @param activeTextures Array of BaseTextures
  57243. */
  57244. getActiveTextures(activeTextures: BaseTexture[]): void;
  57245. /**
  57246. * Returns the animatable textures.
  57247. * @param animatables Array of animatable textures.
  57248. */
  57249. getAnimatables(animatables: IAnimatable[]): void;
  57250. /**
  57251. * Disposes the resources of the material.
  57252. * @param forceDisposeTextures - Forces the disposal of all textures.
  57253. */
  57254. dispose(forceDisposeTextures?: boolean): void;
  57255. /**
  57256. * Get the current class name of the texture useful for serialization or dynamic coding.
  57257. * @returns "PBRClearCoatConfiguration"
  57258. */
  57259. getClassName(): string;
  57260. /**
  57261. * Add fallbacks to the effect fallbacks list.
  57262. * @param defines defines the Base texture to use.
  57263. * @param fallbacks defines the current fallback list.
  57264. * @param currentRank defines the current fallback rank.
  57265. * @returns the new fallback rank.
  57266. */
  57267. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57268. /**
  57269. * Add the required uniforms to the current list.
  57270. * @param uniforms defines the current uniform list.
  57271. */
  57272. static AddUniforms(uniforms: string[]): void;
  57273. /**
  57274. * Add the required samplers to the current list.
  57275. * @param samplers defines the current sampler list.
  57276. */
  57277. static AddSamplers(samplers: string[]): void;
  57278. /**
  57279. * Add the required uniforms to the current buffer.
  57280. * @param uniformBuffer defines the current uniform buffer.
  57281. */
  57282. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57283. /**
  57284. * Makes a duplicate of the current configuration into another one.
  57285. * @param clearCoatConfiguration define the config where to copy the info
  57286. */
  57287. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57288. /**
  57289. * Serializes this clear coat configuration.
  57290. * @returns - An object with the serialized config.
  57291. */
  57292. serialize(): any;
  57293. /**
  57294. * Parses a anisotropy Configuration from a serialized object.
  57295. * @param source - Serialized object.
  57296. * @param scene Defines the scene we are parsing for
  57297. * @param rootUrl Defines the rootUrl to load from
  57298. */
  57299. parse(source: any, scene: Scene, rootUrl: string): void;
  57300. }
  57301. }
  57302. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57303. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57305. import { Vector2 } from "babylonjs/Maths/math.vector";
  57306. import { Scene } from "babylonjs/scene";
  57307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57308. import { Nullable } from "babylonjs/types";
  57309. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57310. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57311. /**
  57312. * @hidden
  57313. */
  57314. export interface IMaterialAnisotropicDefines {
  57315. ANISOTROPIC: boolean;
  57316. ANISOTROPIC_TEXTURE: boolean;
  57317. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57318. MAINUV1: boolean;
  57319. _areTexturesDirty: boolean;
  57320. _needUVs: boolean;
  57321. }
  57322. /**
  57323. * Define the code related to the anisotropic parameters of the pbr material.
  57324. */
  57325. export class PBRAnisotropicConfiguration {
  57326. private _isEnabled;
  57327. /**
  57328. * Defines if the anisotropy is enabled in the material.
  57329. */
  57330. isEnabled: boolean;
  57331. /**
  57332. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57333. */
  57334. intensity: number;
  57335. /**
  57336. * Defines if the effect is along the tangents, bitangents or in between.
  57337. * By default, the effect is "strectching" the highlights along the tangents.
  57338. */
  57339. direction: Vector2;
  57340. private _texture;
  57341. /**
  57342. * Stores the anisotropy values in a texture.
  57343. * rg is direction (like normal from -1 to 1)
  57344. * b is a intensity
  57345. */
  57346. texture: Nullable<BaseTexture>;
  57347. /** @hidden */
  57348. private _internalMarkAllSubMeshesAsTexturesDirty;
  57349. /** @hidden */
  57350. _markAllSubMeshesAsTexturesDirty(): void;
  57351. /**
  57352. * Instantiate a new istance of anisotropy configuration.
  57353. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57354. */
  57355. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57356. /**
  57357. * Specifies that the submesh is ready to be used.
  57358. * @param defines the list of "defines" to update.
  57359. * @param scene defines the scene the material belongs to.
  57360. * @returns - boolean indicating that the submesh is ready or not.
  57361. */
  57362. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57363. /**
  57364. * Checks to see if a texture is used in the material.
  57365. * @param defines the list of "defines" to update.
  57366. * @param mesh the mesh we are preparing the defines for.
  57367. * @param scene defines the scene the material belongs to.
  57368. */
  57369. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57370. /**
  57371. * Binds the material data.
  57372. * @param uniformBuffer defines the Uniform buffer to fill in.
  57373. * @param scene defines the scene the material belongs to.
  57374. * @param isFrozen defines wether the material is frozen or not.
  57375. */
  57376. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57377. /**
  57378. * Checks to see if a texture is used in the material.
  57379. * @param texture - Base texture to use.
  57380. * @returns - Boolean specifying if a texture is used in the material.
  57381. */
  57382. hasTexture(texture: BaseTexture): boolean;
  57383. /**
  57384. * Returns an array of the actively used textures.
  57385. * @param activeTextures Array of BaseTextures
  57386. */
  57387. getActiveTextures(activeTextures: BaseTexture[]): void;
  57388. /**
  57389. * Returns the animatable textures.
  57390. * @param animatables Array of animatable textures.
  57391. */
  57392. getAnimatables(animatables: IAnimatable[]): void;
  57393. /**
  57394. * Disposes the resources of the material.
  57395. * @param forceDisposeTextures - Forces the disposal of all textures.
  57396. */
  57397. dispose(forceDisposeTextures?: boolean): void;
  57398. /**
  57399. * Get the current class name of the texture useful for serialization or dynamic coding.
  57400. * @returns "PBRAnisotropicConfiguration"
  57401. */
  57402. getClassName(): string;
  57403. /**
  57404. * Add fallbacks to the effect fallbacks list.
  57405. * @param defines defines the Base texture to use.
  57406. * @param fallbacks defines the current fallback list.
  57407. * @param currentRank defines the current fallback rank.
  57408. * @returns the new fallback rank.
  57409. */
  57410. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57411. /**
  57412. * Add the required uniforms to the current list.
  57413. * @param uniforms defines the current uniform list.
  57414. */
  57415. static AddUniforms(uniforms: string[]): void;
  57416. /**
  57417. * Add the required uniforms to the current buffer.
  57418. * @param uniformBuffer defines the current uniform buffer.
  57419. */
  57420. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57421. /**
  57422. * Add the required samplers to the current list.
  57423. * @param samplers defines the current sampler list.
  57424. */
  57425. static AddSamplers(samplers: string[]): void;
  57426. /**
  57427. * Makes a duplicate of the current configuration into another one.
  57428. * @param anisotropicConfiguration define the config where to copy the info
  57429. */
  57430. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57431. /**
  57432. * Serializes this anisotropy configuration.
  57433. * @returns - An object with the serialized config.
  57434. */
  57435. serialize(): any;
  57436. /**
  57437. * Parses a anisotropy Configuration from a serialized object.
  57438. * @param source - Serialized object.
  57439. * @param scene Defines the scene we are parsing for
  57440. * @param rootUrl Defines the rootUrl to load from
  57441. */
  57442. parse(source: any, scene: Scene, rootUrl: string): void;
  57443. }
  57444. }
  57445. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57446. import { Scene } from "babylonjs/scene";
  57447. /**
  57448. * @hidden
  57449. */
  57450. export interface IMaterialBRDFDefines {
  57451. BRDF_V_HEIGHT_CORRELATED: boolean;
  57452. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57453. SPHERICAL_HARMONICS: boolean;
  57454. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57455. /** @hidden */
  57456. _areMiscDirty: boolean;
  57457. }
  57458. /**
  57459. * Define the code related to the BRDF parameters of the pbr material.
  57460. */
  57461. export class PBRBRDFConfiguration {
  57462. /**
  57463. * Default value used for the energy conservation.
  57464. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57465. */
  57466. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57467. /**
  57468. * Default value used for the Smith Visibility Height Correlated mode.
  57469. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57470. */
  57471. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57472. /**
  57473. * Default value used for the IBL diffuse part.
  57474. * This can help switching back to the polynomials mode globally which is a tiny bit
  57475. * less GPU intensive at the drawback of a lower quality.
  57476. */
  57477. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57478. /**
  57479. * Default value used for activating energy conservation for the specular workflow.
  57480. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57481. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57482. */
  57483. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57484. private _useEnergyConservation;
  57485. /**
  57486. * Defines if the material uses energy conservation.
  57487. */
  57488. useEnergyConservation: boolean;
  57489. private _useSmithVisibilityHeightCorrelated;
  57490. /**
  57491. * LEGACY Mode set to false
  57492. * Defines if the material uses height smith correlated visibility term.
  57493. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57494. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57495. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57496. * Not relying on height correlated will also disable energy conservation.
  57497. */
  57498. useSmithVisibilityHeightCorrelated: boolean;
  57499. private _useSphericalHarmonics;
  57500. /**
  57501. * LEGACY Mode set to false
  57502. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57503. * diffuse part of the IBL.
  57504. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57505. * to the ground truth.
  57506. */
  57507. useSphericalHarmonics: boolean;
  57508. private _useSpecularGlossinessInputEnergyConservation;
  57509. /**
  57510. * Defines if the material uses energy conservation, when the specular workflow is active.
  57511. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57512. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57513. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57514. */
  57515. useSpecularGlossinessInputEnergyConservation: boolean;
  57516. /** @hidden */
  57517. private _internalMarkAllSubMeshesAsMiscDirty;
  57518. /** @hidden */
  57519. _markAllSubMeshesAsMiscDirty(): void;
  57520. /**
  57521. * Instantiate a new istance of clear coat configuration.
  57522. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57523. */
  57524. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57525. /**
  57526. * Checks to see if a texture is used in the material.
  57527. * @param defines the list of "defines" to update.
  57528. */
  57529. prepareDefines(defines: IMaterialBRDFDefines): void;
  57530. /**
  57531. * Get the current class name of the texture useful for serialization or dynamic coding.
  57532. * @returns "PBRClearCoatConfiguration"
  57533. */
  57534. getClassName(): string;
  57535. /**
  57536. * Makes a duplicate of the current configuration into another one.
  57537. * @param brdfConfiguration define the config where to copy the info
  57538. */
  57539. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57540. /**
  57541. * Serializes this BRDF configuration.
  57542. * @returns - An object with the serialized config.
  57543. */
  57544. serialize(): any;
  57545. /**
  57546. * Parses a anisotropy Configuration from a serialized object.
  57547. * @param source - Serialized object.
  57548. * @param scene Defines the scene we are parsing for
  57549. * @param rootUrl Defines the rootUrl to load from
  57550. */
  57551. parse(source: any, scene: Scene, rootUrl: string): void;
  57552. }
  57553. }
  57554. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57555. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57556. import { Color3 } from "babylonjs/Maths/math.color";
  57557. import { Scene } from "babylonjs/scene";
  57558. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57559. import { Nullable } from "babylonjs/types";
  57560. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57561. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57562. /**
  57563. * @hidden
  57564. */
  57565. export interface IMaterialSheenDefines {
  57566. SHEEN: boolean;
  57567. SHEEN_TEXTURE: boolean;
  57568. SHEEN_TEXTUREDIRECTUV: number;
  57569. SHEEN_LINKWITHALBEDO: boolean;
  57570. SHEEN_ROUGHNESS: boolean;
  57571. SHEEN_ALBEDOSCALING: boolean;
  57572. /** @hidden */
  57573. _areTexturesDirty: boolean;
  57574. }
  57575. /**
  57576. * Define the code related to the Sheen parameters of the pbr material.
  57577. */
  57578. export class PBRSheenConfiguration {
  57579. private _isEnabled;
  57580. /**
  57581. * Defines if the material uses sheen.
  57582. */
  57583. isEnabled: boolean;
  57584. private _linkSheenWithAlbedo;
  57585. /**
  57586. * Defines if the sheen is linked to the sheen color.
  57587. */
  57588. linkSheenWithAlbedo: boolean;
  57589. /**
  57590. * Defines the sheen intensity.
  57591. */
  57592. intensity: number;
  57593. /**
  57594. * Defines the sheen color.
  57595. */
  57596. color: Color3;
  57597. private _texture;
  57598. /**
  57599. * Stores the sheen tint values in a texture.
  57600. * rgb is tint
  57601. * a is a intensity or roughness if roughness has been defined
  57602. */
  57603. texture: Nullable<BaseTexture>;
  57604. private _roughness;
  57605. /**
  57606. * Defines the sheen roughness.
  57607. * It is not taken into account if linkSheenWithAlbedo is true.
  57608. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57609. */
  57610. roughness: Nullable<number>;
  57611. private _albedoScaling;
  57612. /**
  57613. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57614. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57615. * making it easier to setup and tweak the effect
  57616. */
  57617. albedoScaling: boolean;
  57618. /** @hidden */
  57619. private _internalMarkAllSubMeshesAsTexturesDirty;
  57620. /** @hidden */
  57621. _markAllSubMeshesAsTexturesDirty(): void;
  57622. /**
  57623. * Instantiate a new istance of clear coat configuration.
  57624. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57625. */
  57626. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57627. /**
  57628. * Specifies that the submesh is ready to be used.
  57629. * @param defines the list of "defines" to update.
  57630. * @param scene defines the scene the material belongs to.
  57631. * @returns - boolean indicating that the submesh is ready or not.
  57632. */
  57633. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57634. /**
  57635. * Checks to see if a texture is used in the material.
  57636. * @param defines the list of "defines" to update.
  57637. * @param scene defines the scene the material belongs to.
  57638. */
  57639. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57640. /**
  57641. * Binds the material data.
  57642. * @param uniformBuffer defines the Uniform buffer to fill in.
  57643. * @param scene defines the scene the material belongs to.
  57644. * @param isFrozen defines wether the material is frozen or not.
  57645. */
  57646. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57647. /**
  57648. * Checks to see if a texture is used in the material.
  57649. * @param texture - Base texture to use.
  57650. * @returns - Boolean specifying if a texture is used in the material.
  57651. */
  57652. hasTexture(texture: BaseTexture): boolean;
  57653. /**
  57654. * Returns an array of the actively used textures.
  57655. * @param activeTextures Array of BaseTextures
  57656. */
  57657. getActiveTextures(activeTextures: BaseTexture[]): void;
  57658. /**
  57659. * Returns the animatable textures.
  57660. * @param animatables Array of animatable textures.
  57661. */
  57662. getAnimatables(animatables: IAnimatable[]): void;
  57663. /**
  57664. * Disposes the resources of the material.
  57665. * @param forceDisposeTextures - Forces the disposal of all textures.
  57666. */
  57667. dispose(forceDisposeTextures?: boolean): void;
  57668. /**
  57669. * Get the current class name of the texture useful for serialization or dynamic coding.
  57670. * @returns "PBRSheenConfiguration"
  57671. */
  57672. getClassName(): string;
  57673. /**
  57674. * Add fallbacks to the effect fallbacks list.
  57675. * @param defines defines the Base texture to use.
  57676. * @param fallbacks defines the current fallback list.
  57677. * @param currentRank defines the current fallback rank.
  57678. * @returns the new fallback rank.
  57679. */
  57680. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57681. /**
  57682. * Add the required uniforms to the current list.
  57683. * @param uniforms defines the current uniform list.
  57684. */
  57685. static AddUniforms(uniforms: string[]): void;
  57686. /**
  57687. * Add the required uniforms to the current buffer.
  57688. * @param uniformBuffer defines the current uniform buffer.
  57689. */
  57690. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57691. /**
  57692. * Add the required samplers to the current list.
  57693. * @param samplers defines the current sampler list.
  57694. */
  57695. static AddSamplers(samplers: string[]): void;
  57696. /**
  57697. * Makes a duplicate of the current configuration into another one.
  57698. * @param sheenConfiguration define the config where to copy the info
  57699. */
  57700. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57701. /**
  57702. * Serializes this BRDF configuration.
  57703. * @returns - An object with the serialized config.
  57704. */
  57705. serialize(): any;
  57706. /**
  57707. * Parses a anisotropy Configuration from a serialized object.
  57708. * @param source - Serialized object.
  57709. * @param scene Defines the scene we are parsing for
  57710. * @param rootUrl Defines the rootUrl to load from
  57711. */
  57712. parse(source: any, scene: Scene, rootUrl: string): void;
  57713. }
  57714. }
  57715. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57716. import { Nullable } from "babylonjs/types";
  57717. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57718. import { Color3 } from "babylonjs/Maths/math.color";
  57719. import { SmartArray } from "babylonjs/Misc/smartArray";
  57720. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57722. import { Effect } from "babylonjs/Materials/effect";
  57723. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57724. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57725. import { Engine } from "babylonjs/Engines/engine";
  57726. import { Scene } from "babylonjs/scene";
  57727. /**
  57728. * @hidden
  57729. */
  57730. export interface IMaterialSubSurfaceDefines {
  57731. SUBSURFACE: boolean;
  57732. SS_REFRACTION: boolean;
  57733. SS_TRANSLUCENCY: boolean;
  57734. SS_SCATTERING: boolean;
  57735. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57736. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57737. SS_REFRACTIONMAP_3D: boolean;
  57738. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57739. SS_LODINREFRACTIONALPHA: boolean;
  57740. SS_GAMMAREFRACTION: boolean;
  57741. SS_RGBDREFRACTION: boolean;
  57742. SS_LINEARSPECULARREFRACTION: boolean;
  57743. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57744. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57745. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57746. /** @hidden */
  57747. _areTexturesDirty: boolean;
  57748. }
  57749. /**
  57750. * Define the code related to the sub surface parameters of the pbr material.
  57751. */
  57752. export class PBRSubSurfaceConfiguration {
  57753. private _isRefractionEnabled;
  57754. /**
  57755. * Defines if the refraction is enabled in the material.
  57756. */
  57757. isRefractionEnabled: boolean;
  57758. private _isTranslucencyEnabled;
  57759. /**
  57760. * Defines if the translucency is enabled in the material.
  57761. */
  57762. isTranslucencyEnabled: boolean;
  57763. private _isScatteringEnabled;
  57764. /**
  57765. * Defines if the sub surface scattering is enabled in the material.
  57766. */
  57767. isScatteringEnabled: boolean;
  57768. private _scatteringDiffusionProfileIndex;
  57769. /**
  57770. * Diffusion profile for subsurface scattering.
  57771. * Useful for better scattering in the skins or foliages.
  57772. */
  57773. get scatteringDiffusionProfile(): Nullable<Color3>;
  57774. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57775. /**
  57776. * Defines the refraction intensity of the material.
  57777. * The refraction when enabled replaces the Diffuse part of the material.
  57778. * The intensity helps transitionning between diffuse and refraction.
  57779. */
  57780. refractionIntensity: number;
  57781. /**
  57782. * Defines the translucency intensity of the material.
  57783. * When translucency has been enabled, this defines how much of the "translucency"
  57784. * is addded to the diffuse part of the material.
  57785. */
  57786. translucencyIntensity: number;
  57787. /**
  57788. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57789. */
  57790. useAlbedoToTintRefraction: boolean;
  57791. private _thicknessTexture;
  57792. /**
  57793. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57794. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57795. * 0 would mean minimumThickness
  57796. * 1 would mean maximumThickness
  57797. * The other channels might be use as a mask to vary the different effects intensity.
  57798. */
  57799. thicknessTexture: Nullable<BaseTexture>;
  57800. private _refractionTexture;
  57801. /**
  57802. * Defines the texture to use for refraction.
  57803. */
  57804. refractionTexture: Nullable<BaseTexture>;
  57805. private _indexOfRefraction;
  57806. /**
  57807. * Index of refraction of the material base layer.
  57808. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57809. *
  57810. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57811. *
  57812. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57813. */
  57814. indexOfRefraction: number;
  57815. private _volumeIndexOfRefraction;
  57816. /**
  57817. * Index of refraction of the material's volume.
  57818. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57819. *
  57820. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57821. * the volume will use the same IOR as the surface.
  57822. */
  57823. get volumeIndexOfRefraction(): number;
  57824. set volumeIndexOfRefraction(value: number);
  57825. private _invertRefractionY;
  57826. /**
  57827. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57828. */
  57829. invertRefractionY: boolean;
  57830. private _linkRefractionWithTransparency;
  57831. /**
  57832. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57833. * Materials half opaque for instance using refraction could benefit from this control.
  57834. */
  57835. linkRefractionWithTransparency: boolean;
  57836. /**
  57837. * Defines the minimum thickness stored in the thickness map.
  57838. * If no thickness map is defined, this value will be used to simulate thickness.
  57839. */
  57840. minimumThickness: number;
  57841. /**
  57842. * Defines the maximum thickness stored in the thickness map.
  57843. */
  57844. maximumThickness: number;
  57845. /**
  57846. * Defines the volume tint of the material.
  57847. * This is used for both translucency and scattering.
  57848. */
  57849. tintColor: Color3;
  57850. /**
  57851. * Defines the distance at which the tint color should be found in the media.
  57852. * This is used for refraction only.
  57853. */
  57854. tintColorAtDistance: number;
  57855. /**
  57856. * Defines how far each channel transmit through the media.
  57857. * It is defined as a color to simplify it selection.
  57858. */
  57859. diffusionDistance: Color3;
  57860. private _useMaskFromThicknessTexture;
  57861. /**
  57862. * Stores the intensity of the different subsurface effects in the thickness texture.
  57863. * * the green channel is the translucency intensity.
  57864. * * the blue channel is the scattering intensity.
  57865. * * the alpha channel is the refraction intensity.
  57866. */
  57867. useMaskFromThicknessTexture: boolean;
  57868. private _scene;
  57869. /** @hidden */
  57870. private _internalMarkAllSubMeshesAsTexturesDirty;
  57871. private _internalMarkScenePrePassDirty;
  57872. /** @hidden */
  57873. _markAllSubMeshesAsTexturesDirty(): void;
  57874. /** @hidden */
  57875. _markScenePrePassDirty(): void;
  57876. /**
  57877. * Instantiate a new istance of sub surface configuration.
  57878. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57879. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57880. * @param scene The scene
  57881. */
  57882. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57883. /**
  57884. * Gets wehter the submesh is ready to be used or not.
  57885. * @param defines the list of "defines" to update.
  57886. * @param scene defines the scene the material belongs to.
  57887. * @returns - boolean indicating that the submesh is ready or not.
  57888. */
  57889. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57890. /**
  57891. * Checks to see if a texture is used in the material.
  57892. * @param defines the list of "defines" to update.
  57893. * @param scene defines the scene to the material belongs to.
  57894. */
  57895. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57896. /**
  57897. * Binds the material data.
  57898. * @param uniformBuffer defines the Uniform buffer to fill in.
  57899. * @param scene defines the scene the material belongs to.
  57900. * @param engine defines the engine the material belongs to.
  57901. * @param isFrozen defines whether the material is frozen or not.
  57902. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57903. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57904. */
  57905. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57906. /**
  57907. * Unbinds the material from the mesh.
  57908. * @param activeEffect defines the effect that should be unbound from.
  57909. * @returns true if unbound, otherwise false
  57910. */
  57911. unbind(activeEffect: Effect): boolean;
  57912. /**
  57913. * Returns the texture used for refraction or null if none is used.
  57914. * @param scene defines the scene the material belongs to.
  57915. * @returns - Refraction texture if present. If no refraction texture and refraction
  57916. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57917. */
  57918. private _getRefractionTexture;
  57919. /**
  57920. * Returns true if alpha blending should be disabled.
  57921. */
  57922. get disableAlphaBlending(): boolean;
  57923. /**
  57924. * Fills the list of render target textures.
  57925. * @param renderTargets the list of render targets to update
  57926. */
  57927. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57928. /**
  57929. * Checks to see if a texture is used in the material.
  57930. * @param texture - Base texture to use.
  57931. * @returns - Boolean specifying if a texture is used in the material.
  57932. */
  57933. hasTexture(texture: BaseTexture): boolean;
  57934. /**
  57935. * Gets a boolean indicating that current material needs to register RTT
  57936. * @returns true if this uses a render target otherwise false.
  57937. */
  57938. hasRenderTargetTextures(): boolean;
  57939. /**
  57940. * Returns an array of the actively used textures.
  57941. * @param activeTextures Array of BaseTextures
  57942. */
  57943. getActiveTextures(activeTextures: BaseTexture[]): void;
  57944. /**
  57945. * Returns the animatable textures.
  57946. * @param animatables Array of animatable textures.
  57947. */
  57948. getAnimatables(animatables: IAnimatable[]): void;
  57949. /**
  57950. * Disposes the resources of the material.
  57951. * @param forceDisposeTextures - Forces the disposal of all textures.
  57952. */
  57953. dispose(forceDisposeTextures?: boolean): void;
  57954. /**
  57955. * Get the current class name of the texture useful for serialization or dynamic coding.
  57956. * @returns "PBRSubSurfaceConfiguration"
  57957. */
  57958. getClassName(): string;
  57959. /**
  57960. * Add fallbacks to the effect fallbacks list.
  57961. * @param defines defines the Base texture to use.
  57962. * @param fallbacks defines the current fallback list.
  57963. * @param currentRank defines the current fallback rank.
  57964. * @returns the new fallback rank.
  57965. */
  57966. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57967. /**
  57968. * Add the required uniforms to the current list.
  57969. * @param uniforms defines the current uniform list.
  57970. */
  57971. static AddUniforms(uniforms: string[]): void;
  57972. /**
  57973. * Add the required samplers to the current list.
  57974. * @param samplers defines the current sampler list.
  57975. */
  57976. static AddSamplers(samplers: string[]): void;
  57977. /**
  57978. * Add the required uniforms to the current buffer.
  57979. * @param uniformBuffer defines the current uniform buffer.
  57980. */
  57981. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57982. /**
  57983. * Makes a duplicate of the current configuration into another one.
  57984. * @param configuration define the config where to copy the info
  57985. */
  57986. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57987. /**
  57988. * Serializes this Sub Surface configuration.
  57989. * @returns - An object with the serialized config.
  57990. */
  57991. serialize(): any;
  57992. /**
  57993. * Parses a anisotropy Configuration from a serialized object.
  57994. * @param source - Serialized object.
  57995. * @param scene Defines the scene we are parsing for
  57996. * @param rootUrl Defines the rootUrl to load from
  57997. */
  57998. parse(source: any, scene: Scene, rootUrl: string): void;
  57999. }
  58000. }
  58001. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58002. /** @hidden */
  58003. export var pbrFragmentDeclaration: {
  58004. name: string;
  58005. shader: string;
  58006. };
  58007. }
  58008. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58009. /** @hidden */
  58010. export var pbrUboDeclaration: {
  58011. name: string;
  58012. shader: string;
  58013. };
  58014. }
  58015. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58016. /** @hidden */
  58017. export var pbrFragmentExtraDeclaration: {
  58018. name: string;
  58019. shader: string;
  58020. };
  58021. }
  58022. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58023. /** @hidden */
  58024. export var pbrFragmentSamplersDeclaration: {
  58025. name: string;
  58026. shader: string;
  58027. };
  58028. }
  58029. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58030. /** @hidden */
  58031. export var importanceSampling: {
  58032. name: string;
  58033. shader: string;
  58034. };
  58035. }
  58036. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58037. /** @hidden */
  58038. export var pbrHelperFunctions: {
  58039. name: string;
  58040. shader: string;
  58041. };
  58042. }
  58043. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58044. /** @hidden */
  58045. export var harmonicsFunctions: {
  58046. name: string;
  58047. shader: string;
  58048. };
  58049. }
  58050. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58051. /** @hidden */
  58052. export var pbrDirectLightingSetupFunctions: {
  58053. name: string;
  58054. shader: string;
  58055. };
  58056. }
  58057. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58058. /** @hidden */
  58059. export var pbrDirectLightingFalloffFunctions: {
  58060. name: string;
  58061. shader: string;
  58062. };
  58063. }
  58064. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58065. /** @hidden */
  58066. export var pbrBRDFFunctions: {
  58067. name: string;
  58068. shader: string;
  58069. };
  58070. }
  58071. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58072. /** @hidden */
  58073. export var hdrFilteringFunctions: {
  58074. name: string;
  58075. shader: string;
  58076. };
  58077. }
  58078. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58079. /** @hidden */
  58080. export var pbrDirectLightingFunctions: {
  58081. name: string;
  58082. shader: string;
  58083. };
  58084. }
  58085. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58086. /** @hidden */
  58087. export var pbrIBLFunctions: {
  58088. name: string;
  58089. shader: string;
  58090. };
  58091. }
  58092. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58093. /** @hidden */
  58094. export var pbrBlockAlbedoOpacity: {
  58095. name: string;
  58096. shader: string;
  58097. };
  58098. }
  58099. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58100. /** @hidden */
  58101. export var pbrBlockReflectivity: {
  58102. name: string;
  58103. shader: string;
  58104. };
  58105. }
  58106. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58107. /** @hidden */
  58108. export var pbrBlockAmbientOcclusion: {
  58109. name: string;
  58110. shader: string;
  58111. };
  58112. }
  58113. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58114. /** @hidden */
  58115. export var pbrBlockAlphaFresnel: {
  58116. name: string;
  58117. shader: string;
  58118. };
  58119. }
  58120. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58121. /** @hidden */
  58122. export var pbrBlockAnisotropic: {
  58123. name: string;
  58124. shader: string;
  58125. };
  58126. }
  58127. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58128. /** @hidden */
  58129. export var pbrBlockReflection: {
  58130. name: string;
  58131. shader: string;
  58132. };
  58133. }
  58134. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58135. /** @hidden */
  58136. export var pbrBlockSheen: {
  58137. name: string;
  58138. shader: string;
  58139. };
  58140. }
  58141. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58142. /** @hidden */
  58143. export var pbrBlockClearcoat: {
  58144. name: string;
  58145. shader: string;
  58146. };
  58147. }
  58148. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58149. /** @hidden */
  58150. export var pbrBlockSubSurface: {
  58151. name: string;
  58152. shader: string;
  58153. };
  58154. }
  58155. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58156. /** @hidden */
  58157. export var pbrBlockNormalGeometric: {
  58158. name: string;
  58159. shader: string;
  58160. };
  58161. }
  58162. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58163. /** @hidden */
  58164. export var pbrBlockNormalFinal: {
  58165. name: string;
  58166. shader: string;
  58167. };
  58168. }
  58169. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58170. /** @hidden */
  58171. export var pbrBlockLightmapInit: {
  58172. name: string;
  58173. shader: string;
  58174. };
  58175. }
  58176. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58177. /** @hidden */
  58178. export var pbrBlockGeometryInfo: {
  58179. name: string;
  58180. shader: string;
  58181. };
  58182. }
  58183. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58184. /** @hidden */
  58185. export var pbrBlockReflectance0: {
  58186. name: string;
  58187. shader: string;
  58188. };
  58189. }
  58190. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58191. /** @hidden */
  58192. export var pbrBlockReflectance: {
  58193. name: string;
  58194. shader: string;
  58195. };
  58196. }
  58197. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58198. /** @hidden */
  58199. export var pbrBlockDirectLighting: {
  58200. name: string;
  58201. shader: string;
  58202. };
  58203. }
  58204. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58205. /** @hidden */
  58206. export var pbrBlockFinalLitComponents: {
  58207. name: string;
  58208. shader: string;
  58209. };
  58210. }
  58211. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58212. /** @hidden */
  58213. export var pbrBlockFinalUnlitComponents: {
  58214. name: string;
  58215. shader: string;
  58216. };
  58217. }
  58218. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58219. /** @hidden */
  58220. export var pbrBlockFinalColorComposition: {
  58221. name: string;
  58222. shader: string;
  58223. };
  58224. }
  58225. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58226. /** @hidden */
  58227. export var pbrBlockImageProcessing: {
  58228. name: string;
  58229. shader: string;
  58230. };
  58231. }
  58232. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58233. /** @hidden */
  58234. export var pbrDebug: {
  58235. name: string;
  58236. shader: string;
  58237. };
  58238. }
  58239. declare module "babylonjs/Shaders/pbr.fragment" {
  58240. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58241. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58242. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58243. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58244. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58245. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58246. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58247. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58248. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58249. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58250. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58251. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58252. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58253. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58254. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58255. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58256. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58257. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58258. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58259. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58260. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58261. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58262. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58263. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58264. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58265. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58266. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58267. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58268. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58269. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58270. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58271. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58272. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58273. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58274. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58275. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58276. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58277. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58278. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58279. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58280. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58281. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58282. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58283. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58284. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58285. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58286. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58287. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58288. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58289. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58290. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58291. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58292. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58293. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58294. /** @hidden */
  58295. export var pbrPixelShader: {
  58296. name: string;
  58297. shader: string;
  58298. };
  58299. }
  58300. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58301. /** @hidden */
  58302. export var pbrVertexDeclaration: {
  58303. name: string;
  58304. shader: string;
  58305. };
  58306. }
  58307. declare module "babylonjs/Shaders/pbr.vertex" {
  58308. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58309. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58311. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58312. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58313. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58314. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58315. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58316. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58317. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58318. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58320. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58321. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58322. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58323. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58324. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58325. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58327. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58328. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58329. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58330. /** @hidden */
  58331. export var pbrVertexShader: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58337. import { Nullable } from "babylonjs/types";
  58338. import { Scene } from "babylonjs/scene";
  58339. import { Matrix } from "babylonjs/Maths/math.vector";
  58340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58342. import { Mesh } from "babylonjs/Meshes/mesh";
  58343. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58344. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58345. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58346. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58347. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58348. import { Color3 } from "babylonjs/Maths/math.color";
  58349. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58350. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58351. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58352. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58353. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58354. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58355. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58356. import "babylonjs/Shaders/pbr.fragment";
  58357. import "babylonjs/Shaders/pbr.vertex";
  58358. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58359. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58360. /**
  58361. * Manages the defines for the PBR Material.
  58362. * @hidden
  58363. */
  58364. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58365. PBR: boolean;
  58366. NUM_SAMPLES: string;
  58367. REALTIME_FILTERING: boolean;
  58368. MAINUV1: boolean;
  58369. MAINUV2: boolean;
  58370. UV1: boolean;
  58371. UV2: boolean;
  58372. ALBEDO: boolean;
  58373. GAMMAALBEDO: boolean;
  58374. ALBEDODIRECTUV: number;
  58375. VERTEXCOLOR: boolean;
  58376. DETAIL: boolean;
  58377. DETAILDIRECTUV: number;
  58378. DETAIL_NORMALBLENDMETHOD: number;
  58379. AMBIENT: boolean;
  58380. AMBIENTDIRECTUV: number;
  58381. AMBIENTINGRAYSCALE: boolean;
  58382. OPACITY: boolean;
  58383. VERTEXALPHA: boolean;
  58384. OPACITYDIRECTUV: number;
  58385. OPACITYRGB: boolean;
  58386. ALPHATEST: boolean;
  58387. DEPTHPREPASS: boolean;
  58388. ALPHABLEND: boolean;
  58389. ALPHAFROMALBEDO: boolean;
  58390. ALPHATESTVALUE: string;
  58391. SPECULAROVERALPHA: boolean;
  58392. RADIANCEOVERALPHA: boolean;
  58393. ALPHAFRESNEL: boolean;
  58394. LINEARALPHAFRESNEL: boolean;
  58395. PREMULTIPLYALPHA: boolean;
  58396. EMISSIVE: boolean;
  58397. EMISSIVEDIRECTUV: number;
  58398. REFLECTIVITY: boolean;
  58399. REFLECTIVITYDIRECTUV: number;
  58400. SPECULARTERM: boolean;
  58401. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58402. MICROSURFACEAUTOMATIC: boolean;
  58403. LODBASEDMICROSFURACE: boolean;
  58404. MICROSURFACEMAP: boolean;
  58405. MICROSURFACEMAPDIRECTUV: number;
  58406. METALLICWORKFLOW: boolean;
  58407. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58408. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58409. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58410. AOSTOREINMETALMAPRED: boolean;
  58411. METALLIC_REFLECTANCE: boolean;
  58412. METALLIC_REFLECTANCEDIRECTUV: number;
  58413. ENVIRONMENTBRDF: boolean;
  58414. ENVIRONMENTBRDF_RGBD: boolean;
  58415. NORMAL: boolean;
  58416. TANGENT: boolean;
  58417. BUMP: boolean;
  58418. BUMPDIRECTUV: number;
  58419. OBJECTSPACE_NORMALMAP: boolean;
  58420. PARALLAX: boolean;
  58421. PARALLAXOCCLUSION: boolean;
  58422. NORMALXYSCALE: boolean;
  58423. LIGHTMAP: boolean;
  58424. LIGHTMAPDIRECTUV: number;
  58425. USELIGHTMAPASSHADOWMAP: boolean;
  58426. GAMMALIGHTMAP: boolean;
  58427. RGBDLIGHTMAP: boolean;
  58428. REFLECTION: boolean;
  58429. REFLECTIONMAP_3D: boolean;
  58430. REFLECTIONMAP_SPHERICAL: boolean;
  58431. REFLECTIONMAP_PLANAR: boolean;
  58432. REFLECTIONMAP_CUBIC: boolean;
  58433. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58434. REFLECTIONMAP_PROJECTION: boolean;
  58435. REFLECTIONMAP_SKYBOX: boolean;
  58436. REFLECTIONMAP_EXPLICIT: boolean;
  58437. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58438. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58439. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58440. INVERTCUBICMAP: boolean;
  58441. USESPHERICALFROMREFLECTIONMAP: boolean;
  58442. USEIRRADIANCEMAP: boolean;
  58443. SPHERICAL_HARMONICS: boolean;
  58444. USESPHERICALINVERTEX: boolean;
  58445. REFLECTIONMAP_OPPOSITEZ: boolean;
  58446. LODINREFLECTIONALPHA: boolean;
  58447. GAMMAREFLECTION: boolean;
  58448. RGBDREFLECTION: boolean;
  58449. LINEARSPECULARREFLECTION: boolean;
  58450. RADIANCEOCCLUSION: boolean;
  58451. HORIZONOCCLUSION: boolean;
  58452. INSTANCES: boolean;
  58453. THIN_INSTANCES: boolean;
  58454. PREPASS: boolean;
  58455. SCENE_MRT_COUNT: number;
  58456. NUM_BONE_INFLUENCERS: number;
  58457. BonesPerMesh: number;
  58458. BONETEXTURE: boolean;
  58459. NONUNIFORMSCALING: boolean;
  58460. MORPHTARGETS: boolean;
  58461. MORPHTARGETS_NORMAL: boolean;
  58462. MORPHTARGETS_TANGENT: boolean;
  58463. MORPHTARGETS_UV: boolean;
  58464. NUM_MORPH_INFLUENCERS: number;
  58465. IMAGEPROCESSING: boolean;
  58466. VIGNETTE: boolean;
  58467. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58468. VIGNETTEBLENDMODEOPAQUE: boolean;
  58469. TONEMAPPING: boolean;
  58470. TONEMAPPING_ACES: boolean;
  58471. CONTRAST: boolean;
  58472. COLORCURVES: boolean;
  58473. COLORGRADING: boolean;
  58474. COLORGRADING3D: boolean;
  58475. SAMPLER3DGREENDEPTH: boolean;
  58476. SAMPLER3DBGRMAP: boolean;
  58477. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58478. EXPOSURE: boolean;
  58479. MULTIVIEW: boolean;
  58480. USEPHYSICALLIGHTFALLOFF: boolean;
  58481. USEGLTFLIGHTFALLOFF: boolean;
  58482. TWOSIDEDLIGHTING: boolean;
  58483. SHADOWFLOAT: boolean;
  58484. CLIPPLANE: boolean;
  58485. CLIPPLANE2: boolean;
  58486. CLIPPLANE3: boolean;
  58487. CLIPPLANE4: boolean;
  58488. CLIPPLANE5: boolean;
  58489. CLIPPLANE6: boolean;
  58490. POINTSIZE: boolean;
  58491. FOG: boolean;
  58492. LOGARITHMICDEPTH: boolean;
  58493. FORCENORMALFORWARD: boolean;
  58494. SPECULARAA: boolean;
  58495. CLEARCOAT: boolean;
  58496. CLEARCOAT_DEFAULTIOR: boolean;
  58497. CLEARCOAT_TEXTURE: boolean;
  58498. CLEARCOAT_TEXTUREDIRECTUV: number;
  58499. CLEARCOAT_BUMP: boolean;
  58500. CLEARCOAT_BUMPDIRECTUV: number;
  58501. CLEARCOAT_TINT: boolean;
  58502. CLEARCOAT_TINT_TEXTURE: boolean;
  58503. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58504. ANISOTROPIC: boolean;
  58505. ANISOTROPIC_TEXTURE: boolean;
  58506. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58507. BRDF_V_HEIGHT_CORRELATED: boolean;
  58508. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58509. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58510. SHEEN: boolean;
  58511. SHEEN_TEXTURE: boolean;
  58512. SHEEN_TEXTUREDIRECTUV: number;
  58513. SHEEN_LINKWITHALBEDO: boolean;
  58514. SHEEN_ROUGHNESS: boolean;
  58515. SHEEN_ALBEDOSCALING: boolean;
  58516. SUBSURFACE: boolean;
  58517. SS_REFRACTION: boolean;
  58518. SS_TRANSLUCENCY: boolean;
  58519. SS_SCATTERING: boolean;
  58520. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58521. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58522. SS_REFRACTIONMAP_3D: boolean;
  58523. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58524. SS_LODINREFRACTIONALPHA: boolean;
  58525. SS_GAMMAREFRACTION: boolean;
  58526. SS_RGBDREFRACTION: boolean;
  58527. SS_LINEARSPECULARREFRACTION: boolean;
  58528. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58529. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58530. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58531. UNLIT: boolean;
  58532. DEBUGMODE: number;
  58533. /**
  58534. * Initializes the PBR Material defines.
  58535. */
  58536. constructor();
  58537. /**
  58538. * Resets the PBR Material defines.
  58539. */
  58540. reset(): void;
  58541. }
  58542. /**
  58543. * The Physically based material base class of BJS.
  58544. *
  58545. * This offers the main features of a standard PBR material.
  58546. * For more information, please refer to the documentation :
  58547. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58548. */
  58549. export abstract class PBRBaseMaterial extends PushMaterial {
  58550. /**
  58551. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58552. */
  58553. static readonly PBRMATERIAL_OPAQUE: number;
  58554. /**
  58555. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58556. */
  58557. static readonly PBRMATERIAL_ALPHATEST: number;
  58558. /**
  58559. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58560. */
  58561. static readonly PBRMATERIAL_ALPHABLEND: number;
  58562. /**
  58563. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58564. * They are also discarded below the alpha cutoff threshold to improve performances.
  58565. */
  58566. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58567. /**
  58568. * Defines the default value of how much AO map is occluding the analytical lights
  58569. * (point spot...).
  58570. */
  58571. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58572. /**
  58573. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58574. */
  58575. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58576. /**
  58577. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58578. * to enhance interoperability with other engines.
  58579. */
  58580. static readonly LIGHTFALLOFF_GLTF: number;
  58581. /**
  58582. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58583. * to enhance interoperability with other materials.
  58584. */
  58585. static readonly LIGHTFALLOFF_STANDARD: number;
  58586. /**
  58587. * Intensity of the direct lights e.g. the four lights available in your scene.
  58588. * This impacts both the direct diffuse and specular highlights.
  58589. */
  58590. protected _directIntensity: number;
  58591. /**
  58592. * Intensity of the emissive part of the material.
  58593. * This helps controlling the emissive effect without modifying the emissive color.
  58594. */
  58595. protected _emissiveIntensity: number;
  58596. /**
  58597. * Intensity of the environment e.g. how much the environment will light the object
  58598. * either through harmonics for rough material or through the refelction for shiny ones.
  58599. */
  58600. protected _environmentIntensity: number;
  58601. /**
  58602. * This is a special control allowing the reduction of the specular highlights coming from the
  58603. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58604. */
  58605. protected _specularIntensity: number;
  58606. /**
  58607. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58608. */
  58609. private _lightingInfos;
  58610. /**
  58611. * Debug Control allowing disabling the bump map on this material.
  58612. */
  58613. protected _disableBumpMap: boolean;
  58614. /**
  58615. * AKA Diffuse Texture in standard nomenclature.
  58616. */
  58617. protected _albedoTexture: Nullable<BaseTexture>;
  58618. /**
  58619. * AKA Occlusion Texture in other nomenclature.
  58620. */
  58621. protected _ambientTexture: Nullable<BaseTexture>;
  58622. /**
  58623. * AKA Occlusion Texture Intensity in other nomenclature.
  58624. */
  58625. protected _ambientTextureStrength: number;
  58626. /**
  58627. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58628. * 1 means it completely occludes it
  58629. * 0 mean it has no impact
  58630. */
  58631. protected _ambientTextureImpactOnAnalyticalLights: number;
  58632. /**
  58633. * Stores the alpha values in a texture.
  58634. */
  58635. protected _opacityTexture: Nullable<BaseTexture>;
  58636. /**
  58637. * Stores the reflection values in a texture.
  58638. */
  58639. protected _reflectionTexture: Nullable<BaseTexture>;
  58640. /**
  58641. * Stores the emissive values in a texture.
  58642. */
  58643. protected _emissiveTexture: Nullable<BaseTexture>;
  58644. /**
  58645. * AKA Specular texture in other nomenclature.
  58646. */
  58647. protected _reflectivityTexture: Nullable<BaseTexture>;
  58648. /**
  58649. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58650. */
  58651. protected _metallicTexture: Nullable<BaseTexture>;
  58652. /**
  58653. * Specifies the metallic scalar of the metallic/roughness workflow.
  58654. * Can also be used to scale the metalness values of the metallic texture.
  58655. */
  58656. protected _metallic: Nullable<number>;
  58657. /**
  58658. * Specifies the roughness scalar of the metallic/roughness workflow.
  58659. * Can also be used to scale the roughness values of the metallic texture.
  58660. */
  58661. protected _roughness: Nullable<number>;
  58662. /**
  58663. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58664. * By default the indexOfrefraction is used to compute F0;
  58665. *
  58666. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58667. *
  58668. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58669. * F90 = metallicReflectanceColor;
  58670. */
  58671. protected _metallicF0Factor: number;
  58672. /**
  58673. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58674. * By default the F90 is always 1;
  58675. *
  58676. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58677. *
  58678. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58679. * F90 = metallicReflectanceColor;
  58680. */
  58681. protected _metallicReflectanceColor: Color3;
  58682. /**
  58683. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58684. * This is multiply against the scalar values defined in the material.
  58685. */
  58686. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58687. /**
  58688. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58689. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58690. */
  58691. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58692. /**
  58693. * Stores surface normal data used to displace a mesh in a texture.
  58694. */
  58695. protected _bumpTexture: Nullable<BaseTexture>;
  58696. /**
  58697. * Stores the pre-calculated light information of a mesh in a texture.
  58698. */
  58699. protected _lightmapTexture: Nullable<BaseTexture>;
  58700. /**
  58701. * The color of a material in ambient lighting.
  58702. */
  58703. protected _ambientColor: Color3;
  58704. /**
  58705. * AKA Diffuse Color in other nomenclature.
  58706. */
  58707. protected _albedoColor: Color3;
  58708. /**
  58709. * AKA Specular Color in other nomenclature.
  58710. */
  58711. protected _reflectivityColor: Color3;
  58712. /**
  58713. * The color applied when light is reflected from a material.
  58714. */
  58715. protected _reflectionColor: Color3;
  58716. /**
  58717. * The color applied when light is emitted from a material.
  58718. */
  58719. protected _emissiveColor: Color3;
  58720. /**
  58721. * AKA Glossiness in other nomenclature.
  58722. */
  58723. protected _microSurface: number;
  58724. /**
  58725. * Specifies that the material will use the light map as a show map.
  58726. */
  58727. protected _useLightmapAsShadowmap: boolean;
  58728. /**
  58729. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58730. * makes the reflect vector face the model (under horizon).
  58731. */
  58732. protected _useHorizonOcclusion: boolean;
  58733. /**
  58734. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58735. * too much the area relying on ambient texture to define their ambient occlusion.
  58736. */
  58737. protected _useRadianceOcclusion: boolean;
  58738. /**
  58739. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58740. */
  58741. protected _useAlphaFromAlbedoTexture: boolean;
  58742. /**
  58743. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58744. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58745. */
  58746. protected _useSpecularOverAlpha: boolean;
  58747. /**
  58748. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58749. */
  58750. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58751. /**
  58752. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58753. */
  58754. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58755. /**
  58756. * Specifies if the metallic texture contains the roughness information in its green channel.
  58757. */
  58758. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58759. /**
  58760. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58761. */
  58762. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58763. /**
  58764. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58765. */
  58766. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58767. /**
  58768. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58769. */
  58770. protected _useAmbientInGrayScale: boolean;
  58771. /**
  58772. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58773. * The material will try to infer what glossiness each pixel should be.
  58774. */
  58775. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58776. /**
  58777. * Defines the falloff type used in this material.
  58778. * It by default is Physical.
  58779. */
  58780. protected _lightFalloff: number;
  58781. /**
  58782. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58783. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58784. */
  58785. protected _useRadianceOverAlpha: boolean;
  58786. /**
  58787. * Allows using an object space normal map (instead of tangent space).
  58788. */
  58789. protected _useObjectSpaceNormalMap: boolean;
  58790. /**
  58791. * Allows using the bump map in parallax mode.
  58792. */
  58793. protected _useParallax: boolean;
  58794. /**
  58795. * Allows using the bump map in parallax occlusion mode.
  58796. */
  58797. protected _useParallaxOcclusion: boolean;
  58798. /**
  58799. * Controls the scale bias of the parallax mode.
  58800. */
  58801. protected _parallaxScaleBias: number;
  58802. /**
  58803. * If sets to true, disables all the lights affecting the material.
  58804. */
  58805. protected _disableLighting: boolean;
  58806. /**
  58807. * Number of Simultaneous lights allowed on the material.
  58808. */
  58809. protected _maxSimultaneousLights: number;
  58810. /**
  58811. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58812. */
  58813. protected _invertNormalMapX: boolean;
  58814. /**
  58815. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58816. */
  58817. protected _invertNormalMapY: boolean;
  58818. /**
  58819. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58820. */
  58821. protected _twoSidedLighting: boolean;
  58822. /**
  58823. * Defines the alpha limits in alpha test mode.
  58824. */
  58825. protected _alphaCutOff: number;
  58826. /**
  58827. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58828. */
  58829. protected _forceAlphaTest: boolean;
  58830. /**
  58831. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58832. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58833. */
  58834. protected _useAlphaFresnel: boolean;
  58835. /**
  58836. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58837. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58838. */
  58839. protected _useLinearAlphaFresnel: boolean;
  58840. /**
  58841. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58842. * from cos thetav and roughness:
  58843. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58844. */
  58845. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58846. /**
  58847. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58848. */
  58849. protected _forceIrradianceInFragment: boolean;
  58850. private _realTimeFiltering;
  58851. /**
  58852. * Enables realtime filtering on the texture.
  58853. */
  58854. get realTimeFiltering(): boolean;
  58855. set realTimeFiltering(b: boolean);
  58856. private _realTimeFilteringQuality;
  58857. /**
  58858. * Quality switch for realtime filtering
  58859. */
  58860. get realTimeFilteringQuality(): number;
  58861. set realTimeFilteringQuality(n: number);
  58862. /**
  58863. * Can this material render to several textures at once
  58864. */
  58865. get canRenderToMRT(): boolean;
  58866. /**
  58867. * Force normal to face away from face.
  58868. */
  58869. protected _forceNormalForward: boolean;
  58870. /**
  58871. * Enables specular anti aliasing in the PBR shader.
  58872. * It will both interacts on the Geometry for analytical and IBL lighting.
  58873. * It also prefilter the roughness map based on the bump values.
  58874. */
  58875. protected _enableSpecularAntiAliasing: boolean;
  58876. /**
  58877. * Default configuration related to image processing available in the PBR Material.
  58878. */
  58879. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58880. /**
  58881. * Keep track of the image processing observer to allow dispose and replace.
  58882. */
  58883. private _imageProcessingObserver;
  58884. /**
  58885. * Attaches a new image processing configuration to the PBR Material.
  58886. * @param configuration
  58887. */
  58888. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58889. /**
  58890. * Stores the available render targets.
  58891. */
  58892. private _renderTargets;
  58893. /**
  58894. * Sets the global ambient color for the material used in lighting calculations.
  58895. */
  58896. private _globalAmbientColor;
  58897. /**
  58898. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58899. */
  58900. private _useLogarithmicDepth;
  58901. /**
  58902. * If set to true, no lighting calculations will be applied.
  58903. */
  58904. private _unlit;
  58905. private _debugMode;
  58906. /**
  58907. * @hidden
  58908. * This is reserved for the inspector.
  58909. * Defines the material debug mode.
  58910. * It helps seeing only some components of the material while troubleshooting.
  58911. */
  58912. debugMode: number;
  58913. /**
  58914. * @hidden
  58915. * This is reserved for the inspector.
  58916. * Specify from where on screen the debug mode should start.
  58917. * The value goes from -1 (full screen) to 1 (not visible)
  58918. * It helps with side by side comparison against the final render
  58919. * This defaults to -1
  58920. */
  58921. private debugLimit;
  58922. /**
  58923. * @hidden
  58924. * This is reserved for the inspector.
  58925. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58926. * You can use the factor to better multiply the final value.
  58927. */
  58928. private debugFactor;
  58929. /**
  58930. * Defines the clear coat layer parameters for the material.
  58931. */
  58932. readonly clearCoat: PBRClearCoatConfiguration;
  58933. /**
  58934. * Defines the anisotropic parameters for the material.
  58935. */
  58936. readonly anisotropy: PBRAnisotropicConfiguration;
  58937. /**
  58938. * Defines the BRDF parameters for the material.
  58939. */
  58940. readonly brdf: PBRBRDFConfiguration;
  58941. /**
  58942. * Defines the Sheen parameters for the material.
  58943. */
  58944. readonly sheen: PBRSheenConfiguration;
  58945. /**
  58946. * Defines the SubSurface parameters for the material.
  58947. */
  58948. readonly subSurface: PBRSubSurfaceConfiguration;
  58949. /**
  58950. * Defines the detail map parameters for the material.
  58951. */
  58952. readonly detailMap: DetailMapConfiguration;
  58953. protected _rebuildInParallel: boolean;
  58954. /**
  58955. * Instantiates a new PBRMaterial instance.
  58956. *
  58957. * @param name The material name
  58958. * @param scene The scene the material will be use in.
  58959. */
  58960. constructor(name: string, scene: Scene);
  58961. /**
  58962. * Gets a boolean indicating that current material needs to register RTT
  58963. */
  58964. get hasRenderTargetTextures(): boolean;
  58965. /**
  58966. * Gets the name of the material class.
  58967. */
  58968. getClassName(): string;
  58969. /**
  58970. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58971. */
  58972. get useLogarithmicDepth(): boolean;
  58973. /**
  58974. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58975. */
  58976. set useLogarithmicDepth(value: boolean);
  58977. /**
  58978. * Returns true if alpha blending should be disabled.
  58979. */
  58980. protected get _disableAlphaBlending(): boolean;
  58981. /**
  58982. * Specifies whether or not this material should be rendered in alpha blend mode.
  58983. */
  58984. needAlphaBlending(): boolean;
  58985. /**
  58986. * Specifies whether or not this material should be rendered in alpha test mode.
  58987. */
  58988. needAlphaTesting(): boolean;
  58989. /**
  58990. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58991. */
  58992. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58993. /**
  58994. * Gets the texture used for the alpha test.
  58995. */
  58996. getAlphaTestTexture(): Nullable<BaseTexture>;
  58997. /**
  58998. * Specifies that the submesh is ready to be used.
  58999. * @param mesh - BJS mesh.
  59000. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59001. * @param useInstances - Specifies that instances should be used.
  59002. * @returns - boolean indicating that the submesh is ready or not.
  59003. */
  59004. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59005. /**
  59006. * Specifies if the material uses metallic roughness workflow.
  59007. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59008. */
  59009. isMetallicWorkflow(): boolean;
  59010. private _prepareEffect;
  59011. private _prepareDefines;
  59012. /**
  59013. * Force shader compilation
  59014. */
  59015. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59016. /**
  59017. * Initializes the uniform buffer layout for the shader.
  59018. */
  59019. buildUniformLayout(): void;
  59020. /**
  59021. * Unbinds the material from the mesh
  59022. */
  59023. unbind(): void;
  59024. /**
  59025. * Binds the submesh data.
  59026. * @param world - The world matrix.
  59027. * @param mesh - The BJS mesh.
  59028. * @param subMesh - A submesh of the BJS mesh.
  59029. */
  59030. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59031. /**
  59032. * Returns the animatable textures.
  59033. * @returns - Array of animatable textures.
  59034. */
  59035. getAnimatables(): IAnimatable[];
  59036. /**
  59037. * Returns the texture used for reflections.
  59038. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59039. */
  59040. private _getReflectionTexture;
  59041. /**
  59042. * Returns an array of the actively used textures.
  59043. * @returns - Array of BaseTextures
  59044. */
  59045. getActiveTextures(): BaseTexture[];
  59046. /**
  59047. * Checks to see if a texture is used in the material.
  59048. * @param texture - Base texture to use.
  59049. * @returns - Boolean specifying if a texture is used in the material.
  59050. */
  59051. hasTexture(texture: BaseTexture): boolean;
  59052. /**
  59053. * Sets the required values to the prepass renderer.
  59054. * @param prePassRenderer defines the prepass renderer to setup
  59055. */
  59056. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59057. /**
  59058. * Disposes the resources of the material.
  59059. * @param forceDisposeEffect - Forces the disposal of effects.
  59060. * @param forceDisposeTextures - Forces the disposal of all textures.
  59061. */
  59062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59063. }
  59064. }
  59065. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59066. import { Nullable } from "babylonjs/types";
  59067. import { Scene } from "babylonjs/scene";
  59068. import { Color3 } from "babylonjs/Maths/math.color";
  59069. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59070. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59072. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59073. /**
  59074. * The Physically based material of BJS.
  59075. *
  59076. * This offers the main features of a standard PBR material.
  59077. * For more information, please refer to the documentation :
  59078. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59079. */
  59080. export class PBRMaterial extends PBRBaseMaterial {
  59081. /**
  59082. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59083. */
  59084. static readonly PBRMATERIAL_OPAQUE: number;
  59085. /**
  59086. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59087. */
  59088. static readonly PBRMATERIAL_ALPHATEST: number;
  59089. /**
  59090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59091. */
  59092. static readonly PBRMATERIAL_ALPHABLEND: number;
  59093. /**
  59094. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59095. * They are also discarded below the alpha cutoff threshold to improve performances.
  59096. */
  59097. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59098. /**
  59099. * Defines the default value of how much AO map is occluding the analytical lights
  59100. * (point spot...).
  59101. */
  59102. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59103. /**
  59104. * Intensity of the direct lights e.g. the four lights available in your scene.
  59105. * This impacts both the direct diffuse and specular highlights.
  59106. */
  59107. directIntensity: number;
  59108. /**
  59109. * Intensity of the emissive part of the material.
  59110. * This helps controlling the emissive effect without modifying the emissive color.
  59111. */
  59112. emissiveIntensity: number;
  59113. /**
  59114. * Intensity of the environment e.g. how much the environment will light the object
  59115. * either through harmonics for rough material or through the refelction for shiny ones.
  59116. */
  59117. environmentIntensity: number;
  59118. /**
  59119. * This is a special control allowing the reduction of the specular highlights coming from the
  59120. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59121. */
  59122. specularIntensity: number;
  59123. /**
  59124. * Debug Control allowing disabling the bump map on this material.
  59125. */
  59126. disableBumpMap: boolean;
  59127. /**
  59128. * AKA Diffuse Texture in standard nomenclature.
  59129. */
  59130. albedoTexture: BaseTexture;
  59131. /**
  59132. * AKA Occlusion Texture in other nomenclature.
  59133. */
  59134. ambientTexture: BaseTexture;
  59135. /**
  59136. * AKA Occlusion Texture Intensity in other nomenclature.
  59137. */
  59138. ambientTextureStrength: number;
  59139. /**
  59140. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59141. * 1 means it completely occludes it
  59142. * 0 mean it has no impact
  59143. */
  59144. ambientTextureImpactOnAnalyticalLights: number;
  59145. /**
  59146. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59147. */
  59148. opacityTexture: BaseTexture;
  59149. /**
  59150. * Stores the reflection values in a texture.
  59151. */
  59152. reflectionTexture: Nullable<BaseTexture>;
  59153. /**
  59154. * Stores the emissive values in a texture.
  59155. */
  59156. emissiveTexture: BaseTexture;
  59157. /**
  59158. * AKA Specular texture in other nomenclature.
  59159. */
  59160. reflectivityTexture: BaseTexture;
  59161. /**
  59162. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59163. */
  59164. metallicTexture: BaseTexture;
  59165. /**
  59166. * Specifies the metallic scalar of the metallic/roughness workflow.
  59167. * Can also be used to scale the metalness values of the metallic texture.
  59168. */
  59169. metallic: Nullable<number>;
  59170. /**
  59171. * Specifies the roughness scalar of the metallic/roughness workflow.
  59172. * Can also be used to scale the roughness values of the metallic texture.
  59173. */
  59174. roughness: Nullable<number>;
  59175. /**
  59176. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59177. * By default the indexOfrefraction is used to compute F0;
  59178. *
  59179. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59180. *
  59181. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59182. * F90 = metallicReflectanceColor;
  59183. */
  59184. metallicF0Factor: number;
  59185. /**
  59186. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59187. * By default the F90 is always 1;
  59188. *
  59189. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59190. *
  59191. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59192. * F90 = metallicReflectanceColor;
  59193. */
  59194. metallicReflectanceColor: Color3;
  59195. /**
  59196. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59197. * This is multiply against the scalar values defined in the material.
  59198. */
  59199. metallicReflectanceTexture: Nullable<BaseTexture>;
  59200. /**
  59201. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59202. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59203. */
  59204. microSurfaceTexture: BaseTexture;
  59205. /**
  59206. * Stores surface normal data used to displace a mesh in a texture.
  59207. */
  59208. bumpTexture: BaseTexture;
  59209. /**
  59210. * Stores the pre-calculated light information of a mesh in a texture.
  59211. */
  59212. lightmapTexture: BaseTexture;
  59213. /**
  59214. * Stores the refracted light information in a texture.
  59215. */
  59216. get refractionTexture(): Nullable<BaseTexture>;
  59217. set refractionTexture(value: Nullable<BaseTexture>);
  59218. /**
  59219. * The color of a material in ambient lighting.
  59220. */
  59221. ambientColor: Color3;
  59222. /**
  59223. * AKA Diffuse Color in other nomenclature.
  59224. */
  59225. albedoColor: Color3;
  59226. /**
  59227. * AKA Specular Color in other nomenclature.
  59228. */
  59229. reflectivityColor: Color3;
  59230. /**
  59231. * The color reflected from the material.
  59232. */
  59233. reflectionColor: Color3;
  59234. /**
  59235. * The color emitted from the material.
  59236. */
  59237. emissiveColor: Color3;
  59238. /**
  59239. * AKA Glossiness in other nomenclature.
  59240. */
  59241. microSurface: number;
  59242. /**
  59243. * Index of refraction of the material base layer.
  59244. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59245. *
  59246. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59247. *
  59248. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59249. */
  59250. get indexOfRefraction(): number;
  59251. set indexOfRefraction(value: number);
  59252. /**
  59253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59254. */
  59255. get invertRefractionY(): boolean;
  59256. set invertRefractionY(value: boolean);
  59257. /**
  59258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59259. * Materials half opaque for instance using refraction could benefit from this control.
  59260. */
  59261. get linkRefractionWithTransparency(): boolean;
  59262. set linkRefractionWithTransparency(value: boolean);
  59263. /**
  59264. * If true, the light map contains occlusion information instead of lighting info.
  59265. */
  59266. useLightmapAsShadowmap: boolean;
  59267. /**
  59268. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59269. */
  59270. useAlphaFromAlbedoTexture: boolean;
  59271. /**
  59272. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59273. */
  59274. forceAlphaTest: boolean;
  59275. /**
  59276. * Defines the alpha limits in alpha test mode.
  59277. */
  59278. alphaCutOff: number;
  59279. /**
  59280. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59281. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59282. */
  59283. useSpecularOverAlpha: boolean;
  59284. /**
  59285. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59286. */
  59287. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59288. /**
  59289. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59290. */
  59291. useRoughnessFromMetallicTextureAlpha: boolean;
  59292. /**
  59293. * Specifies if the metallic texture contains the roughness information in its green channel.
  59294. */
  59295. useRoughnessFromMetallicTextureGreen: boolean;
  59296. /**
  59297. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59298. */
  59299. useMetallnessFromMetallicTextureBlue: boolean;
  59300. /**
  59301. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59302. */
  59303. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59304. /**
  59305. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59306. */
  59307. useAmbientInGrayScale: boolean;
  59308. /**
  59309. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59310. * The material will try to infer what glossiness each pixel should be.
  59311. */
  59312. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59313. /**
  59314. * BJS is using an harcoded light falloff based on a manually sets up range.
  59315. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59316. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59317. */
  59318. get usePhysicalLightFalloff(): boolean;
  59319. /**
  59320. * BJS is using an harcoded light falloff based on a manually sets up range.
  59321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59323. */
  59324. set usePhysicalLightFalloff(value: boolean);
  59325. /**
  59326. * In order to support the falloff compatibility with gltf, a special mode has been added
  59327. * to reproduce the gltf light falloff.
  59328. */
  59329. get useGLTFLightFalloff(): boolean;
  59330. /**
  59331. * In order to support the falloff compatibility with gltf, a special mode has been added
  59332. * to reproduce the gltf light falloff.
  59333. */
  59334. set useGLTFLightFalloff(value: boolean);
  59335. /**
  59336. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59337. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59338. */
  59339. useRadianceOverAlpha: boolean;
  59340. /**
  59341. * Allows using an object space normal map (instead of tangent space).
  59342. */
  59343. useObjectSpaceNormalMap: boolean;
  59344. /**
  59345. * Allows using the bump map in parallax mode.
  59346. */
  59347. useParallax: boolean;
  59348. /**
  59349. * Allows using the bump map in parallax occlusion mode.
  59350. */
  59351. useParallaxOcclusion: boolean;
  59352. /**
  59353. * Controls the scale bias of the parallax mode.
  59354. */
  59355. parallaxScaleBias: number;
  59356. /**
  59357. * If sets to true, disables all the lights affecting the material.
  59358. */
  59359. disableLighting: boolean;
  59360. /**
  59361. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59362. */
  59363. forceIrradianceInFragment: boolean;
  59364. /**
  59365. * Number of Simultaneous lights allowed on the material.
  59366. */
  59367. maxSimultaneousLights: number;
  59368. /**
  59369. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59370. */
  59371. invertNormalMapX: boolean;
  59372. /**
  59373. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59374. */
  59375. invertNormalMapY: boolean;
  59376. /**
  59377. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59378. */
  59379. twoSidedLighting: boolean;
  59380. /**
  59381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59382. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59383. */
  59384. useAlphaFresnel: boolean;
  59385. /**
  59386. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59387. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59388. */
  59389. useLinearAlphaFresnel: boolean;
  59390. /**
  59391. * Let user defines the brdf lookup texture used for IBL.
  59392. * A default 8bit version is embedded but you could point at :
  59393. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59394. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59395. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59396. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59397. */
  59398. environmentBRDFTexture: Nullable<BaseTexture>;
  59399. /**
  59400. * Force normal to face away from face.
  59401. */
  59402. forceNormalForward: boolean;
  59403. /**
  59404. * Enables specular anti aliasing in the PBR shader.
  59405. * It will both interacts on the Geometry for analytical and IBL lighting.
  59406. * It also prefilter the roughness map based on the bump values.
  59407. */
  59408. enableSpecularAntiAliasing: boolean;
  59409. /**
  59410. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59411. * makes the reflect vector face the model (under horizon).
  59412. */
  59413. useHorizonOcclusion: boolean;
  59414. /**
  59415. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59416. * too much the area relying on ambient texture to define their ambient occlusion.
  59417. */
  59418. useRadianceOcclusion: boolean;
  59419. /**
  59420. * If set to true, no lighting calculations will be applied.
  59421. */
  59422. unlit: boolean;
  59423. /**
  59424. * Gets the image processing configuration used either in this material.
  59425. */
  59426. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59427. /**
  59428. * Sets the Default image processing configuration used either in the this material.
  59429. *
  59430. * If sets to null, the scene one is in use.
  59431. */
  59432. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59433. /**
  59434. * Gets wether the color curves effect is enabled.
  59435. */
  59436. get cameraColorCurvesEnabled(): boolean;
  59437. /**
  59438. * Sets wether the color curves effect is enabled.
  59439. */
  59440. set cameraColorCurvesEnabled(value: boolean);
  59441. /**
  59442. * Gets wether the color grading effect is enabled.
  59443. */
  59444. get cameraColorGradingEnabled(): boolean;
  59445. /**
  59446. * Gets wether the color grading effect is enabled.
  59447. */
  59448. set cameraColorGradingEnabled(value: boolean);
  59449. /**
  59450. * Gets wether tonemapping is enabled or not.
  59451. */
  59452. get cameraToneMappingEnabled(): boolean;
  59453. /**
  59454. * Sets wether tonemapping is enabled or not
  59455. */
  59456. set cameraToneMappingEnabled(value: boolean);
  59457. /**
  59458. * The camera exposure used on this material.
  59459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59460. * This corresponds to a photographic exposure.
  59461. */
  59462. get cameraExposure(): number;
  59463. /**
  59464. * The camera exposure used on this material.
  59465. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59466. * This corresponds to a photographic exposure.
  59467. */
  59468. set cameraExposure(value: number);
  59469. /**
  59470. * Gets The camera contrast used on this material.
  59471. */
  59472. get cameraContrast(): number;
  59473. /**
  59474. * Sets The camera contrast used on this material.
  59475. */
  59476. set cameraContrast(value: number);
  59477. /**
  59478. * Gets the Color Grading 2D Lookup Texture.
  59479. */
  59480. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59481. /**
  59482. * Sets the Color Grading 2D Lookup Texture.
  59483. */
  59484. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59485. /**
  59486. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59487. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59488. * 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;
  59489. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59490. */
  59491. get cameraColorCurves(): Nullable<ColorCurves>;
  59492. /**
  59493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59495. * 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;
  59496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59497. */
  59498. set cameraColorCurves(value: Nullable<ColorCurves>);
  59499. /**
  59500. * Instantiates a new PBRMaterial instance.
  59501. *
  59502. * @param name The material name
  59503. * @param scene The scene the material will be use in.
  59504. */
  59505. constructor(name: string, scene: Scene);
  59506. /**
  59507. * Returns the name of this material class.
  59508. */
  59509. getClassName(): string;
  59510. /**
  59511. * Makes a duplicate of the current material.
  59512. * @param name - name to use for the new material.
  59513. */
  59514. clone(name: string): PBRMaterial;
  59515. /**
  59516. * Serializes this PBR Material.
  59517. * @returns - An object with the serialized material.
  59518. */
  59519. serialize(): any;
  59520. /**
  59521. * Parses a PBR Material from a serialized object.
  59522. * @param source - Serialized object.
  59523. * @param scene - BJS scene instance.
  59524. * @param rootUrl - url for the scene object
  59525. * @returns - PBRMaterial
  59526. */
  59527. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59528. }
  59529. }
  59530. declare module "babylonjs/Misc/dds" {
  59531. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59533. import { Nullable } from "babylonjs/types";
  59534. import { Scene } from "babylonjs/scene";
  59535. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59536. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59537. /**
  59538. * Direct draw surface info
  59539. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59540. */
  59541. export interface DDSInfo {
  59542. /**
  59543. * Width of the texture
  59544. */
  59545. width: number;
  59546. /**
  59547. * Width of the texture
  59548. */
  59549. height: number;
  59550. /**
  59551. * Number of Mipmaps for the texture
  59552. * @see https://en.wikipedia.org/wiki/Mipmap
  59553. */
  59554. mipmapCount: number;
  59555. /**
  59556. * If the textures format is a known fourCC format
  59557. * @see https://www.fourcc.org/
  59558. */
  59559. isFourCC: boolean;
  59560. /**
  59561. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59562. */
  59563. isRGB: boolean;
  59564. /**
  59565. * If the texture is a lumincance format
  59566. */
  59567. isLuminance: boolean;
  59568. /**
  59569. * If this is a cube texture
  59570. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59571. */
  59572. isCube: boolean;
  59573. /**
  59574. * If the texture is a compressed format eg. FOURCC_DXT1
  59575. */
  59576. isCompressed: boolean;
  59577. /**
  59578. * The dxgiFormat of the texture
  59579. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59580. */
  59581. dxgiFormat: number;
  59582. /**
  59583. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59584. */
  59585. textureType: number;
  59586. /**
  59587. * Sphericle polynomial created for the dds texture
  59588. */
  59589. sphericalPolynomial?: SphericalPolynomial;
  59590. }
  59591. /**
  59592. * Class used to provide DDS decompression tools
  59593. */
  59594. export class DDSTools {
  59595. /**
  59596. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59597. */
  59598. static StoreLODInAlphaChannel: boolean;
  59599. /**
  59600. * Gets DDS information from an array buffer
  59601. * @param data defines the array buffer view to read data from
  59602. * @returns the DDS information
  59603. */
  59604. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59605. private static _FloatView;
  59606. private static _Int32View;
  59607. private static _ToHalfFloat;
  59608. private static _FromHalfFloat;
  59609. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59610. private static _GetHalfFloatRGBAArrayBuffer;
  59611. private static _GetFloatRGBAArrayBuffer;
  59612. private static _GetFloatAsUIntRGBAArrayBuffer;
  59613. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59614. private static _GetRGBAArrayBuffer;
  59615. private static _ExtractLongWordOrder;
  59616. private static _GetRGBArrayBuffer;
  59617. private static _GetLuminanceArrayBuffer;
  59618. /**
  59619. * Uploads DDS Levels to a Babylon Texture
  59620. * @hidden
  59621. */
  59622. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59623. }
  59624. module "babylonjs/Engines/thinEngine" {
  59625. interface ThinEngine {
  59626. /**
  59627. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59628. * @param rootUrl defines the url where the file to load is located
  59629. * @param scene defines the current scene
  59630. * @param lodScale defines scale to apply to the mip map selection
  59631. * @param lodOffset defines offset to apply to the mip map selection
  59632. * @param onLoad defines an optional callback raised when the texture is loaded
  59633. * @param onError defines an optional callback raised if there is an issue to load the texture
  59634. * @param format defines the format of the data
  59635. * @param forcedExtension defines the extension to use to pick the right loader
  59636. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59637. * @returns the cube texture as an InternalTexture
  59638. */
  59639. 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;
  59640. }
  59641. }
  59642. }
  59643. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59644. import { Nullable } from "babylonjs/types";
  59645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59646. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59647. /**
  59648. * Implementation of the DDS Texture Loader.
  59649. * @hidden
  59650. */
  59651. export class _DDSTextureLoader implements IInternalTextureLoader {
  59652. /**
  59653. * Defines wether the loader supports cascade loading the different faces.
  59654. */
  59655. readonly supportCascades: boolean;
  59656. /**
  59657. * This returns if the loader support the current file information.
  59658. * @param extension defines the file extension of the file being loaded
  59659. * @returns true if the loader can load the specified file
  59660. */
  59661. canLoad(extension: string): boolean;
  59662. /**
  59663. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59664. * @param data contains the texture data
  59665. * @param texture defines the BabylonJS internal texture
  59666. * @param createPolynomials will be true if polynomials have been requested
  59667. * @param onLoad defines the callback to trigger once the texture is ready
  59668. * @param onError defines the callback to trigger in case of error
  59669. */
  59670. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59671. /**
  59672. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59673. * @param data contains the texture data
  59674. * @param texture defines the BabylonJS internal texture
  59675. * @param callback defines the method to call once ready to upload
  59676. */
  59677. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59678. }
  59679. }
  59680. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59681. import { Nullable } from "babylonjs/types";
  59682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59683. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59684. /**
  59685. * Implementation of the ENV Texture Loader.
  59686. * @hidden
  59687. */
  59688. export class _ENVTextureLoader implements IInternalTextureLoader {
  59689. /**
  59690. * Defines wether the loader supports cascade loading the different faces.
  59691. */
  59692. readonly supportCascades: boolean;
  59693. /**
  59694. * This returns if the loader support the current file information.
  59695. * @param extension defines the file extension of the file being loaded
  59696. * @returns true if the loader can load the specified file
  59697. */
  59698. canLoad(extension: string): boolean;
  59699. /**
  59700. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59701. * @param data contains the texture data
  59702. * @param texture defines the BabylonJS internal texture
  59703. * @param createPolynomials will be true if polynomials have been requested
  59704. * @param onLoad defines the callback to trigger once the texture is ready
  59705. * @param onError defines the callback to trigger in case of error
  59706. */
  59707. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59708. /**
  59709. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59710. * @param data contains the texture data
  59711. * @param texture defines the BabylonJS internal texture
  59712. * @param callback defines the method to call once ready to upload
  59713. */
  59714. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59715. }
  59716. }
  59717. declare module "babylonjs/Misc/khronosTextureContainer" {
  59718. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59719. /**
  59720. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59721. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59722. */
  59723. export class KhronosTextureContainer {
  59724. /** contents of the KTX container file */
  59725. data: ArrayBufferView;
  59726. private static HEADER_LEN;
  59727. private static COMPRESSED_2D;
  59728. private static COMPRESSED_3D;
  59729. private static TEX_2D;
  59730. private static TEX_3D;
  59731. /**
  59732. * Gets the openGL type
  59733. */
  59734. glType: number;
  59735. /**
  59736. * Gets the openGL type size
  59737. */
  59738. glTypeSize: number;
  59739. /**
  59740. * Gets the openGL format
  59741. */
  59742. glFormat: number;
  59743. /**
  59744. * Gets the openGL internal format
  59745. */
  59746. glInternalFormat: number;
  59747. /**
  59748. * Gets the base internal format
  59749. */
  59750. glBaseInternalFormat: number;
  59751. /**
  59752. * Gets image width in pixel
  59753. */
  59754. pixelWidth: number;
  59755. /**
  59756. * Gets image height in pixel
  59757. */
  59758. pixelHeight: number;
  59759. /**
  59760. * Gets image depth in pixels
  59761. */
  59762. pixelDepth: number;
  59763. /**
  59764. * Gets the number of array elements
  59765. */
  59766. numberOfArrayElements: number;
  59767. /**
  59768. * Gets the number of faces
  59769. */
  59770. numberOfFaces: number;
  59771. /**
  59772. * Gets the number of mipmap levels
  59773. */
  59774. numberOfMipmapLevels: number;
  59775. /**
  59776. * Gets the bytes of key value data
  59777. */
  59778. bytesOfKeyValueData: number;
  59779. /**
  59780. * Gets the load type
  59781. */
  59782. loadType: number;
  59783. /**
  59784. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59785. */
  59786. isInvalid: boolean;
  59787. /**
  59788. * Creates a new KhronosTextureContainer
  59789. * @param data contents of the KTX container file
  59790. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59791. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59792. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59793. */
  59794. constructor(
  59795. /** contents of the KTX container file */
  59796. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59797. /**
  59798. * Uploads KTX content to a Babylon Texture.
  59799. * It is assumed that the texture has already been created & is currently bound
  59800. * @hidden
  59801. */
  59802. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59803. private _upload2DCompressedLevels;
  59804. /**
  59805. * Checks if the given data starts with a KTX file identifier.
  59806. * @param data the data to check
  59807. * @returns true if the data is a KTX file or false otherwise
  59808. */
  59809. static IsValid(data: ArrayBufferView): boolean;
  59810. }
  59811. }
  59812. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59814. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59815. /**
  59816. * Class for loading KTX2 files
  59817. * !!! Experimental Extension Subject to Changes !!!
  59818. * @hidden
  59819. */
  59820. export class KhronosTextureContainer2 {
  59821. private static _ModulePromise;
  59822. private static _TranscodeFormat;
  59823. constructor(engine: ThinEngine);
  59824. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59825. private _determineTranscodeFormat;
  59826. /**
  59827. * Checks if the given data starts with a KTX2 file identifier.
  59828. * @param data the data to check
  59829. * @returns true if the data is a KTX2 file or false otherwise
  59830. */
  59831. static IsValid(data: ArrayBufferView): boolean;
  59832. }
  59833. }
  59834. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59835. import { Nullable } from "babylonjs/types";
  59836. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59837. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59838. /**
  59839. * Implementation of the KTX Texture Loader.
  59840. * @hidden
  59841. */
  59842. export class _KTXTextureLoader implements IInternalTextureLoader {
  59843. /**
  59844. * Defines wether the loader supports cascade loading the different faces.
  59845. */
  59846. readonly supportCascades: boolean;
  59847. /**
  59848. * This returns if the loader support the current file information.
  59849. * @param extension defines the file extension of the file being loaded
  59850. * @param mimeType defines the optional mime type of the file being loaded
  59851. * @returns true if the loader can load the specified file
  59852. */
  59853. canLoad(extension: string, mimeType?: string): boolean;
  59854. /**
  59855. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59856. * @param data contains the texture data
  59857. * @param texture defines the BabylonJS internal texture
  59858. * @param createPolynomials will be true if polynomials have been requested
  59859. * @param onLoad defines the callback to trigger once the texture is ready
  59860. * @param onError defines the callback to trigger in case of error
  59861. */
  59862. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59863. /**
  59864. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59865. * @param data contains the texture data
  59866. * @param texture defines the BabylonJS internal texture
  59867. * @param callback defines the method to call once ready to upload
  59868. */
  59869. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59870. }
  59871. }
  59872. declare module "babylonjs/Helpers/sceneHelpers" {
  59873. import { Nullable } from "babylonjs/types";
  59874. import { Mesh } from "babylonjs/Meshes/mesh";
  59875. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59876. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59877. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59878. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59879. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59880. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59881. import "babylonjs/Meshes/Builders/boxBuilder";
  59882. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59883. /** @hidden */
  59884. export var _forceSceneHelpersToBundle: boolean;
  59885. module "babylonjs/scene" {
  59886. interface Scene {
  59887. /**
  59888. * Creates a default light for the scene.
  59889. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59890. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59891. */
  59892. createDefaultLight(replace?: boolean): void;
  59893. /**
  59894. * Creates a default camera for the scene.
  59895. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59896. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59897. * @param replace has default false, when true replaces the active camera in the scene
  59898. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59899. */
  59900. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59901. /**
  59902. * Creates a default camera and a default light.
  59903. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59904. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59905. * @param replace has the default false, when true replaces the active camera/light in the scene
  59906. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59907. */
  59908. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59909. /**
  59910. * Creates a new sky box
  59911. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59912. * @param environmentTexture defines the texture to use as environment texture
  59913. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59914. * @param scale defines the overall scale of the skybox
  59915. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59916. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59917. * @returns a new mesh holding the sky box
  59918. */
  59919. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59920. /**
  59921. * Creates a new environment
  59922. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59923. * @param options defines the options you can use to configure the environment
  59924. * @returns the new EnvironmentHelper
  59925. */
  59926. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59927. /**
  59928. * Creates a new VREXperienceHelper
  59929. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59930. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59931. * @returns a new VREXperienceHelper
  59932. */
  59933. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59934. /**
  59935. * Creates a new WebXRDefaultExperience
  59936. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59937. * @param options experience options
  59938. * @returns a promise for a new WebXRDefaultExperience
  59939. */
  59940. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59941. }
  59942. }
  59943. }
  59944. declare module "babylonjs/Helpers/videoDome" {
  59945. import { Scene } from "babylonjs/scene";
  59946. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59947. import { Mesh } from "babylonjs/Meshes/mesh";
  59948. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59949. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59950. import "babylonjs/Meshes/Builders/sphereBuilder";
  59951. /**
  59952. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59953. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59954. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59955. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59956. */
  59957. export class VideoDome extends TransformNode {
  59958. /**
  59959. * Define the video source as a Monoscopic panoramic 360 video.
  59960. */
  59961. static readonly MODE_MONOSCOPIC: number;
  59962. /**
  59963. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59964. */
  59965. static readonly MODE_TOPBOTTOM: number;
  59966. /**
  59967. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59968. */
  59969. static readonly MODE_SIDEBYSIDE: number;
  59970. private _halfDome;
  59971. private _useDirectMapping;
  59972. /**
  59973. * The video texture being displayed on the sphere
  59974. */
  59975. protected _videoTexture: VideoTexture;
  59976. /**
  59977. * Gets the video texture being displayed on the sphere
  59978. */
  59979. get videoTexture(): VideoTexture;
  59980. /**
  59981. * The skybox material
  59982. */
  59983. protected _material: BackgroundMaterial;
  59984. /**
  59985. * The surface used for the video dome
  59986. */
  59987. protected _mesh: Mesh;
  59988. /**
  59989. * Gets the mesh used for the video dome.
  59990. */
  59991. get mesh(): Mesh;
  59992. /**
  59993. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59994. */
  59995. private _halfDomeMask;
  59996. /**
  59997. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59998. * Also see the options.resolution property.
  59999. */
  60000. get fovMultiplier(): number;
  60001. set fovMultiplier(value: number);
  60002. private _videoMode;
  60003. /**
  60004. * Gets or set the current video mode for the video. It can be:
  60005. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60006. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60007. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60008. */
  60009. get videoMode(): number;
  60010. set videoMode(value: number);
  60011. /**
  60012. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60013. *
  60014. */
  60015. get halfDome(): boolean;
  60016. /**
  60017. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60018. */
  60019. set halfDome(enabled: boolean);
  60020. /**
  60021. * Oberserver used in Stereoscopic VR Mode.
  60022. */
  60023. private _onBeforeCameraRenderObserver;
  60024. /**
  60025. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60026. * @param name Element's name, child elements will append suffixes for their own names.
  60027. * @param urlsOrVideo defines the url(s) or the video element to use
  60028. * @param options An object containing optional or exposed sub element properties
  60029. */
  60030. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60031. resolution?: number;
  60032. clickToPlay?: boolean;
  60033. autoPlay?: boolean;
  60034. loop?: boolean;
  60035. size?: number;
  60036. poster?: string;
  60037. faceForward?: boolean;
  60038. useDirectMapping?: boolean;
  60039. halfDomeMode?: boolean;
  60040. }, scene: Scene);
  60041. private _changeVideoMode;
  60042. /**
  60043. * Releases resources associated with this node.
  60044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60046. */
  60047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60048. }
  60049. }
  60050. declare module "babylonjs/Helpers/index" {
  60051. export * from "babylonjs/Helpers/environmentHelper";
  60052. export * from "babylonjs/Helpers/photoDome";
  60053. export * from "babylonjs/Helpers/sceneHelpers";
  60054. export * from "babylonjs/Helpers/videoDome";
  60055. }
  60056. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60057. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60058. import { IDisposable } from "babylonjs/scene";
  60059. import { Engine } from "babylonjs/Engines/engine";
  60060. /**
  60061. * This class can be used to get instrumentation data from a Babylon engine
  60062. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60063. */
  60064. export class EngineInstrumentation implements IDisposable {
  60065. /**
  60066. * Define the instrumented engine.
  60067. */
  60068. engine: Engine;
  60069. private _captureGPUFrameTime;
  60070. private _gpuFrameTimeToken;
  60071. private _gpuFrameTime;
  60072. private _captureShaderCompilationTime;
  60073. private _shaderCompilationTime;
  60074. private _onBeginFrameObserver;
  60075. private _onEndFrameObserver;
  60076. private _onBeforeShaderCompilationObserver;
  60077. private _onAfterShaderCompilationObserver;
  60078. /**
  60079. * Gets the perf counter used for GPU frame time
  60080. */
  60081. get gpuFrameTimeCounter(): PerfCounter;
  60082. /**
  60083. * Gets the GPU frame time capture status
  60084. */
  60085. get captureGPUFrameTime(): boolean;
  60086. /**
  60087. * Enable or disable the GPU frame time capture
  60088. */
  60089. set captureGPUFrameTime(value: boolean);
  60090. /**
  60091. * Gets the perf counter used for shader compilation time
  60092. */
  60093. get shaderCompilationTimeCounter(): PerfCounter;
  60094. /**
  60095. * Gets the shader compilation time capture status
  60096. */
  60097. get captureShaderCompilationTime(): boolean;
  60098. /**
  60099. * Enable or disable the shader compilation time capture
  60100. */
  60101. set captureShaderCompilationTime(value: boolean);
  60102. /**
  60103. * Instantiates a new engine instrumentation.
  60104. * This class can be used to get instrumentation data from a Babylon engine
  60105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60106. * @param engine Defines the engine to instrument
  60107. */
  60108. constructor(
  60109. /**
  60110. * Define the instrumented engine.
  60111. */
  60112. engine: Engine);
  60113. /**
  60114. * Dispose and release associated resources.
  60115. */
  60116. dispose(): void;
  60117. }
  60118. }
  60119. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60120. import { Scene, IDisposable } from "babylonjs/scene";
  60121. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60122. /**
  60123. * This class can be used to get instrumentation data from a Babylon engine
  60124. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60125. */
  60126. export class SceneInstrumentation implements IDisposable {
  60127. /**
  60128. * Defines the scene to instrument
  60129. */
  60130. scene: Scene;
  60131. private _captureActiveMeshesEvaluationTime;
  60132. private _activeMeshesEvaluationTime;
  60133. private _captureRenderTargetsRenderTime;
  60134. private _renderTargetsRenderTime;
  60135. private _captureFrameTime;
  60136. private _frameTime;
  60137. private _captureRenderTime;
  60138. private _renderTime;
  60139. private _captureInterFrameTime;
  60140. private _interFrameTime;
  60141. private _captureParticlesRenderTime;
  60142. private _particlesRenderTime;
  60143. private _captureSpritesRenderTime;
  60144. private _spritesRenderTime;
  60145. private _capturePhysicsTime;
  60146. private _physicsTime;
  60147. private _captureAnimationsTime;
  60148. private _animationsTime;
  60149. private _captureCameraRenderTime;
  60150. private _cameraRenderTime;
  60151. private _onBeforeActiveMeshesEvaluationObserver;
  60152. private _onAfterActiveMeshesEvaluationObserver;
  60153. private _onBeforeRenderTargetsRenderObserver;
  60154. private _onAfterRenderTargetsRenderObserver;
  60155. private _onAfterRenderObserver;
  60156. private _onBeforeDrawPhaseObserver;
  60157. private _onAfterDrawPhaseObserver;
  60158. private _onBeforeAnimationsObserver;
  60159. private _onBeforeParticlesRenderingObserver;
  60160. private _onAfterParticlesRenderingObserver;
  60161. private _onBeforeSpritesRenderingObserver;
  60162. private _onAfterSpritesRenderingObserver;
  60163. private _onBeforePhysicsObserver;
  60164. private _onAfterPhysicsObserver;
  60165. private _onAfterAnimationsObserver;
  60166. private _onBeforeCameraRenderObserver;
  60167. private _onAfterCameraRenderObserver;
  60168. /**
  60169. * Gets the perf counter used for active meshes evaluation time
  60170. */
  60171. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60172. /**
  60173. * Gets the active meshes evaluation time capture status
  60174. */
  60175. get captureActiveMeshesEvaluationTime(): boolean;
  60176. /**
  60177. * Enable or disable the active meshes evaluation time capture
  60178. */
  60179. set captureActiveMeshesEvaluationTime(value: boolean);
  60180. /**
  60181. * Gets the perf counter used for render targets render time
  60182. */
  60183. get renderTargetsRenderTimeCounter(): PerfCounter;
  60184. /**
  60185. * Gets the render targets render time capture status
  60186. */
  60187. get captureRenderTargetsRenderTime(): boolean;
  60188. /**
  60189. * Enable or disable the render targets render time capture
  60190. */
  60191. set captureRenderTargetsRenderTime(value: boolean);
  60192. /**
  60193. * Gets the perf counter used for particles render time
  60194. */
  60195. get particlesRenderTimeCounter(): PerfCounter;
  60196. /**
  60197. * Gets the particles render time capture status
  60198. */
  60199. get captureParticlesRenderTime(): boolean;
  60200. /**
  60201. * Enable or disable the particles render time capture
  60202. */
  60203. set captureParticlesRenderTime(value: boolean);
  60204. /**
  60205. * Gets the perf counter used for sprites render time
  60206. */
  60207. get spritesRenderTimeCounter(): PerfCounter;
  60208. /**
  60209. * Gets the sprites render time capture status
  60210. */
  60211. get captureSpritesRenderTime(): boolean;
  60212. /**
  60213. * Enable or disable the sprites render time capture
  60214. */
  60215. set captureSpritesRenderTime(value: boolean);
  60216. /**
  60217. * Gets the perf counter used for physics time
  60218. */
  60219. get physicsTimeCounter(): PerfCounter;
  60220. /**
  60221. * Gets the physics time capture status
  60222. */
  60223. get capturePhysicsTime(): boolean;
  60224. /**
  60225. * Enable or disable the physics time capture
  60226. */
  60227. set capturePhysicsTime(value: boolean);
  60228. /**
  60229. * Gets the perf counter used for animations time
  60230. */
  60231. get animationsTimeCounter(): PerfCounter;
  60232. /**
  60233. * Gets the animations time capture status
  60234. */
  60235. get captureAnimationsTime(): boolean;
  60236. /**
  60237. * Enable or disable the animations time capture
  60238. */
  60239. set captureAnimationsTime(value: boolean);
  60240. /**
  60241. * Gets the perf counter used for frame time capture
  60242. */
  60243. get frameTimeCounter(): PerfCounter;
  60244. /**
  60245. * Gets the frame time capture status
  60246. */
  60247. get captureFrameTime(): boolean;
  60248. /**
  60249. * Enable or disable the frame time capture
  60250. */
  60251. set captureFrameTime(value: boolean);
  60252. /**
  60253. * Gets the perf counter used for inter-frames time capture
  60254. */
  60255. get interFrameTimeCounter(): PerfCounter;
  60256. /**
  60257. * Gets the inter-frames time capture status
  60258. */
  60259. get captureInterFrameTime(): boolean;
  60260. /**
  60261. * Enable or disable the inter-frames time capture
  60262. */
  60263. set captureInterFrameTime(value: boolean);
  60264. /**
  60265. * Gets the perf counter used for render time capture
  60266. */
  60267. get renderTimeCounter(): PerfCounter;
  60268. /**
  60269. * Gets the render time capture status
  60270. */
  60271. get captureRenderTime(): boolean;
  60272. /**
  60273. * Enable or disable the render time capture
  60274. */
  60275. set captureRenderTime(value: boolean);
  60276. /**
  60277. * Gets the perf counter used for camera render time capture
  60278. */
  60279. get cameraRenderTimeCounter(): PerfCounter;
  60280. /**
  60281. * Gets the camera render time capture status
  60282. */
  60283. get captureCameraRenderTime(): boolean;
  60284. /**
  60285. * Enable or disable the camera render time capture
  60286. */
  60287. set captureCameraRenderTime(value: boolean);
  60288. /**
  60289. * Gets the perf counter used for draw calls
  60290. */
  60291. get drawCallsCounter(): PerfCounter;
  60292. /**
  60293. * Instantiates a new scene instrumentation.
  60294. * This class can be used to get instrumentation data from a Babylon engine
  60295. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60296. * @param scene Defines the scene to instrument
  60297. */
  60298. constructor(
  60299. /**
  60300. * Defines the scene to instrument
  60301. */
  60302. scene: Scene);
  60303. /**
  60304. * Dispose and release associated resources.
  60305. */
  60306. dispose(): void;
  60307. }
  60308. }
  60309. declare module "babylonjs/Instrumentation/index" {
  60310. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60311. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60312. export * from "babylonjs/Instrumentation/timeToken";
  60313. }
  60314. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60315. /** @hidden */
  60316. export var glowMapGenerationPixelShader: {
  60317. name: string;
  60318. shader: string;
  60319. };
  60320. }
  60321. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60322. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60323. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60324. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60325. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60326. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60327. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60328. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60329. /** @hidden */
  60330. export var glowMapGenerationVertexShader: {
  60331. name: string;
  60332. shader: string;
  60333. };
  60334. }
  60335. declare module "babylonjs/Layers/effectLayer" {
  60336. import { Observable } from "babylonjs/Misc/observable";
  60337. import { Nullable } from "babylonjs/types";
  60338. import { Camera } from "babylonjs/Cameras/camera";
  60339. import { Scene } from "babylonjs/scene";
  60340. import { ISize } from "babylonjs/Maths/math.size";
  60341. import { Color4 } from "babylonjs/Maths/math.color";
  60342. import { Engine } from "babylonjs/Engines/engine";
  60343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60345. import { Mesh } from "babylonjs/Meshes/mesh";
  60346. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60349. import { Effect } from "babylonjs/Materials/effect";
  60350. import { Material } from "babylonjs/Materials/material";
  60351. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60352. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60353. /**
  60354. * Effect layer options. This helps customizing the behaviour
  60355. * of the effect layer.
  60356. */
  60357. export interface IEffectLayerOptions {
  60358. /**
  60359. * Multiplication factor apply to the canvas size to compute the render target size
  60360. * used to generated the objects (the smaller the faster).
  60361. */
  60362. mainTextureRatio: number;
  60363. /**
  60364. * Enforces a fixed size texture to ensure effect stability across devices.
  60365. */
  60366. mainTextureFixedSize?: number;
  60367. /**
  60368. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60369. */
  60370. alphaBlendingMode: number;
  60371. /**
  60372. * The camera attached to the layer.
  60373. */
  60374. camera: Nullable<Camera>;
  60375. /**
  60376. * The rendering group to draw the layer in.
  60377. */
  60378. renderingGroupId: number;
  60379. }
  60380. /**
  60381. * The effect layer Helps adding post process effect blended with the main pass.
  60382. *
  60383. * This can be for instance use to generate glow or higlight effects on the scene.
  60384. *
  60385. * The effect layer class can not be used directly and is intented to inherited from to be
  60386. * customized per effects.
  60387. */
  60388. export abstract class EffectLayer {
  60389. private _vertexBuffers;
  60390. private _indexBuffer;
  60391. private _cachedDefines;
  60392. private _effectLayerMapGenerationEffect;
  60393. private _effectLayerOptions;
  60394. private _mergeEffect;
  60395. protected _scene: Scene;
  60396. protected _engine: Engine;
  60397. protected _maxSize: number;
  60398. protected _mainTextureDesiredSize: ISize;
  60399. protected _mainTexture: RenderTargetTexture;
  60400. protected _shouldRender: boolean;
  60401. protected _postProcesses: PostProcess[];
  60402. protected _textures: BaseTexture[];
  60403. protected _emissiveTextureAndColor: {
  60404. texture: Nullable<BaseTexture>;
  60405. color: Color4;
  60406. };
  60407. /**
  60408. * The name of the layer
  60409. */
  60410. name: string;
  60411. /**
  60412. * The clear color of the texture used to generate the glow map.
  60413. */
  60414. neutralColor: Color4;
  60415. /**
  60416. * Specifies whether the highlight layer is enabled or not.
  60417. */
  60418. isEnabled: boolean;
  60419. /**
  60420. * Gets the camera attached to the layer.
  60421. */
  60422. get camera(): Nullable<Camera>;
  60423. /**
  60424. * Gets the rendering group id the layer should render in.
  60425. */
  60426. get renderingGroupId(): number;
  60427. set renderingGroupId(renderingGroupId: number);
  60428. /**
  60429. * An event triggered when the effect layer has been disposed.
  60430. */
  60431. onDisposeObservable: Observable<EffectLayer>;
  60432. /**
  60433. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60434. */
  60435. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60436. /**
  60437. * An event triggered when the generated texture is being merged in the scene.
  60438. */
  60439. onBeforeComposeObservable: Observable<EffectLayer>;
  60440. /**
  60441. * An event triggered when the mesh is rendered into the effect render target.
  60442. */
  60443. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60444. /**
  60445. * An event triggered after the mesh has been rendered into the effect render target.
  60446. */
  60447. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60448. /**
  60449. * An event triggered when the generated texture has been merged in the scene.
  60450. */
  60451. onAfterComposeObservable: Observable<EffectLayer>;
  60452. /**
  60453. * An event triggered when the efffect layer changes its size.
  60454. */
  60455. onSizeChangedObservable: Observable<EffectLayer>;
  60456. /** @hidden */
  60457. static _SceneComponentInitialization: (scene: Scene) => void;
  60458. /**
  60459. * Instantiates a new effect Layer and references it in the scene.
  60460. * @param name The name of the layer
  60461. * @param scene The scene to use the layer in
  60462. */
  60463. constructor(
  60464. /** The Friendly of the effect in the scene */
  60465. name: string, scene: Scene);
  60466. /**
  60467. * Get the effect name of the layer.
  60468. * @return The effect name
  60469. */
  60470. abstract getEffectName(): string;
  60471. /**
  60472. * Checks for the readiness of the element composing the layer.
  60473. * @param subMesh the mesh to check for
  60474. * @param useInstances specify whether or not to use instances to render the mesh
  60475. * @return true if ready otherwise, false
  60476. */
  60477. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60478. /**
  60479. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60480. * @returns true if the effect requires stencil during the main canvas render pass.
  60481. */
  60482. abstract needStencil(): boolean;
  60483. /**
  60484. * Create the merge effect. This is the shader use to blit the information back
  60485. * to the main canvas at the end of the scene rendering.
  60486. * @returns The effect containing the shader used to merge the effect on the main canvas
  60487. */
  60488. protected abstract _createMergeEffect(): Effect;
  60489. /**
  60490. * Creates the render target textures and post processes used in the effect layer.
  60491. */
  60492. protected abstract _createTextureAndPostProcesses(): void;
  60493. /**
  60494. * Implementation specific of rendering the generating effect on the main canvas.
  60495. * @param effect The effect used to render through
  60496. */
  60497. protected abstract _internalRender(effect: Effect): void;
  60498. /**
  60499. * Sets the required values for both the emissive texture and and the main color.
  60500. */
  60501. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60502. /**
  60503. * Free any resources and references associated to a mesh.
  60504. * Internal use
  60505. * @param mesh The mesh to free.
  60506. */
  60507. abstract _disposeMesh(mesh: Mesh): void;
  60508. /**
  60509. * Serializes this layer (Glow or Highlight for example)
  60510. * @returns a serialized layer object
  60511. */
  60512. abstract serialize?(): any;
  60513. /**
  60514. * Initializes the effect layer with the required options.
  60515. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60516. */
  60517. protected _init(options: Partial<IEffectLayerOptions>): void;
  60518. /**
  60519. * Generates the index buffer of the full screen quad blending to the main canvas.
  60520. */
  60521. private _generateIndexBuffer;
  60522. /**
  60523. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60524. */
  60525. private _generateVertexBuffer;
  60526. /**
  60527. * Sets the main texture desired size which is the closest power of two
  60528. * of the engine canvas size.
  60529. */
  60530. private _setMainTextureSize;
  60531. /**
  60532. * Creates the main texture for the effect layer.
  60533. */
  60534. protected _createMainTexture(): void;
  60535. /**
  60536. * Adds specific effects defines.
  60537. * @param defines The defines to add specifics to.
  60538. */
  60539. protected _addCustomEffectDefines(defines: string[]): void;
  60540. /**
  60541. * Checks for the readiness of the element composing the layer.
  60542. * @param subMesh the mesh to check for
  60543. * @param useInstances specify whether or not to use instances to render the mesh
  60544. * @param emissiveTexture the associated emissive texture used to generate the glow
  60545. * @return true if ready otherwise, false
  60546. */
  60547. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60548. /**
  60549. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60550. */
  60551. render(): void;
  60552. /**
  60553. * Determine if a given mesh will be used in the current effect.
  60554. * @param mesh mesh to test
  60555. * @returns true if the mesh will be used
  60556. */
  60557. hasMesh(mesh: AbstractMesh): boolean;
  60558. /**
  60559. * Returns true if the layer contains information to display, otherwise false.
  60560. * @returns true if the glow layer should be rendered
  60561. */
  60562. shouldRender(): boolean;
  60563. /**
  60564. * Returns true if the mesh should render, otherwise false.
  60565. * @param mesh The mesh to render
  60566. * @returns true if it should render otherwise false
  60567. */
  60568. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60569. /**
  60570. * Returns true if the mesh can be rendered, otherwise false.
  60571. * @param mesh The mesh to render
  60572. * @param material The material used on the mesh
  60573. * @returns true if it can be rendered otherwise false
  60574. */
  60575. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60576. /**
  60577. * Returns true if the mesh should render, otherwise false.
  60578. * @param mesh The mesh to render
  60579. * @returns true if it should render otherwise false
  60580. */
  60581. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60582. /**
  60583. * Renders the submesh passed in parameter to the generation map.
  60584. */
  60585. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60586. /**
  60587. * Defines whether the current material of the mesh should be use to render the effect.
  60588. * @param mesh defines the current mesh to render
  60589. */
  60590. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60591. /**
  60592. * Rebuild the required buffers.
  60593. * @hidden Internal use only.
  60594. */
  60595. _rebuild(): void;
  60596. /**
  60597. * Dispose only the render target textures and post process.
  60598. */
  60599. private _disposeTextureAndPostProcesses;
  60600. /**
  60601. * Dispose the highlight layer and free resources.
  60602. */
  60603. dispose(): void;
  60604. /**
  60605. * Gets the class name of the effect layer
  60606. * @returns the string with the class name of the effect layer
  60607. */
  60608. getClassName(): string;
  60609. /**
  60610. * Creates an effect layer from parsed effect layer data
  60611. * @param parsedEffectLayer defines effect layer data
  60612. * @param scene defines the current scene
  60613. * @param rootUrl defines the root URL containing the effect layer information
  60614. * @returns a parsed effect Layer
  60615. */
  60616. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60617. }
  60618. }
  60619. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60620. import { Scene } from "babylonjs/scene";
  60621. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60622. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60623. import { AbstractScene } from "babylonjs/abstractScene";
  60624. module "babylonjs/abstractScene" {
  60625. interface AbstractScene {
  60626. /**
  60627. * The list of effect layers (highlights/glow) added to the scene
  60628. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60629. * @see https://doc.babylonjs.com/how_to/glow_layer
  60630. */
  60631. effectLayers: Array<EffectLayer>;
  60632. /**
  60633. * Removes the given effect layer from this scene.
  60634. * @param toRemove defines the effect layer to remove
  60635. * @returns the index of the removed effect layer
  60636. */
  60637. removeEffectLayer(toRemove: EffectLayer): number;
  60638. /**
  60639. * Adds the given effect layer to this scene
  60640. * @param newEffectLayer defines the effect layer to add
  60641. */
  60642. addEffectLayer(newEffectLayer: EffectLayer): void;
  60643. }
  60644. }
  60645. /**
  60646. * Defines the layer scene component responsible to manage any effect layers
  60647. * in a given scene.
  60648. */
  60649. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60650. /**
  60651. * The component name helpfull to identify the component in the list of scene components.
  60652. */
  60653. readonly name: string;
  60654. /**
  60655. * The scene the component belongs to.
  60656. */
  60657. scene: Scene;
  60658. private _engine;
  60659. private _renderEffects;
  60660. private _needStencil;
  60661. private _previousStencilState;
  60662. /**
  60663. * Creates a new instance of the component for the given scene
  60664. * @param scene Defines the scene to register the component in
  60665. */
  60666. constructor(scene: Scene);
  60667. /**
  60668. * Registers the component in a given scene
  60669. */
  60670. register(): void;
  60671. /**
  60672. * Rebuilds the elements related to this component in case of
  60673. * context lost for instance.
  60674. */
  60675. rebuild(): void;
  60676. /**
  60677. * Serializes the component data to the specified json object
  60678. * @param serializationObject The object to serialize to
  60679. */
  60680. serialize(serializationObject: any): void;
  60681. /**
  60682. * Adds all the elements from the container to the scene
  60683. * @param container the container holding the elements
  60684. */
  60685. addFromContainer(container: AbstractScene): void;
  60686. /**
  60687. * Removes all the elements in the container from the scene
  60688. * @param container contains the elements to remove
  60689. * @param dispose if the removed element should be disposed (default: false)
  60690. */
  60691. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60692. /**
  60693. * Disposes the component and the associated ressources.
  60694. */
  60695. dispose(): void;
  60696. private _isReadyForMesh;
  60697. private _renderMainTexture;
  60698. private _setStencil;
  60699. private _setStencilBack;
  60700. private _draw;
  60701. private _drawCamera;
  60702. private _drawRenderingGroup;
  60703. }
  60704. }
  60705. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60706. /** @hidden */
  60707. export var glowMapMergePixelShader: {
  60708. name: string;
  60709. shader: string;
  60710. };
  60711. }
  60712. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60713. /** @hidden */
  60714. export var glowMapMergeVertexShader: {
  60715. name: string;
  60716. shader: string;
  60717. };
  60718. }
  60719. declare module "babylonjs/Layers/glowLayer" {
  60720. import { Nullable } from "babylonjs/types";
  60721. import { Camera } from "babylonjs/Cameras/camera";
  60722. import { Scene } from "babylonjs/scene";
  60723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60725. import { Mesh } from "babylonjs/Meshes/mesh";
  60726. import { Texture } from "babylonjs/Materials/Textures/texture";
  60727. import { Effect } from "babylonjs/Materials/effect";
  60728. import { Material } from "babylonjs/Materials/material";
  60729. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60730. import { Color4 } from "babylonjs/Maths/math.color";
  60731. import "babylonjs/Shaders/glowMapMerge.fragment";
  60732. import "babylonjs/Shaders/glowMapMerge.vertex";
  60733. import "babylonjs/Layers/effectLayerSceneComponent";
  60734. module "babylonjs/abstractScene" {
  60735. interface AbstractScene {
  60736. /**
  60737. * Return a the first highlight layer of the scene with a given name.
  60738. * @param name The name of the highlight layer to look for.
  60739. * @return The highlight layer if found otherwise null.
  60740. */
  60741. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60742. }
  60743. }
  60744. /**
  60745. * Glow layer options. This helps customizing the behaviour
  60746. * of the glow layer.
  60747. */
  60748. export interface IGlowLayerOptions {
  60749. /**
  60750. * Multiplication factor apply to the canvas size to compute the render target size
  60751. * used to generated the glowing objects (the smaller the faster).
  60752. */
  60753. mainTextureRatio: number;
  60754. /**
  60755. * Enforces a fixed size texture to ensure resize independant blur.
  60756. */
  60757. mainTextureFixedSize?: number;
  60758. /**
  60759. * How big is the kernel of the blur texture.
  60760. */
  60761. blurKernelSize: number;
  60762. /**
  60763. * The camera attached to the layer.
  60764. */
  60765. camera: Nullable<Camera>;
  60766. /**
  60767. * Enable MSAA by chosing the number of samples.
  60768. */
  60769. mainTextureSamples?: number;
  60770. /**
  60771. * The rendering group to draw the layer in.
  60772. */
  60773. renderingGroupId: number;
  60774. }
  60775. /**
  60776. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60777. *
  60778. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60779. *
  60780. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60781. */
  60782. export class GlowLayer extends EffectLayer {
  60783. /**
  60784. * Effect Name of the layer.
  60785. */
  60786. static readonly EffectName: string;
  60787. /**
  60788. * The default blur kernel size used for the glow.
  60789. */
  60790. static DefaultBlurKernelSize: number;
  60791. /**
  60792. * The default texture size ratio used for the glow.
  60793. */
  60794. static DefaultTextureRatio: number;
  60795. /**
  60796. * Sets the kernel size of the blur.
  60797. */
  60798. set blurKernelSize(value: number);
  60799. /**
  60800. * Gets the kernel size of the blur.
  60801. */
  60802. get blurKernelSize(): number;
  60803. /**
  60804. * Sets the glow intensity.
  60805. */
  60806. set intensity(value: number);
  60807. /**
  60808. * Gets the glow intensity.
  60809. */
  60810. get intensity(): number;
  60811. private _options;
  60812. private _intensity;
  60813. private _horizontalBlurPostprocess1;
  60814. private _verticalBlurPostprocess1;
  60815. private _horizontalBlurPostprocess2;
  60816. private _verticalBlurPostprocess2;
  60817. private _blurTexture1;
  60818. private _blurTexture2;
  60819. private _postProcesses1;
  60820. private _postProcesses2;
  60821. private _includedOnlyMeshes;
  60822. private _excludedMeshes;
  60823. private _meshesUsingTheirOwnMaterials;
  60824. /**
  60825. * Callback used to let the user override the color selection on a per mesh basis
  60826. */
  60827. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60828. /**
  60829. * Callback used to let the user override the texture selection on a per mesh basis
  60830. */
  60831. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60832. /**
  60833. * Instantiates a new glow Layer and references it to the scene.
  60834. * @param name The name of the layer
  60835. * @param scene The scene to use the layer in
  60836. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60837. */
  60838. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60839. /**
  60840. * Get the effect name of the layer.
  60841. * @return The effect name
  60842. */
  60843. getEffectName(): string;
  60844. /**
  60845. * Create the merge effect. This is the shader use to blit the information back
  60846. * to the main canvas at the end of the scene rendering.
  60847. */
  60848. protected _createMergeEffect(): Effect;
  60849. /**
  60850. * Creates the render target textures and post processes used in the glow layer.
  60851. */
  60852. protected _createTextureAndPostProcesses(): void;
  60853. /**
  60854. * Checks for the readiness of the element composing the layer.
  60855. * @param subMesh the mesh to check for
  60856. * @param useInstances specify wether or not to use instances to render the mesh
  60857. * @param emissiveTexture the associated emissive texture used to generate the glow
  60858. * @return true if ready otherwise, false
  60859. */
  60860. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60861. /**
  60862. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60863. */
  60864. needStencil(): boolean;
  60865. /**
  60866. * Returns true if the mesh can be rendered, otherwise false.
  60867. * @param mesh The mesh to render
  60868. * @param material The material used on the mesh
  60869. * @returns true if it can be rendered otherwise false
  60870. */
  60871. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60872. /**
  60873. * Implementation specific of rendering the generating effect on the main canvas.
  60874. * @param effect The effect used to render through
  60875. */
  60876. protected _internalRender(effect: Effect): void;
  60877. /**
  60878. * Sets the required values for both the emissive texture and and the main color.
  60879. */
  60880. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60881. /**
  60882. * Returns true if the mesh should render, otherwise false.
  60883. * @param mesh The mesh to render
  60884. * @returns true if it should render otherwise false
  60885. */
  60886. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60887. /**
  60888. * Adds specific effects defines.
  60889. * @param defines The defines to add specifics to.
  60890. */
  60891. protected _addCustomEffectDefines(defines: string[]): void;
  60892. /**
  60893. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60894. * @param mesh The mesh to exclude from the glow layer
  60895. */
  60896. addExcludedMesh(mesh: Mesh): void;
  60897. /**
  60898. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60899. * @param mesh The mesh to remove
  60900. */
  60901. removeExcludedMesh(mesh: Mesh): void;
  60902. /**
  60903. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60904. * @param mesh The mesh to include in the glow layer
  60905. */
  60906. addIncludedOnlyMesh(mesh: Mesh): void;
  60907. /**
  60908. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60909. * @param mesh The mesh to remove
  60910. */
  60911. removeIncludedOnlyMesh(mesh: Mesh): void;
  60912. /**
  60913. * Determine if a given mesh will be used in the glow layer
  60914. * @param mesh The mesh to test
  60915. * @returns true if the mesh will be highlighted by the current glow layer
  60916. */
  60917. hasMesh(mesh: AbstractMesh): boolean;
  60918. /**
  60919. * Defines whether the current material of the mesh should be use to render the effect.
  60920. * @param mesh defines the current mesh to render
  60921. */
  60922. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60923. /**
  60924. * Add a mesh to be rendered through its own material and not with emissive only.
  60925. * @param mesh The mesh for which we need to use its material
  60926. */
  60927. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60928. /**
  60929. * Remove a mesh from being rendered through its own material and not with emissive only.
  60930. * @param mesh The mesh for which we need to not use its material
  60931. */
  60932. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60933. /**
  60934. * Free any resources and references associated to a mesh.
  60935. * Internal use
  60936. * @param mesh The mesh to free.
  60937. * @hidden
  60938. */
  60939. _disposeMesh(mesh: Mesh): void;
  60940. /**
  60941. * Gets the class name of the effect layer
  60942. * @returns the string with the class name of the effect layer
  60943. */
  60944. getClassName(): string;
  60945. /**
  60946. * Serializes this glow layer
  60947. * @returns a serialized glow layer object
  60948. */
  60949. serialize(): any;
  60950. /**
  60951. * Creates a Glow Layer from parsed glow layer data
  60952. * @param parsedGlowLayer defines glow layer data
  60953. * @param scene defines the current scene
  60954. * @param rootUrl defines the root URL containing the glow layer information
  60955. * @returns a parsed Glow Layer
  60956. */
  60957. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60958. }
  60959. }
  60960. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60961. /** @hidden */
  60962. export var glowBlurPostProcessPixelShader: {
  60963. name: string;
  60964. shader: string;
  60965. };
  60966. }
  60967. declare module "babylonjs/Layers/highlightLayer" {
  60968. import { Observable } from "babylonjs/Misc/observable";
  60969. import { Nullable } from "babylonjs/types";
  60970. import { Camera } from "babylonjs/Cameras/camera";
  60971. import { Scene } from "babylonjs/scene";
  60972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60974. import { Mesh } from "babylonjs/Meshes/mesh";
  60975. import { Effect } from "babylonjs/Materials/effect";
  60976. import { Material } from "babylonjs/Materials/material";
  60977. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60978. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60979. import "babylonjs/Shaders/glowMapMerge.fragment";
  60980. import "babylonjs/Shaders/glowMapMerge.vertex";
  60981. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60982. module "babylonjs/abstractScene" {
  60983. interface AbstractScene {
  60984. /**
  60985. * Return a the first highlight layer of the scene with a given name.
  60986. * @param name The name of the highlight layer to look for.
  60987. * @return The highlight layer if found otherwise null.
  60988. */
  60989. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60990. }
  60991. }
  60992. /**
  60993. * Highlight layer options. This helps customizing the behaviour
  60994. * of the highlight layer.
  60995. */
  60996. export interface IHighlightLayerOptions {
  60997. /**
  60998. * Multiplication factor apply to the canvas size to compute the render target size
  60999. * used to generated the glowing objects (the smaller the faster).
  61000. */
  61001. mainTextureRatio: number;
  61002. /**
  61003. * Enforces a fixed size texture to ensure resize independant blur.
  61004. */
  61005. mainTextureFixedSize?: number;
  61006. /**
  61007. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61008. * of the picture to blur (the smaller the faster).
  61009. */
  61010. blurTextureSizeRatio: number;
  61011. /**
  61012. * How big in texel of the blur texture is the vertical blur.
  61013. */
  61014. blurVerticalSize: number;
  61015. /**
  61016. * How big in texel of the blur texture is the horizontal blur.
  61017. */
  61018. blurHorizontalSize: number;
  61019. /**
  61020. * Alpha blending mode used to apply the blur. Default is combine.
  61021. */
  61022. alphaBlendingMode: number;
  61023. /**
  61024. * The camera attached to the layer.
  61025. */
  61026. camera: Nullable<Camera>;
  61027. /**
  61028. * Should we display highlight as a solid stroke?
  61029. */
  61030. isStroke?: boolean;
  61031. /**
  61032. * The rendering group to draw the layer in.
  61033. */
  61034. renderingGroupId: number;
  61035. }
  61036. /**
  61037. * The highlight layer Helps adding a glow effect around a mesh.
  61038. *
  61039. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61040. * glowy meshes to your scene.
  61041. *
  61042. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61043. */
  61044. export class HighlightLayer extends EffectLayer {
  61045. name: string;
  61046. /**
  61047. * Effect Name of the highlight layer.
  61048. */
  61049. static readonly EffectName: string;
  61050. /**
  61051. * The neutral color used during the preparation of the glow effect.
  61052. * This is black by default as the blend operation is a blend operation.
  61053. */
  61054. static NeutralColor: Color4;
  61055. /**
  61056. * Stencil value used for glowing meshes.
  61057. */
  61058. static GlowingMeshStencilReference: number;
  61059. /**
  61060. * Stencil value used for the other meshes in the scene.
  61061. */
  61062. static NormalMeshStencilReference: number;
  61063. /**
  61064. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61065. */
  61066. innerGlow: boolean;
  61067. /**
  61068. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61069. */
  61070. outerGlow: boolean;
  61071. /**
  61072. * Specifies the horizontal size of the blur.
  61073. */
  61074. set blurHorizontalSize(value: number);
  61075. /**
  61076. * Specifies the vertical size of the blur.
  61077. */
  61078. set blurVerticalSize(value: number);
  61079. /**
  61080. * Gets the horizontal size of the blur.
  61081. */
  61082. get blurHorizontalSize(): number;
  61083. /**
  61084. * Gets the vertical size of the blur.
  61085. */
  61086. get blurVerticalSize(): number;
  61087. /**
  61088. * An event triggered when the highlight layer is being blurred.
  61089. */
  61090. onBeforeBlurObservable: Observable<HighlightLayer>;
  61091. /**
  61092. * An event triggered when the highlight layer has been blurred.
  61093. */
  61094. onAfterBlurObservable: Observable<HighlightLayer>;
  61095. private _instanceGlowingMeshStencilReference;
  61096. private _options;
  61097. private _downSamplePostprocess;
  61098. private _horizontalBlurPostprocess;
  61099. private _verticalBlurPostprocess;
  61100. private _blurTexture;
  61101. private _meshes;
  61102. private _excludedMeshes;
  61103. /**
  61104. * Instantiates a new highlight Layer and references it to the scene..
  61105. * @param name The name of the layer
  61106. * @param scene The scene to use the layer in
  61107. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61108. */
  61109. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61110. /**
  61111. * Get the effect name of the layer.
  61112. * @return The effect name
  61113. */
  61114. getEffectName(): string;
  61115. /**
  61116. * Create the merge effect. This is the shader use to blit the information back
  61117. * to the main canvas at the end of the scene rendering.
  61118. */
  61119. protected _createMergeEffect(): Effect;
  61120. /**
  61121. * Creates the render target textures and post processes used in the highlight layer.
  61122. */
  61123. protected _createTextureAndPostProcesses(): void;
  61124. /**
  61125. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61126. */
  61127. needStencil(): boolean;
  61128. /**
  61129. * Checks for the readiness of the element composing the layer.
  61130. * @param subMesh the mesh to check for
  61131. * @param useInstances specify wether or not to use instances to render the mesh
  61132. * @param emissiveTexture the associated emissive texture used to generate the glow
  61133. * @return true if ready otherwise, false
  61134. */
  61135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61136. /**
  61137. * Implementation specific of rendering the generating effect on the main canvas.
  61138. * @param effect The effect used to render through
  61139. */
  61140. protected _internalRender(effect: Effect): void;
  61141. /**
  61142. * Returns true if the layer contains information to display, otherwise false.
  61143. */
  61144. shouldRender(): boolean;
  61145. /**
  61146. * Returns true if the mesh should render, otherwise false.
  61147. * @param mesh The mesh to render
  61148. * @returns true if it should render otherwise false
  61149. */
  61150. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61151. /**
  61152. * Returns true if the mesh can be rendered, otherwise false.
  61153. * @param mesh The mesh to render
  61154. * @param material The material used on the mesh
  61155. * @returns true if it can be rendered otherwise false
  61156. */
  61157. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61158. /**
  61159. * Adds specific effects defines.
  61160. * @param defines The defines to add specifics to.
  61161. */
  61162. protected _addCustomEffectDefines(defines: string[]): void;
  61163. /**
  61164. * Sets the required values for both the emissive texture and and the main color.
  61165. */
  61166. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61167. /**
  61168. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61169. * @param mesh The mesh to exclude from the highlight layer
  61170. */
  61171. addExcludedMesh(mesh: Mesh): void;
  61172. /**
  61173. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61174. * @param mesh The mesh to highlight
  61175. */
  61176. removeExcludedMesh(mesh: Mesh): void;
  61177. /**
  61178. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61179. * @param mesh mesh to test
  61180. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61181. */
  61182. hasMesh(mesh: AbstractMesh): boolean;
  61183. /**
  61184. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61185. * @param mesh The mesh to highlight
  61186. * @param color The color of the highlight
  61187. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61188. */
  61189. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61190. /**
  61191. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61192. * @param mesh The mesh to highlight
  61193. */
  61194. removeMesh(mesh: Mesh): void;
  61195. /**
  61196. * Remove all the meshes currently referenced in the highlight layer
  61197. */
  61198. removeAllMeshes(): void;
  61199. /**
  61200. * Force the stencil to the normal expected value for none glowing parts
  61201. */
  61202. private _defaultStencilReference;
  61203. /**
  61204. * Free any resources and references associated to a mesh.
  61205. * Internal use
  61206. * @param mesh The mesh to free.
  61207. * @hidden
  61208. */
  61209. _disposeMesh(mesh: Mesh): void;
  61210. /**
  61211. * Dispose the highlight layer and free resources.
  61212. */
  61213. dispose(): void;
  61214. /**
  61215. * Gets the class name of the effect layer
  61216. * @returns the string with the class name of the effect layer
  61217. */
  61218. getClassName(): string;
  61219. /**
  61220. * Serializes this Highlight layer
  61221. * @returns a serialized Highlight layer object
  61222. */
  61223. serialize(): any;
  61224. /**
  61225. * Creates a Highlight layer from parsed Highlight layer data
  61226. * @param parsedHightlightLayer defines the Highlight layer data
  61227. * @param scene defines the current scene
  61228. * @param rootUrl defines the root URL containing the Highlight layer information
  61229. * @returns a parsed Highlight layer
  61230. */
  61231. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61232. }
  61233. }
  61234. declare module "babylonjs/Layers/layerSceneComponent" {
  61235. import { Scene } from "babylonjs/scene";
  61236. import { ISceneComponent } from "babylonjs/sceneComponent";
  61237. import { Layer } from "babylonjs/Layers/layer";
  61238. import { AbstractScene } from "babylonjs/abstractScene";
  61239. module "babylonjs/abstractScene" {
  61240. interface AbstractScene {
  61241. /**
  61242. * The list of layers (background and foreground) of the scene
  61243. */
  61244. layers: Array<Layer>;
  61245. }
  61246. }
  61247. /**
  61248. * Defines the layer scene component responsible to manage any layers
  61249. * in a given scene.
  61250. */
  61251. export class LayerSceneComponent implements ISceneComponent {
  61252. /**
  61253. * The component name helpfull to identify the component in the list of scene components.
  61254. */
  61255. readonly name: string;
  61256. /**
  61257. * The scene the component belongs to.
  61258. */
  61259. scene: Scene;
  61260. private _engine;
  61261. /**
  61262. * Creates a new instance of the component for the given scene
  61263. * @param scene Defines the scene to register the component in
  61264. */
  61265. constructor(scene: Scene);
  61266. /**
  61267. * Registers the component in a given scene
  61268. */
  61269. register(): void;
  61270. /**
  61271. * Rebuilds the elements related to this component in case of
  61272. * context lost for instance.
  61273. */
  61274. rebuild(): void;
  61275. /**
  61276. * Disposes the component and the associated ressources.
  61277. */
  61278. dispose(): void;
  61279. private _draw;
  61280. private _drawCameraPredicate;
  61281. private _drawCameraBackground;
  61282. private _drawCameraForeground;
  61283. private _drawRenderTargetPredicate;
  61284. private _drawRenderTargetBackground;
  61285. private _drawRenderTargetForeground;
  61286. /**
  61287. * Adds all the elements from the container to the scene
  61288. * @param container the container holding the elements
  61289. */
  61290. addFromContainer(container: AbstractScene): void;
  61291. /**
  61292. * Removes all the elements in the container from the scene
  61293. * @param container contains the elements to remove
  61294. * @param dispose if the removed element should be disposed (default: false)
  61295. */
  61296. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61297. }
  61298. }
  61299. declare module "babylonjs/Shaders/layer.fragment" {
  61300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61301. /** @hidden */
  61302. export var layerPixelShader: {
  61303. name: string;
  61304. shader: string;
  61305. };
  61306. }
  61307. declare module "babylonjs/Shaders/layer.vertex" {
  61308. /** @hidden */
  61309. export var layerVertexShader: {
  61310. name: string;
  61311. shader: string;
  61312. };
  61313. }
  61314. declare module "babylonjs/Layers/layer" {
  61315. import { Observable } from "babylonjs/Misc/observable";
  61316. import { Nullable } from "babylonjs/types";
  61317. import { Scene } from "babylonjs/scene";
  61318. import { Vector2 } from "babylonjs/Maths/math.vector";
  61319. import { Color4 } from "babylonjs/Maths/math.color";
  61320. import { Texture } from "babylonjs/Materials/Textures/texture";
  61321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61322. import "babylonjs/Shaders/layer.fragment";
  61323. import "babylonjs/Shaders/layer.vertex";
  61324. /**
  61325. * This represents a full screen 2d layer.
  61326. * This can be useful to display a picture in the background of your scene for instance.
  61327. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61328. */
  61329. export class Layer {
  61330. /**
  61331. * Define the name of the layer.
  61332. */
  61333. name: string;
  61334. /**
  61335. * Define the texture the layer should display.
  61336. */
  61337. texture: Nullable<Texture>;
  61338. /**
  61339. * Is the layer in background or foreground.
  61340. */
  61341. isBackground: boolean;
  61342. /**
  61343. * Define the color of the layer (instead of texture).
  61344. */
  61345. color: Color4;
  61346. /**
  61347. * Define the scale of the layer in order to zoom in out of the texture.
  61348. */
  61349. scale: Vector2;
  61350. /**
  61351. * Define an offset for the layer in order to shift the texture.
  61352. */
  61353. offset: Vector2;
  61354. /**
  61355. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61356. */
  61357. alphaBlendingMode: number;
  61358. /**
  61359. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61360. * Alpha test will not mix with the background color in case of transparency.
  61361. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61362. */
  61363. alphaTest: boolean;
  61364. /**
  61365. * Define a mask to restrict the layer to only some of the scene cameras.
  61366. */
  61367. layerMask: number;
  61368. /**
  61369. * Define the list of render target the layer is visible into.
  61370. */
  61371. renderTargetTextures: RenderTargetTexture[];
  61372. /**
  61373. * Define if the layer is only used in renderTarget or if it also
  61374. * renders in the main frame buffer of the canvas.
  61375. */
  61376. renderOnlyInRenderTargetTextures: boolean;
  61377. private _scene;
  61378. private _vertexBuffers;
  61379. private _indexBuffer;
  61380. private _effect;
  61381. private _previousDefines;
  61382. /**
  61383. * An event triggered when the layer is disposed.
  61384. */
  61385. onDisposeObservable: Observable<Layer>;
  61386. private _onDisposeObserver;
  61387. /**
  61388. * Back compatibility with callback before the onDisposeObservable existed.
  61389. * The set callback will be triggered when the layer has been disposed.
  61390. */
  61391. set onDispose(callback: () => void);
  61392. /**
  61393. * An event triggered before rendering the scene
  61394. */
  61395. onBeforeRenderObservable: Observable<Layer>;
  61396. private _onBeforeRenderObserver;
  61397. /**
  61398. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61399. * The set callback will be triggered just before rendering the layer.
  61400. */
  61401. set onBeforeRender(callback: () => void);
  61402. /**
  61403. * An event triggered after rendering the scene
  61404. */
  61405. onAfterRenderObservable: Observable<Layer>;
  61406. private _onAfterRenderObserver;
  61407. /**
  61408. * Back compatibility with callback before the onAfterRenderObservable existed.
  61409. * The set callback will be triggered just after rendering the layer.
  61410. */
  61411. set onAfterRender(callback: () => void);
  61412. /**
  61413. * Instantiates a new layer.
  61414. * This represents a full screen 2d layer.
  61415. * This can be useful to display a picture in the background of your scene for instance.
  61416. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61417. * @param name Define the name of the layer in the scene
  61418. * @param imgUrl Define the url of the texture to display in the layer
  61419. * @param scene Define the scene the layer belongs to
  61420. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61421. * @param color Defines a color for the layer
  61422. */
  61423. constructor(
  61424. /**
  61425. * Define the name of the layer.
  61426. */
  61427. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61428. private _createIndexBuffer;
  61429. /** @hidden */
  61430. _rebuild(): void;
  61431. /**
  61432. * Renders the layer in the scene.
  61433. */
  61434. render(): void;
  61435. /**
  61436. * Disposes and releases the associated ressources.
  61437. */
  61438. dispose(): void;
  61439. }
  61440. }
  61441. declare module "babylonjs/Layers/index" {
  61442. export * from "babylonjs/Layers/effectLayer";
  61443. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61444. export * from "babylonjs/Layers/glowLayer";
  61445. export * from "babylonjs/Layers/highlightLayer";
  61446. export * from "babylonjs/Layers/layer";
  61447. export * from "babylonjs/Layers/layerSceneComponent";
  61448. }
  61449. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61450. /** @hidden */
  61451. export var lensFlarePixelShader: {
  61452. name: string;
  61453. shader: string;
  61454. };
  61455. }
  61456. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61457. /** @hidden */
  61458. export var lensFlareVertexShader: {
  61459. name: string;
  61460. shader: string;
  61461. };
  61462. }
  61463. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61464. import { Scene } from "babylonjs/scene";
  61465. import { Vector3 } from "babylonjs/Maths/math.vector";
  61466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61467. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61468. import "babylonjs/Shaders/lensFlare.fragment";
  61469. import "babylonjs/Shaders/lensFlare.vertex";
  61470. import { Viewport } from "babylonjs/Maths/math.viewport";
  61471. /**
  61472. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61473. * It is usually composed of several `lensFlare`.
  61474. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61475. */
  61476. export class LensFlareSystem {
  61477. /**
  61478. * Define the name of the lens flare system
  61479. */
  61480. name: string;
  61481. /**
  61482. * List of lens flares used in this system.
  61483. */
  61484. lensFlares: LensFlare[];
  61485. /**
  61486. * Define a limit from the border the lens flare can be visible.
  61487. */
  61488. borderLimit: number;
  61489. /**
  61490. * Define a viewport border we do not want to see the lens flare in.
  61491. */
  61492. viewportBorder: number;
  61493. /**
  61494. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61495. */
  61496. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61497. /**
  61498. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61499. */
  61500. layerMask: number;
  61501. /**
  61502. * Define the id of the lens flare system in the scene.
  61503. * (equal to name by default)
  61504. */
  61505. id: string;
  61506. private _scene;
  61507. private _emitter;
  61508. private _vertexBuffers;
  61509. private _indexBuffer;
  61510. private _effect;
  61511. private _positionX;
  61512. private _positionY;
  61513. private _isEnabled;
  61514. /** @hidden */
  61515. static _SceneComponentInitialization: (scene: Scene) => void;
  61516. /**
  61517. * Instantiates a lens flare system.
  61518. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61519. * It is usually composed of several `lensFlare`.
  61520. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61521. * @param name Define the name of the lens flare system in the scene
  61522. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61523. * @param scene Define the scene the lens flare system belongs to
  61524. */
  61525. constructor(
  61526. /**
  61527. * Define the name of the lens flare system
  61528. */
  61529. name: string, emitter: any, scene: Scene);
  61530. /**
  61531. * Define if the lens flare system is enabled.
  61532. */
  61533. get isEnabled(): boolean;
  61534. set isEnabled(value: boolean);
  61535. /**
  61536. * Get the scene the effects belongs to.
  61537. * @returns the scene holding the lens flare system
  61538. */
  61539. getScene(): Scene;
  61540. /**
  61541. * Get the emitter of the lens flare system.
  61542. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61543. * @returns the emitter of the lens flare system
  61544. */
  61545. getEmitter(): any;
  61546. /**
  61547. * Set the emitter of the lens flare system.
  61548. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61549. * @param newEmitter Define the new emitter of the system
  61550. */
  61551. setEmitter(newEmitter: any): void;
  61552. /**
  61553. * Get the lens flare system emitter position.
  61554. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61555. * @returns the position
  61556. */
  61557. getEmitterPosition(): Vector3;
  61558. /**
  61559. * @hidden
  61560. */
  61561. computeEffectivePosition(globalViewport: Viewport): boolean;
  61562. /** @hidden */
  61563. _isVisible(): boolean;
  61564. /**
  61565. * @hidden
  61566. */
  61567. render(): boolean;
  61568. /**
  61569. * Dispose and release the lens flare with its associated resources.
  61570. */
  61571. dispose(): void;
  61572. /**
  61573. * Parse a lens flare system from a JSON repressentation
  61574. * @param parsedLensFlareSystem Define the JSON to parse
  61575. * @param scene Define the scene the parsed system should be instantiated in
  61576. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61577. * @returns the parsed system
  61578. */
  61579. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61580. /**
  61581. * Serialize the current Lens Flare System into a JSON representation.
  61582. * @returns the serialized JSON
  61583. */
  61584. serialize(): any;
  61585. }
  61586. }
  61587. declare module "babylonjs/LensFlares/lensFlare" {
  61588. import { Nullable } from "babylonjs/types";
  61589. import { Color3 } from "babylonjs/Maths/math.color";
  61590. import { Texture } from "babylonjs/Materials/Textures/texture";
  61591. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61592. /**
  61593. * This represents one of the lens effect in a `lensFlareSystem`.
  61594. * It controls one of the indiviual texture used in the effect.
  61595. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61596. */
  61597. export class LensFlare {
  61598. /**
  61599. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61600. */
  61601. size: number;
  61602. /**
  61603. * 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.
  61604. */
  61605. position: number;
  61606. /**
  61607. * Define the lens color.
  61608. */
  61609. color: Color3;
  61610. /**
  61611. * Define the lens texture.
  61612. */
  61613. texture: Nullable<Texture>;
  61614. /**
  61615. * Define the alpha mode to render this particular lens.
  61616. */
  61617. alphaMode: number;
  61618. private _system;
  61619. /**
  61620. * Creates a new Lens Flare.
  61621. * This represents one of the lens effect in a `lensFlareSystem`.
  61622. * It controls one of the indiviual texture used in the effect.
  61623. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61624. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61625. * @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.
  61626. * @param color Define the lens color
  61627. * @param imgUrl Define the lens texture url
  61628. * @param system Define the `lensFlareSystem` this flare is part of
  61629. * @returns The newly created Lens Flare
  61630. */
  61631. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61632. /**
  61633. * Instantiates a new Lens Flare.
  61634. * This represents one of the lens effect in a `lensFlareSystem`.
  61635. * It controls one of the indiviual texture used in the effect.
  61636. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61637. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61638. * @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.
  61639. * @param color Define the lens color
  61640. * @param imgUrl Define the lens texture url
  61641. * @param system Define the `lensFlareSystem` this flare is part of
  61642. */
  61643. constructor(
  61644. /**
  61645. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61646. */
  61647. size: number,
  61648. /**
  61649. * 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.
  61650. */
  61651. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61652. /**
  61653. * Dispose and release the lens flare with its associated resources.
  61654. */
  61655. dispose(): void;
  61656. }
  61657. }
  61658. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61659. import { Nullable } from "babylonjs/types";
  61660. import { Scene } from "babylonjs/scene";
  61661. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61662. import { AbstractScene } from "babylonjs/abstractScene";
  61663. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61664. module "babylonjs/abstractScene" {
  61665. interface AbstractScene {
  61666. /**
  61667. * The list of lens flare system added to the scene
  61668. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61669. */
  61670. lensFlareSystems: Array<LensFlareSystem>;
  61671. /**
  61672. * Removes the given lens flare system from this scene.
  61673. * @param toRemove The lens flare system to remove
  61674. * @returns The index of the removed lens flare system
  61675. */
  61676. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61677. /**
  61678. * Adds the given lens flare system to this scene
  61679. * @param newLensFlareSystem The lens flare system to add
  61680. */
  61681. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61682. /**
  61683. * Gets a lens flare system using its name
  61684. * @param name defines the name to look for
  61685. * @returns the lens flare system or null if not found
  61686. */
  61687. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61688. /**
  61689. * Gets a lens flare system using its id
  61690. * @param id defines the id to look for
  61691. * @returns the lens flare system or null if not found
  61692. */
  61693. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61694. }
  61695. }
  61696. /**
  61697. * Defines the lens flare scene component responsible to manage any lens flares
  61698. * in a given scene.
  61699. */
  61700. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61701. /**
  61702. * The component name helpfull to identify the component in the list of scene components.
  61703. */
  61704. readonly name: string;
  61705. /**
  61706. * The scene the component belongs to.
  61707. */
  61708. scene: Scene;
  61709. /**
  61710. * Creates a new instance of the component for the given scene
  61711. * @param scene Defines the scene to register the component in
  61712. */
  61713. constructor(scene: Scene);
  61714. /**
  61715. * Registers the component in a given scene
  61716. */
  61717. register(): void;
  61718. /**
  61719. * Rebuilds the elements related to this component in case of
  61720. * context lost for instance.
  61721. */
  61722. rebuild(): void;
  61723. /**
  61724. * Adds all the elements from the container to the scene
  61725. * @param container the container holding the elements
  61726. */
  61727. addFromContainer(container: AbstractScene): void;
  61728. /**
  61729. * Removes all the elements in the container from the scene
  61730. * @param container contains the elements to remove
  61731. * @param dispose if the removed element should be disposed (default: false)
  61732. */
  61733. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61734. /**
  61735. * Serializes the component data to the specified json object
  61736. * @param serializationObject The object to serialize to
  61737. */
  61738. serialize(serializationObject: any): void;
  61739. /**
  61740. * Disposes the component and the associated ressources.
  61741. */
  61742. dispose(): void;
  61743. private _draw;
  61744. }
  61745. }
  61746. declare module "babylonjs/LensFlares/index" {
  61747. export * from "babylonjs/LensFlares/lensFlare";
  61748. export * from "babylonjs/LensFlares/lensFlareSystem";
  61749. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61750. }
  61751. declare module "babylonjs/Shaders/depth.fragment" {
  61752. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61753. /** @hidden */
  61754. export var depthPixelShader: {
  61755. name: string;
  61756. shader: string;
  61757. };
  61758. }
  61759. declare module "babylonjs/Shaders/depth.vertex" {
  61760. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61763. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61765. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61766. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61767. /** @hidden */
  61768. export var depthVertexShader: {
  61769. name: string;
  61770. shader: string;
  61771. };
  61772. }
  61773. declare module "babylonjs/Rendering/depthRenderer" {
  61774. import { Nullable } from "babylonjs/types";
  61775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61776. import { Scene } from "babylonjs/scene";
  61777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61778. import { Camera } from "babylonjs/Cameras/camera";
  61779. import "babylonjs/Shaders/depth.fragment";
  61780. import "babylonjs/Shaders/depth.vertex";
  61781. /**
  61782. * This represents a depth renderer in Babylon.
  61783. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61784. */
  61785. export class DepthRenderer {
  61786. private _scene;
  61787. private _depthMap;
  61788. private _effect;
  61789. private readonly _storeNonLinearDepth;
  61790. private readonly _clearColor;
  61791. /** Get if the depth renderer is using packed depth or not */
  61792. readonly isPacked: boolean;
  61793. private _cachedDefines;
  61794. private _camera;
  61795. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61796. enabled: boolean;
  61797. /**
  61798. * Specifiess that the depth renderer will only be used within
  61799. * the camera it is created for.
  61800. * This can help forcing its rendering during the camera processing.
  61801. */
  61802. useOnlyInActiveCamera: boolean;
  61803. /** @hidden */
  61804. static _SceneComponentInitialization: (scene: Scene) => void;
  61805. /**
  61806. * Instantiates a depth renderer
  61807. * @param scene The scene the renderer belongs to
  61808. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61809. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61810. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61811. */
  61812. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61813. /**
  61814. * Creates the depth rendering effect and checks if the effect is ready.
  61815. * @param subMesh The submesh to be used to render the depth map of
  61816. * @param useInstances If multiple world instances should be used
  61817. * @returns if the depth renderer is ready to render the depth map
  61818. */
  61819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61820. /**
  61821. * Gets the texture which the depth map will be written to.
  61822. * @returns The depth map texture
  61823. */
  61824. getDepthMap(): RenderTargetTexture;
  61825. /**
  61826. * Disposes of the depth renderer.
  61827. */
  61828. dispose(): void;
  61829. }
  61830. }
  61831. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61832. /** @hidden */
  61833. export var minmaxReduxPixelShader: {
  61834. name: string;
  61835. shader: string;
  61836. };
  61837. }
  61838. declare module "babylonjs/Misc/minMaxReducer" {
  61839. import { Nullable } from "babylonjs/types";
  61840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61841. import { Camera } from "babylonjs/Cameras/camera";
  61842. import { Observer } from "babylonjs/Misc/observable";
  61843. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61844. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61845. import { Observable } from "babylonjs/Misc/observable";
  61846. import "babylonjs/Shaders/minmaxRedux.fragment";
  61847. /**
  61848. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61849. * and maximum values from all values of the texture.
  61850. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61851. * The source values are read from the red channel of the texture.
  61852. */
  61853. export class MinMaxReducer {
  61854. /**
  61855. * Observable triggered when the computation has been performed
  61856. */
  61857. onAfterReductionPerformed: Observable<{
  61858. min: number;
  61859. max: number;
  61860. }>;
  61861. protected _camera: Camera;
  61862. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61863. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61864. protected _postProcessManager: PostProcessManager;
  61865. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61866. protected _forceFullscreenViewport: boolean;
  61867. /**
  61868. * Creates a min/max reducer
  61869. * @param camera The camera to use for the post processes
  61870. */
  61871. constructor(camera: Camera);
  61872. /**
  61873. * Gets the texture used to read the values from.
  61874. */
  61875. get sourceTexture(): Nullable<RenderTargetTexture>;
  61876. /**
  61877. * Sets the source texture to read the values from.
  61878. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61879. * because in such textures '1' value must not be taken into account to compute the maximum
  61880. * as this value is used to clear the texture.
  61881. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61882. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61883. * @param depthRedux Indicates if the texture is a depth texture or not
  61884. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61885. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61886. */
  61887. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61888. /**
  61889. * Defines the refresh rate of the computation.
  61890. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61891. */
  61892. get refreshRate(): number;
  61893. set refreshRate(value: number);
  61894. protected _activated: boolean;
  61895. /**
  61896. * Gets the activation status of the reducer
  61897. */
  61898. get activated(): boolean;
  61899. /**
  61900. * Activates the reduction computation.
  61901. * When activated, the observers registered in onAfterReductionPerformed are
  61902. * called after the compuation is performed
  61903. */
  61904. activate(): void;
  61905. /**
  61906. * Deactivates the reduction computation.
  61907. */
  61908. deactivate(): void;
  61909. /**
  61910. * Disposes the min/max reducer
  61911. * @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.
  61912. */
  61913. dispose(disposeAll?: boolean): void;
  61914. }
  61915. }
  61916. declare module "babylonjs/Misc/depthReducer" {
  61917. import { Nullable } from "babylonjs/types";
  61918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61919. import { Camera } from "babylonjs/Cameras/camera";
  61920. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61921. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61922. /**
  61923. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61924. */
  61925. export class DepthReducer extends MinMaxReducer {
  61926. private _depthRenderer;
  61927. private _depthRendererId;
  61928. /**
  61929. * Gets the depth renderer used for the computation.
  61930. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61931. */
  61932. get depthRenderer(): Nullable<DepthRenderer>;
  61933. /**
  61934. * Creates a depth reducer
  61935. * @param camera The camera used to render the depth texture
  61936. */
  61937. constructor(camera: Camera);
  61938. /**
  61939. * Sets the depth renderer to use to generate the depth map
  61940. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61941. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61942. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61943. */
  61944. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61945. /** @hidden */
  61946. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61947. /**
  61948. * Activates the reduction computation.
  61949. * When activated, the observers registered in onAfterReductionPerformed are
  61950. * called after the compuation is performed
  61951. */
  61952. activate(): void;
  61953. /**
  61954. * Deactivates the reduction computation.
  61955. */
  61956. deactivate(): void;
  61957. /**
  61958. * Disposes the depth reducer
  61959. * @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.
  61960. */
  61961. dispose(disposeAll?: boolean): void;
  61962. }
  61963. }
  61964. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61965. import { Nullable } from "babylonjs/types";
  61966. import { Scene } from "babylonjs/scene";
  61967. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61968. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61970. import { Effect } from "babylonjs/Materials/effect";
  61971. import "babylonjs/Shaders/shadowMap.fragment";
  61972. import "babylonjs/Shaders/shadowMap.vertex";
  61973. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61974. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61975. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61976. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61977. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61978. /**
  61979. * A CSM implementation allowing casting shadows on large scenes.
  61980. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61981. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61982. */
  61983. export class CascadedShadowGenerator extends ShadowGenerator {
  61984. private static readonly frustumCornersNDCSpace;
  61985. /**
  61986. * Name of the CSM class
  61987. */
  61988. static CLASSNAME: string;
  61989. /**
  61990. * Defines the default number of cascades used by the CSM.
  61991. */
  61992. static readonly DEFAULT_CASCADES_COUNT: number;
  61993. /**
  61994. * Defines the minimum number of cascades used by the CSM.
  61995. */
  61996. static readonly MIN_CASCADES_COUNT: number;
  61997. /**
  61998. * Defines the maximum number of cascades used by the CSM.
  61999. */
  62000. static readonly MAX_CASCADES_COUNT: number;
  62001. protected _validateFilter(filter: number): number;
  62002. /**
  62003. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62004. */
  62005. penumbraDarkness: number;
  62006. private _numCascades;
  62007. /**
  62008. * Gets or set the number of cascades used by the CSM.
  62009. */
  62010. get numCascades(): number;
  62011. set numCascades(value: number);
  62012. /**
  62013. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62014. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62015. */
  62016. stabilizeCascades: boolean;
  62017. private _freezeShadowCastersBoundingInfo;
  62018. private _freezeShadowCastersBoundingInfoObservable;
  62019. /**
  62020. * Enables or disables the shadow casters bounding info computation.
  62021. * If your shadow casters don't move, you can disable this feature.
  62022. * If it is enabled, the bounding box computation is done every frame.
  62023. */
  62024. get freezeShadowCastersBoundingInfo(): boolean;
  62025. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62026. private _scbiMin;
  62027. private _scbiMax;
  62028. protected _computeShadowCastersBoundingInfo(): void;
  62029. protected _shadowCastersBoundingInfo: BoundingInfo;
  62030. /**
  62031. * Gets or sets the shadow casters bounding info.
  62032. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62033. * so that the system won't overwrite the bounds you provide
  62034. */
  62035. get shadowCastersBoundingInfo(): BoundingInfo;
  62036. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62037. protected _breaksAreDirty: boolean;
  62038. protected _minDistance: number;
  62039. protected _maxDistance: number;
  62040. /**
  62041. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62042. *
  62043. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62044. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62045. * @param min minimal distance for the breaks (default to 0.)
  62046. * @param max maximal distance for the breaks (default to 1.)
  62047. */
  62048. setMinMaxDistance(min: number, max: number): void;
  62049. /** Gets the minimal distance used in the cascade break computation */
  62050. get minDistance(): number;
  62051. /** Gets the maximal distance used in the cascade break computation */
  62052. get maxDistance(): number;
  62053. /**
  62054. * Gets the class name of that object
  62055. * @returns "CascadedShadowGenerator"
  62056. */
  62057. getClassName(): string;
  62058. private _cascadeMinExtents;
  62059. private _cascadeMaxExtents;
  62060. /**
  62061. * Gets a cascade minimum extents
  62062. * @param cascadeIndex index of the cascade
  62063. * @returns the minimum cascade extents
  62064. */
  62065. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62066. /**
  62067. * Gets a cascade maximum extents
  62068. * @param cascadeIndex index of the cascade
  62069. * @returns the maximum cascade extents
  62070. */
  62071. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62072. private _cascades;
  62073. private _currentLayer;
  62074. private _viewSpaceFrustumsZ;
  62075. private _viewMatrices;
  62076. private _projectionMatrices;
  62077. private _transformMatrices;
  62078. private _transformMatricesAsArray;
  62079. private _frustumLengths;
  62080. private _lightSizeUVCorrection;
  62081. private _depthCorrection;
  62082. private _frustumCornersWorldSpace;
  62083. private _frustumCenter;
  62084. private _shadowCameraPos;
  62085. private _shadowMaxZ;
  62086. /**
  62087. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62088. * It defaults to camera.maxZ
  62089. */
  62090. get shadowMaxZ(): number;
  62091. /**
  62092. * Sets the shadow max z distance.
  62093. */
  62094. set shadowMaxZ(value: number);
  62095. protected _debug: boolean;
  62096. /**
  62097. * Gets or sets the debug flag.
  62098. * When enabled, the cascades are materialized by different colors on the screen.
  62099. */
  62100. get debug(): boolean;
  62101. set debug(dbg: boolean);
  62102. private _depthClamp;
  62103. /**
  62104. * Gets or sets the depth clamping value.
  62105. *
  62106. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62107. * to account for the shadow casters far away.
  62108. *
  62109. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62110. */
  62111. get depthClamp(): boolean;
  62112. set depthClamp(value: boolean);
  62113. private _cascadeBlendPercentage;
  62114. /**
  62115. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62116. * It defaults to 0.1 (10% blending).
  62117. */
  62118. get cascadeBlendPercentage(): number;
  62119. set cascadeBlendPercentage(value: number);
  62120. private _lambda;
  62121. /**
  62122. * Gets or set the lambda parameter.
  62123. * This parameter is used to split the camera frustum and create the cascades.
  62124. * 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.
  62125. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62126. */
  62127. get lambda(): number;
  62128. set lambda(value: number);
  62129. /**
  62130. * Gets the view matrix corresponding to a given cascade
  62131. * @param cascadeNum cascade to retrieve the view matrix from
  62132. * @returns the cascade view matrix
  62133. */
  62134. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62135. /**
  62136. * Gets the projection matrix corresponding to a given cascade
  62137. * @param cascadeNum cascade to retrieve the projection matrix from
  62138. * @returns the cascade projection matrix
  62139. */
  62140. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62141. /**
  62142. * Gets the transformation matrix corresponding to a given cascade
  62143. * @param cascadeNum cascade to retrieve the transformation matrix from
  62144. * @returns the cascade transformation matrix
  62145. */
  62146. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62147. private _depthRenderer;
  62148. /**
  62149. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62150. *
  62151. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62152. *
  62153. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62154. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62155. * @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
  62156. */
  62157. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62158. private _depthReducer;
  62159. private _autoCalcDepthBounds;
  62160. /**
  62161. * Gets or sets the autoCalcDepthBounds property.
  62162. *
  62163. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62164. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62165. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62166. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62167. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62168. */
  62169. get autoCalcDepthBounds(): boolean;
  62170. set autoCalcDepthBounds(value: boolean);
  62171. /**
  62172. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62173. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62174. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62175. * for setting the refresh rate on the renderer yourself!
  62176. */
  62177. get autoCalcDepthBoundsRefreshRate(): number;
  62178. set autoCalcDepthBoundsRefreshRate(value: number);
  62179. /**
  62180. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62181. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62182. * you change the camera near/far planes!
  62183. */
  62184. splitFrustum(): void;
  62185. private _splitFrustum;
  62186. private _computeMatrices;
  62187. private _computeFrustumInWorldSpace;
  62188. private _computeCascadeFrustum;
  62189. /**
  62190. * Support test.
  62191. */
  62192. static get IsSupported(): boolean;
  62193. /** @hidden */
  62194. static _SceneComponentInitialization: (scene: Scene) => void;
  62195. /**
  62196. * Creates a Cascaded Shadow Generator object.
  62197. * A ShadowGenerator is the required tool to use the shadows.
  62198. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62199. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62200. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62201. * @param light The directional light object generating the shadows.
  62202. * @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.
  62203. */
  62204. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62205. protected _initializeGenerator(): void;
  62206. protected _createTargetRenderTexture(): void;
  62207. protected _initializeShadowMap(): void;
  62208. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62209. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62210. /**
  62211. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62212. * @param defines Defines of the material we want to update
  62213. * @param lightIndex Index of the light in the enabled light list of the material
  62214. */
  62215. prepareDefines(defines: any, lightIndex: number): void;
  62216. /**
  62217. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62218. * defined in the generator but impacting the effect).
  62219. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62220. * @param effect The effect we are binfing the information for
  62221. */
  62222. bindShadowLight(lightIndex: string, effect: Effect): void;
  62223. /**
  62224. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62225. * (eq to view projection * shadow projection matrices)
  62226. * @returns The transform matrix used to create the shadow map
  62227. */
  62228. getTransformMatrix(): Matrix;
  62229. /**
  62230. * Disposes the ShadowGenerator.
  62231. * Returns nothing.
  62232. */
  62233. dispose(): void;
  62234. /**
  62235. * Serializes the shadow generator setup to a json object.
  62236. * @returns The serialized JSON object
  62237. */
  62238. serialize(): any;
  62239. /**
  62240. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62241. * @param parsedShadowGenerator The JSON object to parse
  62242. * @param scene The scene to create the shadow map for
  62243. * @returns The parsed shadow generator
  62244. */
  62245. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62246. }
  62247. }
  62248. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62249. import { Scene } from "babylonjs/scene";
  62250. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62251. import { AbstractScene } from "babylonjs/abstractScene";
  62252. /**
  62253. * Defines the shadow generator component responsible to manage any shadow generators
  62254. * in a given scene.
  62255. */
  62256. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62257. /**
  62258. * The component name helpfull to identify the component in the list of scene components.
  62259. */
  62260. readonly name: string;
  62261. /**
  62262. * The scene the component belongs to.
  62263. */
  62264. scene: Scene;
  62265. /**
  62266. * Creates a new instance of the component for the given scene
  62267. * @param scene Defines the scene to register the component in
  62268. */
  62269. constructor(scene: Scene);
  62270. /**
  62271. * Registers the component in a given scene
  62272. */
  62273. register(): void;
  62274. /**
  62275. * Rebuilds the elements related to this component in case of
  62276. * context lost for instance.
  62277. */
  62278. rebuild(): void;
  62279. /**
  62280. * Serializes the component data to the specified json object
  62281. * @param serializationObject The object to serialize to
  62282. */
  62283. serialize(serializationObject: any): void;
  62284. /**
  62285. * Adds all the elements from the container to the scene
  62286. * @param container the container holding the elements
  62287. */
  62288. addFromContainer(container: AbstractScene): void;
  62289. /**
  62290. * Removes all the elements in the container from the scene
  62291. * @param container contains the elements to remove
  62292. * @param dispose if the removed element should be disposed (default: false)
  62293. */
  62294. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62295. /**
  62296. * Rebuilds the elements related to this component in case of
  62297. * context lost for instance.
  62298. */
  62299. dispose(): void;
  62300. private _gatherRenderTargets;
  62301. }
  62302. }
  62303. declare module "babylonjs/Lights/Shadows/index" {
  62304. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62305. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62306. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62307. }
  62308. declare module "babylonjs/Lights/pointLight" {
  62309. import { Scene } from "babylonjs/scene";
  62310. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62312. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62313. import { Effect } from "babylonjs/Materials/effect";
  62314. /**
  62315. * A point light is a light defined by an unique point in world space.
  62316. * The light is emitted in every direction from this point.
  62317. * A good example of a point light is a standard light bulb.
  62318. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62319. */
  62320. export class PointLight extends ShadowLight {
  62321. private _shadowAngle;
  62322. /**
  62323. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62324. * This specifies what angle the shadow will use to be created.
  62325. *
  62326. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62327. */
  62328. get shadowAngle(): number;
  62329. /**
  62330. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62331. * This specifies what angle the shadow will use to be created.
  62332. *
  62333. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62334. */
  62335. set shadowAngle(value: number);
  62336. /**
  62337. * Gets the direction if it has been set.
  62338. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62339. */
  62340. get direction(): Vector3;
  62341. /**
  62342. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62343. */
  62344. set direction(value: Vector3);
  62345. /**
  62346. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62347. * A PointLight emits the light in every direction.
  62348. * It can cast shadows.
  62349. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62350. * ```javascript
  62351. * var pointLight = new PointLight("pl", camera.position, scene);
  62352. * ```
  62353. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62354. * @param name The light friendly name
  62355. * @param position The position of the point light in the scene
  62356. * @param scene The scene the lights belongs to
  62357. */
  62358. constructor(name: string, position: Vector3, scene: Scene);
  62359. /**
  62360. * Returns the string "PointLight"
  62361. * @returns the class name
  62362. */
  62363. getClassName(): string;
  62364. /**
  62365. * Returns the integer 0.
  62366. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62367. */
  62368. getTypeID(): number;
  62369. /**
  62370. * Specifies wether or not the shadowmap should be a cube texture.
  62371. * @returns true if the shadowmap needs to be a cube texture.
  62372. */
  62373. needCube(): boolean;
  62374. /**
  62375. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62376. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62377. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62378. */
  62379. getShadowDirection(faceIndex?: number): Vector3;
  62380. /**
  62381. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62382. * - fov = PI / 2
  62383. * - aspect ratio : 1.0
  62384. * - z-near and far equal to the active camera minZ and maxZ.
  62385. * Returns the PointLight.
  62386. */
  62387. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62388. protected _buildUniformLayout(): void;
  62389. /**
  62390. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62391. * @param effect The effect to update
  62392. * @param lightIndex The index of the light in the effect to update
  62393. * @returns The point light
  62394. */
  62395. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62396. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62397. /**
  62398. * Prepares the list of defines specific to the light type.
  62399. * @param defines the list of defines
  62400. * @param lightIndex defines the index of the light for the effect
  62401. */
  62402. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62403. }
  62404. }
  62405. declare module "babylonjs/Lights/index" {
  62406. export * from "babylonjs/Lights/light";
  62407. export * from "babylonjs/Lights/shadowLight";
  62408. export * from "babylonjs/Lights/Shadows/index";
  62409. export * from "babylonjs/Lights/directionalLight";
  62410. export * from "babylonjs/Lights/hemisphericLight";
  62411. export * from "babylonjs/Lights/pointLight";
  62412. export * from "babylonjs/Lights/spotLight";
  62413. }
  62414. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62415. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62416. /**
  62417. * Header information of HDR texture files.
  62418. */
  62419. export interface HDRInfo {
  62420. /**
  62421. * The height of the texture in pixels.
  62422. */
  62423. height: number;
  62424. /**
  62425. * The width of the texture in pixels.
  62426. */
  62427. width: number;
  62428. /**
  62429. * The index of the beginning of the data in the binary file.
  62430. */
  62431. dataPosition: number;
  62432. }
  62433. /**
  62434. * This groups tools to convert HDR texture to native colors array.
  62435. */
  62436. export class HDRTools {
  62437. private static Ldexp;
  62438. private static Rgbe2float;
  62439. private static readStringLine;
  62440. /**
  62441. * Reads header information from an RGBE texture stored in a native array.
  62442. * More information on this format are available here:
  62443. * https://en.wikipedia.org/wiki/RGBE_image_format
  62444. *
  62445. * @param uint8array The binary file stored in native array.
  62446. * @return The header information.
  62447. */
  62448. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62449. /**
  62450. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62451. * This RGBE texture needs to store the information as a panorama.
  62452. *
  62453. * More information on this format are available here:
  62454. * https://en.wikipedia.org/wiki/RGBE_image_format
  62455. *
  62456. * @param buffer The binary file stored in an array buffer.
  62457. * @param size The expected size of the extracted cubemap.
  62458. * @return The Cube Map information.
  62459. */
  62460. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62461. /**
  62462. * Returns the pixels data extracted from an RGBE texture.
  62463. * This pixels will be stored left to right up to down in the R G B order in one array.
  62464. *
  62465. * More information on this format are available here:
  62466. * https://en.wikipedia.org/wiki/RGBE_image_format
  62467. *
  62468. * @param uint8array The binary file stored in an array buffer.
  62469. * @param hdrInfo The header information of the file.
  62470. * @return The pixels data in RGB right to left up to down order.
  62471. */
  62472. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62473. private static RGBE_ReadPixels_RLE;
  62474. private static RGBE_ReadPixels_NOT_RLE;
  62475. }
  62476. }
  62477. declare module "babylonjs/Materials/effectRenderer" {
  62478. import { Nullable } from "babylonjs/types";
  62479. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62480. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62481. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62482. import { Viewport } from "babylonjs/Maths/math.viewport";
  62483. import { Observable } from "babylonjs/Misc/observable";
  62484. import { Effect } from "babylonjs/Materials/effect";
  62485. import "babylonjs/Shaders/postprocess.vertex";
  62486. /**
  62487. * Effect Render Options
  62488. */
  62489. export interface IEffectRendererOptions {
  62490. /**
  62491. * Defines the vertices positions.
  62492. */
  62493. positions?: number[];
  62494. /**
  62495. * Defines the indices.
  62496. */
  62497. indices?: number[];
  62498. }
  62499. /**
  62500. * Helper class to render one or more effects.
  62501. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62502. */
  62503. export class EffectRenderer {
  62504. private engine;
  62505. private static _DefaultOptions;
  62506. private _vertexBuffers;
  62507. private _indexBuffer;
  62508. private _fullscreenViewport;
  62509. /**
  62510. * Creates an effect renderer
  62511. * @param engine the engine to use for rendering
  62512. * @param options defines the options of the effect renderer
  62513. */
  62514. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62515. /**
  62516. * Sets the current viewport in normalized coordinates 0-1
  62517. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62518. */
  62519. setViewport(viewport?: Viewport): void;
  62520. /**
  62521. * Binds the embedded attributes buffer to the effect.
  62522. * @param effect Defines the effect to bind the attributes for
  62523. */
  62524. bindBuffers(effect: Effect): void;
  62525. /**
  62526. * Sets the current effect wrapper to use during draw.
  62527. * The effect needs to be ready before calling this api.
  62528. * This also sets the default full screen position attribute.
  62529. * @param effectWrapper Defines the effect to draw with
  62530. */
  62531. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62532. /**
  62533. * Restores engine states
  62534. */
  62535. restoreStates(): void;
  62536. /**
  62537. * Draws a full screen quad.
  62538. */
  62539. draw(): void;
  62540. private isRenderTargetTexture;
  62541. /**
  62542. * renders one or more effects to a specified texture
  62543. * @param effectWrapper the effect to renderer
  62544. * @param outputTexture texture to draw to, if null it will render to the screen.
  62545. */
  62546. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62547. /**
  62548. * Disposes of the effect renderer
  62549. */
  62550. dispose(): void;
  62551. }
  62552. /**
  62553. * Options to create an EffectWrapper
  62554. */
  62555. interface EffectWrapperCreationOptions {
  62556. /**
  62557. * Engine to use to create the effect
  62558. */
  62559. engine: ThinEngine;
  62560. /**
  62561. * Fragment shader for the effect
  62562. */
  62563. fragmentShader: string;
  62564. /**
  62565. * Use the shader store instead of direct source code
  62566. */
  62567. useShaderStore?: boolean;
  62568. /**
  62569. * Vertex shader for the effect
  62570. */
  62571. vertexShader?: string;
  62572. /**
  62573. * Attributes to use in the shader
  62574. */
  62575. attributeNames?: Array<string>;
  62576. /**
  62577. * Uniforms to use in the shader
  62578. */
  62579. uniformNames?: Array<string>;
  62580. /**
  62581. * Texture sampler names to use in the shader
  62582. */
  62583. samplerNames?: Array<string>;
  62584. /**
  62585. * Defines to use in the shader
  62586. */
  62587. defines?: Array<string>;
  62588. /**
  62589. * Callback when effect is compiled
  62590. */
  62591. onCompiled?: Nullable<(effect: Effect) => void>;
  62592. /**
  62593. * The friendly name of the effect displayed in Spector.
  62594. */
  62595. name?: string;
  62596. }
  62597. /**
  62598. * Wraps an effect to be used for rendering
  62599. */
  62600. export class EffectWrapper {
  62601. /**
  62602. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62603. */
  62604. onApplyObservable: Observable<{}>;
  62605. /**
  62606. * The underlying effect
  62607. */
  62608. effect: Effect;
  62609. /**
  62610. * Creates an effect to be renderer
  62611. * @param creationOptions options to create the effect
  62612. */
  62613. constructor(creationOptions: EffectWrapperCreationOptions);
  62614. /**
  62615. * Disposes of the effect wrapper
  62616. */
  62617. dispose(): void;
  62618. }
  62619. }
  62620. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62621. /** @hidden */
  62622. export var hdrFilteringVertexShader: {
  62623. name: string;
  62624. shader: string;
  62625. };
  62626. }
  62627. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62628. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62629. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62630. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62631. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62632. /** @hidden */
  62633. export var hdrFilteringPixelShader: {
  62634. name: string;
  62635. shader: string;
  62636. };
  62637. }
  62638. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62640. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62641. import { Nullable } from "babylonjs/types";
  62642. import "babylonjs/Shaders/hdrFiltering.vertex";
  62643. import "babylonjs/Shaders/hdrFiltering.fragment";
  62644. /**
  62645. * Options for texture filtering
  62646. */
  62647. interface IHDRFilteringOptions {
  62648. /**
  62649. * Scales pixel intensity for the input HDR map.
  62650. */
  62651. hdrScale?: number;
  62652. /**
  62653. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62654. */
  62655. quality?: number;
  62656. }
  62657. /**
  62658. * Filters HDR maps to get correct renderings of PBR reflections
  62659. */
  62660. export class HDRFiltering {
  62661. private _engine;
  62662. private _effectRenderer;
  62663. private _effectWrapper;
  62664. private _lodGenerationOffset;
  62665. private _lodGenerationScale;
  62666. /**
  62667. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62668. * you care about baking speed.
  62669. */
  62670. quality: number;
  62671. /**
  62672. * Scales pixel intensity for the input HDR map.
  62673. */
  62674. hdrScale: number;
  62675. /**
  62676. * Instantiates HDR filter for reflection maps
  62677. *
  62678. * @param engine Thin engine
  62679. * @param options Options
  62680. */
  62681. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62682. private _createRenderTarget;
  62683. private _prefilterInternal;
  62684. private _createEffect;
  62685. /**
  62686. * Get a value indicating if the filter is ready to be used
  62687. * @param texture Texture to filter
  62688. * @returns true if the filter is ready
  62689. */
  62690. isReady(texture: BaseTexture): boolean;
  62691. /**
  62692. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62693. * Prefiltering will be invoked at the end of next rendering pass.
  62694. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62695. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62696. * @param texture Texture to filter
  62697. * @param onFinished Callback when filtering is done
  62698. * @return Promise called when prefiltering is done
  62699. */
  62700. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62701. }
  62702. }
  62703. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62704. import { Nullable } from "babylonjs/types";
  62705. import { Scene } from "babylonjs/scene";
  62706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62708. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62709. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62710. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62711. /**
  62712. * This represents a texture coming from an HDR input.
  62713. *
  62714. * The only supported format is currently panorama picture stored in RGBE format.
  62715. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62716. */
  62717. export class HDRCubeTexture extends BaseTexture {
  62718. private static _facesMapping;
  62719. private _generateHarmonics;
  62720. private _noMipmap;
  62721. private _prefilterOnLoad;
  62722. private _textureMatrix;
  62723. private _size;
  62724. private _onLoad;
  62725. private _onError;
  62726. /**
  62727. * The texture URL.
  62728. */
  62729. url: string;
  62730. /**
  62731. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62732. */
  62733. coordinatesMode: number;
  62734. protected _isBlocking: boolean;
  62735. /**
  62736. * Sets wether or not the texture is blocking during loading.
  62737. */
  62738. set isBlocking(value: boolean);
  62739. /**
  62740. * Gets wether or not the texture is blocking during loading.
  62741. */
  62742. get isBlocking(): boolean;
  62743. protected _rotationY: number;
  62744. /**
  62745. * Sets texture matrix rotation angle around Y axis in radians.
  62746. */
  62747. set rotationY(value: number);
  62748. /**
  62749. * Gets texture matrix rotation angle around Y axis radians.
  62750. */
  62751. get rotationY(): number;
  62752. /**
  62753. * Gets or sets the center of the bounding box associated with the cube texture
  62754. * It must define where the camera used to render the texture was set
  62755. */
  62756. boundingBoxPosition: Vector3;
  62757. private _boundingBoxSize;
  62758. /**
  62759. * Gets or sets the size of the bounding box associated with the cube texture
  62760. * When defined, the cubemap will switch to local mode
  62761. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62762. * @example https://www.babylonjs-playground.com/#RNASML
  62763. */
  62764. set boundingBoxSize(value: Vector3);
  62765. get boundingBoxSize(): Vector3;
  62766. /**
  62767. * Instantiates an HDRTexture from the following parameters.
  62768. *
  62769. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62770. * @param sceneOrEngine The scene or engine the texture will be used in
  62771. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62772. * @param noMipmap Forces to not generate the mipmap if true
  62773. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62774. * @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)
  62775. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62776. */
  62777. 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>);
  62778. /**
  62779. * Get the current class name of the texture useful for serialization or dynamic coding.
  62780. * @returns "HDRCubeTexture"
  62781. */
  62782. getClassName(): string;
  62783. /**
  62784. * Occurs when the file is raw .hdr file.
  62785. */
  62786. private loadTexture;
  62787. clone(): HDRCubeTexture;
  62788. delayLoad(): void;
  62789. /**
  62790. * Get the texture reflection matrix used to rotate/transform the reflection.
  62791. * @returns the reflection matrix
  62792. */
  62793. getReflectionTextureMatrix(): Matrix;
  62794. /**
  62795. * Set the texture reflection matrix used to rotate/transform the reflection.
  62796. * @param value Define the reflection matrix to set
  62797. */
  62798. setReflectionTextureMatrix(value: Matrix): void;
  62799. /**
  62800. * Parses a JSON representation of an HDR Texture in order to create the texture
  62801. * @param parsedTexture Define the JSON representation
  62802. * @param scene Define the scene the texture should be created in
  62803. * @param rootUrl Define the root url in case we need to load relative dependencies
  62804. * @returns the newly created texture after parsing
  62805. */
  62806. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62807. serialize(): any;
  62808. }
  62809. }
  62810. declare module "babylonjs/Physics/physicsEngine" {
  62811. import { Nullable } from "babylonjs/types";
  62812. import { Vector3 } from "babylonjs/Maths/math.vector";
  62813. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62814. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62815. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62817. /**
  62818. * Class used to control physics engine
  62819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62820. */
  62821. export class PhysicsEngine implements IPhysicsEngine {
  62822. private _physicsPlugin;
  62823. /**
  62824. * Global value used to control the smallest number supported by the simulation
  62825. */
  62826. static Epsilon: number;
  62827. private _impostors;
  62828. private _joints;
  62829. private _subTimeStep;
  62830. /**
  62831. * Gets the gravity vector used by the simulation
  62832. */
  62833. gravity: Vector3;
  62834. /**
  62835. * Factory used to create the default physics plugin.
  62836. * @returns The default physics plugin
  62837. */
  62838. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62839. /**
  62840. * Creates a new Physics Engine
  62841. * @param gravity defines the gravity vector used by the simulation
  62842. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62843. */
  62844. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62845. /**
  62846. * Sets the gravity vector used by the simulation
  62847. * @param gravity defines the gravity vector to use
  62848. */
  62849. setGravity(gravity: Vector3): void;
  62850. /**
  62851. * Set the time step of the physics engine.
  62852. * Default is 1/60.
  62853. * To slow it down, enter 1/600 for example.
  62854. * To speed it up, 1/30
  62855. * @param newTimeStep defines the new timestep to apply to this world.
  62856. */
  62857. setTimeStep(newTimeStep?: number): void;
  62858. /**
  62859. * Get the time step of the physics engine.
  62860. * @returns the current time step
  62861. */
  62862. getTimeStep(): number;
  62863. /**
  62864. * Set the sub time step of the physics engine.
  62865. * Default is 0 meaning there is no sub steps
  62866. * To increase physics resolution precision, set a small value (like 1 ms)
  62867. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62868. */
  62869. setSubTimeStep(subTimeStep?: number): void;
  62870. /**
  62871. * Get the sub time step of the physics engine.
  62872. * @returns the current sub time step
  62873. */
  62874. getSubTimeStep(): number;
  62875. /**
  62876. * Release all resources
  62877. */
  62878. dispose(): void;
  62879. /**
  62880. * Gets the name of the current physics plugin
  62881. * @returns the name of the plugin
  62882. */
  62883. getPhysicsPluginName(): string;
  62884. /**
  62885. * Adding a new impostor for the impostor tracking.
  62886. * This will be done by the impostor itself.
  62887. * @param impostor the impostor to add
  62888. */
  62889. addImpostor(impostor: PhysicsImpostor): void;
  62890. /**
  62891. * Remove an impostor from the engine.
  62892. * This impostor and its mesh will not longer be updated by the physics engine.
  62893. * @param impostor the impostor to remove
  62894. */
  62895. removeImpostor(impostor: PhysicsImpostor): void;
  62896. /**
  62897. * Add a joint to the physics engine
  62898. * @param mainImpostor defines the main impostor to which the joint is added.
  62899. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62900. * @param joint defines the joint that will connect both impostors.
  62901. */
  62902. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62903. /**
  62904. * Removes a joint from the simulation
  62905. * @param mainImpostor defines the impostor used with the joint
  62906. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62907. * @param joint defines the joint to remove
  62908. */
  62909. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62910. /**
  62911. * Called by the scene. No need to call it.
  62912. * @param delta defines the timespam between frames
  62913. */
  62914. _step(delta: number): void;
  62915. /**
  62916. * Gets the current plugin used to run the simulation
  62917. * @returns current plugin
  62918. */
  62919. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62920. /**
  62921. * Gets the list of physic impostors
  62922. * @returns an array of PhysicsImpostor
  62923. */
  62924. getImpostors(): Array<PhysicsImpostor>;
  62925. /**
  62926. * Gets the impostor for a physics enabled object
  62927. * @param object defines the object impersonated by the impostor
  62928. * @returns the PhysicsImpostor or null if not found
  62929. */
  62930. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62931. /**
  62932. * Gets the impostor for a physics body object
  62933. * @param body defines physics body used by the impostor
  62934. * @returns the PhysicsImpostor or null if not found
  62935. */
  62936. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62937. /**
  62938. * Does a raycast in the physics world
  62939. * @param from when should the ray start?
  62940. * @param to when should the ray end?
  62941. * @returns PhysicsRaycastResult
  62942. */
  62943. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62944. }
  62945. }
  62946. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62947. import { Nullable } from "babylonjs/types";
  62948. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62950. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62951. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62952. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62953. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62954. /** @hidden */
  62955. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62956. private _useDeltaForWorldStep;
  62957. world: any;
  62958. name: string;
  62959. private _physicsMaterials;
  62960. private _fixedTimeStep;
  62961. private _cannonRaycastResult;
  62962. private _raycastResult;
  62963. private _physicsBodysToRemoveAfterStep;
  62964. private _firstFrame;
  62965. BJSCANNON: any;
  62966. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62967. setGravity(gravity: Vector3): void;
  62968. setTimeStep(timeStep: number): void;
  62969. getTimeStep(): number;
  62970. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62971. private _removeMarkedPhysicsBodiesFromWorld;
  62972. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62973. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62974. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62975. private _processChildMeshes;
  62976. removePhysicsBody(impostor: PhysicsImpostor): void;
  62977. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62978. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62979. private _addMaterial;
  62980. private _checkWithEpsilon;
  62981. private _createShape;
  62982. private _createHeightmap;
  62983. private _minus90X;
  62984. private _plus90X;
  62985. private _tmpPosition;
  62986. private _tmpDeltaPosition;
  62987. private _tmpUnityRotation;
  62988. private _updatePhysicsBodyTransformation;
  62989. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62990. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62991. isSupported(): boolean;
  62992. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62993. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62994. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62995. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62996. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62997. getBodyMass(impostor: PhysicsImpostor): number;
  62998. getBodyFriction(impostor: PhysicsImpostor): number;
  62999. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63000. getBodyRestitution(impostor: PhysicsImpostor): number;
  63001. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63002. sleepBody(impostor: PhysicsImpostor): void;
  63003. wakeUpBody(impostor: PhysicsImpostor): void;
  63004. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63005. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63006. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63007. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63008. getRadius(impostor: PhysicsImpostor): number;
  63009. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63010. dispose(): void;
  63011. private _extendNamespace;
  63012. /**
  63013. * Does a raycast in the physics world
  63014. * @param from when should the ray start?
  63015. * @param to when should the ray end?
  63016. * @returns PhysicsRaycastResult
  63017. */
  63018. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63019. }
  63020. }
  63021. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63022. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63023. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63024. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63026. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63027. import { Nullable } from "babylonjs/types";
  63028. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63029. /** @hidden */
  63030. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63031. private _useDeltaForWorldStep;
  63032. world: any;
  63033. name: string;
  63034. BJSOIMO: any;
  63035. private _raycastResult;
  63036. private _fixedTimeStep;
  63037. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63038. setGravity(gravity: Vector3): void;
  63039. setTimeStep(timeStep: number): void;
  63040. getTimeStep(): number;
  63041. private _tmpImpostorsArray;
  63042. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63043. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63044. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63045. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63046. private _tmpPositionVector;
  63047. removePhysicsBody(impostor: PhysicsImpostor): void;
  63048. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63049. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63050. isSupported(): boolean;
  63051. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63052. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63053. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63054. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63055. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63056. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63057. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63058. getBodyMass(impostor: PhysicsImpostor): number;
  63059. getBodyFriction(impostor: PhysicsImpostor): number;
  63060. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63061. getBodyRestitution(impostor: PhysicsImpostor): number;
  63062. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63063. sleepBody(impostor: PhysicsImpostor): void;
  63064. wakeUpBody(impostor: PhysicsImpostor): void;
  63065. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63066. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63067. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63068. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63069. getRadius(impostor: PhysicsImpostor): number;
  63070. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63071. dispose(): void;
  63072. /**
  63073. * Does a raycast in the physics world
  63074. * @param from when should the ray start?
  63075. * @param to when should the ray end?
  63076. * @returns PhysicsRaycastResult
  63077. */
  63078. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63079. }
  63080. }
  63081. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63082. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63083. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63084. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63085. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63086. import { Nullable } from "babylonjs/types";
  63087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63088. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63089. /**
  63090. * AmmoJS Physics plugin
  63091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63092. * @see https://github.com/kripken/ammo.js/
  63093. */
  63094. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63095. private _useDeltaForWorldStep;
  63096. /**
  63097. * Reference to the Ammo library
  63098. */
  63099. bjsAMMO: any;
  63100. /**
  63101. * Created ammoJS world which physics bodies are added to
  63102. */
  63103. world: any;
  63104. /**
  63105. * Name of the plugin
  63106. */
  63107. name: string;
  63108. private _timeStep;
  63109. private _fixedTimeStep;
  63110. private _maxSteps;
  63111. private _tmpQuaternion;
  63112. private _tmpAmmoTransform;
  63113. private _tmpAmmoQuaternion;
  63114. private _tmpAmmoConcreteContactResultCallback;
  63115. private _collisionConfiguration;
  63116. private _dispatcher;
  63117. private _overlappingPairCache;
  63118. private _solver;
  63119. private _softBodySolver;
  63120. private _tmpAmmoVectorA;
  63121. private _tmpAmmoVectorB;
  63122. private _tmpAmmoVectorC;
  63123. private _tmpAmmoVectorD;
  63124. private _tmpContactCallbackResult;
  63125. private _tmpAmmoVectorRCA;
  63126. private _tmpAmmoVectorRCB;
  63127. private _raycastResult;
  63128. private static readonly DISABLE_COLLISION_FLAG;
  63129. private static readonly KINEMATIC_FLAG;
  63130. private static readonly DISABLE_DEACTIVATION_FLAG;
  63131. /**
  63132. * Initializes the ammoJS plugin
  63133. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63134. * @param ammoInjection can be used to inject your own ammo reference
  63135. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63136. */
  63137. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63138. /**
  63139. * Sets the gravity of the physics world (m/(s^2))
  63140. * @param gravity Gravity to set
  63141. */
  63142. setGravity(gravity: Vector3): void;
  63143. /**
  63144. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63145. * @param timeStep timestep to use in seconds
  63146. */
  63147. setTimeStep(timeStep: number): void;
  63148. /**
  63149. * 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)
  63150. * @param fixedTimeStep fixedTimeStep to use in seconds
  63151. */
  63152. setFixedTimeStep(fixedTimeStep: number): void;
  63153. /**
  63154. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63155. * @param maxSteps the maximum number of steps by the physics engine per frame
  63156. */
  63157. setMaxSteps(maxSteps: number): void;
  63158. /**
  63159. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63160. * @returns the current timestep in seconds
  63161. */
  63162. getTimeStep(): number;
  63163. /**
  63164. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63165. */
  63166. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63167. private _isImpostorInContact;
  63168. private _isImpostorPairInContact;
  63169. private _stepSimulation;
  63170. /**
  63171. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63172. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63173. * After the step the babylon meshes are set to the position of the physics imposters
  63174. * @param delta amount of time to step forward
  63175. * @param impostors array of imposters to update before/after the step
  63176. */
  63177. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63178. /**
  63179. * Update babylon mesh to match physics world object
  63180. * @param impostor imposter to match
  63181. */
  63182. private _afterSoftStep;
  63183. /**
  63184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63185. * @param impostor imposter to match
  63186. */
  63187. private _ropeStep;
  63188. /**
  63189. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63190. * @param impostor imposter to match
  63191. */
  63192. private _softbodyOrClothStep;
  63193. private _tmpMatrix;
  63194. /**
  63195. * Applies an impulse on the imposter
  63196. * @param impostor imposter to apply impulse to
  63197. * @param force amount of force to be applied to the imposter
  63198. * @param contactPoint the location to apply the impulse on the imposter
  63199. */
  63200. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63201. /**
  63202. * Applies a force on the imposter
  63203. * @param impostor imposter to apply force
  63204. * @param force amount of force to be applied to the imposter
  63205. * @param contactPoint the location to apply the force on the imposter
  63206. */
  63207. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63208. /**
  63209. * Creates a physics body using the plugin
  63210. * @param impostor the imposter to create the physics body on
  63211. */
  63212. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63213. /**
  63214. * Removes the physics body from the imposter and disposes of the body's memory
  63215. * @param impostor imposter to remove the physics body from
  63216. */
  63217. removePhysicsBody(impostor: PhysicsImpostor): void;
  63218. /**
  63219. * Generates a joint
  63220. * @param impostorJoint the imposter joint to create the joint with
  63221. */
  63222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63223. /**
  63224. * Removes a joint
  63225. * @param impostorJoint the imposter joint to remove the joint from
  63226. */
  63227. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63228. private _addMeshVerts;
  63229. /**
  63230. * Initialise the soft body vertices to match its object's (mesh) vertices
  63231. * Softbody vertices (nodes) are in world space and to match this
  63232. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63233. * @param impostor to create the softbody for
  63234. */
  63235. private _softVertexData;
  63236. /**
  63237. * Create an impostor's soft body
  63238. * @param impostor to create the softbody for
  63239. */
  63240. private _createSoftbody;
  63241. /**
  63242. * Create cloth for an impostor
  63243. * @param impostor to create the softbody for
  63244. */
  63245. private _createCloth;
  63246. /**
  63247. * Create rope for an impostor
  63248. * @param impostor to create the softbody for
  63249. */
  63250. private _createRope;
  63251. /**
  63252. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63253. * @param impostor to create the custom physics shape for
  63254. */
  63255. private _createCustom;
  63256. private _addHullVerts;
  63257. private _createShape;
  63258. /**
  63259. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63260. * @param impostor imposter containing the physics body and babylon object
  63261. */
  63262. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63263. /**
  63264. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63265. * @param impostor imposter containing the physics body and babylon object
  63266. * @param newPosition new position
  63267. * @param newRotation new rotation
  63268. */
  63269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63270. /**
  63271. * If this plugin is supported
  63272. * @returns true if its supported
  63273. */
  63274. isSupported(): boolean;
  63275. /**
  63276. * Sets the linear velocity of the physics body
  63277. * @param impostor imposter to set the velocity on
  63278. * @param velocity velocity to set
  63279. */
  63280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63281. /**
  63282. * Sets the angular velocity of the physics body
  63283. * @param impostor imposter to set the velocity on
  63284. * @param velocity velocity to set
  63285. */
  63286. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63287. /**
  63288. * gets the linear velocity
  63289. * @param impostor imposter to get linear velocity from
  63290. * @returns linear velocity
  63291. */
  63292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63293. /**
  63294. * gets the angular velocity
  63295. * @param impostor imposter to get angular velocity from
  63296. * @returns angular velocity
  63297. */
  63298. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63299. /**
  63300. * Sets the mass of physics body
  63301. * @param impostor imposter to set the mass on
  63302. * @param mass mass to set
  63303. */
  63304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63305. /**
  63306. * Gets the mass of the physics body
  63307. * @param impostor imposter to get the mass from
  63308. * @returns mass
  63309. */
  63310. getBodyMass(impostor: PhysicsImpostor): number;
  63311. /**
  63312. * Gets friction of the impostor
  63313. * @param impostor impostor to get friction from
  63314. * @returns friction value
  63315. */
  63316. getBodyFriction(impostor: PhysicsImpostor): number;
  63317. /**
  63318. * Sets friction of the impostor
  63319. * @param impostor impostor to set friction on
  63320. * @param friction friction value
  63321. */
  63322. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63323. /**
  63324. * Gets restitution of the impostor
  63325. * @param impostor impostor to get restitution from
  63326. * @returns restitution value
  63327. */
  63328. getBodyRestitution(impostor: PhysicsImpostor): number;
  63329. /**
  63330. * Sets resitution of the impostor
  63331. * @param impostor impostor to set resitution on
  63332. * @param restitution resitution value
  63333. */
  63334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63335. /**
  63336. * Gets pressure inside the impostor
  63337. * @param impostor impostor to get pressure from
  63338. * @returns pressure value
  63339. */
  63340. getBodyPressure(impostor: PhysicsImpostor): number;
  63341. /**
  63342. * Sets pressure inside a soft body impostor
  63343. * Cloth and rope must remain 0 pressure
  63344. * @param impostor impostor to set pressure on
  63345. * @param pressure pressure value
  63346. */
  63347. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63348. /**
  63349. * Gets stiffness of the impostor
  63350. * @param impostor impostor to get stiffness from
  63351. * @returns pressure value
  63352. */
  63353. getBodyStiffness(impostor: PhysicsImpostor): number;
  63354. /**
  63355. * Sets stiffness of the impostor
  63356. * @param impostor impostor to set stiffness on
  63357. * @param stiffness stiffness value from 0 to 1
  63358. */
  63359. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63360. /**
  63361. * Gets velocityIterations of the impostor
  63362. * @param impostor impostor to get velocity iterations from
  63363. * @returns velocityIterations value
  63364. */
  63365. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63366. /**
  63367. * Sets velocityIterations of the impostor
  63368. * @param impostor impostor to set velocity iterations on
  63369. * @param velocityIterations velocityIterations value
  63370. */
  63371. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63372. /**
  63373. * Gets positionIterations of the impostor
  63374. * @param impostor impostor to get position iterations from
  63375. * @returns positionIterations value
  63376. */
  63377. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63378. /**
  63379. * Sets positionIterations of the impostor
  63380. * @param impostor impostor to set position on
  63381. * @param positionIterations positionIterations value
  63382. */
  63383. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63384. /**
  63385. * Append an anchor to a cloth object
  63386. * @param impostor is the cloth impostor to add anchor to
  63387. * @param otherImpostor is the rigid impostor to anchor to
  63388. * @param width ratio across width from 0 to 1
  63389. * @param height ratio up height from 0 to 1
  63390. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63391. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63392. */
  63393. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63394. /**
  63395. * Append an hook to a rope object
  63396. * @param impostor is the rope impostor to add hook to
  63397. * @param otherImpostor is the rigid impostor to hook to
  63398. * @param length ratio along the rope from 0 to 1
  63399. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63400. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63401. */
  63402. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63403. /**
  63404. * Sleeps the physics body and stops it from being active
  63405. * @param impostor impostor to sleep
  63406. */
  63407. sleepBody(impostor: PhysicsImpostor): void;
  63408. /**
  63409. * Activates the physics body
  63410. * @param impostor impostor to activate
  63411. */
  63412. wakeUpBody(impostor: PhysicsImpostor): void;
  63413. /**
  63414. * Updates the distance parameters of the joint
  63415. * @param joint joint to update
  63416. * @param maxDistance maximum distance of the joint
  63417. * @param minDistance minimum distance of the joint
  63418. */
  63419. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63420. /**
  63421. * Sets a motor on the joint
  63422. * @param joint joint to set motor on
  63423. * @param speed speed of the motor
  63424. * @param maxForce maximum force of the motor
  63425. * @param motorIndex index of the motor
  63426. */
  63427. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63428. /**
  63429. * Sets the motors limit
  63430. * @param joint joint to set limit on
  63431. * @param upperLimit upper limit
  63432. * @param lowerLimit lower limit
  63433. */
  63434. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63435. /**
  63436. * Syncs the position and rotation of a mesh with the impostor
  63437. * @param mesh mesh to sync
  63438. * @param impostor impostor to update the mesh with
  63439. */
  63440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63441. /**
  63442. * Gets the radius of the impostor
  63443. * @param impostor impostor to get radius from
  63444. * @returns the radius
  63445. */
  63446. getRadius(impostor: PhysicsImpostor): number;
  63447. /**
  63448. * Gets the box size of the impostor
  63449. * @param impostor impostor to get box size from
  63450. * @param result the resulting box size
  63451. */
  63452. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63453. /**
  63454. * Disposes of the impostor
  63455. */
  63456. dispose(): void;
  63457. /**
  63458. * Does a raycast in the physics world
  63459. * @param from when should the ray start?
  63460. * @param to when should the ray end?
  63461. * @returns PhysicsRaycastResult
  63462. */
  63463. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63464. }
  63465. }
  63466. declare module "babylonjs/Probes/reflectionProbe" {
  63467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63468. import { Vector3 } from "babylonjs/Maths/math.vector";
  63469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63470. import { Nullable } from "babylonjs/types";
  63471. import { Scene } from "babylonjs/scene";
  63472. module "babylonjs/abstractScene" {
  63473. interface AbstractScene {
  63474. /**
  63475. * The list of reflection probes added to the scene
  63476. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63477. */
  63478. reflectionProbes: Array<ReflectionProbe>;
  63479. /**
  63480. * Removes the given reflection probe from this scene.
  63481. * @param toRemove The reflection probe to remove
  63482. * @returns The index of the removed reflection probe
  63483. */
  63484. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63485. /**
  63486. * Adds the given reflection probe to this scene.
  63487. * @param newReflectionProbe The reflection probe to add
  63488. */
  63489. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63490. }
  63491. }
  63492. /**
  63493. * Class used to generate realtime reflection / refraction cube textures
  63494. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63495. */
  63496. export class ReflectionProbe {
  63497. /** defines the name of the probe */
  63498. name: string;
  63499. private _scene;
  63500. private _renderTargetTexture;
  63501. private _projectionMatrix;
  63502. private _viewMatrix;
  63503. private _target;
  63504. private _add;
  63505. private _attachedMesh;
  63506. private _invertYAxis;
  63507. /** Gets or sets probe position (center of the cube map) */
  63508. position: Vector3;
  63509. /**
  63510. * Creates a new reflection probe
  63511. * @param name defines the name of the probe
  63512. * @param size defines the texture resolution (for each face)
  63513. * @param scene defines the hosting scene
  63514. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63515. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63516. */
  63517. constructor(
  63518. /** defines the name of the probe */
  63519. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63520. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63521. get samples(): number;
  63522. set samples(value: number);
  63523. /** Gets or sets the refresh rate to use (on every frame by default) */
  63524. get refreshRate(): number;
  63525. set refreshRate(value: number);
  63526. /**
  63527. * Gets the hosting scene
  63528. * @returns a Scene
  63529. */
  63530. getScene(): Scene;
  63531. /** Gets the internal CubeTexture used to render to */
  63532. get cubeTexture(): RenderTargetTexture;
  63533. /** Gets the list of meshes to render */
  63534. get renderList(): Nullable<AbstractMesh[]>;
  63535. /**
  63536. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63537. * @param mesh defines the mesh to attach to
  63538. */
  63539. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63540. /**
  63541. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63542. * @param renderingGroupId The rendering group id corresponding to its index
  63543. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63544. */
  63545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63546. /**
  63547. * Clean all associated resources
  63548. */
  63549. dispose(): void;
  63550. /**
  63551. * Converts the reflection probe information to a readable string for debug purpose.
  63552. * @param fullDetails Supports for multiple levels of logging within scene loading
  63553. * @returns the human readable reflection probe info
  63554. */
  63555. toString(fullDetails?: boolean): string;
  63556. /**
  63557. * Get the class name of the relfection probe.
  63558. * @returns "ReflectionProbe"
  63559. */
  63560. getClassName(): string;
  63561. /**
  63562. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63563. * @returns The JSON representation of the texture
  63564. */
  63565. serialize(): any;
  63566. /**
  63567. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63568. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63569. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63570. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63571. * @returns The parsed reflection probe if successful
  63572. */
  63573. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63574. }
  63575. }
  63576. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63577. /** @hidden */
  63578. export var _BabylonLoaderRegistered: boolean;
  63579. /**
  63580. * Helps setting up some configuration for the babylon file loader.
  63581. */
  63582. export class BabylonFileLoaderConfiguration {
  63583. /**
  63584. * The loader does not allow injecting custom physix engine into the plugins.
  63585. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63586. * So you could set this variable to your engine import to make it work.
  63587. */
  63588. static LoaderInjectedPhysicsEngine: any;
  63589. }
  63590. }
  63591. declare module "babylonjs/Loading/Plugins/index" {
  63592. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63593. }
  63594. declare module "babylonjs/Loading/index" {
  63595. export * from "babylonjs/Loading/loadingScreen";
  63596. export * from "babylonjs/Loading/Plugins/index";
  63597. export * from "babylonjs/Loading/sceneLoader";
  63598. export * from "babylonjs/Loading/sceneLoaderFlags";
  63599. }
  63600. declare module "babylonjs/Materials/Background/index" {
  63601. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63602. }
  63603. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63604. import { Scene } from "babylonjs/scene";
  63605. import { Color3 } from "babylonjs/Maths/math.color";
  63606. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63608. /**
  63609. * The Physically based simple base material of BJS.
  63610. *
  63611. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63612. * It is used as the base class for both the specGloss and metalRough conventions.
  63613. */
  63614. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63615. /**
  63616. * Number of Simultaneous lights allowed on the material.
  63617. */
  63618. maxSimultaneousLights: number;
  63619. /**
  63620. * If sets to true, disables all the lights affecting the material.
  63621. */
  63622. disableLighting: boolean;
  63623. /**
  63624. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63625. */
  63626. environmentTexture: BaseTexture;
  63627. /**
  63628. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63629. */
  63630. invertNormalMapX: boolean;
  63631. /**
  63632. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63633. */
  63634. invertNormalMapY: boolean;
  63635. /**
  63636. * Normal map used in the model.
  63637. */
  63638. normalTexture: BaseTexture;
  63639. /**
  63640. * Emissivie color used to self-illuminate the model.
  63641. */
  63642. emissiveColor: Color3;
  63643. /**
  63644. * Emissivie texture used to self-illuminate the model.
  63645. */
  63646. emissiveTexture: BaseTexture;
  63647. /**
  63648. * Occlusion Channel Strenght.
  63649. */
  63650. occlusionStrength: number;
  63651. /**
  63652. * Occlusion Texture of the material (adding extra occlusion effects).
  63653. */
  63654. occlusionTexture: BaseTexture;
  63655. /**
  63656. * Defines the alpha limits in alpha test mode.
  63657. */
  63658. alphaCutOff: number;
  63659. /**
  63660. * Gets the current double sided mode.
  63661. */
  63662. get doubleSided(): boolean;
  63663. /**
  63664. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63665. */
  63666. set doubleSided(value: boolean);
  63667. /**
  63668. * Stores the pre-calculated light information of a mesh in a texture.
  63669. */
  63670. lightmapTexture: BaseTexture;
  63671. /**
  63672. * If true, the light map contains occlusion information instead of lighting info.
  63673. */
  63674. useLightmapAsShadowmap: boolean;
  63675. /**
  63676. * Instantiates a new PBRMaterial instance.
  63677. *
  63678. * @param name The material name
  63679. * @param scene The scene the material will be use in.
  63680. */
  63681. constructor(name: string, scene: Scene);
  63682. getClassName(): string;
  63683. }
  63684. }
  63685. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63686. import { Scene } from "babylonjs/scene";
  63687. import { Color3 } from "babylonjs/Maths/math.color";
  63688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63689. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63690. /**
  63691. * The PBR material of BJS following the metal roughness convention.
  63692. *
  63693. * This fits to the PBR convention in the GLTF definition:
  63694. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63695. */
  63696. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63697. /**
  63698. * The base color has two different interpretations depending on the value of metalness.
  63699. * When the material is a metal, the base color is the specific measured reflectance value
  63700. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63701. * of the material.
  63702. */
  63703. baseColor: Color3;
  63704. /**
  63705. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63706. * well as opacity information in the alpha channel.
  63707. */
  63708. baseTexture: BaseTexture;
  63709. /**
  63710. * Specifies the metallic scalar value of the material.
  63711. * Can also be used to scale the metalness values of the metallic texture.
  63712. */
  63713. metallic: number;
  63714. /**
  63715. * Specifies the roughness scalar value of the material.
  63716. * Can also be used to scale the roughness values of the metallic texture.
  63717. */
  63718. roughness: number;
  63719. /**
  63720. * Texture containing both the metallic value in the B channel and the
  63721. * roughness value in the G channel to keep better precision.
  63722. */
  63723. metallicRoughnessTexture: BaseTexture;
  63724. /**
  63725. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63726. *
  63727. * @param name The material name
  63728. * @param scene The scene the material will be use in.
  63729. */
  63730. constructor(name: string, scene: Scene);
  63731. /**
  63732. * Return the currrent class name of the material.
  63733. */
  63734. getClassName(): string;
  63735. /**
  63736. * Makes a duplicate of the current material.
  63737. * @param name - name to use for the new material.
  63738. */
  63739. clone(name: string): PBRMetallicRoughnessMaterial;
  63740. /**
  63741. * Serialize the material to a parsable JSON object.
  63742. */
  63743. serialize(): any;
  63744. /**
  63745. * Parses a JSON object correponding to the serialize function.
  63746. */
  63747. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63748. }
  63749. }
  63750. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63751. import { Scene } from "babylonjs/scene";
  63752. import { Color3 } from "babylonjs/Maths/math.color";
  63753. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63754. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63755. /**
  63756. * The PBR material of BJS following the specular glossiness convention.
  63757. *
  63758. * This fits to the PBR convention in the GLTF definition:
  63759. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63760. */
  63761. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63762. /**
  63763. * Specifies the diffuse color of the material.
  63764. */
  63765. diffuseColor: Color3;
  63766. /**
  63767. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63768. * channel.
  63769. */
  63770. diffuseTexture: BaseTexture;
  63771. /**
  63772. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63773. */
  63774. specularColor: Color3;
  63775. /**
  63776. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63777. */
  63778. glossiness: number;
  63779. /**
  63780. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63781. */
  63782. specularGlossinessTexture: BaseTexture;
  63783. /**
  63784. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63785. *
  63786. * @param name The material name
  63787. * @param scene The scene the material will be use in.
  63788. */
  63789. constructor(name: string, scene: Scene);
  63790. /**
  63791. * Return the currrent class name of the material.
  63792. */
  63793. getClassName(): string;
  63794. /**
  63795. * Makes a duplicate of the current material.
  63796. * @param name - name to use for the new material.
  63797. */
  63798. clone(name: string): PBRSpecularGlossinessMaterial;
  63799. /**
  63800. * Serialize the material to a parsable JSON object.
  63801. */
  63802. serialize(): any;
  63803. /**
  63804. * Parses a JSON object correponding to the serialize function.
  63805. */
  63806. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63807. }
  63808. }
  63809. declare module "babylonjs/Materials/PBR/index" {
  63810. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63811. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63812. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63813. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63814. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63815. }
  63816. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63817. import { Nullable } from "babylonjs/types";
  63818. import { Scene } from "babylonjs/scene";
  63819. import { Matrix } from "babylonjs/Maths/math.vector";
  63820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63821. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63822. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63823. /**
  63824. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63825. * It can help converting any input color in a desired output one. This can then be used to create effects
  63826. * from sepia, black and white to sixties or futuristic rendering...
  63827. *
  63828. * The only supported format is currently 3dl.
  63829. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63830. */
  63831. export class ColorGradingTexture extends BaseTexture {
  63832. /**
  63833. * The texture URL.
  63834. */
  63835. url: string;
  63836. /**
  63837. * Empty line regex stored for GC.
  63838. */
  63839. private static _noneEmptyLineRegex;
  63840. private _textureMatrix;
  63841. private _onLoad;
  63842. /**
  63843. * Instantiates a ColorGradingTexture from the following parameters.
  63844. *
  63845. * @param url The location of the color gradind data (currently only supporting 3dl)
  63846. * @param sceneOrEngine The scene or engine the texture will be used in
  63847. * @param onLoad defines a callback triggered when the texture has been loaded
  63848. */
  63849. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63850. /**
  63851. * Fires the onload event from the constructor if requested.
  63852. */
  63853. private _triggerOnLoad;
  63854. /**
  63855. * Returns the texture matrix used in most of the material.
  63856. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63857. */
  63858. getTextureMatrix(): Matrix;
  63859. /**
  63860. * Occurs when the file being loaded is a .3dl LUT file.
  63861. */
  63862. private load3dlTexture;
  63863. /**
  63864. * Starts the loading process of the texture.
  63865. */
  63866. private loadTexture;
  63867. /**
  63868. * Clones the color gradind texture.
  63869. */
  63870. clone(): ColorGradingTexture;
  63871. /**
  63872. * Called during delayed load for textures.
  63873. */
  63874. delayLoad(): void;
  63875. /**
  63876. * Parses a color grading texture serialized by Babylon.
  63877. * @param parsedTexture The texture information being parsedTexture
  63878. * @param scene The scene to load the texture in
  63879. * @param rootUrl The root url of the data assets to load
  63880. * @return A color gradind texture
  63881. */
  63882. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63883. /**
  63884. * Serializes the LUT texture to json format.
  63885. */
  63886. serialize(): any;
  63887. }
  63888. }
  63889. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63891. import { Scene } from "babylonjs/scene";
  63892. import { Nullable } from "babylonjs/types";
  63893. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63894. /**
  63895. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63896. */
  63897. export class EquiRectangularCubeTexture extends BaseTexture {
  63898. /** The six faces of the cube. */
  63899. private static _FacesMapping;
  63900. private _noMipmap;
  63901. private _onLoad;
  63902. private _onError;
  63903. /** The size of the cubemap. */
  63904. private _size;
  63905. /** The buffer of the image. */
  63906. private _buffer;
  63907. /** The width of the input image. */
  63908. private _width;
  63909. /** The height of the input image. */
  63910. private _height;
  63911. /** The URL to the image. */
  63912. url: string;
  63913. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63914. coordinatesMode: number;
  63915. /**
  63916. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63917. * @param url The location of the image
  63918. * @param scene The scene the texture will be used in
  63919. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63920. * @param noMipmap Forces to not generate the mipmap if true
  63921. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63922. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63923. * @param onLoad — defines a callback called when texture is loaded
  63924. * @param onError — defines a callback called if there is an error
  63925. */
  63926. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63927. /**
  63928. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63929. */
  63930. private loadImage;
  63931. /**
  63932. * Convert the image buffer into a cubemap and create a CubeTexture.
  63933. */
  63934. private loadTexture;
  63935. /**
  63936. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63937. * @param buffer The ArrayBuffer that should be converted.
  63938. * @returns The buffer as Float32Array.
  63939. */
  63940. private getFloat32ArrayFromArrayBuffer;
  63941. /**
  63942. * Get the current class name of the texture useful for serialization or dynamic coding.
  63943. * @returns "EquiRectangularCubeTexture"
  63944. */
  63945. getClassName(): string;
  63946. /**
  63947. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63948. * @returns A clone of the current EquiRectangularCubeTexture.
  63949. */
  63950. clone(): EquiRectangularCubeTexture;
  63951. }
  63952. }
  63953. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63954. import { Nullable } from "babylonjs/types";
  63955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63956. import { Matrix } from "babylonjs/Maths/math.vector";
  63957. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63958. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63959. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63960. import { Scene } from "babylonjs/scene";
  63961. /**
  63962. * Defines the options related to the creation of an HtmlElementTexture
  63963. */
  63964. export interface IHtmlElementTextureOptions {
  63965. /**
  63966. * Defines wether mip maps should be created or not.
  63967. */
  63968. generateMipMaps?: boolean;
  63969. /**
  63970. * Defines the sampling mode of the texture.
  63971. */
  63972. samplingMode?: number;
  63973. /**
  63974. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63975. */
  63976. engine: Nullable<ThinEngine>;
  63977. /**
  63978. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63979. */
  63980. scene: Nullable<Scene>;
  63981. }
  63982. /**
  63983. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63984. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63985. * is automatically managed.
  63986. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63987. * in your application.
  63988. *
  63989. * As the update is not automatic, you need to call them manually.
  63990. */
  63991. export class HtmlElementTexture extends BaseTexture {
  63992. /**
  63993. * The texture URL.
  63994. */
  63995. element: HTMLVideoElement | HTMLCanvasElement;
  63996. private static readonly DefaultOptions;
  63997. private _textureMatrix;
  63998. private _isVideo;
  63999. private _generateMipMaps;
  64000. private _samplingMode;
  64001. /**
  64002. * Instantiates a HtmlElementTexture from the following parameters.
  64003. *
  64004. * @param name Defines the name of the texture
  64005. * @param element Defines the video or canvas the texture is filled with
  64006. * @param options Defines the other none mandatory texture creation options
  64007. */
  64008. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64009. private _createInternalTexture;
  64010. /**
  64011. * Returns the texture matrix used in most of the material.
  64012. */
  64013. getTextureMatrix(): Matrix;
  64014. /**
  64015. * Updates the content of the texture.
  64016. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64017. */
  64018. update(invertY?: Nullable<boolean>): void;
  64019. }
  64020. }
  64021. declare module "babylonjs/Misc/tga" {
  64022. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64023. /**
  64024. * Based on jsTGALoader - Javascript loader for TGA file
  64025. * By Vincent Thibault
  64026. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64027. */
  64028. export class TGATools {
  64029. private static _TYPE_INDEXED;
  64030. private static _TYPE_RGB;
  64031. private static _TYPE_GREY;
  64032. private static _TYPE_RLE_INDEXED;
  64033. private static _TYPE_RLE_RGB;
  64034. private static _TYPE_RLE_GREY;
  64035. private static _ORIGIN_MASK;
  64036. private static _ORIGIN_SHIFT;
  64037. private static _ORIGIN_BL;
  64038. private static _ORIGIN_BR;
  64039. private static _ORIGIN_UL;
  64040. private static _ORIGIN_UR;
  64041. /**
  64042. * Gets the header of a TGA file
  64043. * @param data defines the TGA data
  64044. * @returns the header
  64045. */
  64046. static GetTGAHeader(data: Uint8Array): any;
  64047. /**
  64048. * Uploads TGA content to a Babylon Texture
  64049. * @hidden
  64050. */
  64051. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64052. /** @hidden */
  64053. 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;
  64054. /** @hidden */
  64055. 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;
  64056. /** @hidden */
  64057. 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;
  64058. /** @hidden */
  64059. 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;
  64060. /** @hidden */
  64061. 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;
  64062. /** @hidden */
  64063. 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;
  64064. }
  64065. }
  64066. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64067. import { Nullable } from "babylonjs/types";
  64068. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64069. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64070. /**
  64071. * Implementation of the TGA Texture Loader.
  64072. * @hidden
  64073. */
  64074. export class _TGATextureLoader implements IInternalTextureLoader {
  64075. /**
  64076. * Defines wether the loader supports cascade loading the different faces.
  64077. */
  64078. readonly supportCascades: boolean;
  64079. /**
  64080. * This returns if the loader support the current file information.
  64081. * @param extension defines the file extension of the file being loaded
  64082. * @returns true if the loader can load the specified file
  64083. */
  64084. canLoad(extension: string): boolean;
  64085. /**
  64086. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64087. * @param data contains the texture data
  64088. * @param texture defines the BabylonJS internal texture
  64089. * @param createPolynomials will be true if polynomials have been requested
  64090. * @param onLoad defines the callback to trigger once the texture is ready
  64091. * @param onError defines the callback to trigger in case of error
  64092. */
  64093. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64094. /**
  64095. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64096. * @param data contains the texture data
  64097. * @param texture defines the BabylonJS internal texture
  64098. * @param callback defines the method to call once ready to upload
  64099. */
  64100. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64101. }
  64102. }
  64103. declare module "babylonjs/Misc/basis" {
  64104. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64105. /**
  64106. * Info about the .basis files
  64107. */
  64108. class BasisFileInfo {
  64109. /**
  64110. * If the file has alpha
  64111. */
  64112. hasAlpha: boolean;
  64113. /**
  64114. * Info about each image of the basis file
  64115. */
  64116. images: Array<{
  64117. levels: Array<{
  64118. width: number;
  64119. height: number;
  64120. transcodedPixels: ArrayBufferView;
  64121. }>;
  64122. }>;
  64123. }
  64124. /**
  64125. * Result of transcoding a basis file
  64126. */
  64127. class TranscodeResult {
  64128. /**
  64129. * Info about the .basis file
  64130. */
  64131. fileInfo: BasisFileInfo;
  64132. /**
  64133. * Format to use when loading the file
  64134. */
  64135. format: number;
  64136. }
  64137. /**
  64138. * Configuration options for the Basis transcoder
  64139. */
  64140. export class BasisTranscodeConfiguration {
  64141. /**
  64142. * Supported compression formats used to determine the supported output format of the transcoder
  64143. */
  64144. supportedCompressionFormats?: {
  64145. /**
  64146. * etc1 compression format
  64147. */
  64148. etc1?: boolean;
  64149. /**
  64150. * s3tc compression format
  64151. */
  64152. s3tc?: boolean;
  64153. /**
  64154. * pvrtc compression format
  64155. */
  64156. pvrtc?: boolean;
  64157. /**
  64158. * etc2 compression format
  64159. */
  64160. etc2?: boolean;
  64161. };
  64162. /**
  64163. * If mipmap levels should be loaded for transcoded images (Default: true)
  64164. */
  64165. loadMipmapLevels?: boolean;
  64166. /**
  64167. * Index of a single image to load (Default: all images)
  64168. */
  64169. loadSingleImage?: number;
  64170. }
  64171. /**
  64172. * Used to load .Basis files
  64173. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64174. */
  64175. export class BasisTools {
  64176. private static _IgnoreSupportedFormats;
  64177. /**
  64178. * URL to use when loading the basis transcoder
  64179. */
  64180. static JSModuleURL: string;
  64181. /**
  64182. * URL to use when loading the wasm module for the transcoder
  64183. */
  64184. static WasmModuleURL: string;
  64185. /**
  64186. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64187. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64188. * @returns internal format corresponding to the Basis format
  64189. */
  64190. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64191. private static _WorkerPromise;
  64192. private static _Worker;
  64193. private static _actionId;
  64194. private static _CreateWorkerAsync;
  64195. /**
  64196. * Transcodes a loaded image file to compressed pixel data
  64197. * @param data image data to transcode
  64198. * @param config configuration options for the transcoding
  64199. * @returns a promise resulting in the transcoded image
  64200. */
  64201. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64202. /**
  64203. * Loads a texture from the transcode result
  64204. * @param texture texture load to
  64205. * @param transcodeResult the result of transcoding the basis file to load from
  64206. */
  64207. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64208. }
  64209. }
  64210. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64211. import { Nullable } from "babylonjs/types";
  64212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64213. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64214. /**
  64215. * Loader for .basis file format
  64216. */
  64217. export class _BasisTextureLoader implements IInternalTextureLoader {
  64218. /**
  64219. * Defines whether the loader supports cascade loading the different faces.
  64220. */
  64221. readonly supportCascades: boolean;
  64222. /**
  64223. * This returns if the loader support the current file information.
  64224. * @param extension defines the file extension of the file being loaded
  64225. * @returns true if the loader can load the specified file
  64226. */
  64227. canLoad(extension: string): boolean;
  64228. /**
  64229. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64230. * @param data contains the texture data
  64231. * @param texture defines the BabylonJS internal texture
  64232. * @param createPolynomials will be true if polynomials have been requested
  64233. * @param onLoad defines the callback to trigger once the texture is ready
  64234. * @param onError defines the callback to trigger in case of error
  64235. */
  64236. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64237. /**
  64238. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64239. * @param data contains the texture data
  64240. * @param texture defines the BabylonJS internal texture
  64241. * @param callback defines the method to call once ready to upload
  64242. */
  64243. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64244. }
  64245. }
  64246. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64247. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64248. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64249. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64250. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64251. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64252. }
  64253. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64254. import { Vector2 } from "babylonjs/Maths/math.vector";
  64255. /**
  64256. * Defines the basic options interface of a TexturePacker Frame
  64257. */
  64258. export interface ITexturePackerFrame {
  64259. /**
  64260. * The frame ID
  64261. */
  64262. id: number;
  64263. /**
  64264. * The frames Scale
  64265. */
  64266. scale: Vector2;
  64267. /**
  64268. * The Frames offset
  64269. */
  64270. offset: Vector2;
  64271. }
  64272. /**
  64273. * This is a support class for frame Data on texture packer sets.
  64274. */
  64275. export class TexturePackerFrame implements ITexturePackerFrame {
  64276. /**
  64277. * The frame ID
  64278. */
  64279. id: number;
  64280. /**
  64281. * The frames Scale
  64282. */
  64283. scale: Vector2;
  64284. /**
  64285. * The Frames offset
  64286. */
  64287. offset: Vector2;
  64288. /**
  64289. * Initializes a texture package frame.
  64290. * @param id The numerical frame identifier
  64291. * @param scale Scalar Vector2 for UV frame
  64292. * @param offset Vector2 for the frame position in UV units.
  64293. * @returns TexturePackerFrame
  64294. */
  64295. constructor(id: number, scale: Vector2, offset: Vector2);
  64296. }
  64297. }
  64298. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64300. import { Scene } from "babylonjs/scene";
  64301. import { Nullable } from "babylonjs/types";
  64302. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64303. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64304. /**
  64305. * Defines the basic options interface of a TexturePacker
  64306. */
  64307. export interface ITexturePackerOptions {
  64308. /**
  64309. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64310. */
  64311. map?: string[];
  64312. /**
  64313. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64314. */
  64315. uvsIn?: string;
  64316. /**
  64317. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64318. */
  64319. uvsOut?: string;
  64320. /**
  64321. * number representing the layout style. Defaults to LAYOUT_STRIP
  64322. */
  64323. layout?: number;
  64324. /**
  64325. * number of columns if using custom column count layout(2). This defaults to 4.
  64326. */
  64327. colnum?: number;
  64328. /**
  64329. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64330. */
  64331. updateInputMeshes?: boolean;
  64332. /**
  64333. * boolean flag to dispose all the source textures. Defaults to true.
  64334. */
  64335. disposeSources?: boolean;
  64336. /**
  64337. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64338. */
  64339. fillBlanks?: boolean;
  64340. /**
  64341. * string value representing the context fill style color. Defaults to 'black'.
  64342. */
  64343. customFillColor?: string;
  64344. /**
  64345. * Width and Height Value of each Frame in the TexturePacker Sets
  64346. */
  64347. frameSize?: number;
  64348. /**
  64349. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64350. */
  64351. paddingRatio?: number;
  64352. /**
  64353. * Number that declares the fill method for the padding gutter.
  64354. */
  64355. paddingMode?: number;
  64356. /**
  64357. * If in SUBUV_COLOR padding mode what color to use.
  64358. */
  64359. paddingColor?: Color3 | Color4;
  64360. }
  64361. /**
  64362. * Defines the basic interface of a TexturePacker JSON File
  64363. */
  64364. export interface ITexturePackerJSON {
  64365. /**
  64366. * The frame ID
  64367. */
  64368. name: string;
  64369. /**
  64370. * The base64 channel data
  64371. */
  64372. sets: any;
  64373. /**
  64374. * The options of the Packer
  64375. */
  64376. options: ITexturePackerOptions;
  64377. /**
  64378. * The frame data of the Packer
  64379. */
  64380. frames: Array<number>;
  64381. }
  64382. /**
  64383. * This is a support class that generates a series of packed texture sets.
  64384. * @see https://doc.babylonjs.com/babylon101/materials
  64385. */
  64386. export class TexturePacker {
  64387. /** Packer Layout Constant 0 */
  64388. static readonly LAYOUT_STRIP: number;
  64389. /** Packer Layout Constant 1 */
  64390. static readonly LAYOUT_POWER2: number;
  64391. /** Packer Layout Constant 2 */
  64392. static readonly LAYOUT_COLNUM: number;
  64393. /** Packer Layout Constant 0 */
  64394. static readonly SUBUV_WRAP: number;
  64395. /** Packer Layout Constant 1 */
  64396. static readonly SUBUV_EXTEND: number;
  64397. /** Packer Layout Constant 2 */
  64398. static readonly SUBUV_COLOR: number;
  64399. /** The Name of the Texture Package */
  64400. name: string;
  64401. /** The scene scope of the TexturePacker */
  64402. scene: Scene;
  64403. /** The Meshes to target */
  64404. meshes: AbstractMesh[];
  64405. /** Arguments passed with the Constructor */
  64406. options: ITexturePackerOptions;
  64407. /** The promise that is started upon initialization */
  64408. promise: Nullable<Promise<TexturePacker | string>>;
  64409. /** The Container object for the channel sets that are generated */
  64410. sets: object;
  64411. /** The Container array for the frames that are generated */
  64412. frames: TexturePackerFrame[];
  64413. /** The expected number of textures the system is parsing. */
  64414. private _expecting;
  64415. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64416. private _paddingValue;
  64417. /**
  64418. * Initializes a texture package series from an array of meshes or a single mesh.
  64419. * @param name The name of the package
  64420. * @param meshes The target meshes to compose the package from
  64421. * @param options The arguments that texture packer should follow while building.
  64422. * @param scene The scene which the textures are scoped to.
  64423. * @returns TexturePacker
  64424. */
  64425. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64426. /**
  64427. * Starts the package process
  64428. * @param resolve The promises resolution function
  64429. * @returns TexturePacker
  64430. */
  64431. private _createFrames;
  64432. /**
  64433. * Calculates the Size of the Channel Sets
  64434. * @returns Vector2
  64435. */
  64436. private _calculateSize;
  64437. /**
  64438. * Calculates the UV data for the frames.
  64439. * @param baseSize the base frameSize
  64440. * @param padding the base frame padding
  64441. * @param dtSize size of the Dynamic Texture for that channel
  64442. * @param dtUnits is 1/dtSize
  64443. * @param update flag to update the input meshes
  64444. */
  64445. private _calculateMeshUVFrames;
  64446. /**
  64447. * Calculates the frames Offset.
  64448. * @param index of the frame
  64449. * @returns Vector2
  64450. */
  64451. private _getFrameOffset;
  64452. /**
  64453. * Updates a Mesh to the frame data
  64454. * @param mesh that is the target
  64455. * @param frameID or the frame index
  64456. */
  64457. private _updateMeshUV;
  64458. /**
  64459. * Updates a Meshes materials to use the texture packer channels
  64460. * @param m is the mesh to target
  64461. * @param force all channels on the packer to be set.
  64462. */
  64463. private _updateTextureReferences;
  64464. /**
  64465. * Public method to set a Mesh to a frame
  64466. * @param m that is the target
  64467. * @param frameID or the frame index
  64468. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64469. */
  64470. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64471. /**
  64472. * Starts the async promise to compile the texture packer.
  64473. * @returns Promise<void>
  64474. */
  64475. processAsync(): Promise<void>;
  64476. /**
  64477. * Disposes all textures associated with this packer
  64478. */
  64479. dispose(): void;
  64480. /**
  64481. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64482. * @param imageType is the image type to use.
  64483. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64484. */
  64485. download(imageType?: string, quality?: number): void;
  64486. /**
  64487. * Public method to load a texturePacker JSON file.
  64488. * @param data of the JSON file in string format.
  64489. */
  64490. updateFromJSON(data: string): void;
  64491. }
  64492. }
  64493. declare module "babylonjs/Materials/Textures/Packer/index" {
  64494. export * from "babylonjs/Materials/Textures/Packer/packer";
  64495. export * from "babylonjs/Materials/Textures/Packer/frame";
  64496. }
  64497. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64498. import { Scene } from "babylonjs/scene";
  64499. import { Texture } from "babylonjs/Materials/Textures/texture";
  64500. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64501. /**
  64502. * 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.
  64503. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64504. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64505. */
  64506. export class CustomProceduralTexture extends ProceduralTexture {
  64507. private _animate;
  64508. private _time;
  64509. private _config;
  64510. private _texturePath;
  64511. /**
  64512. * Instantiates a new Custom Procedural Texture.
  64513. * 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.
  64514. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64515. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64516. * @param name Define the name of the texture
  64517. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64518. * @param size Define the size of the texture to create
  64519. * @param scene Define the scene the texture belongs to
  64520. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64521. * @param generateMipMaps Define if the texture should creates mip maps or not
  64522. */
  64523. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64524. private _loadJson;
  64525. /**
  64526. * Is the texture ready to be used ? (rendered at least once)
  64527. * @returns true if ready, otherwise, false.
  64528. */
  64529. isReady(): boolean;
  64530. /**
  64531. * Render the texture to its associated render target.
  64532. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64533. */
  64534. render(useCameraPostProcess?: boolean): void;
  64535. /**
  64536. * Update the list of dependant textures samplers in the shader.
  64537. */
  64538. updateTextures(): void;
  64539. /**
  64540. * Update the uniform values of the procedural texture in the shader.
  64541. */
  64542. updateShaderUniforms(): void;
  64543. /**
  64544. * Define if the texture animates or not.
  64545. */
  64546. get animate(): boolean;
  64547. set animate(value: boolean);
  64548. }
  64549. }
  64550. declare module "babylonjs/Shaders/noise.fragment" {
  64551. /** @hidden */
  64552. export var noisePixelShader: {
  64553. name: string;
  64554. shader: string;
  64555. };
  64556. }
  64557. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64558. import { Nullable } from "babylonjs/types";
  64559. import { Scene } from "babylonjs/scene";
  64560. import { Texture } from "babylonjs/Materials/Textures/texture";
  64561. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64562. import "babylonjs/Shaders/noise.fragment";
  64563. /**
  64564. * Class used to generate noise procedural textures
  64565. */
  64566. export class NoiseProceduralTexture extends ProceduralTexture {
  64567. private _time;
  64568. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64569. brightness: number;
  64570. /** Defines the number of octaves to process */
  64571. octaves: number;
  64572. /** Defines the level of persistence (0.8 by default) */
  64573. persistence: number;
  64574. /** Gets or sets animation speed factor (default is 1) */
  64575. animationSpeedFactor: number;
  64576. /**
  64577. * Creates a new NoiseProceduralTexture
  64578. * @param name defines the name fo the texture
  64579. * @param size defines the size of the texture (default is 256)
  64580. * @param scene defines the hosting scene
  64581. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64582. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64583. */
  64584. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64585. private _updateShaderUniforms;
  64586. protected _getDefines(): string;
  64587. /** Generate the current state of the procedural texture */
  64588. render(useCameraPostProcess?: boolean): void;
  64589. /**
  64590. * Serializes this noise procedural texture
  64591. * @returns a serialized noise procedural texture object
  64592. */
  64593. serialize(): any;
  64594. /**
  64595. * Clone the texture.
  64596. * @returns the cloned texture
  64597. */
  64598. clone(): NoiseProceduralTexture;
  64599. /**
  64600. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64601. * @param parsedTexture defines parsed texture data
  64602. * @param scene defines the current scene
  64603. * @param rootUrl defines the root URL containing noise procedural texture information
  64604. * @returns a parsed NoiseProceduralTexture
  64605. */
  64606. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64607. }
  64608. }
  64609. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64610. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64611. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64612. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64613. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64614. }
  64615. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64616. import { Nullable } from "babylonjs/types";
  64617. import { Scene } from "babylonjs/scene";
  64618. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64619. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64620. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64621. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64622. /**
  64623. * Raw cube texture where the raw buffers are passed in
  64624. */
  64625. export class RawCubeTexture extends CubeTexture {
  64626. /**
  64627. * Creates a cube texture where the raw buffers are passed in.
  64628. * @param scene defines the scene the texture is attached to
  64629. * @param data defines the array of data to use to create each face
  64630. * @param size defines the size of the textures
  64631. * @param format defines the format of the data
  64632. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64633. * @param generateMipMaps defines if the engine should generate the mip levels
  64634. * @param invertY defines if data must be stored with Y axis inverted
  64635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64636. * @param compression defines the compression used (null by default)
  64637. */
  64638. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64639. /**
  64640. * Updates the raw cube texture.
  64641. * @param data defines the data to store
  64642. * @param format defines the data format
  64643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64644. * @param invertY defines if data must be stored with Y axis inverted
  64645. * @param compression defines the compression used (null by default)
  64646. * @param level defines which level of the texture to update
  64647. */
  64648. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64649. /**
  64650. * Updates a raw cube texture with RGBD encoded data.
  64651. * @param data defines the array of data [mipmap][face] to use to create each face
  64652. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64655. * @returns a promsie that resolves when the operation is complete
  64656. */
  64657. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64658. /**
  64659. * Clones the raw cube texture.
  64660. * @return a new cube texture
  64661. */
  64662. clone(): CubeTexture;
  64663. /** @hidden */
  64664. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64665. }
  64666. }
  64667. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64668. import { Scene } from "babylonjs/scene";
  64669. import { Texture } from "babylonjs/Materials/Textures/texture";
  64670. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64671. /**
  64672. * Class used to store 2D array textures containing user data
  64673. */
  64674. export class RawTexture2DArray extends Texture {
  64675. /** Gets or sets the texture format to use */
  64676. format: number;
  64677. /**
  64678. * Create a new RawTexture2DArray
  64679. * @param data defines the data of the texture
  64680. * @param width defines the width of the texture
  64681. * @param height defines the height of the texture
  64682. * @param depth defines the number of layers of the texture
  64683. * @param format defines the texture format to use
  64684. * @param scene defines the hosting scene
  64685. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64686. * @param invertY defines if texture must be stored with Y axis inverted
  64687. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64688. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64689. */
  64690. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64691. /** Gets or sets the texture format to use */
  64692. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64693. /**
  64694. * Update the texture with new data
  64695. * @param data defines the data to store in the texture
  64696. */
  64697. update(data: ArrayBufferView): void;
  64698. }
  64699. }
  64700. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64701. import { Scene } from "babylonjs/scene";
  64702. import { Texture } from "babylonjs/Materials/Textures/texture";
  64703. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64704. /**
  64705. * Class used to store 3D textures containing user data
  64706. */
  64707. export class RawTexture3D extends Texture {
  64708. /** Gets or sets the texture format to use */
  64709. format: number;
  64710. /**
  64711. * Create a new RawTexture3D
  64712. * @param data defines the data of the texture
  64713. * @param width defines the width of the texture
  64714. * @param height defines the height of the texture
  64715. * @param depth defines the depth of the texture
  64716. * @param format defines the texture format to use
  64717. * @param scene defines the hosting scene
  64718. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64719. * @param invertY defines if texture must be stored with Y axis inverted
  64720. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64721. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64722. */
  64723. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64724. /** Gets or sets the texture format to use */
  64725. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64726. /**
  64727. * Update the texture with new data
  64728. * @param data defines the data to store in the texture
  64729. */
  64730. update(data: ArrayBufferView): void;
  64731. }
  64732. }
  64733. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64734. import { Scene } from "babylonjs/scene";
  64735. import { Plane } from "babylonjs/Maths/math.plane";
  64736. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64737. /**
  64738. * Creates a refraction texture used by refraction channel of the standard material.
  64739. * It is like a mirror but to see through a material.
  64740. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64741. */
  64742. export class RefractionTexture extends RenderTargetTexture {
  64743. /**
  64744. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64745. * 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.
  64746. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64747. */
  64748. refractionPlane: Plane;
  64749. /**
  64750. * Define how deep under the surface we should see.
  64751. */
  64752. depth: number;
  64753. /**
  64754. * Creates a refraction texture used by refraction channel of the standard material.
  64755. * It is like a mirror but to see through a material.
  64756. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64757. * @param name Define the texture name
  64758. * @param size Define the size of the underlying texture
  64759. * @param scene Define the scene the refraction belongs to
  64760. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64761. */
  64762. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64763. /**
  64764. * Clone the refraction texture.
  64765. * @returns the cloned texture
  64766. */
  64767. clone(): RefractionTexture;
  64768. /**
  64769. * Serialize the texture to a JSON representation you could use in Parse later on
  64770. * @returns the serialized JSON representation
  64771. */
  64772. serialize(): any;
  64773. }
  64774. }
  64775. declare module "babylonjs/Materials/Textures/index" {
  64776. export * from "babylonjs/Materials/Textures/baseTexture";
  64777. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64778. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64779. export * from "babylonjs/Materials/Textures/cubeTexture";
  64780. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64781. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64782. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64783. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64784. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64785. export * from "babylonjs/Materials/Textures/internalTexture";
  64786. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64787. export * from "babylonjs/Materials/Textures/Loaders/index";
  64788. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64789. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64790. export * from "babylonjs/Materials/Textures/Packer/index";
  64791. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64792. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64793. export * from "babylonjs/Materials/Textures/rawTexture";
  64794. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64795. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64796. export * from "babylonjs/Materials/Textures/refractionTexture";
  64797. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64798. export * from "babylonjs/Materials/Textures/texture";
  64799. export * from "babylonjs/Materials/Textures/videoTexture";
  64800. }
  64801. declare module "babylonjs/Materials/Node/Enums/index" {
  64802. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64803. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64804. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64805. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64806. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64807. }
  64808. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64812. import { Mesh } from "babylonjs/Meshes/mesh";
  64813. import { Effect } from "babylonjs/Materials/effect";
  64814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64816. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64817. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64818. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64819. /**
  64820. * Block used to add support for vertex skinning (bones)
  64821. */
  64822. export class BonesBlock extends NodeMaterialBlock {
  64823. /**
  64824. * Creates a new BonesBlock
  64825. * @param name defines the block name
  64826. */
  64827. constructor(name: string);
  64828. /**
  64829. * Initialize the block and prepare the context for build
  64830. * @param state defines the state that will be used for the build
  64831. */
  64832. initialize(state: NodeMaterialBuildState): void;
  64833. /**
  64834. * Gets the current class name
  64835. * @returns the class name
  64836. */
  64837. getClassName(): string;
  64838. /**
  64839. * Gets the matrix indices input component
  64840. */
  64841. get matricesIndices(): NodeMaterialConnectionPoint;
  64842. /**
  64843. * Gets the matrix weights input component
  64844. */
  64845. get matricesWeights(): NodeMaterialConnectionPoint;
  64846. /**
  64847. * Gets the extra matrix indices input component
  64848. */
  64849. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the extra matrix weights input component
  64852. */
  64853. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the world input component
  64856. */
  64857. get world(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the output component
  64860. */
  64861. get output(): NodeMaterialConnectionPoint;
  64862. autoConfigure(material: NodeMaterial): void;
  64863. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64866. protected _buildBlock(state: NodeMaterialBuildState): this;
  64867. }
  64868. }
  64869. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64874. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64876. /**
  64877. * Block used to add support for instances
  64878. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64879. */
  64880. export class InstancesBlock extends NodeMaterialBlock {
  64881. /**
  64882. * Creates a new InstancesBlock
  64883. * @param name defines the block name
  64884. */
  64885. constructor(name: string);
  64886. /**
  64887. * Gets the current class name
  64888. * @returns the class name
  64889. */
  64890. getClassName(): string;
  64891. /**
  64892. * Gets the first world row input component
  64893. */
  64894. get world0(): NodeMaterialConnectionPoint;
  64895. /**
  64896. * Gets the second world row input component
  64897. */
  64898. get world1(): NodeMaterialConnectionPoint;
  64899. /**
  64900. * Gets the third world row input component
  64901. */
  64902. get world2(): NodeMaterialConnectionPoint;
  64903. /**
  64904. * Gets the forth world row input component
  64905. */
  64906. get world3(): NodeMaterialConnectionPoint;
  64907. /**
  64908. * Gets the world input component
  64909. */
  64910. get world(): NodeMaterialConnectionPoint;
  64911. /**
  64912. * Gets the output component
  64913. */
  64914. get output(): NodeMaterialConnectionPoint;
  64915. /**
  64916. * Gets the isntanceID component
  64917. */
  64918. get instanceID(): NodeMaterialConnectionPoint;
  64919. autoConfigure(material: NodeMaterial): void;
  64920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64921. protected _buildBlock(state: NodeMaterialBuildState): this;
  64922. }
  64923. }
  64924. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64929. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64930. import { Effect } from "babylonjs/Materials/effect";
  64931. import { Mesh } from "babylonjs/Meshes/mesh";
  64932. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64933. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64934. /**
  64935. * Block used to add morph targets support to vertex shader
  64936. */
  64937. export class MorphTargetsBlock extends NodeMaterialBlock {
  64938. private _repeatableContentAnchor;
  64939. /**
  64940. * Create a new MorphTargetsBlock
  64941. * @param name defines the block name
  64942. */
  64943. constructor(name: string);
  64944. /**
  64945. * Gets the current class name
  64946. * @returns the class name
  64947. */
  64948. getClassName(): string;
  64949. /**
  64950. * Gets the position input component
  64951. */
  64952. get position(): NodeMaterialConnectionPoint;
  64953. /**
  64954. * Gets the normal input component
  64955. */
  64956. get normal(): NodeMaterialConnectionPoint;
  64957. /**
  64958. * Gets the tangent input component
  64959. */
  64960. get tangent(): NodeMaterialConnectionPoint;
  64961. /**
  64962. * Gets the tangent input component
  64963. */
  64964. get uv(): NodeMaterialConnectionPoint;
  64965. /**
  64966. * Gets the position output component
  64967. */
  64968. get positionOutput(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the normal output component
  64971. */
  64972. get normalOutput(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the tangent output component
  64975. */
  64976. get tangentOutput(): NodeMaterialConnectionPoint;
  64977. /**
  64978. * Gets the tangent output component
  64979. */
  64980. get uvOutput(): NodeMaterialConnectionPoint;
  64981. initialize(state: NodeMaterialBuildState): void;
  64982. autoConfigure(material: NodeMaterial): void;
  64983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64984. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64985. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64986. protected _buildBlock(state: NodeMaterialBuildState): this;
  64987. }
  64988. }
  64989. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64993. import { Nullable } from "babylonjs/types";
  64994. import { Scene } from "babylonjs/scene";
  64995. import { Effect } from "babylonjs/Materials/effect";
  64996. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64997. import { Mesh } from "babylonjs/Meshes/mesh";
  64998. import { Light } from "babylonjs/Lights/light";
  64999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65000. /**
  65001. * Block used to get data information from a light
  65002. */
  65003. export class LightInformationBlock extends NodeMaterialBlock {
  65004. private _lightDataUniformName;
  65005. private _lightColorUniformName;
  65006. private _lightTypeDefineName;
  65007. /**
  65008. * Gets or sets the light associated with this block
  65009. */
  65010. light: Nullable<Light>;
  65011. /**
  65012. * Creates a new LightInformationBlock
  65013. * @param name defines the block name
  65014. */
  65015. constructor(name: string);
  65016. /**
  65017. * Gets the current class name
  65018. * @returns the class name
  65019. */
  65020. getClassName(): string;
  65021. /**
  65022. * Gets the world position input component
  65023. */
  65024. get worldPosition(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the direction output component
  65027. */
  65028. get direction(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the direction output component
  65031. */
  65032. get color(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the direction output component
  65035. */
  65036. get intensity(): NodeMaterialConnectionPoint;
  65037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65039. protected _buildBlock(state: NodeMaterialBuildState): this;
  65040. serialize(): any;
  65041. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65042. }
  65043. }
  65044. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65045. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65046. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65047. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65048. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65049. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65050. }
  65051. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65056. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65057. import { Effect } from "babylonjs/Materials/effect";
  65058. import { Mesh } from "babylonjs/Meshes/mesh";
  65059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65060. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65061. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65062. /**
  65063. * Block used to add image processing support to fragment shader
  65064. */
  65065. export class ImageProcessingBlock extends NodeMaterialBlock {
  65066. /**
  65067. * Create a new ImageProcessingBlock
  65068. * @param name defines the block name
  65069. */
  65070. constructor(name: string);
  65071. /**
  65072. * Gets the current class name
  65073. * @returns the class name
  65074. */
  65075. getClassName(): string;
  65076. /**
  65077. * Gets the color input component
  65078. */
  65079. get color(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the output component
  65082. */
  65083. get output(): NodeMaterialConnectionPoint;
  65084. /**
  65085. * Initialize the block and prepare the context for build
  65086. * @param state defines the state that will be used for the build
  65087. */
  65088. initialize(state: NodeMaterialBuildState): void;
  65089. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65092. protected _buildBlock(state: NodeMaterialBuildState): this;
  65093. }
  65094. }
  65095. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65099. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65101. import { Effect } from "babylonjs/Materials/effect";
  65102. import { Mesh } from "babylonjs/Meshes/mesh";
  65103. import { Scene } from "babylonjs/scene";
  65104. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65105. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65106. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65107. /**
  65108. * Block used to pertub normals based on a normal map
  65109. */
  65110. export class PerturbNormalBlock extends NodeMaterialBlock {
  65111. private _tangentSpaceParameterName;
  65112. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65113. invertX: boolean;
  65114. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65115. invertY: boolean;
  65116. /**
  65117. * Create a new PerturbNormalBlock
  65118. * @param name defines the block name
  65119. */
  65120. constructor(name: string);
  65121. /**
  65122. * Gets the current class name
  65123. * @returns the class name
  65124. */
  65125. getClassName(): string;
  65126. /**
  65127. * Gets the world position input component
  65128. */
  65129. get worldPosition(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Gets the world normal input component
  65132. */
  65133. get worldNormal(): NodeMaterialConnectionPoint;
  65134. /**
  65135. * Gets the world tangent input component
  65136. */
  65137. get worldTangent(): NodeMaterialConnectionPoint;
  65138. /**
  65139. * Gets the uv input component
  65140. */
  65141. get uv(): NodeMaterialConnectionPoint;
  65142. /**
  65143. * Gets the normal map color input component
  65144. */
  65145. get normalMapColor(): NodeMaterialConnectionPoint;
  65146. /**
  65147. * Gets the strength input component
  65148. */
  65149. get strength(): NodeMaterialConnectionPoint;
  65150. /**
  65151. * Gets the output component
  65152. */
  65153. get output(): NodeMaterialConnectionPoint;
  65154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65155. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65156. autoConfigure(material: NodeMaterial): void;
  65157. protected _buildBlock(state: NodeMaterialBuildState): this;
  65158. protected _dumpPropertiesCode(): string;
  65159. serialize(): any;
  65160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65161. }
  65162. }
  65163. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65167. /**
  65168. * Block used to discard a pixel if a value is smaller than a cutoff
  65169. */
  65170. export class DiscardBlock extends NodeMaterialBlock {
  65171. /**
  65172. * Create a new DiscardBlock
  65173. * @param name defines the block name
  65174. */
  65175. constructor(name: string);
  65176. /**
  65177. * Gets the current class name
  65178. * @returns the class name
  65179. */
  65180. getClassName(): string;
  65181. /**
  65182. * Gets the color input component
  65183. */
  65184. get value(): NodeMaterialConnectionPoint;
  65185. /**
  65186. * Gets the cutoff input component
  65187. */
  65188. get cutoff(): NodeMaterialConnectionPoint;
  65189. protected _buildBlock(state: NodeMaterialBuildState): this;
  65190. }
  65191. }
  65192. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65196. /**
  65197. * Block used to test if the fragment shader is front facing
  65198. */
  65199. export class FrontFacingBlock extends NodeMaterialBlock {
  65200. /**
  65201. * Creates a new FrontFacingBlock
  65202. * @param name defines the block name
  65203. */
  65204. constructor(name: string);
  65205. /**
  65206. * Gets the current class name
  65207. * @returns the class name
  65208. */
  65209. getClassName(): string;
  65210. /**
  65211. * Gets the output component
  65212. */
  65213. get output(): NodeMaterialConnectionPoint;
  65214. protected _buildBlock(state: NodeMaterialBuildState): this;
  65215. }
  65216. }
  65217. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65219. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65221. /**
  65222. * Block used to get the derivative value on x and y of a given input
  65223. */
  65224. export class DerivativeBlock extends NodeMaterialBlock {
  65225. /**
  65226. * Create a new DerivativeBlock
  65227. * @param name defines the block name
  65228. */
  65229. constructor(name: string);
  65230. /**
  65231. * Gets the current class name
  65232. * @returns the class name
  65233. */
  65234. getClassName(): string;
  65235. /**
  65236. * Gets the input component
  65237. */
  65238. get input(): NodeMaterialConnectionPoint;
  65239. /**
  65240. * Gets the derivative output on x
  65241. */
  65242. get dx(): NodeMaterialConnectionPoint;
  65243. /**
  65244. * Gets the derivative output on y
  65245. */
  65246. get dy(): NodeMaterialConnectionPoint;
  65247. protected _buildBlock(state: NodeMaterialBuildState): this;
  65248. }
  65249. }
  65250. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65251. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65253. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65254. /**
  65255. * Block used to make gl_FragCoord available
  65256. */
  65257. export class FragCoordBlock extends NodeMaterialBlock {
  65258. /**
  65259. * Creates a new FragCoordBlock
  65260. * @param name defines the block name
  65261. */
  65262. constructor(name: string);
  65263. /**
  65264. * Gets the current class name
  65265. * @returns the class name
  65266. */
  65267. getClassName(): string;
  65268. /**
  65269. * Gets the xy component
  65270. */
  65271. get xy(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the xyz component
  65274. */
  65275. get xyz(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the xyzw component
  65278. */
  65279. get xyzw(): NodeMaterialConnectionPoint;
  65280. /**
  65281. * Gets the x component
  65282. */
  65283. get x(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the y component
  65286. */
  65287. get y(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the z component
  65290. */
  65291. get z(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the w component
  65294. */
  65295. get output(): NodeMaterialConnectionPoint;
  65296. protected writeOutputs(state: NodeMaterialBuildState): string;
  65297. protected _buildBlock(state: NodeMaterialBuildState): this;
  65298. }
  65299. }
  65300. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65304. import { Effect } from "babylonjs/Materials/effect";
  65305. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65306. import { Mesh } from "babylonjs/Meshes/mesh";
  65307. /**
  65308. * Block used to get the screen sizes
  65309. */
  65310. export class ScreenSizeBlock extends NodeMaterialBlock {
  65311. private _varName;
  65312. private _scene;
  65313. /**
  65314. * Creates a new ScreenSizeBlock
  65315. * @param name defines the block name
  65316. */
  65317. constructor(name: string);
  65318. /**
  65319. * Gets the current class name
  65320. * @returns the class name
  65321. */
  65322. getClassName(): string;
  65323. /**
  65324. * Gets the xy component
  65325. */
  65326. get xy(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the x component
  65329. */
  65330. get x(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the y component
  65333. */
  65334. get y(): NodeMaterialConnectionPoint;
  65335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65336. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65337. protected _buildBlock(state: NodeMaterialBuildState): this;
  65338. }
  65339. }
  65340. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65341. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65342. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65343. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65344. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65345. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65346. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65347. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65348. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65349. }
  65350. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65353. import { Mesh } from "babylonjs/Meshes/mesh";
  65354. import { Effect } from "babylonjs/Materials/effect";
  65355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65357. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65358. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65359. /**
  65360. * Block used to add support for scene fog
  65361. */
  65362. export class FogBlock extends NodeMaterialBlock {
  65363. private _fogDistanceName;
  65364. private _fogParameters;
  65365. /**
  65366. * Create a new FogBlock
  65367. * @param name defines the block name
  65368. */
  65369. constructor(name: string);
  65370. /**
  65371. * Gets the current class name
  65372. * @returns the class name
  65373. */
  65374. getClassName(): string;
  65375. /**
  65376. * Gets the world position input component
  65377. */
  65378. get worldPosition(): NodeMaterialConnectionPoint;
  65379. /**
  65380. * Gets the view input component
  65381. */
  65382. get view(): NodeMaterialConnectionPoint;
  65383. /**
  65384. * Gets the color input component
  65385. */
  65386. get input(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the fog color input component
  65389. */
  65390. get fogColor(): NodeMaterialConnectionPoint;
  65391. /**
  65392. * Gets the output component
  65393. */
  65394. get output(): NodeMaterialConnectionPoint;
  65395. autoConfigure(material: NodeMaterial): void;
  65396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65398. protected _buildBlock(state: NodeMaterialBuildState): this;
  65399. }
  65400. }
  65401. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65406. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65407. import { Effect } from "babylonjs/Materials/effect";
  65408. import { Mesh } from "babylonjs/Meshes/mesh";
  65409. import { Light } from "babylonjs/Lights/light";
  65410. import { Nullable } from "babylonjs/types";
  65411. import { Scene } from "babylonjs/scene";
  65412. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65413. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65414. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65415. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65416. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65417. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65418. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65419. /**
  65420. * Block used to add light in the fragment shader
  65421. */
  65422. export class LightBlock extends NodeMaterialBlock {
  65423. private _lightId;
  65424. /**
  65425. * Gets or sets the light associated with this block
  65426. */
  65427. light: Nullable<Light>;
  65428. /**
  65429. * Create a new LightBlock
  65430. * @param name defines the block name
  65431. */
  65432. constructor(name: string);
  65433. /**
  65434. * Gets the current class name
  65435. * @returns the class name
  65436. */
  65437. getClassName(): string;
  65438. /**
  65439. * Gets the world position input component
  65440. */
  65441. get worldPosition(): NodeMaterialConnectionPoint;
  65442. /**
  65443. * Gets the world normal input component
  65444. */
  65445. get worldNormal(): NodeMaterialConnectionPoint;
  65446. /**
  65447. * Gets the camera (or eye) position component
  65448. */
  65449. get cameraPosition(): NodeMaterialConnectionPoint;
  65450. /**
  65451. * Gets the glossiness component
  65452. */
  65453. get glossiness(): NodeMaterialConnectionPoint;
  65454. /**
  65455. * Gets the glossinness power component
  65456. */
  65457. get glossPower(): NodeMaterialConnectionPoint;
  65458. /**
  65459. * Gets the diffuse color component
  65460. */
  65461. get diffuseColor(): NodeMaterialConnectionPoint;
  65462. /**
  65463. * Gets the specular color component
  65464. */
  65465. get specularColor(): NodeMaterialConnectionPoint;
  65466. /**
  65467. * Gets the diffuse output component
  65468. */
  65469. get diffuseOutput(): NodeMaterialConnectionPoint;
  65470. /**
  65471. * Gets the specular output component
  65472. */
  65473. get specularOutput(): NodeMaterialConnectionPoint;
  65474. /**
  65475. * Gets the shadow output component
  65476. */
  65477. get shadow(): NodeMaterialConnectionPoint;
  65478. autoConfigure(material: NodeMaterial): void;
  65479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65480. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65482. private _injectVertexCode;
  65483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65484. serialize(): any;
  65485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65486. }
  65487. }
  65488. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65491. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65492. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65493. /**
  65494. * Block used to read a reflection texture from a sampler
  65495. */
  65496. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65497. /**
  65498. * Create a new ReflectionTextureBlock
  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 world position input component
  65509. */
  65510. get position(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the world position input component
  65513. */
  65514. get worldPosition(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the world normal input component
  65517. */
  65518. get worldNormal(): NodeMaterialConnectionPoint;
  65519. /**
  65520. * Gets the world input component
  65521. */
  65522. get world(): NodeMaterialConnectionPoint;
  65523. /**
  65524. * Gets the camera (or eye) position component
  65525. */
  65526. get cameraPosition(): NodeMaterialConnectionPoint;
  65527. /**
  65528. * Gets the view input component
  65529. */
  65530. get view(): NodeMaterialConnectionPoint;
  65531. /**
  65532. * Gets the rgb output component
  65533. */
  65534. get rgb(): NodeMaterialConnectionPoint;
  65535. /**
  65536. * Gets the rgba output component
  65537. */
  65538. get rgba(): NodeMaterialConnectionPoint;
  65539. /**
  65540. * Gets the r output component
  65541. */
  65542. get r(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the g output component
  65545. */
  65546. get g(): NodeMaterialConnectionPoint;
  65547. /**
  65548. * Gets the b output component
  65549. */
  65550. get b(): NodeMaterialConnectionPoint;
  65551. /**
  65552. * Gets the a output component
  65553. */
  65554. get a(): NodeMaterialConnectionPoint;
  65555. autoConfigure(material: NodeMaterial): void;
  65556. protected _buildBlock(state: NodeMaterialBuildState): this;
  65557. }
  65558. }
  65559. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65560. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65561. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65562. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65563. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65564. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65565. }
  65566. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65567. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65568. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65569. }
  65570. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65574. /**
  65575. * Block used to add 2 vectors
  65576. */
  65577. export class AddBlock extends NodeMaterialBlock {
  65578. /**
  65579. * Creates a new AddBlock
  65580. * @param name defines the block name
  65581. */
  65582. constructor(name: string);
  65583. /**
  65584. * Gets the current class name
  65585. * @returns the class name
  65586. */
  65587. getClassName(): string;
  65588. /**
  65589. * Gets the left operand input component
  65590. */
  65591. get left(): NodeMaterialConnectionPoint;
  65592. /**
  65593. * Gets the right operand input component
  65594. */
  65595. get right(): NodeMaterialConnectionPoint;
  65596. /**
  65597. * Gets the output component
  65598. */
  65599. get output(): NodeMaterialConnectionPoint;
  65600. protected _buildBlock(state: NodeMaterialBuildState): this;
  65601. }
  65602. }
  65603. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65607. /**
  65608. * Block used to scale a vector by a float
  65609. */
  65610. export class ScaleBlock extends NodeMaterialBlock {
  65611. /**
  65612. * Creates a new ScaleBlock
  65613. * @param name defines the block name
  65614. */
  65615. constructor(name: string);
  65616. /**
  65617. * Gets the current class name
  65618. * @returns the class name
  65619. */
  65620. getClassName(): string;
  65621. /**
  65622. * Gets the input component
  65623. */
  65624. get input(): NodeMaterialConnectionPoint;
  65625. /**
  65626. * Gets the factor input component
  65627. */
  65628. get factor(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the output component
  65631. */
  65632. get output(): NodeMaterialConnectionPoint;
  65633. protected _buildBlock(state: NodeMaterialBuildState): this;
  65634. }
  65635. }
  65636. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65638. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65640. import { Scene } from "babylonjs/scene";
  65641. /**
  65642. * Block used to clamp a float
  65643. */
  65644. export class ClampBlock extends NodeMaterialBlock {
  65645. /** Gets or sets the minimum range */
  65646. minimum: number;
  65647. /** Gets or sets the maximum range */
  65648. maximum: number;
  65649. /**
  65650. * Creates a new ClampBlock
  65651. * @param name defines the block name
  65652. */
  65653. constructor(name: string);
  65654. /**
  65655. * Gets the current class name
  65656. * @returns the class name
  65657. */
  65658. getClassName(): string;
  65659. /**
  65660. * Gets the value input component
  65661. */
  65662. get value(): NodeMaterialConnectionPoint;
  65663. /**
  65664. * Gets the output component
  65665. */
  65666. get output(): NodeMaterialConnectionPoint;
  65667. protected _buildBlock(state: NodeMaterialBuildState): this;
  65668. protected _dumpPropertiesCode(): string;
  65669. serialize(): any;
  65670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65671. }
  65672. }
  65673. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65677. /**
  65678. * Block used to apply a cross product between 2 vectors
  65679. */
  65680. export class CrossBlock extends NodeMaterialBlock {
  65681. /**
  65682. * Creates a new CrossBlock
  65683. * @param name defines the block name
  65684. */
  65685. constructor(name: string);
  65686. /**
  65687. * Gets the current class name
  65688. * @returns the class name
  65689. */
  65690. getClassName(): string;
  65691. /**
  65692. * Gets the left operand input component
  65693. */
  65694. get left(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the right operand input component
  65697. */
  65698. get right(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the output component
  65701. */
  65702. get output(): NodeMaterialConnectionPoint;
  65703. protected _buildBlock(state: NodeMaterialBuildState): this;
  65704. }
  65705. }
  65706. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65710. /**
  65711. * Block used to apply a dot product between 2 vectors
  65712. */
  65713. export class DotBlock extends NodeMaterialBlock {
  65714. /**
  65715. * Creates a new DotBlock
  65716. * @param name defines the block name
  65717. */
  65718. constructor(name: string);
  65719. /**
  65720. * Gets the current class name
  65721. * @returns the class name
  65722. */
  65723. getClassName(): string;
  65724. /**
  65725. * Gets the left operand input component
  65726. */
  65727. get left(): NodeMaterialConnectionPoint;
  65728. /**
  65729. * Gets the right operand input component
  65730. */
  65731. get right(): NodeMaterialConnectionPoint;
  65732. /**
  65733. * Gets the output component
  65734. */
  65735. get output(): NodeMaterialConnectionPoint;
  65736. protected _buildBlock(state: NodeMaterialBuildState): this;
  65737. }
  65738. }
  65739. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65743. /**
  65744. * Block used to normalize a vector
  65745. */
  65746. export class NormalizeBlock extends NodeMaterialBlock {
  65747. /**
  65748. * Creates a new NormalizeBlock
  65749. * @param name defines the block name
  65750. */
  65751. constructor(name: string);
  65752. /**
  65753. * Gets the current class name
  65754. * @returns the class name
  65755. */
  65756. getClassName(): string;
  65757. /**
  65758. * Gets the input component
  65759. */
  65760. get input(): NodeMaterialConnectionPoint;
  65761. /**
  65762. * Gets the output component
  65763. */
  65764. get output(): NodeMaterialConnectionPoint;
  65765. protected _buildBlock(state: NodeMaterialBuildState): this;
  65766. }
  65767. }
  65768. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65772. import { Scene } from "babylonjs/scene";
  65773. /**
  65774. * Operations supported by the Trigonometry block
  65775. */
  65776. export enum TrigonometryBlockOperations {
  65777. /** Cos */
  65778. Cos = 0,
  65779. /** Sin */
  65780. Sin = 1,
  65781. /** Abs */
  65782. Abs = 2,
  65783. /** Exp */
  65784. Exp = 3,
  65785. /** Exp2 */
  65786. Exp2 = 4,
  65787. /** Round */
  65788. Round = 5,
  65789. /** Floor */
  65790. Floor = 6,
  65791. /** Ceiling */
  65792. Ceiling = 7,
  65793. /** Square root */
  65794. Sqrt = 8,
  65795. /** Log */
  65796. Log = 9,
  65797. /** Tangent */
  65798. Tan = 10,
  65799. /** Arc tangent */
  65800. ArcTan = 11,
  65801. /** Arc cosinus */
  65802. ArcCos = 12,
  65803. /** Arc sinus */
  65804. ArcSin = 13,
  65805. /** Fraction */
  65806. Fract = 14,
  65807. /** Sign */
  65808. Sign = 15,
  65809. /** To radians (from degrees) */
  65810. Radians = 16,
  65811. /** To degrees (from radians) */
  65812. Degrees = 17
  65813. }
  65814. /**
  65815. * Block used to apply trigonometry operation to floats
  65816. */
  65817. export class TrigonometryBlock extends NodeMaterialBlock {
  65818. /**
  65819. * Gets or sets the operation applied by the block
  65820. */
  65821. operation: TrigonometryBlockOperations;
  65822. /**
  65823. * Creates a new TrigonometryBlock
  65824. * @param name defines the block name
  65825. */
  65826. constructor(name: string);
  65827. /**
  65828. * Gets the current class name
  65829. * @returns the class name
  65830. */
  65831. getClassName(): string;
  65832. /**
  65833. * Gets the input component
  65834. */
  65835. get input(): NodeMaterialConnectionPoint;
  65836. /**
  65837. * Gets the output component
  65838. */
  65839. get output(): NodeMaterialConnectionPoint;
  65840. protected _buildBlock(state: NodeMaterialBuildState): this;
  65841. serialize(): any;
  65842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65843. protected _dumpPropertiesCode(): string;
  65844. }
  65845. }
  65846. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65850. /**
  65851. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65852. */
  65853. export class ColorMergerBlock extends NodeMaterialBlock {
  65854. /**
  65855. * Create a new ColorMergerBlock
  65856. * @param name defines the block name
  65857. */
  65858. constructor(name: string);
  65859. /**
  65860. * Gets the current class name
  65861. * @returns the class name
  65862. */
  65863. getClassName(): string;
  65864. /**
  65865. * Gets the rgb component (input)
  65866. */
  65867. get rgbIn(): NodeMaterialConnectionPoint;
  65868. /**
  65869. * Gets the r component (input)
  65870. */
  65871. get r(): NodeMaterialConnectionPoint;
  65872. /**
  65873. * Gets the g component (input)
  65874. */
  65875. get g(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the b component (input)
  65878. */
  65879. get b(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the a component (input)
  65882. */
  65883. get a(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the rgba component (output)
  65886. */
  65887. get rgba(): NodeMaterialConnectionPoint;
  65888. /**
  65889. * Gets the rgb component (output)
  65890. */
  65891. get rgbOut(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Gets the rgb component (output)
  65894. * @deprecated Please use rgbOut instead.
  65895. */
  65896. get rgb(): NodeMaterialConnectionPoint;
  65897. protected _buildBlock(state: NodeMaterialBuildState): this;
  65898. }
  65899. }
  65900. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65904. /**
  65905. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65906. */
  65907. export class VectorSplitterBlock extends NodeMaterialBlock {
  65908. /**
  65909. * Create a new VectorSplitterBlock
  65910. * @param name defines the block name
  65911. */
  65912. constructor(name: string);
  65913. /**
  65914. * Gets the current class name
  65915. * @returns the class name
  65916. */
  65917. getClassName(): string;
  65918. /**
  65919. * Gets the xyzw component (input)
  65920. */
  65921. get xyzw(): NodeMaterialConnectionPoint;
  65922. /**
  65923. * Gets the xyz component (input)
  65924. */
  65925. get xyzIn(): NodeMaterialConnectionPoint;
  65926. /**
  65927. * Gets the xy component (input)
  65928. */
  65929. get xyIn(): NodeMaterialConnectionPoint;
  65930. /**
  65931. * Gets the xyz component (output)
  65932. */
  65933. get xyzOut(): NodeMaterialConnectionPoint;
  65934. /**
  65935. * Gets the xy component (output)
  65936. */
  65937. get xyOut(): NodeMaterialConnectionPoint;
  65938. /**
  65939. * Gets the x component (output)
  65940. */
  65941. get x(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the y component (output)
  65944. */
  65945. get y(): NodeMaterialConnectionPoint;
  65946. /**
  65947. * Gets the z component (output)
  65948. */
  65949. get z(): NodeMaterialConnectionPoint;
  65950. /**
  65951. * Gets the w component (output)
  65952. */
  65953. get w(): NodeMaterialConnectionPoint;
  65954. protected _inputRename(name: string): string;
  65955. protected _outputRename(name: string): string;
  65956. protected _buildBlock(state: NodeMaterialBuildState): this;
  65957. }
  65958. }
  65959. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65960. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65963. /**
  65964. * Block used to lerp between 2 values
  65965. */
  65966. export class LerpBlock extends NodeMaterialBlock {
  65967. /**
  65968. * Creates a new LerpBlock
  65969. * @param name defines the block name
  65970. */
  65971. constructor(name: string);
  65972. /**
  65973. * Gets the current class name
  65974. * @returns the class name
  65975. */
  65976. getClassName(): string;
  65977. /**
  65978. * Gets the left operand input component
  65979. */
  65980. get left(): NodeMaterialConnectionPoint;
  65981. /**
  65982. * Gets the right operand input component
  65983. */
  65984. get right(): NodeMaterialConnectionPoint;
  65985. /**
  65986. * Gets the gradient operand input component
  65987. */
  65988. get gradient(): NodeMaterialConnectionPoint;
  65989. /**
  65990. * Gets the output component
  65991. */
  65992. get output(): NodeMaterialConnectionPoint;
  65993. protected _buildBlock(state: NodeMaterialBuildState): this;
  65994. }
  65995. }
  65996. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66000. /**
  66001. * Block used to divide 2 vectors
  66002. */
  66003. export class DivideBlock extends NodeMaterialBlock {
  66004. /**
  66005. * Creates a new DivideBlock
  66006. * @param name defines the block name
  66007. */
  66008. constructor(name: string);
  66009. /**
  66010. * Gets the current class name
  66011. * @returns the class name
  66012. */
  66013. getClassName(): string;
  66014. /**
  66015. * Gets the left operand input component
  66016. */
  66017. get left(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the right operand input component
  66020. */
  66021. get right(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the output component
  66024. */
  66025. get output(): NodeMaterialConnectionPoint;
  66026. protected _buildBlock(state: NodeMaterialBuildState): this;
  66027. }
  66028. }
  66029. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66033. /**
  66034. * Block used to subtract 2 vectors
  66035. */
  66036. export class SubtractBlock extends NodeMaterialBlock {
  66037. /**
  66038. * Creates a new SubtractBlock
  66039. * @param name defines the block name
  66040. */
  66041. constructor(name: string);
  66042. /**
  66043. * Gets the current class name
  66044. * @returns the class name
  66045. */
  66046. getClassName(): string;
  66047. /**
  66048. * Gets the left operand input component
  66049. */
  66050. get left(): NodeMaterialConnectionPoint;
  66051. /**
  66052. * Gets the right operand input component
  66053. */
  66054. get right(): NodeMaterialConnectionPoint;
  66055. /**
  66056. * Gets the output component
  66057. */
  66058. get output(): NodeMaterialConnectionPoint;
  66059. protected _buildBlock(state: NodeMaterialBuildState): this;
  66060. }
  66061. }
  66062. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66066. /**
  66067. * Block used to step a value
  66068. */
  66069. export class StepBlock extends NodeMaterialBlock {
  66070. /**
  66071. * Creates a new StepBlock
  66072. * @param name defines the block name
  66073. */
  66074. constructor(name: string);
  66075. /**
  66076. * Gets the current class name
  66077. * @returns the class name
  66078. */
  66079. getClassName(): string;
  66080. /**
  66081. * Gets the value operand input component
  66082. */
  66083. get value(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the edge operand input component
  66086. */
  66087. get edge(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the output component
  66090. */
  66091. get output(): NodeMaterialConnectionPoint;
  66092. protected _buildBlock(state: NodeMaterialBuildState): this;
  66093. }
  66094. }
  66095. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66099. /**
  66100. * Block used to get the opposite (1 - x) of a value
  66101. */
  66102. export class OneMinusBlock extends NodeMaterialBlock {
  66103. /**
  66104. * Creates a new OneMinusBlock
  66105. * @param name defines the block name
  66106. */
  66107. constructor(name: string);
  66108. /**
  66109. * Gets the current class name
  66110. * @returns the class name
  66111. */
  66112. getClassName(): string;
  66113. /**
  66114. * Gets the input component
  66115. */
  66116. get input(): NodeMaterialConnectionPoint;
  66117. /**
  66118. * Gets the output component
  66119. */
  66120. get output(): NodeMaterialConnectionPoint;
  66121. protected _buildBlock(state: NodeMaterialBuildState): this;
  66122. }
  66123. }
  66124. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66128. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66129. /**
  66130. * Block used to get the view direction
  66131. */
  66132. export class ViewDirectionBlock extends NodeMaterialBlock {
  66133. /**
  66134. * Creates a new ViewDirectionBlock
  66135. * @param name defines the block name
  66136. */
  66137. constructor(name: string);
  66138. /**
  66139. * Gets the current class name
  66140. * @returns the class name
  66141. */
  66142. getClassName(): string;
  66143. /**
  66144. * Gets the world position component
  66145. */
  66146. get worldPosition(): NodeMaterialConnectionPoint;
  66147. /**
  66148. * Gets the camera position component
  66149. */
  66150. get cameraPosition(): NodeMaterialConnectionPoint;
  66151. /**
  66152. * Gets the output component
  66153. */
  66154. get output(): NodeMaterialConnectionPoint;
  66155. autoConfigure(material: NodeMaterial): void;
  66156. protected _buildBlock(state: NodeMaterialBuildState): this;
  66157. }
  66158. }
  66159. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66163. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66164. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66165. /**
  66166. * Block used to compute fresnel value
  66167. */
  66168. export class FresnelBlock extends NodeMaterialBlock {
  66169. /**
  66170. * Create a new FresnelBlock
  66171. * @param name defines the block name
  66172. */
  66173. constructor(name: string);
  66174. /**
  66175. * Gets the current class name
  66176. * @returns the class name
  66177. */
  66178. getClassName(): string;
  66179. /**
  66180. * Gets the world normal input component
  66181. */
  66182. get worldNormal(): NodeMaterialConnectionPoint;
  66183. /**
  66184. * Gets the view direction input component
  66185. */
  66186. get viewDirection(): NodeMaterialConnectionPoint;
  66187. /**
  66188. * Gets the bias input component
  66189. */
  66190. get bias(): NodeMaterialConnectionPoint;
  66191. /**
  66192. * Gets the camera (or eye) position component
  66193. */
  66194. get power(): NodeMaterialConnectionPoint;
  66195. /**
  66196. * Gets the fresnel output component
  66197. */
  66198. get fresnel(): NodeMaterialConnectionPoint;
  66199. autoConfigure(material: NodeMaterial): void;
  66200. protected _buildBlock(state: NodeMaterialBuildState): this;
  66201. }
  66202. }
  66203. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66207. /**
  66208. * Block used to get the max of 2 values
  66209. */
  66210. export class MaxBlock extends NodeMaterialBlock {
  66211. /**
  66212. * Creates a new MaxBlock
  66213. * @param name defines the block name
  66214. */
  66215. constructor(name: string);
  66216. /**
  66217. * Gets the current class name
  66218. * @returns the class name
  66219. */
  66220. getClassName(): string;
  66221. /**
  66222. * Gets the left operand input component
  66223. */
  66224. get left(): NodeMaterialConnectionPoint;
  66225. /**
  66226. * Gets the right operand input component
  66227. */
  66228. get right(): NodeMaterialConnectionPoint;
  66229. /**
  66230. * Gets the output component
  66231. */
  66232. get output(): NodeMaterialConnectionPoint;
  66233. protected _buildBlock(state: NodeMaterialBuildState): this;
  66234. }
  66235. }
  66236. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66240. /**
  66241. * Block used to get the min of 2 values
  66242. */
  66243. export class MinBlock extends NodeMaterialBlock {
  66244. /**
  66245. * Creates a new MinBlock
  66246. * @param name defines the block name
  66247. */
  66248. constructor(name: string);
  66249. /**
  66250. * Gets the current class name
  66251. * @returns the class name
  66252. */
  66253. getClassName(): string;
  66254. /**
  66255. * Gets the left operand input component
  66256. */
  66257. get left(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the right operand input component
  66260. */
  66261. get right(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the output component
  66264. */
  66265. get output(): NodeMaterialConnectionPoint;
  66266. protected _buildBlock(state: NodeMaterialBuildState): this;
  66267. }
  66268. }
  66269. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66273. /**
  66274. * Block used to get the distance between 2 values
  66275. */
  66276. export class DistanceBlock extends NodeMaterialBlock {
  66277. /**
  66278. * Creates a new DistanceBlock
  66279. * @param name defines the block name
  66280. */
  66281. constructor(name: string);
  66282. /**
  66283. * Gets the current class name
  66284. * @returns the class name
  66285. */
  66286. getClassName(): string;
  66287. /**
  66288. * Gets the left operand input component
  66289. */
  66290. get left(): NodeMaterialConnectionPoint;
  66291. /**
  66292. * Gets the right operand input component
  66293. */
  66294. get right(): NodeMaterialConnectionPoint;
  66295. /**
  66296. * Gets the output component
  66297. */
  66298. get output(): NodeMaterialConnectionPoint;
  66299. protected _buildBlock(state: NodeMaterialBuildState): this;
  66300. }
  66301. }
  66302. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66305. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66306. /**
  66307. * Block used to get the length of a vector
  66308. */
  66309. export class LengthBlock extends NodeMaterialBlock {
  66310. /**
  66311. * Creates a new LengthBlock
  66312. * @param name defines the block name
  66313. */
  66314. constructor(name: string);
  66315. /**
  66316. * Gets the current class name
  66317. * @returns the class name
  66318. */
  66319. getClassName(): string;
  66320. /**
  66321. * Gets the value input component
  66322. */
  66323. get value(): NodeMaterialConnectionPoint;
  66324. /**
  66325. * Gets the output component
  66326. */
  66327. get output(): NodeMaterialConnectionPoint;
  66328. protected _buildBlock(state: NodeMaterialBuildState): this;
  66329. }
  66330. }
  66331. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66332. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66334. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66335. /**
  66336. * Block used to get negative version of a value (i.e. x * -1)
  66337. */
  66338. export class NegateBlock extends NodeMaterialBlock {
  66339. /**
  66340. * Creates a new NegateBlock
  66341. * @param name defines the block name
  66342. */
  66343. constructor(name: string);
  66344. /**
  66345. * Gets the current class name
  66346. * @returns the class name
  66347. */
  66348. getClassName(): string;
  66349. /**
  66350. * Gets the value input component
  66351. */
  66352. get value(): NodeMaterialConnectionPoint;
  66353. /**
  66354. * Gets the output component
  66355. */
  66356. get output(): NodeMaterialConnectionPoint;
  66357. protected _buildBlock(state: NodeMaterialBuildState): this;
  66358. }
  66359. }
  66360. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66364. /**
  66365. * Block used to get the value of the first parameter raised to the power of the second
  66366. */
  66367. export class PowBlock extends NodeMaterialBlock {
  66368. /**
  66369. * Creates a new PowBlock
  66370. * @param name defines the block name
  66371. */
  66372. constructor(name: string);
  66373. /**
  66374. * Gets the current class name
  66375. * @returns the class name
  66376. */
  66377. getClassName(): string;
  66378. /**
  66379. * Gets the value operand input component
  66380. */
  66381. get value(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the power operand input component
  66384. */
  66385. get power(): NodeMaterialConnectionPoint;
  66386. /**
  66387. * Gets the output component
  66388. */
  66389. get output(): NodeMaterialConnectionPoint;
  66390. protected _buildBlock(state: NodeMaterialBuildState): this;
  66391. }
  66392. }
  66393. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66397. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66398. /**
  66399. * Block used to get a random number
  66400. */
  66401. export class RandomNumberBlock extends NodeMaterialBlock {
  66402. /**
  66403. * Creates a new RandomNumberBlock
  66404. * @param name defines the block name
  66405. */
  66406. constructor(name: string);
  66407. /**
  66408. * Gets the current class name
  66409. * @returns the class name
  66410. */
  66411. getClassName(): string;
  66412. /**
  66413. * Gets the seed input component
  66414. */
  66415. get seed(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the output component
  66418. */
  66419. get output(): NodeMaterialConnectionPoint;
  66420. protected _buildBlock(state: NodeMaterialBuildState): this;
  66421. }
  66422. }
  66423. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66427. /**
  66428. * Block used to compute arc tangent of 2 values
  66429. */
  66430. export class ArcTan2Block extends NodeMaterialBlock {
  66431. /**
  66432. * Creates a new ArcTan2Block
  66433. * @param name defines the block name
  66434. */
  66435. constructor(name: string);
  66436. /**
  66437. * Gets the current class name
  66438. * @returns the class name
  66439. */
  66440. getClassName(): string;
  66441. /**
  66442. * Gets the x operand input component
  66443. */
  66444. get x(): NodeMaterialConnectionPoint;
  66445. /**
  66446. * Gets the y operand input component
  66447. */
  66448. get y(): NodeMaterialConnectionPoint;
  66449. /**
  66450. * Gets the output component
  66451. */
  66452. get output(): NodeMaterialConnectionPoint;
  66453. protected _buildBlock(state: NodeMaterialBuildState): this;
  66454. }
  66455. }
  66456. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66460. /**
  66461. * Block used to smooth step a value
  66462. */
  66463. export class SmoothStepBlock extends NodeMaterialBlock {
  66464. /**
  66465. * Creates a new SmoothStepBlock
  66466. * @param name defines the block name
  66467. */
  66468. constructor(name: string);
  66469. /**
  66470. * Gets the current class name
  66471. * @returns the class name
  66472. */
  66473. getClassName(): string;
  66474. /**
  66475. * Gets the value operand input component
  66476. */
  66477. get value(): NodeMaterialConnectionPoint;
  66478. /**
  66479. * Gets the first edge operand input component
  66480. */
  66481. get edge0(): NodeMaterialConnectionPoint;
  66482. /**
  66483. * Gets the second edge operand input component
  66484. */
  66485. get edge1(): NodeMaterialConnectionPoint;
  66486. /**
  66487. * Gets the output component
  66488. */
  66489. get output(): NodeMaterialConnectionPoint;
  66490. protected _buildBlock(state: NodeMaterialBuildState): this;
  66491. }
  66492. }
  66493. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66497. /**
  66498. * Block used to get the reciprocal (1 / x) of a value
  66499. */
  66500. export class ReciprocalBlock extends NodeMaterialBlock {
  66501. /**
  66502. * Creates a new ReciprocalBlock
  66503. * @param name defines the block name
  66504. */
  66505. constructor(name: string);
  66506. /**
  66507. * Gets the current class name
  66508. * @returns the class name
  66509. */
  66510. getClassName(): string;
  66511. /**
  66512. * Gets the input component
  66513. */
  66514. get input(): NodeMaterialConnectionPoint;
  66515. /**
  66516. * Gets the output component
  66517. */
  66518. get output(): NodeMaterialConnectionPoint;
  66519. protected _buildBlock(state: NodeMaterialBuildState): this;
  66520. }
  66521. }
  66522. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66526. /**
  66527. * Block used to replace a color by another one
  66528. */
  66529. export class ReplaceColorBlock extends NodeMaterialBlock {
  66530. /**
  66531. * Creates a new ReplaceColorBlock
  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 value input component
  66542. */
  66543. get value(): NodeMaterialConnectionPoint;
  66544. /**
  66545. * Gets the reference input component
  66546. */
  66547. get reference(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the distance input component
  66550. */
  66551. get distance(): NodeMaterialConnectionPoint;
  66552. /**
  66553. * Gets the replacement input component
  66554. */
  66555. get replacement(): NodeMaterialConnectionPoint;
  66556. /**
  66557. * Gets the output component
  66558. */
  66559. get output(): NodeMaterialConnectionPoint;
  66560. protected _buildBlock(state: NodeMaterialBuildState): this;
  66561. }
  66562. }
  66563. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66567. /**
  66568. * Block used to posterize a value
  66569. * @see https://en.wikipedia.org/wiki/Posterization
  66570. */
  66571. export class PosterizeBlock extends NodeMaterialBlock {
  66572. /**
  66573. * Creates a new PosterizeBlock
  66574. * @param name defines the block name
  66575. */
  66576. constructor(name: string);
  66577. /**
  66578. * Gets the current class name
  66579. * @returns the class name
  66580. */
  66581. getClassName(): string;
  66582. /**
  66583. * Gets the value input component
  66584. */
  66585. get value(): NodeMaterialConnectionPoint;
  66586. /**
  66587. * Gets the steps input component
  66588. */
  66589. get steps(): NodeMaterialConnectionPoint;
  66590. /**
  66591. * Gets the output component
  66592. */
  66593. get output(): NodeMaterialConnectionPoint;
  66594. protected _buildBlock(state: NodeMaterialBuildState): this;
  66595. }
  66596. }
  66597. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66601. import { Scene } from "babylonjs/scene";
  66602. /**
  66603. * Operations supported by the Wave block
  66604. */
  66605. export enum WaveBlockKind {
  66606. /** SawTooth */
  66607. SawTooth = 0,
  66608. /** Square */
  66609. Square = 1,
  66610. /** Triangle */
  66611. Triangle = 2
  66612. }
  66613. /**
  66614. * Block used to apply wave operation to floats
  66615. */
  66616. export class WaveBlock extends NodeMaterialBlock {
  66617. /**
  66618. * Gets or sets the kibnd of wave to be applied by the block
  66619. */
  66620. kind: WaveBlockKind;
  66621. /**
  66622. * Creates a new WaveBlock
  66623. * @param name defines the block name
  66624. */
  66625. constructor(name: string);
  66626. /**
  66627. * Gets the current class name
  66628. * @returns the class name
  66629. */
  66630. getClassName(): string;
  66631. /**
  66632. * Gets the input component
  66633. */
  66634. get input(): NodeMaterialConnectionPoint;
  66635. /**
  66636. * Gets the output component
  66637. */
  66638. get output(): NodeMaterialConnectionPoint;
  66639. protected _buildBlock(state: NodeMaterialBuildState): this;
  66640. serialize(): any;
  66641. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66642. }
  66643. }
  66644. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66648. import { Color3 } from "babylonjs/Maths/math.color";
  66649. import { Scene } from "babylonjs/scene";
  66650. /**
  66651. * Class used to store a color step for the GradientBlock
  66652. */
  66653. export class GradientBlockColorStep {
  66654. /**
  66655. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66656. */
  66657. step: number;
  66658. /**
  66659. * Gets or sets the color associated with this step
  66660. */
  66661. color: Color3;
  66662. /**
  66663. * Creates a new GradientBlockColorStep
  66664. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66665. * @param color defines the color associated with this step
  66666. */
  66667. constructor(
  66668. /**
  66669. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66670. */
  66671. step: number,
  66672. /**
  66673. * Gets or sets the color associated with this step
  66674. */
  66675. color: Color3);
  66676. }
  66677. /**
  66678. * Block used to return a color from a gradient based on an input value between 0 and 1
  66679. */
  66680. export class GradientBlock extends NodeMaterialBlock {
  66681. /**
  66682. * Gets or sets the list of color steps
  66683. */
  66684. colorSteps: GradientBlockColorStep[];
  66685. /**
  66686. * Creates a new GradientBlock
  66687. * @param name defines the block name
  66688. */
  66689. constructor(name: string);
  66690. /**
  66691. * Gets the current class name
  66692. * @returns the class name
  66693. */
  66694. getClassName(): string;
  66695. /**
  66696. * Gets the gradient input component
  66697. */
  66698. get gradient(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the output component
  66701. */
  66702. get output(): NodeMaterialConnectionPoint;
  66703. private _writeColorConstant;
  66704. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66705. serialize(): any;
  66706. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66707. protected _dumpPropertiesCode(): string;
  66708. }
  66709. }
  66710. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66714. /**
  66715. * Block used to normalize lerp between 2 values
  66716. */
  66717. export class NLerpBlock extends NodeMaterialBlock {
  66718. /**
  66719. * Creates a new NLerpBlock
  66720. * @param name defines the block name
  66721. */
  66722. constructor(name: string);
  66723. /**
  66724. * Gets the current class name
  66725. * @returns the class name
  66726. */
  66727. getClassName(): string;
  66728. /**
  66729. * Gets the left operand input component
  66730. */
  66731. get left(): NodeMaterialConnectionPoint;
  66732. /**
  66733. * Gets the right operand input component
  66734. */
  66735. get right(): NodeMaterialConnectionPoint;
  66736. /**
  66737. * Gets the gradient operand input component
  66738. */
  66739. get gradient(): NodeMaterialConnectionPoint;
  66740. /**
  66741. * Gets the output component
  66742. */
  66743. get output(): NodeMaterialConnectionPoint;
  66744. protected _buildBlock(state: NodeMaterialBuildState): this;
  66745. }
  66746. }
  66747. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66751. import { Scene } from "babylonjs/scene";
  66752. /**
  66753. * block used to Generate a Worley Noise 3D Noise Pattern
  66754. */
  66755. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66756. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66757. manhattanDistance: boolean;
  66758. /**
  66759. * Creates a new WorleyNoise3DBlock
  66760. * @param name defines the block name
  66761. */
  66762. constructor(name: string);
  66763. /**
  66764. * Gets the current class name
  66765. * @returns the class name
  66766. */
  66767. getClassName(): string;
  66768. /**
  66769. * Gets the seed input component
  66770. */
  66771. get seed(): NodeMaterialConnectionPoint;
  66772. /**
  66773. * Gets the jitter input component
  66774. */
  66775. get jitter(): NodeMaterialConnectionPoint;
  66776. /**
  66777. * Gets the output component
  66778. */
  66779. get output(): NodeMaterialConnectionPoint;
  66780. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66781. /**
  66782. * Exposes the properties to the UI?
  66783. */
  66784. protected _dumpPropertiesCode(): string;
  66785. /**
  66786. * Exposes the properties to the Seralize?
  66787. */
  66788. serialize(): any;
  66789. /**
  66790. * Exposes the properties to the deseralize?
  66791. */
  66792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66793. }
  66794. }
  66795. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66799. /**
  66800. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66801. */
  66802. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66803. /**
  66804. * Creates a new SimplexPerlin3DBlock
  66805. * @param name defines the block name
  66806. */
  66807. constructor(name: string);
  66808. /**
  66809. * Gets the current class name
  66810. * @returns the class name
  66811. */
  66812. getClassName(): string;
  66813. /**
  66814. * Gets the seed operand input component
  66815. */
  66816. get seed(): NodeMaterialConnectionPoint;
  66817. /**
  66818. * Gets the output component
  66819. */
  66820. get output(): NodeMaterialConnectionPoint;
  66821. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66822. }
  66823. }
  66824. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66828. /**
  66829. * Block used to blend normals
  66830. */
  66831. export class NormalBlendBlock extends NodeMaterialBlock {
  66832. /**
  66833. * Creates a new NormalBlendBlock
  66834. * @param name defines the block name
  66835. */
  66836. constructor(name: string);
  66837. /**
  66838. * Gets the current class name
  66839. * @returns the class name
  66840. */
  66841. getClassName(): string;
  66842. /**
  66843. * Gets the first input component
  66844. */
  66845. get normalMap0(): NodeMaterialConnectionPoint;
  66846. /**
  66847. * Gets the second input component
  66848. */
  66849. get normalMap1(): NodeMaterialConnectionPoint;
  66850. /**
  66851. * Gets the output component
  66852. */
  66853. get output(): NodeMaterialConnectionPoint;
  66854. protected _buildBlock(state: NodeMaterialBuildState): this;
  66855. }
  66856. }
  66857. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66861. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66862. /**
  66863. * Block used to rotate a 2d vector by a given angle
  66864. */
  66865. export class Rotate2dBlock extends NodeMaterialBlock {
  66866. /**
  66867. * Creates a new Rotate2dBlock
  66868. * @param name defines the block name
  66869. */
  66870. constructor(name: string);
  66871. /**
  66872. * Gets the current class name
  66873. * @returns the class name
  66874. */
  66875. getClassName(): string;
  66876. /**
  66877. * Gets the input vector
  66878. */
  66879. get input(): NodeMaterialConnectionPoint;
  66880. /**
  66881. * Gets the input angle
  66882. */
  66883. get angle(): NodeMaterialConnectionPoint;
  66884. /**
  66885. * Gets the output component
  66886. */
  66887. get output(): NodeMaterialConnectionPoint;
  66888. autoConfigure(material: NodeMaterial): void;
  66889. protected _buildBlock(state: NodeMaterialBuildState): this;
  66890. }
  66891. }
  66892. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66896. /**
  66897. * Block used to get the reflected vector from a direction and a normal
  66898. */
  66899. export class ReflectBlock extends NodeMaterialBlock {
  66900. /**
  66901. * Creates a new ReflectBlock
  66902. * @param name defines the block name
  66903. */
  66904. constructor(name: string);
  66905. /**
  66906. * Gets the current class name
  66907. * @returns the class name
  66908. */
  66909. getClassName(): string;
  66910. /**
  66911. * Gets the incident component
  66912. */
  66913. get incident(): NodeMaterialConnectionPoint;
  66914. /**
  66915. * Gets the normal component
  66916. */
  66917. get normal(): NodeMaterialConnectionPoint;
  66918. /**
  66919. * Gets the output component
  66920. */
  66921. get output(): NodeMaterialConnectionPoint;
  66922. protected _buildBlock(state: NodeMaterialBuildState): this;
  66923. }
  66924. }
  66925. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66929. /**
  66930. * Block used to get the refracted vector from a direction and a normal
  66931. */
  66932. export class RefractBlock extends NodeMaterialBlock {
  66933. /**
  66934. * Creates a new RefractBlock
  66935. * @param name defines the block name
  66936. */
  66937. constructor(name: string);
  66938. /**
  66939. * Gets the current class name
  66940. * @returns the class name
  66941. */
  66942. getClassName(): string;
  66943. /**
  66944. * Gets the incident component
  66945. */
  66946. get incident(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the normal component
  66949. */
  66950. get normal(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the index of refraction component
  66953. */
  66954. get ior(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the output component
  66957. */
  66958. get output(): NodeMaterialConnectionPoint;
  66959. protected _buildBlock(state: NodeMaterialBuildState): this;
  66960. }
  66961. }
  66962. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66966. /**
  66967. * Block used to desaturate a color
  66968. */
  66969. export class DesaturateBlock extends NodeMaterialBlock {
  66970. /**
  66971. * Creates a new DesaturateBlock
  66972. * @param name defines the block name
  66973. */
  66974. constructor(name: string);
  66975. /**
  66976. * Gets the current class name
  66977. * @returns the class name
  66978. */
  66979. getClassName(): string;
  66980. /**
  66981. * Gets the color operand input component
  66982. */
  66983. get color(): NodeMaterialConnectionPoint;
  66984. /**
  66985. * Gets the level operand input component
  66986. */
  66987. get level(): NodeMaterialConnectionPoint;
  66988. /**
  66989. * Gets the output component
  66990. */
  66991. get output(): NodeMaterialConnectionPoint;
  66992. protected _buildBlock(state: NodeMaterialBuildState): this;
  66993. }
  66994. }
  66995. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66999. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67000. import { Nullable } from "babylonjs/types";
  67001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67002. import { Scene } from "babylonjs/scene";
  67003. /**
  67004. * Block used to implement the ambient occlusion module of the PBR material
  67005. */
  67006. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67007. /**
  67008. * Create a new AmbientOcclusionBlock
  67009. * @param name defines the block name
  67010. */
  67011. constructor(name: string);
  67012. /**
  67013. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67014. */
  67015. useAmbientInGrayScale: boolean;
  67016. /**
  67017. * Initialize the block and prepare the context for build
  67018. * @param state defines the state that will be used for the build
  67019. */
  67020. initialize(state: NodeMaterialBuildState): void;
  67021. /**
  67022. * Gets the current class name
  67023. * @returns the class name
  67024. */
  67025. getClassName(): string;
  67026. /**
  67027. * Gets the texture input component
  67028. */
  67029. get texture(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the texture intensity component
  67032. */
  67033. get intensity(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the direct light intensity input component
  67036. */
  67037. get directLightIntensity(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the ambient occlusion object output component
  67040. */
  67041. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the main code of the block (fragment side)
  67044. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67045. * @returns the shader code
  67046. */
  67047. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67049. protected _buildBlock(state: NodeMaterialBuildState): this;
  67050. protected _dumpPropertiesCode(): string;
  67051. serialize(): any;
  67052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67053. }
  67054. }
  67055. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67058. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67059. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67061. import { Nullable } from "babylonjs/types";
  67062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67063. import { Mesh } from "babylonjs/Meshes/mesh";
  67064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67065. import { Effect } from "babylonjs/Materials/effect";
  67066. import { Scene } from "babylonjs/scene";
  67067. /**
  67068. * Block used to implement the reflection module of the PBR material
  67069. */
  67070. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67071. /** @hidden */
  67072. _defineLODReflectionAlpha: string;
  67073. /** @hidden */
  67074. _defineLinearSpecularReflection: string;
  67075. private _vEnvironmentIrradianceName;
  67076. /** @hidden */
  67077. _vReflectionMicrosurfaceInfosName: string;
  67078. /** @hidden */
  67079. _vReflectionInfosName: string;
  67080. /** @hidden */
  67081. _vReflectionFilteringInfoName: string;
  67082. private _scene;
  67083. /**
  67084. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67085. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67086. * It's less burden on the user side in the editor part.
  67087. */
  67088. /** @hidden */
  67089. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67090. /** @hidden */
  67091. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67092. /** @hidden */
  67093. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67094. /**
  67095. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67096. * diffuse part of the IBL.
  67097. */
  67098. useSphericalHarmonics: boolean;
  67099. /**
  67100. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67101. */
  67102. forceIrradianceInFragment: boolean;
  67103. /**
  67104. * Create a new ReflectionBlock
  67105. * @param name defines the block name
  67106. */
  67107. constructor(name: string);
  67108. /**
  67109. * Gets the current class name
  67110. * @returns the class name
  67111. */
  67112. getClassName(): string;
  67113. /**
  67114. * Gets the position input component
  67115. */
  67116. get position(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the world position input component
  67119. */
  67120. get worldPosition(): NodeMaterialConnectionPoint;
  67121. /**
  67122. * Gets the world normal input component
  67123. */
  67124. get worldNormal(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the world input component
  67127. */
  67128. get world(): NodeMaterialConnectionPoint;
  67129. /**
  67130. * Gets the camera (or eye) position component
  67131. */
  67132. get cameraPosition(): NodeMaterialConnectionPoint;
  67133. /**
  67134. * Gets the view input component
  67135. */
  67136. get view(): NodeMaterialConnectionPoint;
  67137. /**
  67138. * Gets the color input component
  67139. */
  67140. get color(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Gets the reflection object output component
  67143. */
  67144. get reflection(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67147. */
  67148. get hasTexture(): boolean;
  67149. /**
  67150. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67151. */
  67152. get reflectionColor(): string;
  67153. protected _getTexture(): Nullable<BaseTexture>;
  67154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67155. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67156. /**
  67157. * Gets the code to inject in the vertex shader
  67158. * @param state current state of the node material building
  67159. * @returns the shader code
  67160. */
  67161. handleVertexSide(state: NodeMaterialBuildState): string;
  67162. /**
  67163. * Gets the main code of the block (fragment side)
  67164. * @param state current state of the node material building
  67165. * @param normalVarName name of the existing variable corresponding to the normal
  67166. * @returns the shader code
  67167. */
  67168. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67169. protected _buildBlock(state: NodeMaterialBuildState): this;
  67170. protected _dumpPropertiesCode(): string;
  67171. serialize(): any;
  67172. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67173. }
  67174. }
  67175. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67181. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67182. import { Scene } from "babylonjs/scene";
  67183. import { Nullable } from "babylonjs/types";
  67184. /**
  67185. * Block used to implement the sheen module of the PBR material
  67186. */
  67187. export class SheenBlock extends NodeMaterialBlock {
  67188. /**
  67189. * Create a new SheenBlock
  67190. * @param name defines the block name
  67191. */
  67192. constructor(name: string);
  67193. /**
  67194. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67195. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67196. * making it easier to setup and tweak the effect
  67197. */
  67198. albedoScaling: boolean;
  67199. /**
  67200. * Defines if the sheen is linked to the sheen color.
  67201. */
  67202. linkSheenWithAlbedo: boolean;
  67203. /**
  67204. * Initialize the block and prepare the context for build
  67205. * @param state defines the state that will be used for the build
  67206. */
  67207. initialize(state: NodeMaterialBuildState): void;
  67208. /**
  67209. * Gets the current class name
  67210. * @returns the class name
  67211. */
  67212. getClassName(): string;
  67213. /**
  67214. * Gets the intensity input component
  67215. */
  67216. get intensity(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the color input component
  67219. */
  67220. get color(): NodeMaterialConnectionPoint;
  67221. /**
  67222. * Gets the roughness input component
  67223. */
  67224. get roughness(): NodeMaterialConnectionPoint;
  67225. /**
  67226. * Gets the sheen object output component
  67227. */
  67228. get sheen(): NodeMaterialConnectionPoint;
  67229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67230. /**
  67231. * Gets the main code of the block (fragment side)
  67232. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67233. * @returns the shader code
  67234. */
  67235. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67236. protected _buildBlock(state: NodeMaterialBuildState): this;
  67237. protected _dumpPropertiesCode(): string;
  67238. serialize(): any;
  67239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67240. }
  67241. }
  67242. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67248. import { Scene } from "babylonjs/scene";
  67249. import { Nullable } from "babylonjs/types";
  67250. import { Mesh } from "babylonjs/Meshes/mesh";
  67251. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67252. import { Effect } from "babylonjs/Materials/effect";
  67253. /**
  67254. * Block used to implement the reflectivity module of the PBR material
  67255. */
  67256. export class ReflectivityBlock extends NodeMaterialBlock {
  67257. private _metallicReflectanceColor;
  67258. private _metallicF0Factor;
  67259. /** @hidden */
  67260. _vMetallicReflectanceFactorsName: string;
  67261. /**
  67262. * The property below is set by the main PBR block prior to calling methods of this class.
  67263. */
  67264. /** @hidden */
  67265. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67266. /**
  67267. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67268. */
  67269. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67270. /**
  67271. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67272. */
  67273. useMetallnessFromMetallicTextureBlue: boolean;
  67274. /**
  67275. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67276. */
  67277. useRoughnessFromMetallicTextureAlpha: boolean;
  67278. /**
  67279. * Specifies if the metallic texture contains the roughness information in its green channel.
  67280. */
  67281. useRoughnessFromMetallicTextureGreen: boolean;
  67282. /**
  67283. * Create a new ReflectivityBlock
  67284. * @param name defines the block name
  67285. */
  67286. constructor(name: string);
  67287. /**
  67288. * Initialize the block and prepare the context for build
  67289. * @param state defines the state that will be used for the build
  67290. */
  67291. initialize(state: NodeMaterialBuildState): void;
  67292. /**
  67293. * Gets the current class name
  67294. * @returns the class name
  67295. */
  67296. getClassName(): string;
  67297. /**
  67298. * Gets the metallic input component
  67299. */
  67300. get metallic(): NodeMaterialConnectionPoint;
  67301. /**
  67302. * Gets the roughness input component
  67303. */
  67304. get roughness(): NodeMaterialConnectionPoint;
  67305. /**
  67306. * Gets the texture input component
  67307. */
  67308. get texture(): NodeMaterialConnectionPoint;
  67309. /**
  67310. * Gets the reflectivity object output component
  67311. */
  67312. get reflectivity(): NodeMaterialConnectionPoint;
  67313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67314. /**
  67315. * Gets the main code of the block (fragment side)
  67316. * @param state current state of the node material building
  67317. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67318. * @returns the shader code
  67319. */
  67320. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67322. protected _buildBlock(state: NodeMaterialBuildState): this;
  67323. protected _dumpPropertiesCode(): string;
  67324. serialize(): any;
  67325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67326. }
  67327. }
  67328. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67329. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67334. /**
  67335. * Block used to implement the anisotropy module of the PBR material
  67336. */
  67337. export class AnisotropyBlock extends NodeMaterialBlock {
  67338. /**
  67339. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67340. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67341. * It's less burden on the user side in the editor part.
  67342. */
  67343. /** @hidden */
  67344. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67345. /** @hidden */
  67346. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67347. /**
  67348. * Create a new AnisotropyBlock
  67349. * @param name defines the block name
  67350. */
  67351. constructor(name: string);
  67352. /**
  67353. * Initialize the block and prepare the context for build
  67354. * @param state defines the state that will be used for the build
  67355. */
  67356. initialize(state: NodeMaterialBuildState): void;
  67357. /**
  67358. * Gets the current class name
  67359. * @returns the class name
  67360. */
  67361. getClassName(): string;
  67362. /**
  67363. * Gets the intensity input component
  67364. */
  67365. get intensity(): NodeMaterialConnectionPoint;
  67366. /**
  67367. * Gets the direction input component
  67368. */
  67369. get direction(): NodeMaterialConnectionPoint;
  67370. /**
  67371. * Gets the texture input component
  67372. */
  67373. get texture(): NodeMaterialConnectionPoint;
  67374. /**
  67375. * Gets the uv input component
  67376. */
  67377. get uv(): NodeMaterialConnectionPoint;
  67378. /**
  67379. * Gets the worldTangent input component
  67380. */
  67381. get worldTangent(): NodeMaterialConnectionPoint;
  67382. /**
  67383. * Gets the anisotropy object output component
  67384. */
  67385. get anisotropy(): NodeMaterialConnectionPoint;
  67386. private _generateTBNSpace;
  67387. /**
  67388. * Gets the main code of the block (fragment side)
  67389. * @param state current state of the node material building
  67390. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67391. * @returns the shader code
  67392. */
  67393. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67395. protected _buildBlock(state: NodeMaterialBuildState): this;
  67396. }
  67397. }
  67398. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67402. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67404. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67405. import { Nullable } from "babylonjs/types";
  67406. import { Mesh } from "babylonjs/Meshes/mesh";
  67407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67408. import { Effect } from "babylonjs/Materials/effect";
  67409. /**
  67410. * Block used to implement the clear coat module of the PBR material
  67411. */
  67412. export class ClearCoatBlock extends NodeMaterialBlock {
  67413. private _scene;
  67414. /**
  67415. * Create a new ClearCoatBlock
  67416. * @param name defines the block name
  67417. */
  67418. constructor(name: string);
  67419. /**
  67420. * Initialize the block and prepare the context for build
  67421. * @param state defines the state that will be used for the build
  67422. */
  67423. initialize(state: NodeMaterialBuildState): void;
  67424. /**
  67425. * Gets the current class name
  67426. * @returns the class name
  67427. */
  67428. getClassName(): string;
  67429. /**
  67430. * Gets the intensity input component
  67431. */
  67432. get intensity(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the roughness input component
  67435. */
  67436. get roughness(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the ior input component
  67439. */
  67440. get ior(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the texture input component
  67443. */
  67444. get texture(): NodeMaterialConnectionPoint;
  67445. /**
  67446. * Gets the bump texture input component
  67447. */
  67448. get bumpTexture(): NodeMaterialConnectionPoint;
  67449. /**
  67450. * Gets the uv input component
  67451. */
  67452. get uv(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Gets the tint color input component
  67455. */
  67456. get tintColor(): NodeMaterialConnectionPoint;
  67457. /**
  67458. * Gets the tint "at distance" input component
  67459. */
  67460. get tintAtDistance(): NodeMaterialConnectionPoint;
  67461. /**
  67462. * Gets the tint thickness input component
  67463. */
  67464. get tintThickness(): NodeMaterialConnectionPoint;
  67465. /**
  67466. * Gets the world tangent input component
  67467. */
  67468. get worldTangent(): NodeMaterialConnectionPoint;
  67469. /**
  67470. * Gets the clear coat object output component
  67471. */
  67472. get clearcoat(): NodeMaterialConnectionPoint;
  67473. autoConfigure(material: NodeMaterial): void;
  67474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67476. private _generateTBNSpace;
  67477. /**
  67478. * Gets the main code of the block (fragment side)
  67479. * @param state current state of the node material building
  67480. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67481. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67482. * @param worldPosVarName name of the variable holding the world position
  67483. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67484. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67485. * @param worldNormalVarName name of the variable holding the world normal
  67486. * @returns the shader code
  67487. */
  67488. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67489. protected _buildBlock(state: NodeMaterialBuildState): this;
  67490. }
  67491. }
  67492. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67496. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67498. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67499. import { Nullable } from "babylonjs/types";
  67500. /**
  67501. * Block used to implement the sub surface module of the PBR material
  67502. */
  67503. export class SubSurfaceBlock extends NodeMaterialBlock {
  67504. /**
  67505. * Create a new SubSurfaceBlock
  67506. * @param name defines the block name
  67507. */
  67508. constructor(name: string);
  67509. /**
  67510. * Stores the intensity of the different subsurface effects in the thickness texture.
  67511. * * the green channel is the translucency intensity.
  67512. * * the blue channel is the scattering intensity.
  67513. * * the alpha channel is the refraction intensity.
  67514. */
  67515. useMaskFromThicknessTexture: boolean;
  67516. /**
  67517. * Initialize the block and prepare the context for build
  67518. * @param state defines the state that will be used for the build
  67519. */
  67520. initialize(state: NodeMaterialBuildState): void;
  67521. /**
  67522. * Gets the current class name
  67523. * @returns the class name
  67524. */
  67525. getClassName(): string;
  67526. /**
  67527. * Gets the min thickness input component
  67528. */
  67529. get minThickness(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the max thickness input component
  67532. */
  67533. get maxThickness(): NodeMaterialConnectionPoint;
  67534. /**
  67535. * Gets the thickness texture component
  67536. */
  67537. get thicknessTexture(): NodeMaterialConnectionPoint;
  67538. /**
  67539. * Gets the tint color input component
  67540. */
  67541. get tintColor(): NodeMaterialConnectionPoint;
  67542. /**
  67543. * Gets the translucency intensity input component
  67544. */
  67545. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67546. /**
  67547. * Gets the translucency diffusion distance input component
  67548. */
  67549. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67550. /**
  67551. * Gets the refraction object parameters
  67552. */
  67553. get refraction(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the sub surface object output component
  67556. */
  67557. get subsurface(): NodeMaterialConnectionPoint;
  67558. autoConfigure(material: NodeMaterial): void;
  67559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67560. /**
  67561. * Gets the main code of the block (fragment side)
  67562. * @param state current state of the node material building
  67563. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67564. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67565. * @param worldPosVarName name of the variable holding the world position
  67566. * @returns the shader code
  67567. */
  67568. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67569. protected _buildBlock(state: NodeMaterialBuildState): this;
  67570. }
  67571. }
  67572. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67576. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67577. import { Light } from "babylonjs/Lights/light";
  67578. import { Nullable } from "babylonjs/types";
  67579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67580. import { Effect } from "babylonjs/Materials/effect";
  67581. import { Mesh } from "babylonjs/Meshes/mesh";
  67582. import { Scene } from "babylonjs/scene";
  67583. /**
  67584. * Block used to implement the PBR metallic/roughness model
  67585. */
  67586. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67587. /**
  67588. * Gets or sets the light associated with this block
  67589. */
  67590. light: Nullable<Light>;
  67591. private _lightId;
  67592. private _scene;
  67593. private _environmentBRDFTexture;
  67594. private _environmentBrdfSamplerName;
  67595. private _vNormalWName;
  67596. private _invertNormalName;
  67597. /**
  67598. * Create a new ReflectionBlock
  67599. * @param name defines the block name
  67600. */
  67601. constructor(name: string);
  67602. /**
  67603. * Intensity of the direct lights e.g. the four lights available in your scene.
  67604. * This impacts both the direct diffuse and specular highlights.
  67605. */
  67606. directIntensity: number;
  67607. /**
  67608. * Intensity of the environment e.g. how much the environment will light the object
  67609. * either through harmonics for rough material or through the refelction for shiny ones.
  67610. */
  67611. environmentIntensity: number;
  67612. /**
  67613. * This is a special control allowing the reduction of the specular highlights coming from the
  67614. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67615. */
  67616. specularIntensity: number;
  67617. /**
  67618. * Defines the falloff type used in this material.
  67619. * It by default is Physical.
  67620. */
  67621. lightFalloff: number;
  67622. /**
  67623. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67624. */
  67625. useAlphaFromAlbedoTexture: boolean;
  67626. /**
  67627. * Specifies that alpha test should be used
  67628. */
  67629. useAlphaTest: boolean;
  67630. /**
  67631. * Defines the alpha limits in alpha test mode.
  67632. */
  67633. alphaTestCutoff: number;
  67634. /**
  67635. * Specifies that alpha blending should be used
  67636. */
  67637. useAlphaBlending: boolean;
  67638. /**
  67639. * Defines if the alpha value should be determined via the rgb values.
  67640. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67641. */
  67642. opacityRGB: boolean;
  67643. /**
  67644. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67645. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67646. */
  67647. useRadianceOverAlpha: boolean;
  67648. /**
  67649. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67650. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67651. */
  67652. useSpecularOverAlpha: boolean;
  67653. /**
  67654. * Enables specular anti aliasing in the PBR shader.
  67655. * It will both interacts on the Geometry for analytical and IBL lighting.
  67656. * It also prefilter the roughness map based on the bump values.
  67657. */
  67658. enableSpecularAntiAliasing: boolean;
  67659. /**
  67660. * Enables realtime filtering on the texture.
  67661. */
  67662. realTimeFiltering: boolean;
  67663. /**
  67664. * Quality switch for realtime filtering
  67665. */
  67666. realTimeFilteringQuality: number;
  67667. /**
  67668. * Defines if the material uses energy conservation.
  67669. */
  67670. useEnergyConservation: boolean;
  67671. /**
  67672. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67673. * too much the area relying on ambient texture to define their ambient occlusion.
  67674. */
  67675. useRadianceOcclusion: boolean;
  67676. /**
  67677. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67678. * makes the reflect vector face the model (under horizon).
  67679. */
  67680. useHorizonOcclusion: boolean;
  67681. /**
  67682. * If set to true, no lighting calculations will be applied.
  67683. */
  67684. unlit: boolean;
  67685. /**
  67686. * Force normal to face away from face.
  67687. */
  67688. forceNormalForward: boolean;
  67689. /**
  67690. * Defines the material debug mode.
  67691. * It helps seeing only some components of the material while troubleshooting.
  67692. */
  67693. debugMode: number;
  67694. /**
  67695. * Specify from where on screen the debug mode should start.
  67696. * The value goes from -1 (full screen) to 1 (not visible)
  67697. * It helps with side by side comparison against the final render
  67698. * This defaults to 0
  67699. */
  67700. debugLimit: number;
  67701. /**
  67702. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67703. * You can use the factor to better multiply the final value.
  67704. */
  67705. debugFactor: number;
  67706. /**
  67707. * Initialize the block and prepare the context for build
  67708. * @param state defines the state that will be used for the build
  67709. */
  67710. initialize(state: NodeMaterialBuildState): void;
  67711. /**
  67712. * Gets the current class name
  67713. * @returns the class name
  67714. */
  67715. getClassName(): string;
  67716. /**
  67717. * Gets the world position input component
  67718. */
  67719. get worldPosition(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the world normal input component
  67722. */
  67723. get worldNormal(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the perturbed normal input component
  67726. */
  67727. get perturbedNormal(): NodeMaterialConnectionPoint;
  67728. /**
  67729. * Gets the camera position input component
  67730. */
  67731. get cameraPosition(): NodeMaterialConnectionPoint;
  67732. /**
  67733. * Gets the base color input component
  67734. */
  67735. get baseColor(): NodeMaterialConnectionPoint;
  67736. /**
  67737. * Gets the opacity texture input component
  67738. */
  67739. get opacityTexture(): NodeMaterialConnectionPoint;
  67740. /**
  67741. * Gets the ambient color input component
  67742. */
  67743. get ambientColor(): NodeMaterialConnectionPoint;
  67744. /**
  67745. * Gets the reflectivity object parameters
  67746. */
  67747. get reflectivity(): NodeMaterialConnectionPoint;
  67748. /**
  67749. * Gets the ambient occlusion object parameters
  67750. */
  67751. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67752. /**
  67753. * Gets the reflection object parameters
  67754. */
  67755. get reflection(): NodeMaterialConnectionPoint;
  67756. /**
  67757. * Gets the sheen object parameters
  67758. */
  67759. get sheen(): NodeMaterialConnectionPoint;
  67760. /**
  67761. * Gets the clear coat object parameters
  67762. */
  67763. get clearcoat(): NodeMaterialConnectionPoint;
  67764. /**
  67765. * Gets the sub surface object parameters
  67766. */
  67767. get subsurface(): NodeMaterialConnectionPoint;
  67768. /**
  67769. * Gets the anisotropy object parameters
  67770. */
  67771. get anisotropy(): NodeMaterialConnectionPoint;
  67772. /**
  67773. * Gets the ambient output component
  67774. */
  67775. get ambient(): NodeMaterialConnectionPoint;
  67776. /**
  67777. * Gets the diffuse output component
  67778. */
  67779. get diffuse(): NodeMaterialConnectionPoint;
  67780. /**
  67781. * Gets the specular output component
  67782. */
  67783. get specular(): NodeMaterialConnectionPoint;
  67784. /**
  67785. * Gets the sheen output component
  67786. */
  67787. get sheenDir(): NodeMaterialConnectionPoint;
  67788. /**
  67789. * Gets the clear coat output component
  67790. */
  67791. get clearcoatDir(): NodeMaterialConnectionPoint;
  67792. /**
  67793. * Gets the indirect diffuse output component
  67794. */
  67795. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67796. /**
  67797. * Gets the indirect specular output component
  67798. */
  67799. get specularIndirect(): NodeMaterialConnectionPoint;
  67800. /**
  67801. * Gets the indirect sheen output component
  67802. */
  67803. get sheenIndirect(): NodeMaterialConnectionPoint;
  67804. /**
  67805. * Gets the indirect clear coat output component
  67806. */
  67807. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67808. /**
  67809. * Gets the refraction output component
  67810. */
  67811. get refraction(): NodeMaterialConnectionPoint;
  67812. /**
  67813. * Gets the global lighting output component
  67814. */
  67815. get lighting(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the shadow output component
  67818. */
  67819. get shadow(): NodeMaterialConnectionPoint;
  67820. /**
  67821. * Gets the alpha output component
  67822. */
  67823. get alpha(): NodeMaterialConnectionPoint;
  67824. autoConfigure(material: NodeMaterial): void;
  67825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67826. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67828. private _injectVertexCode;
  67829. /**
  67830. * Gets the code corresponding to the albedo/opacity module
  67831. * @returns the shader code
  67832. */
  67833. getAlbedoOpacityCode(): string;
  67834. protected _buildBlock(state: NodeMaterialBuildState): this;
  67835. protected _dumpPropertiesCode(): string;
  67836. serialize(): any;
  67837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67838. }
  67839. }
  67840. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67841. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67842. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67843. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67844. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67845. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67846. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67847. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67848. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67849. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67850. }
  67851. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67852. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67853. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67854. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67855. }
  67856. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67860. /**
  67861. * Block used to compute value of one parameter modulo another
  67862. */
  67863. export class ModBlock extends NodeMaterialBlock {
  67864. /**
  67865. * Creates a new ModBlock
  67866. * @param name defines the block name
  67867. */
  67868. constructor(name: string);
  67869. /**
  67870. * Gets the current class name
  67871. * @returns the class name
  67872. */
  67873. getClassName(): string;
  67874. /**
  67875. * Gets the left operand input component
  67876. */
  67877. get left(): NodeMaterialConnectionPoint;
  67878. /**
  67879. * Gets the right operand input component
  67880. */
  67881. get right(): NodeMaterialConnectionPoint;
  67882. /**
  67883. * Gets the output component
  67884. */
  67885. get output(): NodeMaterialConnectionPoint;
  67886. protected _buildBlock(state: NodeMaterialBuildState): this;
  67887. }
  67888. }
  67889. declare module "babylonjs/Materials/Node/Blocks/index" {
  67890. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67891. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67892. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67893. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67894. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67895. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67896. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67897. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67898. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67899. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67900. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67901. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67902. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67903. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67904. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67905. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67906. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67907. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67908. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67909. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67910. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67911. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67912. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67913. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67914. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67915. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67916. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67917. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67918. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67919. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67920. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67921. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67922. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67923. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67924. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67925. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67926. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67927. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67928. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67929. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67930. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67931. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67932. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67933. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67934. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67935. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67936. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67937. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67938. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67939. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67940. }
  67941. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67942. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67943. }
  67944. declare module "babylonjs/Materials/Node/index" {
  67945. export * from "babylonjs/Materials/Node/Enums/index";
  67946. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67947. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67948. export * from "babylonjs/Materials/Node/nodeMaterial";
  67949. export * from "babylonjs/Materials/Node/Blocks/index";
  67950. export * from "babylonjs/Materials/Node/Optimizers/index";
  67951. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67952. }
  67953. declare module "babylonjs/Materials/index" {
  67954. export * from "babylonjs/Materials/Background/index";
  67955. export * from "babylonjs/Materials/colorCurves";
  67956. export * from "babylonjs/Materials/iEffectFallbacks";
  67957. export * from "babylonjs/Materials/effectFallbacks";
  67958. export * from "babylonjs/Materials/effect";
  67959. export * from "babylonjs/Materials/fresnelParameters";
  67960. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67961. export * from "babylonjs/Materials/material";
  67962. export * from "babylonjs/Materials/materialDefines";
  67963. export * from "babylonjs/Materials/materialHelper";
  67964. export * from "babylonjs/Materials/multiMaterial";
  67965. export * from "babylonjs/Materials/PBR/index";
  67966. export * from "babylonjs/Materials/pushMaterial";
  67967. export * from "babylonjs/Materials/shaderMaterial";
  67968. export * from "babylonjs/Materials/standardMaterial";
  67969. export * from "babylonjs/Materials/Textures/index";
  67970. export * from "babylonjs/Materials/uniformBuffer";
  67971. export * from "babylonjs/Materials/materialFlags";
  67972. export * from "babylonjs/Materials/Node/index";
  67973. export * from "babylonjs/Materials/effectRenderer";
  67974. export * from "babylonjs/Materials/shadowDepthWrapper";
  67975. }
  67976. declare module "babylonjs/Maths/index" {
  67977. export * from "babylonjs/Maths/math.scalar";
  67978. export * from "babylonjs/Maths/math";
  67979. export * from "babylonjs/Maths/sphericalPolynomial";
  67980. }
  67981. declare module "babylonjs/Misc/workerPool" {
  67982. import { IDisposable } from "babylonjs/scene";
  67983. /**
  67984. * Helper class to push actions to a pool of workers.
  67985. */
  67986. export class WorkerPool implements IDisposable {
  67987. private _workerInfos;
  67988. private _pendingActions;
  67989. /**
  67990. * Constructor
  67991. * @param workers Array of workers to use for actions
  67992. */
  67993. constructor(workers: Array<Worker>);
  67994. /**
  67995. * Terminates all workers and clears any pending actions.
  67996. */
  67997. dispose(): void;
  67998. /**
  67999. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68000. * pended until a worker has completed its action.
  68001. * @param action The action to perform. Call onComplete when the action is complete.
  68002. */
  68003. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68004. private _execute;
  68005. }
  68006. }
  68007. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68008. import { IDisposable } from "babylonjs/scene";
  68009. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68010. /**
  68011. * Configuration for Draco compression
  68012. */
  68013. export interface IDracoCompressionConfiguration {
  68014. /**
  68015. * Configuration for the decoder.
  68016. */
  68017. decoder: {
  68018. /**
  68019. * The url to the WebAssembly module.
  68020. */
  68021. wasmUrl?: string;
  68022. /**
  68023. * The url to the WebAssembly binary.
  68024. */
  68025. wasmBinaryUrl?: string;
  68026. /**
  68027. * The url to the fallback JavaScript module.
  68028. */
  68029. fallbackUrl?: string;
  68030. };
  68031. }
  68032. /**
  68033. * Draco compression (https://google.github.io/draco/)
  68034. *
  68035. * This class wraps the Draco module.
  68036. *
  68037. * **Encoder**
  68038. *
  68039. * The encoder is not currently implemented.
  68040. *
  68041. * **Decoder**
  68042. *
  68043. * 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.
  68044. *
  68045. * To update the configuration, use the following code:
  68046. * ```javascript
  68047. * DracoCompression.Configuration = {
  68048. * decoder: {
  68049. * wasmUrl: "<url to the WebAssembly library>",
  68050. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68051. * fallbackUrl: "<url to the fallback JavaScript library>",
  68052. * }
  68053. * };
  68054. * ```
  68055. *
  68056. * 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.
  68057. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68058. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68059. *
  68060. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68061. * ```javascript
  68062. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68063. * ```
  68064. *
  68065. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68066. */
  68067. export class DracoCompression implements IDisposable {
  68068. private _workerPoolPromise?;
  68069. private _decoderModulePromise?;
  68070. /**
  68071. * The configuration. Defaults to the following urls:
  68072. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68073. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68074. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68075. */
  68076. static Configuration: IDracoCompressionConfiguration;
  68077. /**
  68078. * Returns true if the decoder configuration is available.
  68079. */
  68080. static get DecoderAvailable(): boolean;
  68081. /**
  68082. * Default number of workers to create when creating the draco compression object.
  68083. */
  68084. static DefaultNumWorkers: number;
  68085. private static GetDefaultNumWorkers;
  68086. private static _Default;
  68087. /**
  68088. * Default instance for the draco compression object.
  68089. */
  68090. static get Default(): DracoCompression;
  68091. /**
  68092. * Constructor
  68093. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68094. */
  68095. constructor(numWorkers?: number);
  68096. /**
  68097. * Stop all async operations and release resources.
  68098. */
  68099. dispose(): void;
  68100. /**
  68101. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68102. * @returns a promise that resolves when ready
  68103. */
  68104. whenReadyAsync(): Promise<void>;
  68105. /**
  68106. * Decode Draco compressed mesh data to vertex data.
  68107. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68108. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68109. * @returns A promise that resolves with the decoded vertex data
  68110. */
  68111. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68112. [kind: string]: number;
  68113. }): Promise<VertexData>;
  68114. }
  68115. }
  68116. declare module "babylonjs/Meshes/Compression/index" {
  68117. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68118. }
  68119. declare module "babylonjs/Meshes/csg" {
  68120. import { Nullable } from "babylonjs/types";
  68121. import { Scene } from "babylonjs/scene";
  68122. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68123. import { Mesh } from "babylonjs/Meshes/mesh";
  68124. import { Material } from "babylonjs/Materials/material";
  68125. /**
  68126. * Class for building Constructive Solid Geometry
  68127. */
  68128. export class CSG {
  68129. private polygons;
  68130. /**
  68131. * The world matrix
  68132. */
  68133. matrix: Matrix;
  68134. /**
  68135. * Stores the position
  68136. */
  68137. position: Vector3;
  68138. /**
  68139. * Stores the rotation
  68140. */
  68141. rotation: Vector3;
  68142. /**
  68143. * Stores the rotation quaternion
  68144. */
  68145. rotationQuaternion: Nullable<Quaternion>;
  68146. /**
  68147. * Stores the scaling vector
  68148. */
  68149. scaling: Vector3;
  68150. /**
  68151. * Convert the Mesh to CSG
  68152. * @param mesh The Mesh to convert to CSG
  68153. * @returns A new CSG from the Mesh
  68154. */
  68155. static FromMesh(mesh: Mesh): CSG;
  68156. /**
  68157. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68158. * @param polygons Polygons used to construct a CSG solid
  68159. */
  68160. private static FromPolygons;
  68161. /**
  68162. * Clones, or makes a deep copy, of the CSG
  68163. * @returns A new CSG
  68164. */
  68165. clone(): CSG;
  68166. /**
  68167. * Unions this CSG with another CSG
  68168. * @param csg The CSG to union against this CSG
  68169. * @returns The unioned CSG
  68170. */
  68171. union(csg: CSG): CSG;
  68172. /**
  68173. * Unions this CSG with another CSG in place
  68174. * @param csg The CSG to union against this CSG
  68175. */
  68176. unionInPlace(csg: CSG): void;
  68177. /**
  68178. * Subtracts this CSG with another CSG
  68179. * @param csg The CSG to subtract against this CSG
  68180. * @returns A new CSG
  68181. */
  68182. subtract(csg: CSG): CSG;
  68183. /**
  68184. * Subtracts this CSG with another CSG in place
  68185. * @param csg The CSG to subtact against this CSG
  68186. */
  68187. subtractInPlace(csg: CSG): void;
  68188. /**
  68189. * Intersect this CSG with another CSG
  68190. * @param csg The CSG to intersect against this CSG
  68191. * @returns A new CSG
  68192. */
  68193. intersect(csg: CSG): CSG;
  68194. /**
  68195. * Intersects this CSG with another CSG in place
  68196. * @param csg The CSG to intersect against this CSG
  68197. */
  68198. intersectInPlace(csg: CSG): void;
  68199. /**
  68200. * Return a new CSG solid with solid and empty space switched. This solid is
  68201. * not modified.
  68202. * @returns A new CSG solid with solid and empty space switched
  68203. */
  68204. inverse(): CSG;
  68205. /**
  68206. * Inverses the CSG in place
  68207. */
  68208. inverseInPlace(): void;
  68209. /**
  68210. * This is used to keep meshes transformations so they can be restored
  68211. * when we build back a Babylon Mesh
  68212. * NB : All CSG operations are performed in world coordinates
  68213. * @param csg The CSG to copy the transform attributes from
  68214. * @returns This CSG
  68215. */
  68216. copyTransformAttributes(csg: CSG): CSG;
  68217. /**
  68218. * Build Raw mesh from CSG
  68219. * Coordinates here are in world space
  68220. * @param name The name of the mesh geometry
  68221. * @param scene The Scene
  68222. * @param keepSubMeshes Specifies if the submeshes should be kept
  68223. * @returns A new Mesh
  68224. */
  68225. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68226. /**
  68227. * Build Mesh from CSG taking material and transforms into account
  68228. * @param name The name of the Mesh
  68229. * @param material The material of the Mesh
  68230. * @param scene The Scene
  68231. * @param keepSubMeshes Specifies if submeshes should be kept
  68232. * @returns The new Mesh
  68233. */
  68234. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68235. }
  68236. }
  68237. declare module "babylonjs/Meshes/trailMesh" {
  68238. import { Mesh } from "babylonjs/Meshes/mesh";
  68239. import { Scene } from "babylonjs/scene";
  68240. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68241. /**
  68242. * Class used to create a trail following a mesh
  68243. */
  68244. export class TrailMesh extends Mesh {
  68245. private _generator;
  68246. private _autoStart;
  68247. private _running;
  68248. private _diameter;
  68249. private _length;
  68250. private _sectionPolygonPointsCount;
  68251. private _sectionVectors;
  68252. private _sectionNormalVectors;
  68253. private _beforeRenderObserver;
  68254. /**
  68255. * @constructor
  68256. * @param name The value used by scene.getMeshByName() to do a lookup.
  68257. * @param generator The mesh or transform node to generate a trail.
  68258. * @param scene The scene to add this mesh to.
  68259. * @param diameter Diameter of trailing mesh. Default is 1.
  68260. * @param length Length of trailing mesh. Default is 60.
  68261. * @param autoStart Automatically start trailing mesh. Default true.
  68262. */
  68263. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68264. /**
  68265. * "TrailMesh"
  68266. * @returns "TrailMesh"
  68267. */
  68268. getClassName(): string;
  68269. private _createMesh;
  68270. /**
  68271. * Start trailing mesh.
  68272. */
  68273. start(): void;
  68274. /**
  68275. * Stop trailing mesh.
  68276. */
  68277. stop(): void;
  68278. /**
  68279. * Update trailing mesh geometry.
  68280. */
  68281. update(): void;
  68282. /**
  68283. * Returns a new TrailMesh object.
  68284. * @param name is a string, the name given to the new mesh
  68285. * @param newGenerator use new generator object for cloned trail mesh
  68286. * @returns a new mesh
  68287. */
  68288. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68289. /**
  68290. * Serializes this trail mesh
  68291. * @param serializationObject object to write serialization to
  68292. */
  68293. serialize(serializationObject: any): void;
  68294. /**
  68295. * Parses a serialized trail mesh
  68296. * @param parsedMesh the serialized mesh
  68297. * @param scene the scene to create the trail mesh in
  68298. * @returns the created trail mesh
  68299. */
  68300. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68301. }
  68302. }
  68303. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68304. import { Nullable } from "babylonjs/types";
  68305. import { Scene } from "babylonjs/scene";
  68306. import { Vector4 } from "babylonjs/Maths/math.vector";
  68307. import { Color4 } from "babylonjs/Maths/math.color";
  68308. import { Mesh } from "babylonjs/Meshes/mesh";
  68309. /**
  68310. * Class containing static functions to help procedurally build meshes
  68311. */
  68312. export class TiledBoxBuilder {
  68313. /**
  68314. * Creates a box mesh
  68315. * 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)
  68316. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68320. * @param name defines the name of the mesh
  68321. * @param options defines the options used to create the mesh
  68322. * @param scene defines the hosting scene
  68323. * @returns the box mesh
  68324. */
  68325. static CreateTiledBox(name: string, options: {
  68326. pattern?: number;
  68327. width?: number;
  68328. height?: number;
  68329. depth?: number;
  68330. tileSize?: number;
  68331. tileWidth?: number;
  68332. tileHeight?: number;
  68333. alignHorizontal?: number;
  68334. alignVertical?: number;
  68335. faceUV?: Vector4[];
  68336. faceColors?: Color4[];
  68337. sideOrientation?: number;
  68338. updatable?: boolean;
  68339. }, scene?: Nullable<Scene>): Mesh;
  68340. }
  68341. }
  68342. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68343. import { Vector4 } from "babylonjs/Maths/math.vector";
  68344. import { Mesh } from "babylonjs/Meshes/mesh";
  68345. /**
  68346. * Class containing static functions to help procedurally build meshes
  68347. */
  68348. export class TorusKnotBuilder {
  68349. /**
  68350. * Creates a torus knot mesh
  68351. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68352. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68353. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68354. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68358. * @param name defines the name of the mesh
  68359. * @param options defines the options used to create the mesh
  68360. * @param scene defines the hosting scene
  68361. * @returns the torus knot mesh
  68362. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68363. */
  68364. static CreateTorusKnot(name: string, options: {
  68365. radius?: number;
  68366. tube?: number;
  68367. radialSegments?: number;
  68368. tubularSegments?: number;
  68369. p?: number;
  68370. q?: number;
  68371. updatable?: boolean;
  68372. sideOrientation?: number;
  68373. frontUVs?: Vector4;
  68374. backUVs?: Vector4;
  68375. }, scene: any): Mesh;
  68376. }
  68377. }
  68378. declare module "babylonjs/Meshes/polygonMesh" {
  68379. import { Scene } from "babylonjs/scene";
  68380. import { Vector2 } from "babylonjs/Maths/math.vector";
  68381. import { Mesh } from "babylonjs/Meshes/mesh";
  68382. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68383. import { Path2 } from "babylonjs/Maths/math.path";
  68384. /**
  68385. * Polygon
  68386. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68387. */
  68388. export class Polygon {
  68389. /**
  68390. * Creates a rectangle
  68391. * @param xmin bottom X coord
  68392. * @param ymin bottom Y coord
  68393. * @param xmax top X coord
  68394. * @param ymax top Y coord
  68395. * @returns points that make the resulting rectation
  68396. */
  68397. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68398. /**
  68399. * Creates a circle
  68400. * @param radius radius of circle
  68401. * @param cx scale in x
  68402. * @param cy scale in y
  68403. * @param numberOfSides number of sides that make up the circle
  68404. * @returns points that make the resulting circle
  68405. */
  68406. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68407. /**
  68408. * Creates a polygon from input string
  68409. * @param input Input polygon data
  68410. * @returns the parsed points
  68411. */
  68412. static Parse(input: string): Vector2[];
  68413. /**
  68414. * Starts building a polygon from x and y coordinates
  68415. * @param x x coordinate
  68416. * @param y y coordinate
  68417. * @returns the started path2
  68418. */
  68419. static StartingAt(x: number, y: number): Path2;
  68420. }
  68421. /**
  68422. * Builds a polygon
  68423. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68424. */
  68425. export class PolygonMeshBuilder {
  68426. private _points;
  68427. private _outlinepoints;
  68428. private _holes;
  68429. private _name;
  68430. private _scene;
  68431. private _epoints;
  68432. private _eholes;
  68433. private _addToepoint;
  68434. /**
  68435. * Babylon reference to the earcut plugin.
  68436. */
  68437. bjsEarcut: any;
  68438. /**
  68439. * Creates a PolygonMeshBuilder
  68440. * @param name name of the builder
  68441. * @param contours Path of the polygon
  68442. * @param scene scene to add to when creating the mesh
  68443. * @param earcutInjection can be used to inject your own earcut reference
  68444. */
  68445. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68446. /**
  68447. * Adds a whole within the polygon
  68448. * @param hole Array of points defining the hole
  68449. * @returns this
  68450. */
  68451. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68452. /**
  68453. * Creates the polygon
  68454. * @param updatable If the mesh should be updatable
  68455. * @param depth The depth of the mesh created
  68456. * @returns the created mesh
  68457. */
  68458. build(updatable?: boolean, depth?: number): Mesh;
  68459. /**
  68460. * Creates the polygon
  68461. * @param depth The depth of the mesh created
  68462. * @returns the created VertexData
  68463. */
  68464. buildVertexData(depth?: number): VertexData;
  68465. /**
  68466. * Adds a side to the polygon
  68467. * @param positions points that make the polygon
  68468. * @param normals normals of the polygon
  68469. * @param uvs uvs of the polygon
  68470. * @param indices indices of the polygon
  68471. * @param bounds bounds of the polygon
  68472. * @param points points of the polygon
  68473. * @param depth depth of the polygon
  68474. * @param flip flip of the polygon
  68475. */
  68476. private addSide;
  68477. }
  68478. }
  68479. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68480. import { Scene } from "babylonjs/scene";
  68481. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68482. import { Color4 } from "babylonjs/Maths/math.color";
  68483. import { Mesh } from "babylonjs/Meshes/mesh";
  68484. import { Nullable } from "babylonjs/types";
  68485. /**
  68486. * Class containing static functions to help procedurally build meshes
  68487. */
  68488. export class PolygonBuilder {
  68489. /**
  68490. * Creates a polygon mesh
  68491. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68492. * * 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
  68493. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68496. * * Remember you can only change the shape positions, not their number when updating a polygon
  68497. * @param name defines the name of the mesh
  68498. * @param options defines the options used to create the mesh
  68499. * @param scene defines the hosting scene
  68500. * @param earcutInjection can be used to inject your own earcut reference
  68501. * @returns the polygon mesh
  68502. */
  68503. static CreatePolygon(name: string, options: {
  68504. shape: Vector3[];
  68505. holes?: Vector3[][];
  68506. depth?: number;
  68507. faceUV?: Vector4[];
  68508. faceColors?: Color4[];
  68509. updatable?: boolean;
  68510. sideOrientation?: number;
  68511. frontUVs?: Vector4;
  68512. backUVs?: Vector4;
  68513. wrap?: boolean;
  68514. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68515. /**
  68516. * Creates an extruded polygon mesh, with depth in the Y direction.
  68517. * * 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)
  68518. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68519. * @param name defines the name of the mesh
  68520. * @param options defines the options used to create the mesh
  68521. * @param scene defines the hosting scene
  68522. * @param earcutInjection can be used to inject your own earcut reference
  68523. * @returns the polygon mesh
  68524. */
  68525. static ExtrudePolygon(name: string, options: {
  68526. shape: Vector3[];
  68527. holes?: Vector3[][];
  68528. depth?: number;
  68529. faceUV?: Vector4[];
  68530. faceColors?: Color4[];
  68531. updatable?: boolean;
  68532. sideOrientation?: number;
  68533. frontUVs?: Vector4;
  68534. backUVs?: Vector4;
  68535. wrap?: boolean;
  68536. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68537. }
  68538. }
  68539. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68540. import { Scene } from "babylonjs/scene";
  68541. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68542. import { Mesh } from "babylonjs/Meshes/mesh";
  68543. import { Nullable } from "babylonjs/types";
  68544. /**
  68545. * Class containing static functions to help procedurally build meshes
  68546. */
  68547. export class LatheBuilder {
  68548. /**
  68549. * Creates lathe mesh.
  68550. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68551. * * 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
  68552. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68553. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68554. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68555. * * 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
  68556. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68557. * * 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
  68558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68562. * @param name defines the name of the mesh
  68563. * @param options defines the options used to create the mesh
  68564. * @param scene defines the hosting scene
  68565. * @returns the lathe mesh
  68566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68567. */
  68568. static CreateLathe(name: string, options: {
  68569. shape: Vector3[];
  68570. radius?: number;
  68571. tessellation?: number;
  68572. clip?: number;
  68573. arc?: number;
  68574. closed?: boolean;
  68575. updatable?: boolean;
  68576. sideOrientation?: number;
  68577. frontUVs?: Vector4;
  68578. backUVs?: Vector4;
  68579. cap?: number;
  68580. invertUV?: boolean;
  68581. }, scene?: Nullable<Scene>): Mesh;
  68582. }
  68583. }
  68584. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68585. import { Nullable } from "babylonjs/types";
  68586. import { Scene } from "babylonjs/scene";
  68587. import { Vector4 } from "babylonjs/Maths/math.vector";
  68588. import { Mesh } from "babylonjs/Meshes/mesh";
  68589. /**
  68590. * Class containing static functions to help procedurally build meshes
  68591. */
  68592. export class TiledPlaneBuilder {
  68593. /**
  68594. * Creates a tiled plane mesh
  68595. * * The parameter `pattern` will, depending on value, do nothing or
  68596. * * * flip (reflect about central vertical) alternate tiles across and up
  68597. * * * flip every tile on alternate rows
  68598. * * * rotate (180 degs) alternate tiles across and up
  68599. * * * rotate every tile on alternate rows
  68600. * * * flip and rotate alternate tiles across and up
  68601. * * * flip and rotate every tile on alternate rows
  68602. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68603. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68606. * * 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)
  68607. * * 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)
  68608. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68609. * @param name defines the name of the mesh
  68610. * @param options defines the options used to create the mesh
  68611. * @param scene defines the hosting scene
  68612. * @returns the box mesh
  68613. */
  68614. static CreateTiledPlane(name: string, options: {
  68615. pattern?: number;
  68616. tileSize?: number;
  68617. tileWidth?: number;
  68618. tileHeight?: number;
  68619. size?: number;
  68620. width?: number;
  68621. height?: number;
  68622. alignHorizontal?: number;
  68623. alignVertical?: number;
  68624. sideOrientation?: number;
  68625. frontUVs?: Vector4;
  68626. backUVs?: Vector4;
  68627. updatable?: boolean;
  68628. }, scene?: Nullable<Scene>): Mesh;
  68629. }
  68630. }
  68631. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68632. import { Nullable } from "babylonjs/types";
  68633. import { Scene } from "babylonjs/scene";
  68634. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68635. import { Mesh } from "babylonjs/Meshes/mesh";
  68636. /**
  68637. * Class containing static functions to help procedurally build meshes
  68638. */
  68639. export class TubeBuilder {
  68640. /**
  68641. * Creates a tube mesh.
  68642. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68643. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68644. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68645. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68646. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68647. * * 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)
  68648. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68649. * * 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
  68650. * * 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
  68651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68655. * @param name defines the name of the mesh
  68656. * @param options defines the options used to create the mesh
  68657. * @param scene defines the hosting scene
  68658. * @returns the tube mesh
  68659. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68660. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68661. */
  68662. static CreateTube(name: string, options: {
  68663. path: Vector3[];
  68664. radius?: number;
  68665. tessellation?: number;
  68666. radiusFunction?: {
  68667. (i: number, distance: number): number;
  68668. };
  68669. cap?: number;
  68670. arc?: number;
  68671. updatable?: boolean;
  68672. sideOrientation?: number;
  68673. frontUVs?: Vector4;
  68674. backUVs?: Vector4;
  68675. instance?: Mesh;
  68676. invertUV?: boolean;
  68677. }, scene?: Nullable<Scene>): Mesh;
  68678. }
  68679. }
  68680. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68681. import { Scene } from "babylonjs/scene";
  68682. import { Vector4 } from "babylonjs/Maths/math.vector";
  68683. import { Mesh } from "babylonjs/Meshes/mesh";
  68684. import { Nullable } from "babylonjs/types";
  68685. /**
  68686. * Class containing static functions to help procedurally build meshes
  68687. */
  68688. export class IcoSphereBuilder {
  68689. /**
  68690. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68691. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68692. * * 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`)
  68693. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68694. * * 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
  68695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68698. * @param name defines the name of the mesh
  68699. * @param options defines the options used to create the mesh
  68700. * @param scene defines the hosting scene
  68701. * @returns the icosahedron mesh
  68702. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68703. */
  68704. static CreateIcoSphere(name: string, options: {
  68705. radius?: number;
  68706. radiusX?: number;
  68707. radiusY?: number;
  68708. radiusZ?: number;
  68709. flat?: boolean;
  68710. subdivisions?: number;
  68711. sideOrientation?: number;
  68712. frontUVs?: Vector4;
  68713. backUVs?: Vector4;
  68714. updatable?: boolean;
  68715. }, scene?: Nullable<Scene>): Mesh;
  68716. }
  68717. }
  68718. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68719. import { Vector3 } from "babylonjs/Maths/math.vector";
  68720. import { Mesh } from "babylonjs/Meshes/mesh";
  68721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68722. /**
  68723. * Class containing static functions to help procedurally build meshes
  68724. */
  68725. export class DecalBuilder {
  68726. /**
  68727. * Creates a decal mesh.
  68728. * 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
  68729. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68730. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68731. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68732. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68733. * @param name defines the name of the mesh
  68734. * @param sourceMesh defines the mesh where the decal must be applied
  68735. * @param options defines the options used to create the mesh
  68736. * @param scene defines the hosting scene
  68737. * @returns the decal mesh
  68738. * @see https://doc.babylonjs.com/how_to/decals
  68739. */
  68740. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68741. position?: Vector3;
  68742. normal?: Vector3;
  68743. size?: Vector3;
  68744. angle?: number;
  68745. }): Mesh;
  68746. }
  68747. }
  68748. declare module "babylonjs/Meshes/meshBuilder" {
  68749. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68750. import { Nullable } from "babylonjs/types";
  68751. import { Scene } from "babylonjs/scene";
  68752. import { Mesh } from "babylonjs/Meshes/mesh";
  68753. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68754. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68756. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68757. import { Plane } from "babylonjs/Maths/math.plane";
  68758. /**
  68759. * Class containing static functions to help procedurally build meshes
  68760. */
  68761. export class MeshBuilder {
  68762. /**
  68763. * Creates a box mesh
  68764. * * The parameter `size` sets the size (float) of each box side (default 1)
  68765. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68766. * * 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)
  68767. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68771. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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. * @returns the box mesh
  68776. */
  68777. static CreateBox(name: string, options: {
  68778. size?: number;
  68779. width?: number;
  68780. height?: number;
  68781. depth?: number;
  68782. faceUV?: Vector4[];
  68783. faceColors?: Color4[];
  68784. sideOrientation?: number;
  68785. frontUVs?: Vector4;
  68786. backUVs?: Vector4;
  68787. wrap?: boolean;
  68788. topBaseAt?: number;
  68789. bottomBaseAt?: number;
  68790. updatable?: boolean;
  68791. }, scene?: Nullable<Scene>): Mesh;
  68792. /**
  68793. * Creates a tiled box mesh
  68794. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68796. * @param name defines the name of the mesh
  68797. * @param options defines the options used to create the mesh
  68798. * @param scene defines the hosting scene
  68799. * @returns the tiled box mesh
  68800. */
  68801. static CreateTiledBox(name: string, options: {
  68802. pattern?: number;
  68803. size?: number;
  68804. width?: number;
  68805. height?: number;
  68806. depth: number;
  68807. tileSize?: number;
  68808. tileWidth?: number;
  68809. tileHeight?: number;
  68810. faceUV?: Vector4[];
  68811. faceColors?: Color4[];
  68812. alignHorizontal?: number;
  68813. alignVertical?: number;
  68814. sideOrientation?: number;
  68815. updatable?: boolean;
  68816. }, scene?: Nullable<Scene>): Mesh;
  68817. /**
  68818. * Creates a sphere mesh
  68819. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68820. * * 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`)
  68821. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68822. * * 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
  68823. * * 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)
  68824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68827. * @param name defines the name of the mesh
  68828. * @param options defines the options used to create the mesh
  68829. * @param scene defines the hosting scene
  68830. * @returns the sphere mesh
  68831. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68832. */
  68833. static CreateSphere(name: string, options: {
  68834. segments?: number;
  68835. diameter?: number;
  68836. diameterX?: number;
  68837. diameterY?: number;
  68838. diameterZ?: number;
  68839. arc?: number;
  68840. slice?: number;
  68841. sideOrientation?: number;
  68842. frontUVs?: Vector4;
  68843. backUVs?: Vector4;
  68844. updatable?: boolean;
  68845. }, scene?: Nullable<Scene>): Mesh;
  68846. /**
  68847. * Creates a plane polygonal mesh. By default, this is a disc
  68848. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68849. * * 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
  68850. * * 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
  68851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68854. * @param name defines the name of the mesh
  68855. * @param options defines the options used to create the mesh
  68856. * @param scene defines the hosting scene
  68857. * @returns the plane polygonal mesh
  68858. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68859. */
  68860. static CreateDisc(name: string, options: {
  68861. radius?: number;
  68862. tessellation?: number;
  68863. arc?: number;
  68864. updatable?: boolean;
  68865. sideOrientation?: number;
  68866. frontUVs?: Vector4;
  68867. backUVs?: Vector4;
  68868. }, scene?: Nullable<Scene>): Mesh;
  68869. /**
  68870. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68871. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68872. * * 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`)
  68873. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68874. * * 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
  68875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68878. * @param name defines the name of the mesh
  68879. * @param options defines the options used to create the mesh
  68880. * @param scene defines the hosting scene
  68881. * @returns the icosahedron mesh
  68882. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68883. */
  68884. static CreateIcoSphere(name: string, options: {
  68885. radius?: number;
  68886. radiusX?: number;
  68887. radiusY?: number;
  68888. radiusZ?: number;
  68889. flat?: boolean;
  68890. subdivisions?: number;
  68891. sideOrientation?: number;
  68892. frontUVs?: Vector4;
  68893. backUVs?: Vector4;
  68894. updatable?: boolean;
  68895. }, scene?: Nullable<Scene>): Mesh;
  68896. /**
  68897. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68898. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68899. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68900. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68901. * * 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
  68902. * * 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
  68903. * * 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
  68904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68907. * * 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
  68908. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68909. * * 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
  68910. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68912. * @param name defines the name of the mesh
  68913. * @param options defines the options used to create the mesh
  68914. * @param scene defines the hosting scene
  68915. * @returns the ribbon mesh
  68916. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68918. */
  68919. static CreateRibbon(name: string, options: {
  68920. pathArray: Vector3[][];
  68921. closeArray?: boolean;
  68922. closePath?: boolean;
  68923. offset?: number;
  68924. updatable?: boolean;
  68925. sideOrientation?: number;
  68926. frontUVs?: Vector4;
  68927. backUVs?: Vector4;
  68928. instance?: Mesh;
  68929. invertUV?: boolean;
  68930. uvs?: Vector2[];
  68931. colors?: Color4[];
  68932. }, scene?: Nullable<Scene>): Mesh;
  68933. /**
  68934. * Creates a cylinder or a cone mesh
  68935. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68936. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68937. * * 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.
  68938. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68939. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68940. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68941. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68942. * * 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).
  68943. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68944. * * 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).
  68945. * * 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
  68946. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68947. * * 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
  68948. * * 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.
  68949. * * If `enclose` is false, a ring surface is one element.
  68950. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68951. * * 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
  68952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68955. * @param name defines the name of the mesh
  68956. * @param options defines the options used to create the mesh
  68957. * @param scene defines the hosting scene
  68958. * @returns the cylinder mesh
  68959. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68960. */
  68961. static CreateCylinder(name: string, options: {
  68962. height?: number;
  68963. diameterTop?: number;
  68964. diameterBottom?: number;
  68965. diameter?: number;
  68966. tessellation?: number;
  68967. subdivisions?: number;
  68968. arc?: number;
  68969. faceColors?: Color4[];
  68970. faceUV?: Vector4[];
  68971. updatable?: boolean;
  68972. hasRings?: boolean;
  68973. enclose?: boolean;
  68974. cap?: number;
  68975. sideOrientation?: number;
  68976. frontUVs?: Vector4;
  68977. backUVs?: Vector4;
  68978. }, scene?: Nullable<Scene>): Mesh;
  68979. /**
  68980. * Creates a torus mesh
  68981. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68982. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68983. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68987. * @param name defines the name of the mesh
  68988. * @param options defines the options used to create the mesh
  68989. * @param scene defines the hosting scene
  68990. * @returns the torus mesh
  68991. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68992. */
  68993. static CreateTorus(name: string, options: {
  68994. diameter?: number;
  68995. thickness?: number;
  68996. tessellation?: number;
  68997. updatable?: boolean;
  68998. sideOrientation?: number;
  68999. frontUVs?: Vector4;
  69000. backUVs?: Vector4;
  69001. }, scene?: Nullable<Scene>): Mesh;
  69002. /**
  69003. * Creates a torus knot mesh
  69004. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69005. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69006. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69007. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69011. * @param name defines the name of the mesh
  69012. * @param options defines the options used to create the mesh
  69013. * @param scene defines the hosting scene
  69014. * @returns the torus knot mesh
  69015. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69016. */
  69017. static CreateTorusKnot(name: string, options: {
  69018. radius?: number;
  69019. tube?: number;
  69020. radialSegments?: number;
  69021. tubularSegments?: number;
  69022. p?: number;
  69023. q?: number;
  69024. updatable?: boolean;
  69025. sideOrientation?: number;
  69026. frontUVs?: Vector4;
  69027. backUVs?: Vector4;
  69028. }, scene?: Nullable<Scene>): Mesh;
  69029. /**
  69030. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69031. * * 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
  69032. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69033. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69034. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69035. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69036. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69037. * * 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
  69038. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69041. * @param name defines the name of the new line system
  69042. * @param options defines the options used to create the line system
  69043. * @param scene defines the hosting scene
  69044. * @returns a new line system mesh
  69045. */
  69046. static CreateLineSystem(name: string, options: {
  69047. lines: Vector3[][];
  69048. updatable?: boolean;
  69049. instance?: Nullable<LinesMesh>;
  69050. colors?: Nullable<Color4[][]>;
  69051. useVertexAlpha?: boolean;
  69052. }, scene: Nullable<Scene>): LinesMesh;
  69053. /**
  69054. * Creates a line mesh
  69055. * 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
  69056. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69057. * * The parameter `points` is an array successive Vector3
  69058. * * 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
  69059. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69060. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69061. * * When updating an instance, remember that only point positions can change, not the number of points
  69062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69064. * @param name defines the name of the new line system
  69065. * @param options defines the options used to create the line system
  69066. * @param scene defines the hosting scene
  69067. * @returns a new line mesh
  69068. */
  69069. static CreateLines(name: string, options: {
  69070. points: Vector3[];
  69071. updatable?: boolean;
  69072. instance?: Nullable<LinesMesh>;
  69073. colors?: Color4[];
  69074. useVertexAlpha?: boolean;
  69075. }, scene?: Nullable<Scene>): LinesMesh;
  69076. /**
  69077. * Creates a dashed line mesh
  69078. * * 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
  69079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69080. * * The parameter `points` is an array successive Vector3
  69081. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69082. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69083. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69084. * * 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
  69085. * * When updating an instance, remember that only point positions can change, not the number of points
  69086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69087. * @param name defines the name of the mesh
  69088. * @param options defines the options used to create the mesh
  69089. * @param scene defines the hosting scene
  69090. * @returns the dashed line mesh
  69091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69092. */
  69093. static CreateDashedLines(name: string, options: {
  69094. points: Vector3[];
  69095. dashSize?: number;
  69096. gapSize?: number;
  69097. dashNb?: number;
  69098. updatable?: boolean;
  69099. instance?: LinesMesh;
  69100. }, scene?: Nullable<Scene>): LinesMesh;
  69101. /**
  69102. * 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.
  69103. * * 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.
  69104. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69105. * * 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.
  69106. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69107. * * 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
  69108. * * 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
  69109. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69114. * @param name defines the name of the mesh
  69115. * @param options defines the options used to create the mesh
  69116. * @param scene defines the hosting scene
  69117. * @returns the extruded shape mesh
  69118. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69120. */
  69121. static ExtrudeShape(name: string, options: {
  69122. shape: Vector3[];
  69123. path: Vector3[];
  69124. scale?: number;
  69125. rotation?: number;
  69126. cap?: number;
  69127. updatable?: boolean;
  69128. sideOrientation?: number;
  69129. frontUVs?: Vector4;
  69130. backUVs?: Vector4;
  69131. instance?: Mesh;
  69132. invertUV?: boolean;
  69133. }, scene?: Nullable<Scene>): Mesh;
  69134. /**
  69135. * Creates an custom extruded shape mesh.
  69136. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69137. * * 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.
  69138. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69139. * * 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
  69140. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69141. * * 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
  69142. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69143. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69144. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69145. * * 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
  69146. * * 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
  69147. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69152. * @param name defines the name of the mesh
  69153. * @param options defines the options used to create the mesh
  69154. * @param scene defines the hosting scene
  69155. * @returns the custom extruded shape mesh
  69156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69159. */
  69160. static ExtrudeShapeCustom(name: string, options: {
  69161. shape: Vector3[];
  69162. path: Vector3[];
  69163. scaleFunction?: any;
  69164. rotationFunction?: any;
  69165. ribbonCloseArray?: boolean;
  69166. ribbonClosePath?: boolean;
  69167. cap?: number;
  69168. updatable?: boolean;
  69169. sideOrientation?: number;
  69170. frontUVs?: Vector4;
  69171. backUVs?: Vector4;
  69172. instance?: Mesh;
  69173. invertUV?: boolean;
  69174. }, scene?: Nullable<Scene>): Mesh;
  69175. /**
  69176. * Creates lathe mesh.
  69177. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69178. * * 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
  69179. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69180. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69181. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69182. * * 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
  69183. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69184. * * 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
  69185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69189. * @param name defines the name of the mesh
  69190. * @param options defines the options used to create the mesh
  69191. * @param scene defines the hosting scene
  69192. * @returns the lathe mesh
  69193. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69194. */
  69195. static CreateLathe(name: string, options: {
  69196. shape: Vector3[];
  69197. radius?: number;
  69198. tessellation?: number;
  69199. clip?: number;
  69200. arc?: number;
  69201. closed?: boolean;
  69202. updatable?: boolean;
  69203. sideOrientation?: number;
  69204. frontUVs?: Vector4;
  69205. backUVs?: Vector4;
  69206. cap?: number;
  69207. invertUV?: boolean;
  69208. }, scene?: Nullable<Scene>): Mesh;
  69209. /**
  69210. * Creates a tiled plane mesh
  69211. * * You can set a limited pattern arrangement with the tiles
  69212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69215. * @param name defines the name of the mesh
  69216. * @param options defines the options used to create the mesh
  69217. * @param scene defines the hosting scene
  69218. * @returns the plane mesh
  69219. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69220. */
  69221. static CreateTiledPlane(name: string, options: {
  69222. pattern?: number;
  69223. tileSize?: number;
  69224. tileWidth?: number;
  69225. tileHeight?: number;
  69226. size?: number;
  69227. width?: number;
  69228. height?: number;
  69229. alignHorizontal?: number;
  69230. alignVertical?: number;
  69231. sideOrientation?: number;
  69232. frontUVs?: Vector4;
  69233. backUVs?: Vector4;
  69234. updatable?: boolean;
  69235. }, scene?: Nullable<Scene>): Mesh;
  69236. /**
  69237. * Creates a plane mesh
  69238. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69239. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69240. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69244. * @param name defines the name of the mesh
  69245. * @param options defines the options used to create the mesh
  69246. * @param scene defines the hosting scene
  69247. * @returns the plane mesh
  69248. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69249. */
  69250. static CreatePlane(name: string, options: {
  69251. size?: number;
  69252. width?: number;
  69253. height?: number;
  69254. sideOrientation?: number;
  69255. frontUVs?: Vector4;
  69256. backUVs?: Vector4;
  69257. updatable?: boolean;
  69258. sourcePlane?: Plane;
  69259. }, scene?: Nullable<Scene>): Mesh;
  69260. /**
  69261. * Creates a ground mesh
  69262. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69263. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69265. * @param name defines the name of the mesh
  69266. * @param options defines the options used to create the mesh
  69267. * @param scene defines the hosting scene
  69268. * @returns the ground mesh
  69269. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69270. */
  69271. static CreateGround(name: string, options: {
  69272. width?: number;
  69273. height?: number;
  69274. subdivisions?: number;
  69275. subdivisionsX?: number;
  69276. subdivisionsY?: number;
  69277. updatable?: boolean;
  69278. }, scene?: Nullable<Scene>): Mesh;
  69279. /**
  69280. * Creates a tiled ground mesh
  69281. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69282. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69283. * * 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
  69284. * * 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
  69285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69286. * @param name defines the name of the mesh
  69287. * @param options defines the options used to create the mesh
  69288. * @param scene defines the hosting scene
  69289. * @returns the tiled ground mesh
  69290. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69291. */
  69292. static CreateTiledGround(name: string, options: {
  69293. xmin: number;
  69294. zmin: number;
  69295. xmax: number;
  69296. zmax: number;
  69297. subdivisions?: {
  69298. w: number;
  69299. h: number;
  69300. };
  69301. precision?: {
  69302. w: number;
  69303. h: number;
  69304. };
  69305. updatable?: boolean;
  69306. }, scene?: Nullable<Scene>): Mesh;
  69307. /**
  69308. * Creates a ground mesh from a height map
  69309. * * The parameter `url` sets the URL of the height map image resource.
  69310. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69311. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69312. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69313. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69314. * * 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.
  69315. * * 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).
  69316. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69318. * @param name defines the name of the mesh
  69319. * @param url defines the url to the height map
  69320. * @param options defines the options used to create the mesh
  69321. * @param scene defines the hosting scene
  69322. * @returns the ground mesh
  69323. * @see https://doc.babylonjs.com/babylon101/height_map
  69324. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69325. */
  69326. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69327. width?: number;
  69328. height?: number;
  69329. subdivisions?: number;
  69330. minHeight?: number;
  69331. maxHeight?: number;
  69332. colorFilter?: Color3;
  69333. alphaFilter?: number;
  69334. updatable?: boolean;
  69335. onReady?: (mesh: GroundMesh) => void;
  69336. }, scene?: Nullable<Scene>): GroundMesh;
  69337. /**
  69338. * Creates a polygon mesh
  69339. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69340. * * 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
  69341. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69344. * * Remember you can only change the shape positions, not their number when updating a polygon
  69345. * @param name defines the name of the mesh
  69346. * @param options defines the options used to create the mesh
  69347. * @param scene defines the hosting scene
  69348. * @param earcutInjection can be used to inject your own earcut reference
  69349. * @returns the polygon mesh
  69350. */
  69351. static CreatePolygon(name: string, options: {
  69352. shape: Vector3[];
  69353. holes?: Vector3[][];
  69354. depth?: number;
  69355. faceUV?: Vector4[];
  69356. faceColors?: Color4[];
  69357. updatable?: boolean;
  69358. sideOrientation?: number;
  69359. frontUVs?: Vector4;
  69360. backUVs?: Vector4;
  69361. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69362. /**
  69363. * Creates an extruded polygon mesh, with depth in the Y direction.
  69364. * * 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)
  69365. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69366. * @param name defines the name of the mesh
  69367. * @param options defines the options used to create the mesh
  69368. * @param scene defines the hosting scene
  69369. * @param earcutInjection can be used to inject your own earcut reference
  69370. * @returns the polygon mesh
  69371. */
  69372. static ExtrudePolygon(name: string, options: {
  69373. shape: Vector3[];
  69374. holes?: Vector3[][];
  69375. depth?: number;
  69376. faceUV?: Vector4[];
  69377. faceColors?: Color4[];
  69378. updatable?: boolean;
  69379. sideOrientation?: number;
  69380. frontUVs?: Vector4;
  69381. backUVs?: Vector4;
  69382. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69383. /**
  69384. * Creates a tube mesh.
  69385. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69386. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69387. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69388. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69389. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69390. * * 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)
  69391. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69392. * * 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
  69393. * * 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
  69394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69398. * @param name defines the name of the mesh
  69399. * @param options defines the options used to create the mesh
  69400. * @param scene defines the hosting scene
  69401. * @returns the tube mesh
  69402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69403. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69404. */
  69405. static CreateTube(name: string, options: {
  69406. path: Vector3[];
  69407. radius?: number;
  69408. tessellation?: number;
  69409. radiusFunction?: {
  69410. (i: number, distance: number): number;
  69411. };
  69412. cap?: number;
  69413. arc?: number;
  69414. updatable?: boolean;
  69415. sideOrientation?: number;
  69416. frontUVs?: Vector4;
  69417. backUVs?: Vector4;
  69418. instance?: Mesh;
  69419. invertUV?: boolean;
  69420. }, scene?: Nullable<Scene>): Mesh;
  69421. /**
  69422. * Creates a polyhedron mesh
  69423. * * 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
  69424. * * The parameter `size` (positive float, default 1) sets the polygon size
  69425. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69426. * * 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`
  69427. * * 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
  69428. * * 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)`)
  69429. * * 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
  69430. * * 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
  69431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69434. * @param name defines the name of the mesh
  69435. * @param options defines the options used to create the mesh
  69436. * @param scene defines the hosting scene
  69437. * @returns the polyhedron mesh
  69438. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69439. */
  69440. static CreatePolyhedron(name: string, options: {
  69441. type?: number;
  69442. size?: number;
  69443. sizeX?: number;
  69444. sizeY?: number;
  69445. sizeZ?: number;
  69446. custom?: any;
  69447. faceUV?: Vector4[];
  69448. faceColors?: Color4[];
  69449. flat?: boolean;
  69450. updatable?: boolean;
  69451. sideOrientation?: number;
  69452. frontUVs?: Vector4;
  69453. backUVs?: Vector4;
  69454. }, scene?: Nullable<Scene>): Mesh;
  69455. /**
  69456. * Creates a decal mesh.
  69457. * 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
  69458. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69459. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69460. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69461. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69462. * @param name defines the name of the mesh
  69463. * @param sourceMesh defines the mesh where the decal must be applied
  69464. * @param options defines the options used to create the mesh
  69465. * @param scene defines the hosting scene
  69466. * @returns the decal mesh
  69467. * @see https://doc.babylonjs.com/how_to/decals
  69468. */
  69469. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69470. position?: Vector3;
  69471. normal?: Vector3;
  69472. size?: Vector3;
  69473. angle?: number;
  69474. }): Mesh;
  69475. }
  69476. }
  69477. declare module "babylonjs/Meshes/meshSimplification" {
  69478. import { Mesh } from "babylonjs/Meshes/mesh";
  69479. /**
  69480. * A simplifier interface for future simplification implementations
  69481. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69482. */
  69483. export interface ISimplifier {
  69484. /**
  69485. * Simplification of a given mesh according to the given settings.
  69486. * Since this requires computation, it is assumed that the function runs async.
  69487. * @param settings The settings of the simplification, including quality and distance
  69488. * @param successCallback A callback that will be called after the mesh was simplified.
  69489. * @param errorCallback in case of an error, this callback will be called. optional.
  69490. */
  69491. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69492. }
  69493. /**
  69494. * Expected simplification settings.
  69495. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69496. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69497. */
  69498. export interface ISimplificationSettings {
  69499. /**
  69500. * Gets or sets the expected quality
  69501. */
  69502. quality: number;
  69503. /**
  69504. * Gets or sets the distance when this optimized version should be used
  69505. */
  69506. distance: number;
  69507. /**
  69508. * Gets an already optimized mesh
  69509. */
  69510. optimizeMesh?: boolean;
  69511. }
  69512. /**
  69513. * Class used to specify simplification options
  69514. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69515. */
  69516. export class SimplificationSettings implements ISimplificationSettings {
  69517. /** expected quality */
  69518. quality: number;
  69519. /** distance when this optimized version should be used */
  69520. distance: number;
  69521. /** already optimized mesh */
  69522. optimizeMesh?: boolean | undefined;
  69523. /**
  69524. * Creates a SimplificationSettings
  69525. * @param quality expected quality
  69526. * @param distance distance when this optimized version should be used
  69527. * @param optimizeMesh already optimized mesh
  69528. */
  69529. constructor(
  69530. /** expected quality */
  69531. quality: number,
  69532. /** distance when this optimized version should be used */
  69533. distance: number,
  69534. /** already optimized mesh */
  69535. optimizeMesh?: boolean | undefined);
  69536. }
  69537. /**
  69538. * Interface used to define a simplification task
  69539. */
  69540. export interface ISimplificationTask {
  69541. /**
  69542. * Array of settings
  69543. */
  69544. settings: Array<ISimplificationSettings>;
  69545. /**
  69546. * Simplification type
  69547. */
  69548. simplificationType: SimplificationType;
  69549. /**
  69550. * Mesh to simplify
  69551. */
  69552. mesh: Mesh;
  69553. /**
  69554. * Callback called on success
  69555. */
  69556. successCallback?: () => void;
  69557. /**
  69558. * Defines if parallel processing can be used
  69559. */
  69560. parallelProcessing: boolean;
  69561. }
  69562. /**
  69563. * Queue used to order the simplification tasks
  69564. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69565. */
  69566. export class SimplificationQueue {
  69567. private _simplificationArray;
  69568. /**
  69569. * Gets a boolean indicating that the process is still running
  69570. */
  69571. running: boolean;
  69572. /**
  69573. * Creates a new queue
  69574. */
  69575. constructor();
  69576. /**
  69577. * Adds a new simplification task
  69578. * @param task defines a task to add
  69579. */
  69580. addTask(task: ISimplificationTask): void;
  69581. /**
  69582. * Execute next task
  69583. */
  69584. executeNext(): void;
  69585. /**
  69586. * Execute a simplification task
  69587. * @param task defines the task to run
  69588. */
  69589. runSimplification(task: ISimplificationTask): void;
  69590. private getSimplifier;
  69591. }
  69592. /**
  69593. * The implemented types of simplification
  69594. * At the moment only Quadratic Error Decimation is implemented
  69595. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69596. */
  69597. export enum SimplificationType {
  69598. /** Quadratic error decimation */
  69599. QUADRATIC = 0
  69600. }
  69601. /**
  69602. * An implementation of the Quadratic Error simplification algorithm.
  69603. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69604. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69605. * @author RaananW
  69606. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69607. */
  69608. export class QuadraticErrorSimplification implements ISimplifier {
  69609. private _mesh;
  69610. private triangles;
  69611. private vertices;
  69612. private references;
  69613. private _reconstructedMesh;
  69614. /** Gets or sets the number pf sync interations */
  69615. syncIterations: number;
  69616. /** Gets or sets the aggressiveness of the simplifier */
  69617. aggressiveness: number;
  69618. /** Gets or sets the number of allowed iterations for decimation */
  69619. decimationIterations: number;
  69620. /** Gets or sets the espilon to use for bounding box computation */
  69621. boundingBoxEpsilon: number;
  69622. /**
  69623. * Creates a new QuadraticErrorSimplification
  69624. * @param _mesh defines the target mesh
  69625. */
  69626. constructor(_mesh: Mesh);
  69627. /**
  69628. * Simplification of a given mesh according to the given settings.
  69629. * Since this requires computation, it is assumed that the function runs async.
  69630. * @param settings The settings of the simplification, including quality and distance
  69631. * @param successCallback A callback that will be called after the mesh was simplified.
  69632. */
  69633. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69634. private runDecimation;
  69635. private initWithMesh;
  69636. private init;
  69637. private reconstructMesh;
  69638. private initDecimatedMesh;
  69639. private isFlipped;
  69640. private updateTriangles;
  69641. private identifyBorder;
  69642. private updateMesh;
  69643. private vertexError;
  69644. private calculateError;
  69645. }
  69646. }
  69647. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69648. import { Scene } from "babylonjs/scene";
  69649. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69650. import { ISceneComponent } from "babylonjs/sceneComponent";
  69651. module "babylonjs/scene" {
  69652. interface Scene {
  69653. /** @hidden (Backing field) */
  69654. _simplificationQueue: SimplificationQueue;
  69655. /**
  69656. * Gets or sets the simplification queue attached to the scene
  69657. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69658. */
  69659. simplificationQueue: SimplificationQueue;
  69660. }
  69661. }
  69662. module "babylonjs/Meshes/mesh" {
  69663. interface Mesh {
  69664. /**
  69665. * Simplify the mesh according to the given array of settings.
  69666. * Function will return immediately and will simplify async
  69667. * @param settings a collection of simplification settings
  69668. * @param parallelProcessing should all levels calculate parallel or one after the other
  69669. * @param simplificationType the type of simplification to run
  69670. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69671. * @returns the current mesh
  69672. */
  69673. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69674. }
  69675. }
  69676. /**
  69677. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69678. * created in a scene
  69679. */
  69680. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69681. /**
  69682. * The component name helpfull to identify the component in the list of scene components.
  69683. */
  69684. readonly name: string;
  69685. /**
  69686. * The scene the component belongs to.
  69687. */
  69688. scene: Scene;
  69689. /**
  69690. * Creates a new instance of the component for the given scene
  69691. * @param scene Defines the scene to register the component in
  69692. */
  69693. constructor(scene: Scene);
  69694. /**
  69695. * Registers the component in a given scene
  69696. */
  69697. register(): void;
  69698. /**
  69699. * Rebuilds the elements related to this component in case of
  69700. * context lost for instance.
  69701. */
  69702. rebuild(): void;
  69703. /**
  69704. * Disposes the component and the associated ressources
  69705. */
  69706. dispose(): void;
  69707. private _beforeCameraUpdate;
  69708. }
  69709. }
  69710. declare module "babylonjs/Meshes/Builders/index" {
  69711. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69712. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69713. export * from "babylonjs/Meshes/Builders/discBuilder";
  69714. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69715. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69716. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69717. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69718. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69719. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69720. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69721. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69722. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69723. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69724. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69725. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69726. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69727. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69728. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69729. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69730. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69731. }
  69732. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69733. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69734. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69735. import { Matrix } from "babylonjs/Maths/math.vector";
  69736. module "babylonjs/Meshes/mesh" {
  69737. interface Mesh {
  69738. /**
  69739. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  69740. */
  69741. thinInstanceEnablePicking: boolean;
  69742. /**
  69743. * Creates a new thin instance
  69744. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69745. * @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
  69746. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69747. */
  69748. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69749. /**
  69750. * Adds the transformation (matrix) of the current mesh as a thin instance
  69751. * @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
  69752. * @returns the thin instance index number
  69753. */
  69754. thinInstanceAddSelf(refresh: boolean): number;
  69755. /**
  69756. * Registers a custom attribute to be used with thin instances
  69757. * @param kind name of the attribute
  69758. * @param stride size in floats of the attribute
  69759. */
  69760. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69761. /**
  69762. * Sets the matrix of a thin instance
  69763. * @param index index of the thin instance
  69764. * @param matrix matrix to set
  69765. * @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
  69766. */
  69767. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69768. /**
  69769. * Sets the value of a custom attribute for a thin instance
  69770. * @param kind name of the attribute
  69771. * @param index index of the thin instance
  69772. * @param value value to set
  69773. * @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
  69774. */
  69775. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69776. /**
  69777. * 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.
  69778. */
  69779. thinInstanceCount: number;
  69780. /**
  69781. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69782. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69783. * @param buffer buffer to set
  69784. * @param stride size in floats of each value of the buffer
  69785. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69786. */
  69787. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69788. /**
  69789. * Gets the list of world matrices
  69790. * @return an array containing all the world matrices from the thin instances
  69791. */
  69792. thinInstanceGetWorldMatrices(): Matrix[];
  69793. /**
  69794. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69795. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69796. */
  69797. thinInstanceBufferUpdated(kind: string): void;
  69798. /**
  69799. * Refreshes the bounding info, taking into account all the thin instances defined
  69800. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69801. */
  69802. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69803. /** @hidden */
  69804. _thinInstanceInitializeUserStorage(): void;
  69805. /** @hidden */
  69806. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69807. /** @hidden */
  69808. _userThinInstanceBuffersStorage: {
  69809. data: {
  69810. [key: string]: Float32Array;
  69811. };
  69812. sizes: {
  69813. [key: string]: number;
  69814. };
  69815. vertexBuffers: {
  69816. [key: string]: Nullable<VertexBuffer>;
  69817. };
  69818. strides: {
  69819. [key: string]: number;
  69820. };
  69821. };
  69822. }
  69823. }
  69824. }
  69825. declare module "babylonjs/Meshes/index" {
  69826. export * from "babylonjs/Meshes/abstractMesh";
  69827. export * from "babylonjs/Meshes/buffer";
  69828. export * from "babylonjs/Meshes/Compression/index";
  69829. export * from "babylonjs/Meshes/csg";
  69830. export * from "babylonjs/Meshes/geometry";
  69831. export * from "babylonjs/Meshes/groundMesh";
  69832. export * from "babylonjs/Meshes/trailMesh";
  69833. export * from "babylonjs/Meshes/instancedMesh";
  69834. export * from "babylonjs/Meshes/linesMesh";
  69835. export * from "babylonjs/Meshes/mesh";
  69836. export * from "babylonjs/Meshes/mesh.vertexData";
  69837. export * from "babylonjs/Meshes/meshBuilder";
  69838. export * from "babylonjs/Meshes/meshSimplification";
  69839. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69840. export * from "babylonjs/Meshes/polygonMesh";
  69841. export * from "babylonjs/Meshes/subMesh";
  69842. export * from "babylonjs/Meshes/meshLODLevel";
  69843. export * from "babylonjs/Meshes/transformNode";
  69844. export * from "babylonjs/Meshes/Builders/index";
  69845. export * from "babylonjs/Meshes/dataBuffer";
  69846. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69847. import "babylonjs/Meshes/thinInstanceMesh";
  69848. export * from "babylonjs/Meshes/thinInstanceMesh";
  69849. }
  69850. declare module "babylonjs/Morph/index" {
  69851. export * from "babylonjs/Morph/morphTarget";
  69852. export * from "babylonjs/Morph/morphTargetManager";
  69853. }
  69854. declare module "babylonjs/Navigation/INavigationEngine" {
  69855. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69856. import { Vector3 } from "babylonjs/Maths/math";
  69857. import { Mesh } from "babylonjs/Meshes/mesh";
  69858. import { Scene } from "babylonjs/scene";
  69859. /**
  69860. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69861. */
  69862. export interface INavigationEnginePlugin {
  69863. /**
  69864. * plugin name
  69865. */
  69866. name: string;
  69867. /**
  69868. * Creates a navigation mesh
  69869. * @param meshes array of all the geometry used to compute the navigatio mesh
  69870. * @param parameters bunch of parameters used to filter geometry
  69871. */
  69872. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69873. /**
  69874. * Create a navigation mesh debug mesh
  69875. * @param scene is where the mesh will be added
  69876. * @returns debug display mesh
  69877. */
  69878. createDebugNavMesh(scene: Scene): Mesh;
  69879. /**
  69880. * Get a navigation mesh constrained position, closest to the parameter position
  69881. * @param position world position
  69882. * @returns the closest point to position constrained by the navigation mesh
  69883. */
  69884. getClosestPoint(position: Vector3): Vector3;
  69885. /**
  69886. * Get a navigation mesh constrained position, closest to the parameter position
  69887. * @param position world position
  69888. * @param result output the closest point to position constrained by the navigation mesh
  69889. */
  69890. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69891. /**
  69892. * Get a navigation mesh constrained position, within a particular radius
  69893. * @param position world position
  69894. * @param maxRadius the maximum distance to the constrained world position
  69895. * @returns the closest point to position constrained by the navigation mesh
  69896. */
  69897. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69898. /**
  69899. * Get a navigation mesh constrained position, within a particular radius
  69900. * @param position world position
  69901. * @param maxRadius the maximum distance to the constrained world position
  69902. * @param result output the closest point to position constrained by the navigation mesh
  69903. */
  69904. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69905. /**
  69906. * Compute the final position from a segment made of destination-position
  69907. * @param position world position
  69908. * @param destination world position
  69909. * @returns the resulting point along the navmesh
  69910. */
  69911. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69912. /**
  69913. * Compute the final position from a segment made of destination-position
  69914. * @param position world position
  69915. * @param destination world position
  69916. * @param result output the resulting point along the navmesh
  69917. */
  69918. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69919. /**
  69920. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69921. * @param start world position
  69922. * @param end world position
  69923. * @returns array containing world position composing the path
  69924. */
  69925. computePath(start: Vector3, end: Vector3): Vector3[];
  69926. /**
  69927. * If this plugin is supported
  69928. * @returns true if plugin is supported
  69929. */
  69930. isSupported(): boolean;
  69931. /**
  69932. * Create a new Crowd so you can add agents
  69933. * @param maxAgents the maximum agent count in the crowd
  69934. * @param maxAgentRadius the maximum radius an agent can have
  69935. * @param scene to attach the crowd to
  69936. * @returns the crowd you can add agents to
  69937. */
  69938. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69939. /**
  69940. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69941. * The queries will try to find a solution within those bounds
  69942. * default is (1,1,1)
  69943. * @param extent x,y,z value that define the extent around the queries point of reference
  69944. */
  69945. setDefaultQueryExtent(extent: Vector3): void;
  69946. /**
  69947. * Get the Bounding box extent specified by setDefaultQueryExtent
  69948. * @returns the box extent values
  69949. */
  69950. getDefaultQueryExtent(): Vector3;
  69951. /**
  69952. * build the navmesh from a previously saved state using getNavmeshData
  69953. * @param data the Uint8Array returned by getNavmeshData
  69954. */
  69955. buildFromNavmeshData(data: Uint8Array): void;
  69956. /**
  69957. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69958. * @returns data the Uint8Array that can be saved and reused
  69959. */
  69960. getNavmeshData(): Uint8Array;
  69961. /**
  69962. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69963. * @param result output the box extent values
  69964. */
  69965. getDefaultQueryExtentToRef(result: Vector3): void;
  69966. /**
  69967. * Release all resources
  69968. */
  69969. dispose(): void;
  69970. }
  69971. /**
  69972. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69973. */
  69974. export interface ICrowd {
  69975. /**
  69976. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69977. * You can attach anything to that node. The node position is updated in the scene update tick.
  69978. * @param pos world position that will be constrained by the navigation mesh
  69979. * @param parameters agent parameters
  69980. * @param transform hooked to the agent that will be update by the scene
  69981. * @returns agent index
  69982. */
  69983. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69984. /**
  69985. * Returns the agent position in world space
  69986. * @param index agent index returned by addAgent
  69987. * @returns world space position
  69988. */
  69989. getAgentPosition(index: number): Vector3;
  69990. /**
  69991. * Gets the agent position result in world space
  69992. * @param index agent index returned by addAgent
  69993. * @param result output world space position
  69994. */
  69995. getAgentPositionToRef(index: number, result: Vector3): void;
  69996. /**
  69997. * Gets the agent velocity in world space
  69998. * @param index agent index returned by addAgent
  69999. * @returns world space velocity
  70000. */
  70001. getAgentVelocity(index: number): Vector3;
  70002. /**
  70003. * Gets the agent velocity result in world space
  70004. * @param index agent index returned by addAgent
  70005. * @param result output world space velocity
  70006. */
  70007. getAgentVelocityToRef(index: number, result: Vector3): void;
  70008. /**
  70009. * remove a particular agent previously created
  70010. * @param index agent index returned by addAgent
  70011. */
  70012. removeAgent(index: number): void;
  70013. /**
  70014. * get the list of all agents attached to this crowd
  70015. * @returns list of agent indices
  70016. */
  70017. getAgents(): number[];
  70018. /**
  70019. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70020. * @param deltaTime in seconds
  70021. */
  70022. update(deltaTime: number): void;
  70023. /**
  70024. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70025. * @param index agent index returned by addAgent
  70026. * @param destination targeted world position
  70027. */
  70028. agentGoto(index: number, destination: Vector3): void;
  70029. /**
  70030. * Teleport the agent to a new position
  70031. * @param index agent index returned by addAgent
  70032. * @param destination targeted world position
  70033. */
  70034. agentTeleport(index: number, destination: Vector3): void;
  70035. /**
  70036. * Update agent parameters
  70037. * @param index agent index returned by addAgent
  70038. * @param parameters agent parameters
  70039. */
  70040. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70041. /**
  70042. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70043. * The queries will try to find a solution within those bounds
  70044. * default is (1,1,1)
  70045. * @param extent x,y,z value that define the extent around the queries point of reference
  70046. */
  70047. setDefaultQueryExtent(extent: Vector3): void;
  70048. /**
  70049. * Get the Bounding box extent specified by setDefaultQueryExtent
  70050. * @returns the box extent values
  70051. */
  70052. getDefaultQueryExtent(): Vector3;
  70053. /**
  70054. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70055. * @param result output the box extent values
  70056. */
  70057. getDefaultQueryExtentToRef(result: Vector3): void;
  70058. /**
  70059. * Release all resources
  70060. */
  70061. dispose(): void;
  70062. }
  70063. /**
  70064. * Configures an agent
  70065. */
  70066. export interface IAgentParameters {
  70067. /**
  70068. * Agent radius. [Limit: >= 0]
  70069. */
  70070. radius: number;
  70071. /**
  70072. * Agent height. [Limit: > 0]
  70073. */
  70074. height: number;
  70075. /**
  70076. * Maximum allowed acceleration. [Limit: >= 0]
  70077. */
  70078. maxAcceleration: number;
  70079. /**
  70080. * Maximum allowed speed. [Limit: >= 0]
  70081. */
  70082. maxSpeed: number;
  70083. /**
  70084. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70085. */
  70086. collisionQueryRange: number;
  70087. /**
  70088. * The path visibility optimization range. [Limit: > 0]
  70089. */
  70090. pathOptimizationRange: number;
  70091. /**
  70092. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70093. */
  70094. separationWeight: number;
  70095. }
  70096. /**
  70097. * Configures the navigation mesh creation
  70098. */
  70099. export interface INavMeshParameters {
  70100. /**
  70101. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70102. */
  70103. cs: number;
  70104. /**
  70105. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70106. */
  70107. ch: number;
  70108. /**
  70109. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70110. */
  70111. walkableSlopeAngle: number;
  70112. /**
  70113. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70114. * be considered walkable. [Limit: >= 3] [Units: vx]
  70115. */
  70116. walkableHeight: number;
  70117. /**
  70118. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70119. */
  70120. walkableClimb: number;
  70121. /**
  70122. * The distance to erode/shrink the walkable area of the heightfield away from
  70123. * obstructions. [Limit: >=0] [Units: vx]
  70124. */
  70125. walkableRadius: number;
  70126. /**
  70127. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70128. */
  70129. maxEdgeLen: number;
  70130. /**
  70131. * The maximum distance a simplfied contour's border edges should deviate
  70132. * the original raw contour. [Limit: >=0] [Units: vx]
  70133. */
  70134. maxSimplificationError: number;
  70135. /**
  70136. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70137. */
  70138. minRegionArea: number;
  70139. /**
  70140. * Any regions with a span count smaller than this value will, if possible,
  70141. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70142. */
  70143. mergeRegionArea: number;
  70144. /**
  70145. * The maximum number of vertices allowed for polygons generated during the
  70146. * contour to polygon conversion process. [Limit: >= 3]
  70147. */
  70148. maxVertsPerPoly: number;
  70149. /**
  70150. * Sets the sampling distance to use when generating the detail mesh.
  70151. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70152. */
  70153. detailSampleDist: number;
  70154. /**
  70155. * The maximum distance the detail mesh surface should deviate from heightfield
  70156. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70157. */
  70158. detailSampleMaxError: number;
  70159. }
  70160. }
  70161. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70162. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70163. import { Mesh } from "babylonjs/Meshes/mesh";
  70164. import { Scene } from "babylonjs/scene";
  70165. import { Vector3 } from "babylonjs/Maths/math";
  70166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70167. /**
  70168. * RecastJS navigation plugin
  70169. */
  70170. export class RecastJSPlugin implements INavigationEnginePlugin {
  70171. /**
  70172. * Reference to the Recast library
  70173. */
  70174. bjsRECAST: any;
  70175. /**
  70176. * plugin name
  70177. */
  70178. name: string;
  70179. /**
  70180. * the first navmesh created. We might extend this to support multiple navmeshes
  70181. */
  70182. navMesh: any;
  70183. /**
  70184. * Initializes the recastJS plugin
  70185. * @param recastInjection can be used to inject your own recast reference
  70186. */
  70187. constructor(recastInjection?: any);
  70188. /**
  70189. * Creates a navigation mesh
  70190. * @param meshes array of all the geometry used to compute the navigatio mesh
  70191. * @param parameters bunch of parameters used to filter geometry
  70192. */
  70193. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70194. /**
  70195. * Create a navigation mesh debug mesh
  70196. * @param scene is where the mesh will be added
  70197. * @returns debug display mesh
  70198. */
  70199. createDebugNavMesh(scene: Scene): Mesh;
  70200. /**
  70201. * Get a navigation mesh constrained position, closest to the parameter position
  70202. * @param position world position
  70203. * @returns the closest point to position constrained by the navigation mesh
  70204. */
  70205. getClosestPoint(position: Vector3): Vector3;
  70206. /**
  70207. * Get a navigation mesh constrained position, closest to the parameter position
  70208. * @param position world position
  70209. * @param result output the closest point to position constrained by the navigation mesh
  70210. */
  70211. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70212. /**
  70213. * Get a navigation mesh constrained position, within a particular radius
  70214. * @param position world position
  70215. * @param maxRadius the maximum distance to the constrained world position
  70216. * @returns the closest point to position constrained by the navigation mesh
  70217. */
  70218. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70219. /**
  70220. * Get a navigation mesh constrained position, within a particular radius
  70221. * @param position world position
  70222. * @param maxRadius the maximum distance to the constrained world position
  70223. * @param result output the closest point to position constrained by the navigation mesh
  70224. */
  70225. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70226. /**
  70227. * Compute the final position from a segment made of destination-position
  70228. * @param position world position
  70229. * @param destination world position
  70230. * @returns the resulting point along the navmesh
  70231. */
  70232. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70233. /**
  70234. * Compute the final position from a segment made of destination-position
  70235. * @param position world position
  70236. * @param destination world position
  70237. * @param result output the resulting point along the navmesh
  70238. */
  70239. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70240. /**
  70241. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70242. * @param start world position
  70243. * @param end world position
  70244. * @returns array containing world position composing the path
  70245. */
  70246. computePath(start: Vector3, end: Vector3): Vector3[];
  70247. /**
  70248. * Create a new Crowd so you can add agents
  70249. * @param maxAgents the maximum agent count in the crowd
  70250. * @param maxAgentRadius the maximum radius an agent can have
  70251. * @param scene to attach the crowd to
  70252. * @returns the crowd you can add agents to
  70253. */
  70254. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70255. /**
  70256. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70257. * The queries will try to find a solution within those bounds
  70258. * default is (1,1,1)
  70259. * @param extent x,y,z value that define the extent around the queries point of reference
  70260. */
  70261. setDefaultQueryExtent(extent: Vector3): void;
  70262. /**
  70263. * Get the Bounding box extent specified by setDefaultQueryExtent
  70264. * @returns the box extent values
  70265. */
  70266. getDefaultQueryExtent(): Vector3;
  70267. /**
  70268. * build the navmesh from a previously saved state using getNavmeshData
  70269. * @param data the Uint8Array returned by getNavmeshData
  70270. */
  70271. buildFromNavmeshData(data: Uint8Array): void;
  70272. /**
  70273. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70274. * @returns data the Uint8Array that can be saved and reused
  70275. */
  70276. getNavmeshData(): Uint8Array;
  70277. /**
  70278. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70279. * @param result output the box extent values
  70280. */
  70281. getDefaultQueryExtentToRef(result: Vector3): void;
  70282. /**
  70283. * Disposes
  70284. */
  70285. dispose(): void;
  70286. /**
  70287. * If this plugin is supported
  70288. * @returns true if plugin is supported
  70289. */
  70290. isSupported(): boolean;
  70291. }
  70292. /**
  70293. * Recast detour crowd implementation
  70294. */
  70295. export class RecastJSCrowd implements ICrowd {
  70296. /**
  70297. * Recast/detour plugin
  70298. */
  70299. bjsRECASTPlugin: RecastJSPlugin;
  70300. /**
  70301. * Link to the detour crowd
  70302. */
  70303. recastCrowd: any;
  70304. /**
  70305. * One transform per agent
  70306. */
  70307. transforms: TransformNode[];
  70308. /**
  70309. * All agents created
  70310. */
  70311. agents: number[];
  70312. /**
  70313. * Link to the scene is kept to unregister the crowd from the scene
  70314. */
  70315. private _scene;
  70316. /**
  70317. * Observer for crowd updates
  70318. */
  70319. private _onBeforeAnimationsObserver;
  70320. /**
  70321. * Constructor
  70322. * @param plugin recastJS plugin
  70323. * @param maxAgents the maximum agent count in the crowd
  70324. * @param maxAgentRadius the maximum radius an agent can have
  70325. * @param scene to attach the crowd to
  70326. * @returns the crowd you can add agents to
  70327. */
  70328. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70329. /**
  70330. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70331. * You can attach anything to that node. The node position is updated in the scene update tick.
  70332. * @param pos world position that will be constrained by the navigation mesh
  70333. * @param parameters agent parameters
  70334. * @param transform hooked to the agent that will be update by the scene
  70335. * @returns agent index
  70336. */
  70337. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70338. /**
  70339. * Returns the agent position in world space
  70340. * @param index agent index returned by addAgent
  70341. * @returns world space position
  70342. */
  70343. getAgentPosition(index: number): Vector3;
  70344. /**
  70345. * Returns the agent position result in world space
  70346. * @param index agent index returned by addAgent
  70347. * @param result output world space position
  70348. */
  70349. getAgentPositionToRef(index: number, result: Vector3): void;
  70350. /**
  70351. * Returns the agent velocity in world space
  70352. * @param index agent index returned by addAgent
  70353. * @returns world space velocity
  70354. */
  70355. getAgentVelocity(index: number): Vector3;
  70356. /**
  70357. * Returns the agent velocity result in world space
  70358. * @param index agent index returned by addAgent
  70359. * @param result output world space velocity
  70360. */
  70361. getAgentVelocityToRef(index: number, result: Vector3): void;
  70362. /**
  70363. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70364. * @param index agent index returned by addAgent
  70365. * @param destination targeted world position
  70366. */
  70367. agentGoto(index: number, destination: Vector3): void;
  70368. /**
  70369. * Teleport the agent to a new position
  70370. * @param index agent index returned by addAgent
  70371. * @param destination targeted world position
  70372. */
  70373. agentTeleport(index: number, destination: Vector3): void;
  70374. /**
  70375. * Update agent parameters
  70376. * @param index agent index returned by addAgent
  70377. * @param parameters agent parameters
  70378. */
  70379. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70380. /**
  70381. * remove a particular agent previously created
  70382. * @param index agent index returned by addAgent
  70383. */
  70384. removeAgent(index: number): void;
  70385. /**
  70386. * get the list of all agents attached to this crowd
  70387. * @returns list of agent indices
  70388. */
  70389. getAgents(): number[];
  70390. /**
  70391. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70392. * @param deltaTime in seconds
  70393. */
  70394. update(deltaTime: number): void;
  70395. /**
  70396. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70397. * The queries will try to find a solution within those bounds
  70398. * default is (1,1,1)
  70399. * @param extent x,y,z value that define the extent around the queries point of reference
  70400. */
  70401. setDefaultQueryExtent(extent: Vector3): void;
  70402. /**
  70403. * Get the Bounding box extent specified by setDefaultQueryExtent
  70404. * @returns the box extent values
  70405. */
  70406. getDefaultQueryExtent(): Vector3;
  70407. /**
  70408. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70409. * @param result output the box extent values
  70410. */
  70411. getDefaultQueryExtentToRef(result: Vector3): void;
  70412. /**
  70413. * Release all resources
  70414. */
  70415. dispose(): void;
  70416. }
  70417. }
  70418. declare module "babylonjs/Navigation/Plugins/index" {
  70419. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70420. }
  70421. declare module "babylonjs/Navigation/index" {
  70422. export * from "babylonjs/Navigation/INavigationEngine";
  70423. export * from "babylonjs/Navigation/Plugins/index";
  70424. }
  70425. declare module "babylonjs/Offline/database" {
  70426. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70427. /**
  70428. * Class used to enable access to IndexedDB
  70429. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70430. */
  70431. export class Database implements IOfflineProvider {
  70432. private _callbackManifestChecked;
  70433. private _currentSceneUrl;
  70434. private _db;
  70435. private _enableSceneOffline;
  70436. private _enableTexturesOffline;
  70437. private _manifestVersionFound;
  70438. private _mustUpdateRessources;
  70439. private _hasReachedQuota;
  70440. private _isSupported;
  70441. private _idbFactory;
  70442. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70443. private static IsUASupportingBlobStorage;
  70444. /**
  70445. * Gets a boolean indicating if Database storate is enabled (off by default)
  70446. */
  70447. static IDBStorageEnabled: boolean;
  70448. /**
  70449. * Gets a boolean indicating if scene must be saved in the database
  70450. */
  70451. get enableSceneOffline(): boolean;
  70452. /**
  70453. * Gets a boolean indicating if textures must be saved in the database
  70454. */
  70455. get enableTexturesOffline(): boolean;
  70456. /**
  70457. * Creates a new Database
  70458. * @param urlToScene defines the url to load the scene
  70459. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70460. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70461. */
  70462. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70463. private static _ParseURL;
  70464. private static _ReturnFullUrlLocation;
  70465. private _checkManifestFile;
  70466. /**
  70467. * Open the database and make it available
  70468. * @param successCallback defines the callback to call on success
  70469. * @param errorCallback defines the callback to call on error
  70470. */
  70471. open(successCallback: () => void, errorCallback: () => void): void;
  70472. /**
  70473. * Loads an image from the database
  70474. * @param url defines the url to load from
  70475. * @param image defines the target DOM image
  70476. */
  70477. loadImage(url: string, image: HTMLImageElement): void;
  70478. private _loadImageFromDBAsync;
  70479. private _saveImageIntoDBAsync;
  70480. private _checkVersionFromDB;
  70481. private _loadVersionFromDBAsync;
  70482. private _saveVersionIntoDBAsync;
  70483. /**
  70484. * Loads a file from database
  70485. * @param url defines the URL to load from
  70486. * @param sceneLoaded defines a callback to call on success
  70487. * @param progressCallBack defines a callback to call when progress changed
  70488. * @param errorCallback defines a callback to call on error
  70489. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70490. */
  70491. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70492. private _loadFileAsync;
  70493. private _saveFileAsync;
  70494. /**
  70495. * Validates if xhr data is correct
  70496. * @param xhr defines the request to validate
  70497. * @param dataType defines the expected data type
  70498. * @returns true if data is correct
  70499. */
  70500. private static _ValidateXHRData;
  70501. }
  70502. }
  70503. declare module "babylonjs/Offline/index" {
  70504. export * from "babylonjs/Offline/database";
  70505. export * from "babylonjs/Offline/IOfflineProvider";
  70506. }
  70507. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70508. /** @hidden */
  70509. export var gpuUpdateParticlesPixelShader: {
  70510. name: string;
  70511. shader: string;
  70512. };
  70513. }
  70514. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70515. /** @hidden */
  70516. export var gpuUpdateParticlesVertexShader: {
  70517. name: string;
  70518. shader: string;
  70519. };
  70520. }
  70521. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70522. /** @hidden */
  70523. export var clipPlaneFragmentDeclaration2: {
  70524. name: string;
  70525. shader: string;
  70526. };
  70527. }
  70528. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70529. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70530. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70531. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70532. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70533. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70534. /** @hidden */
  70535. export var gpuRenderParticlesPixelShader: {
  70536. name: string;
  70537. shader: string;
  70538. };
  70539. }
  70540. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70541. /** @hidden */
  70542. export var clipPlaneVertexDeclaration2: {
  70543. name: string;
  70544. shader: string;
  70545. };
  70546. }
  70547. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70548. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70549. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70550. /** @hidden */
  70551. export var gpuRenderParticlesVertexShader: {
  70552. name: string;
  70553. shader: string;
  70554. };
  70555. }
  70556. declare module "babylonjs/Particles/gpuParticleSystem" {
  70557. import { Nullable } from "babylonjs/types";
  70558. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70559. import { Observable } from "babylonjs/Misc/observable";
  70560. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70561. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70562. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70563. import { Scene, IDisposable } from "babylonjs/scene";
  70564. import { Effect } from "babylonjs/Materials/effect";
  70565. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70566. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70567. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70568. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70569. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70570. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70571. /**
  70572. * This represents a GPU particle system in Babylon
  70573. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70574. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70575. */
  70576. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70577. /**
  70578. * The layer mask we are rendering the particles through.
  70579. */
  70580. layerMask: number;
  70581. private _capacity;
  70582. private _activeCount;
  70583. private _currentActiveCount;
  70584. private _accumulatedCount;
  70585. private _renderEffect;
  70586. private _updateEffect;
  70587. private _buffer0;
  70588. private _buffer1;
  70589. private _spriteBuffer;
  70590. private _updateVAO;
  70591. private _renderVAO;
  70592. private _targetIndex;
  70593. private _sourceBuffer;
  70594. private _targetBuffer;
  70595. private _engine;
  70596. private _currentRenderId;
  70597. private _started;
  70598. private _stopped;
  70599. private _timeDelta;
  70600. private _randomTexture;
  70601. private _randomTexture2;
  70602. private _attributesStrideSize;
  70603. private _updateEffectOptions;
  70604. private _randomTextureSize;
  70605. private _actualFrame;
  70606. private _customEffect;
  70607. private readonly _rawTextureWidth;
  70608. /**
  70609. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70610. */
  70611. static get IsSupported(): boolean;
  70612. /**
  70613. * An event triggered when the system is disposed.
  70614. */
  70615. onDisposeObservable: Observable<IParticleSystem>;
  70616. /**
  70617. * Gets the maximum number of particles active at the same time.
  70618. * @returns The max number of active particles.
  70619. */
  70620. getCapacity(): number;
  70621. /**
  70622. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70623. * to override the particles.
  70624. */
  70625. forceDepthWrite: boolean;
  70626. /**
  70627. * Gets or set the number of active particles
  70628. */
  70629. get activeParticleCount(): number;
  70630. set activeParticleCount(value: number);
  70631. private _preWarmDone;
  70632. /**
  70633. * Specifies if the particles are updated in emitter local space or world space.
  70634. */
  70635. isLocal: boolean;
  70636. /**
  70637. * Is this system ready to be used/rendered
  70638. * @return true if the system is ready
  70639. */
  70640. isReady(): boolean;
  70641. /**
  70642. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70643. * @returns True if it has been started, otherwise false.
  70644. */
  70645. isStarted(): boolean;
  70646. /**
  70647. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70648. * @returns True if it has been stopped, otherwise false.
  70649. */
  70650. isStopped(): boolean;
  70651. /**
  70652. * Gets a boolean indicating that the system is stopping
  70653. * @returns true if the system is currently stopping
  70654. */
  70655. isStopping(): boolean;
  70656. /**
  70657. * Gets the number of particles active at the same time.
  70658. * @returns The number of active particles.
  70659. */
  70660. getActiveCount(): number;
  70661. /**
  70662. * Starts the particle system and begins to emit
  70663. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70664. */
  70665. start(delay?: number): void;
  70666. /**
  70667. * Stops the particle system.
  70668. */
  70669. stop(): void;
  70670. /**
  70671. * Remove all active particles
  70672. */
  70673. reset(): void;
  70674. /**
  70675. * Returns the string "GPUParticleSystem"
  70676. * @returns a string containing the class name
  70677. */
  70678. getClassName(): string;
  70679. /**
  70680. * Gets the custom effect used to render the particles
  70681. * @param blendMode Blend mode for which the effect should be retrieved
  70682. * @returns The effect
  70683. */
  70684. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70685. /**
  70686. * Sets the custom effect used to render the particles
  70687. * @param effect The effect to set
  70688. * @param blendMode Blend mode for which the effect should be set
  70689. */
  70690. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70691. /** @hidden */
  70692. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70693. /**
  70694. * Observable that will be called just before the particles are drawn
  70695. */
  70696. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70697. /**
  70698. * Gets the name of the particle vertex shader
  70699. */
  70700. get vertexShaderName(): string;
  70701. private _colorGradientsTexture;
  70702. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70703. /**
  70704. * Adds a new color gradient
  70705. * @param gradient defines the gradient to use (between 0 and 1)
  70706. * @param color1 defines the color to affect to the specified gradient
  70707. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70708. * @returns the current particle system
  70709. */
  70710. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70711. private _refreshColorGradient;
  70712. /** Force the system to rebuild all gradients that need to be resync */
  70713. forceRefreshGradients(): void;
  70714. /**
  70715. * Remove a specific color gradient
  70716. * @param gradient defines the gradient to remove
  70717. * @returns the current particle system
  70718. */
  70719. removeColorGradient(gradient: number): GPUParticleSystem;
  70720. private _angularSpeedGradientsTexture;
  70721. private _sizeGradientsTexture;
  70722. private _velocityGradientsTexture;
  70723. private _limitVelocityGradientsTexture;
  70724. private _dragGradientsTexture;
  70725. private _addFactorGradient;
  70726. /**
  70727. * Adds a new size gradient
  70728. * @param gradient defines the gradient to use (between 0 and 1)
  70729. * @param factor defines the size factor to affect to the specified gradient
  70730. * @returns the current particle system
  70731. */
  70732. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70733. /**
  70734. * Remove a specific size gradient
  70735. * @param gradient defines the gradient to remove
  70736. * @returns the current particle system
  70737. */
  70738. removeSizeGradient(gradient: number): GPUParticleSystem;
  70739. private _refreshFactorGradient;
  70740. /**
  70741. * Adds a new angular speed gradient
  70742. * @param gradient defines the gradient to use (between 0 and 1)
  70743. * @param factor defines the angular speed to affect to the specified gradient
  70744. * @returns the current particle system
  70745. */
  70746. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70747. /**
  70748. * Remove a specific angular speed gradient
  70749. * @param gradient defines the gradient to remove
  70750. * @returns the current particle system
  70751. */
  70752. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70753. /**
  70754. * Adds a new velocity gradient
  70755. * @param gradient defines the gradient to use (between 0 and 1)
  70756. * @param factor defines the velocity to affect to the specified gradient
  70757. * @returns the current particle system
  70758. */
  70759. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70760. /**
  70761. * Remove a specific velocity gradient
  70762. * @param gradient defines the gradient to remove
  70763. * @returns the current particle system
  70764. */
  70765. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70766. /**
  70767. * Adds a new limit velocity gradient
  70768. * @param gradient defines the gradient to use (between 0 and 1)
  70769. * @param factor defines the limit velocity value to affect to the specified gradient
  70770. * @returns the current particle system
  70771. */
  70772. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70773. /**
  70774. * Remove a specific limit velocity gradient
  70775. * @param gradient defines the gradient to remove
  70776. * @returns the current particle system
  70777. */
  70778. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70779. /**
  70780. * Adds a new drag gradient
  70781. * @param gradient defines the gradient to use (between 0 and 1)
  70782. * @param factor defines the drag value to affect to the specified gradient
  70783. * @returns the current particle system
  70784. */
  70785. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70786. /**
  70787. * Remove a specific drag gradient
  70788. * @param gradient defines the gradient to remove
  70789. * @returns the current particle system
  70790. */
  70791. removeDragGradient(gradient: number): GPUParticleSystem;
  70792. /**
  70793. * Not supported by GPUParticleSystem
  70794. * @param gradient defines the gradient to use (between 0 and 1)
  70795. * @param factor defines the emit rate value to affect to the specified gradient
  70796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70797. * @returns the current particle system
  70798. */
  70799. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70800. /**
  70801. * Not supported by GPUParticleSystem
  70802. * @param gradient defines the gradient to remove
  70803. * @returns the current particle system
  70804. */
  70805. removeEmitRateGradient(gradient: number): IParticleSystem;
  70806. /**
  70807. * Not supported by GPUParticleSystem
  70808. * @param gradient defines the gradient to use (between 0 and 1)
  70809. * @param factor defines the start size value to affect to the specified gradient
  70810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70811. * @returns the current particle system
  70812. */
  70813. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70814. /**
  70815. * Not supported by GPUParticleSystem
  70816. * @param gradient defines the gradient to remove
  70817. * @returns the current particle system
  70818. */
  70819. removeStartSizeGradient(gradient: number): IParticleSystem;
  70820. /**
  70821. * Not supported by GPUParticleSystem
  70822. * @param gradient defines the gradient to use (between 0 and 1)
  70823. * @param min defines the color remap minimal range
  70824. * @param max defines the color remap maximal range
  70825. * @returns the current particle system
  70826. */
  70827. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70828. /**
  70829. * Not supported by GPUParticleSystem
  70830. * @param gradient defines the gradient to remove
  70831. * @returns the current particle system
  70832. */
  70833. removeColorRemapGradient(): IParticleSystem;
  70834. /**
  70835. * Not supported by GPUParticleSystem
  70836. * @param gradient defines the gradient to use (between 0 and 1)
  70837. * @param min defines the alpha remap minimal range
  70838. * @param max defines the alpha remap maximal range
  70839. * @returns the current particle system
  70840. */
  70841. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70842. /**
  70843. * Not supported by GPUParticleSystem
  70844. * @param gradient defines the gradient to remove
  70845. * @returns the current particle system
  70846. */
  70847. removeAlphaRemapGradient(): IParticleSystem;
  70848. /**
  70849. * Not supported by GPUParticleSystem
  70850. * @param gradient defines the gradient to use (between 0 and 1)
  70851. * @param color defines the color to affect to the specified gradient
  70852. * @returns the current particle system
  70853. */
  70854. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70855. /**
  70856. * Not supported by GPUParticleSystem
  70857. * @param gradient defines the gradient to remove
  70858. * @returns the current particle system
  70859. */
  70860. removeRampGradient(): IParticleSystem;
  70861. /**
  70862. * Not supported by GPUParticleSystem
  70863. * @returns the list of ramp gradients
  70864. */
  70865. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70866. /**
  70867. * Not supported by GPUParticleSystem
  70868. * Gets or sets a boolean indicating that ramp gradients must be used
  70869. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70870. */
  70871. get useRampGradients(): boolean;
  70872. set useRampGradients(value: boolean);
  70873. /**
  70874. * Not supported by GPUParticleSystem
  70875. * @param gradient defines the gradient to use (between 0 and 1)
  70876. * @param factor defines the life time factor to affect to the specified gradient
  70877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70878. * @returns the current particle system
  70879. */
  70880. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70881. /**
  70882. * Not supported by GPUParticleSystem
  70883. * @param gradient defines the gradient to remove
  70884. * @returns the current particle system
  70885. */
  70886. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70887. /**
  70888. * Instantiates a GPU particle system.
  70889. * 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.
  70890. * @param name The name of the particle system
  70891. * @param options The options used to create the system
  70892. * @param scene The scene the particle system belongs to
  70893. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70894. * @param customEffect a custom effect used to change the way particles are rendered by default
  70895. */
  70896. constructor(name: string, options: Partial<{
  70897. capacity: number;
  70898. randomTextureSize: number;
  70899. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70900. protected _reset(): void;
  70901. private _createUpdateVAO;
  70902. private _createRenderVAO;
  70903. private _initialize;
  70904. /** @hidden */
  70905. _recreateUpdateEffect(): void;
  70906. private _getEffect;
  70907. /**
  70908. * Fill the defines array according to the current settings of the particle system
  70909. * @param defines Array to be updated
  70910. * @param blendMode blend mode to take into account when updating the array
  70911. */
  70912. fillDefines(defines: Array<string>, blendMode?: number): void;
  70913. /**
  70914. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70915. * @param uniforms Uniforms array to fill
  70916. * @param attributes Attributes array to fill
  70917. * @param samplers Samplers array to fill
  70918. */
  70919. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70920. /** @hidden */
  70921. _recreateRenderEffect(): Effect;
  70922. /**
  70923. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70924. * @param preWarm defines if we are in the pre-warmimg phase
  70925. */
  70926. animate(preWarm?: boolean): void;
  70927. private _createFactorGradientTexture;
  70928. private _createSizeGradientTexture;
  70929. private _createAngularSpeedGradientTexture;
  70930. private _createVelocityGradientTexture;
  70931. private _createLimitVelocityGradientTexture;
  70932. private _createDragGradientTexture;
  70933. private _createColorGradientTexture;
  70934. /**
  70935. * Renders the particle system in its current state
  70936. * @param preWarm defines if the system should only update the particles but not render them
  70937. * @returns the current number of particles
  70938. */
  70939. render(preWarm?: boolean): number;
  70940. /**
  70941. * Rebuilds the particle system
  70942. */
  70943. rebuild(): void;
  70944. private _releaseBuffers;
  70945. private _releaseVAOs;
  70946. /**
  70947. * Disposes the particle system and free the associated resources
  70948. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70949. */
  70950. dispose(disposeTexture?: boolean): void;
  70951. /**
  70952. * Clones the particle system.
  70953. * @param name The name of the cloned object
  70954. * @param newEmitter The new emitter to use
  70955. * @returns the cloned particle system
  70956. */
  70957. clone(name: string, newEmitter: any): GPUParticleSystem;
  70958. /**
  70959. * Serializes the particle system to a JSON object
  70960. * @param serializeTexture defines if the texture must be serialized as well
  70961. * @returns the JSON object
  70962. */
  70963. serialize(serializeTexture?: boolean): any;
  70964. /**
  70965. * Parses a JSON object to create a GPU particle system.
  70966. * @param parsedParticleSystem The JSON object to parse
  70967. * @param scene The scene to create the particle system in
  70968. * @param rootUrl The root url to use to load external dependencies like texture
  70969. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70970. * @returns the parsed GPU particle system
  70971. */
  70972. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70973. }
  70974. }
  70975. declare module "babylonjs/Particles/particleSystemSet" {
  70976. import { Nullable } from "babylonjs/types";
  70977. import { Color3 } from "babylonjs/Maths/math.color";
  70978. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70980. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70981. import { Scene, IDisposable } from "babylonjs/scene";
  70982. /**
  70983. * Represents a set of particle systems working together to create a specific effect
  70984. */
  70985. export class ParticleSystemSet implements IDisposable {
  70986. /**
  70987. * Gets or sets base Assets URL
  70988. */
  70989. static BaseAssetsUrl: string;
  70990. private _emitterCreationOptions;
  70991. private _emitterNode;
  70992. /**
  70993. * Gets the particle system list
  70994. */
  70995. systems: IParticleSystem[];
  70996. /**
  70997. * Gets the emitter node used with this set
  70998. */
  70999. get emitterNode(): Nullable<TransformNode>;
  71000. /**
  71001. * Creates a new emitter mesh as a sphere
  71002. * @param options defines the options used to create the sphere
  71003. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71004. * @param scene defines the hosting scene
  71005. */
  71006. setEmitterAsSphere(options: {
  71007. diameter: number;
  71008. segments: number;
  71009. color: Color3;
  71010. }, renderingGroupId: number, scene: Scene): void;
  71011. /**
  71012. * Starts all particle systems of the set
  71013. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71014. */
  71015. start(emitter?: AbstractMesh): void;
  71016. /**
  71017. * Release all associated resources
  71018. */
  71019. dispose(): void;
  71020. /**
  71021. * Serialize the set into a JSON compatible object
  71022. * @param serializeTexture defines if the texture must be serialized as well
  71023. * @returns a JSON compatible representation of the set
  71024. */
  71025. serialize(serializeTexture?: boolean): any;
  71026. /**
  71027. * Parse a new ParticleSystemSet from a serialized source
  71028. * @param data defines a JSON compatible representation of the set
  71029. * @param scene defines the hosting scene
  71030. * @param gpu defines if we want GPU particles or CPU particles
  71031. * @returns a new ParticleSystemSet
  71032. */
  71033. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71034. }
  71035. }
  71036. declare module "babylonjs/Particles/particleHelper" {
  71037. import { Nullable } from "babylonjs/types";
  71038. import { Scene } from "babylonjs/scene";
  71039. import { Vector3 } from "babylonjs/Maths/math.vector";
  71040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71041. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71042. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71043. /**
  71044. * This class is made for on one-liner static method to help creating particle system set.
  71045. */
  71046. export class ParticleHelper {
  71047. /**
  71048. * Gets or sets base Assets URL
  71049. */
  71050. static BaseAssetsUrl: string;
  71051. /** Define the Url to load snippets */
  71052. static SnippetUrl: string;
  71053. /**
  71054. * Create a default particle system that you can tweak
  71055. * @param emitter defines the emitter to use
  71056. * @param capacity defines the system capacity (default is 500 particles)
  71057. * @param scene defines the hosting scene
  71058. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71059. * @returns the new Particle system
  71060. */
  71061. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71062. /**
  71063. * This is the main static method (one-liner) of this helper to create different particle systems
  71064. * @param type This string represents the type to the particle system to create
  71065. * @param scene The scene where the particle system should live
  71066. * @param gpu If the system will use gpu
  71067. * @returns the ParticleSystemSet created
  71068. */
  71069. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71070. /**
  71071. * Static function used to export a particle system to a ParticleSystemSet variable.
  71072. * Please note that the emitter shape is not exported
  71073. * @param systems defines the particle systems to export
  71074. * @returns the created particle system set
  71075. */
  71076. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71077. /**
  71078. * Creates a particle system from a snippet saved in a remote file
  71079. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71080. * @param url defines the url to load from
  71081. * @param scene defines the hosting scene
  71082. * @param gpu If the system will use gpu
  71083. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71084. * @returns a promise that will resolve to the new particle system
  71085. */
  71086. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71087. /**
  71088. * Creates a particle system from a snippet saved by the particle system editor
  71089. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71090. * @param scene defines the hosting scene
  71091. * @param gpu If the system will use gpu
  71092. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71093. * @returns a promise that will resolve to the new particle system
  71094. */
  71095. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71096. }
  71097. }
  71098. declare module "babylonjs/Particles/particleSystemComponent" {
  71099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71100. import { Effect } from "babylonjs/Materials/effect";
  71101. import "babylonjs/Shaders/particles.vertex";
  71102. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71103. module "babylonjs/Engines/engine" {
  71104. interface Engine {
  71105. /**
  71106. * Create an effect to use with particle systems.
  71107. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71108. * the particle system for which you want to create a custom effect in the last parameter
  71109. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71110. * @param uniformsNames defines a list of attribute names
  71111. * @param samplers defines an array of string used to represent textures
  71112. * @param defines defines the string containing the defines to use to compile the shaders
  71113. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71114. * @param onCompiled defines a function to call when the effect creation is successful
  71115. * @param onError defines a function to call when the effect creation has failed
  71116. * @param particleSystem the particle system you want to create the effect for
  71117. * @returns the new Effect
  71118. */
  71119. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71120. }
  71121. }
  71122. module "babylonjs/Meshes/mesh" {
  71123. interface Mesh {
  71124. /**
  71125. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71126. * @returns an array of IParticleSystem
  71127. */
  71128. getEmittedParticleSystems(): IParticleSystem[];
  71129. /**
  71130. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71131. * @returns an array of IParticleSystem
  71132. */
  71133. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71134. }
  71135. }
  71136. }
  71137. declare module "babylonjs/Particles/pointsCloudSystem" {
  71138. import { Color4 } from "babylonjs/Maths/math";
  71139. import { Mesh } from "babylonjs/Meshes/mesh";
  71140. import { Scene, IDisposable } from "babylonjs/scene";
  71141. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71142. /** Defines the 4 color options */
  71143. export enum PointColor {
  71144. /** color value */
  71145. Color = 2,
  71146. /** uv value */
  71147. UV = 1,
  71148. /** random value */
  71149. Random = 0,
  71150. /** stated value */
  71151. Stated = 3
  71152. }
  71153. /**
  71154. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71155. * 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.
  71156. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71157. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71158. *
  71159. * Full documentation here : TO BE ENTERED
  71160. */
  71161. export class PointsCloudSystem implements IDisposable {
  71162. /**
  71163. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71164. * Example : var p = SPS.particles[i];
  71165. */
  71166. particles: CloudPoint[];
  71167. /**
  71168. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71169. */
  71170. nbParticles: number;
  71171. /**
  71172. * This a counter for your own usage. It's not set by any SPS functions.
  71173. */
  71174. counter: number;
  71175. /**
  71176. * The PCS name. This name is also given to the underlying mesh.
  71177. */
  71178. name: string;
  71179. /**
  71180. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71181. */
  71182. mesh: Mesh;
  71183. /**
  71184. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71185. * Please read :
  71186. */
  71187. vars: any;
  71188. /**
  71189. * @hidden
  71190. */
  71191. _size: number;
  71192. private _scene;
  71193. private _promises;
  71194. private _positions;
  71195. private _indices;
  71196. private _normals;
  71197. private _colors;
  71198. private _uvs;
  71199. private _indices32;
  71200. private _positions32;
  71201. private _colors32;
  71202. private _uvs32;
  71203. private _updatable;
  71204. private _isVisibilityBoxLocked;
  71205. private _alwaysVisible;
  71206. private _groups;
  71207. private _groupCounter;
  71208. private _computeParticleColor;
  71209. private _computeParticleTexture;
  71210. private _computeParticleRotation;
  71211. private _computeBoundingBox;
  71212. private _isReady;
  71213. /**
  71214. * Creates a PCS (Points Cloud System) object
  71215. * @param name (String) is the PCS name, this will be the underlying mesh name
  71216. * @param pointSize (number) is the size for each point
  71217. * @param scene (Scene) is the scene in which the PCS is added
  71218. * @param options defines the options of the PCS e.g.
  71219. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71220. */
  71221. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71222. updatable?: boolean;
  71223. });
  71224. /**
  71225. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71226. * If no points were added to the PCS, the returned mesh is just a single point.
  71227. * @returns a promise for the created mesh
  71228. */
  71229. buildMeshAsync(): Promise<Mesh>;
  71230. /**
  71231. * @hidden
  71232. */
  71233. private _buildMesh;
  71234. private _addParticle;
  71235. private _randomUnitVector;
  71236. private _getColorIndicesForCoord;
  71237. private _setPointsColorOrUV;
  71238. private _colorFromTexture;
  71239. private _calculateDensity;
  71240. /**
  71241. * Adds points to the PCS in random positions within a unit sphere
  71242. * @param nb (positive integer) the number of particles to be created from this model
  71243. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71244. * @returns the number of groups in the system
  71245. */
  71246. addPoints(nb: number, pointFunction?: any): number;
  71247. /**
  71248. * Adds points to the PCS from the surface of the model shape
  71249. * @param mesh is any Mesh object that will be used as a surface model for the points
  71250. * @param nb (positive integer) the number of particles to be created from this model
  71251. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71252. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71253. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71254. * @returns the number of groups in the system
  71255. */
  71256. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71257. /**
  71258. * Adds points to the PCS inside the model shape
  71259. * @param mesh is any Mesh object that will be used as a surface model for the points
  71260. * @param nb (positive integer) the number of particles to be created from this model
  71261. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71262. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71263. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71264. * @returns the number of groups in the system
  71265. */
  71266. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71267. /**
  71268. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71269. * This method calls `updateParticle()` for each particle of the SPS.
  71270. * For an animated SPS, it is usually called within the render loop.
  71271. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71272. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71273. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71274. * @returns the PCS.
  71275. */
  71276. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71277. /**
  71278. * Disposes the PCS.
  71279. */
  71280. dispose(): void;
  71281. /**
  71282. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71283. * doc :
  71284. * @returns the PCS.
  71285. */
  71286. refreshVisibleSize(): PointsCloudSystem;
  71287. /**
  71288. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71289. * @param size the size (float) of the visibility box
  71290. * note : this doesn't lock the PCS mesh bounding box.
  71291. * doc :
  71292. */
  71293. setVisibilityBox(size: number): void;
  71294. /**
  71295. * Gets whether the PCS is always visible or not
  71296. * doc :
  71297. */
  71298. get isAlwaysVisible(): boolean;
  71299. /**
  71300. * Sets the PCS as always visible or not
  71301. * doc :
  71302. */
  71303. set isAlwaysVisible(val: boolean);
  71304. /**
  71305. * Tells to `setParticles()` to compute the particle rotations or not
  71306. * Default value : false. The PCS is faster when it's set to false
  71307. * Note : particle rotations are only applied to parent particles
  71308. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71309. */
  71310. set computeParticleRotation(val: boolean);
  71311. /**
  71312. * Tells to `setParticles()` to compute the particle colors or not.
  71313. * Default value : true. The PCS is faster when it's set to false.
  71314. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71315. */
  71316. set computeParticleColor(val: boolean);
  71317. set computeParticleTexture(val: boolean);
  71318. /**
  71319. * Gets if `setParticles()` computes the particle colors or not.
  71320. * Default value : false. The PCS is faster when it's set to false.
  71321. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71322. */
  71323. get computeParticleColor(): boolean;
  71324. /**
  71325. * Gets if `setParticles()` computes the particle textures or not.
  71326. * Default value : false. The PCS is faster when it's set to false.
  71327. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71328. */
  71329. get computeParticleTexture(): boolean;
  71330. /**
  71331. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71332. */
  71333. set computeBoundingBox(val: boolean);
  71334. /**
  71335. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71336. */
  71337. get computeBoundingBox(): boolean;
  71338. /**
  71339. * This function does nothing. It may be overwritten to set all the particle first values.
  71340. * The PCS doesn't call this function, you may have to call it by your own.
  71341. * doc :
  71342. */
  71343. initParticles(): void;
  71344. /**
  71345. * This function does nothing. It may be overwritten to recycle a particle
  71346. * The PCS doesn't call this function, you can to call it
  71347. * doc :
  71348. * @param particle The particle to recycle
  71349. * @returns the recycled particle
  71350. */
  71351. recycleParticle(particle: CloudPoint): CloudPoint;
  71352. /**
  71353. * Updates a particle : this function should be overwritten by the user.
  71354. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71355. * doc :
  71356. * @example : just set a particle position or velocity and recycle conditions
  71357. * @param particle The particle to update
  71358. * @returns the updated particle
  71359. */
  71360. updateParticle(particle: CloudPoint): CloudPoint;
  71361. /**
  71362. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71363. * This does nothing and may be overwritten by the user.
  71364. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71365. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71366. * @param update the boolean update value actually passed to setParticles()
  71367. */
  71368. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71369. /**
  71370. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71371. * This will be passed three parameters.
  71372. * This does nothing and may be overwritten by the user.
  71373. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71374. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71375. * @param update the boolean update value actually passed to setParticles()
  71376. */
  71377. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71378. }
  71379. }
  71380. declare module "babylonjs/Particles/cloudPoint" {
  71381. import { Nullable } from "babylonjs/types";
  71382. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71383. import { Mesh } from "babylonjs/Meshes/mesh";
  71384. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71385. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71386. /**
  71387. * Represents one particle of a points cloud system.
  71388. */
  71389. export class CloudPoint {
  71390. /**
  71391. * particle global index
  71392. */
  71393. idx: number;
  71394. /**
  71395. * The color of the particle
  71396. */
  71397. color: Nullable<Color4>;
  71398. /**
  71399. * The world space position of the particle.
  71400. */
  71401. position: Vector3;
  71402. /**
  71403. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71404. */
  71405. rotation: Vector3;
  71406. /**
  71407. * The world space rotation quaternion of the particle.
  71408. */
  71409. rotationQuaternion: Nullable<Quaternion>;
  71410. /**
  71411. * The uv of the particle.
  71412. */
  71413. uv: Nullable<Vector2>;
  71414. /**
  71415. * The current speed of the particle.
  71416. */
  71417. velocity: Vector3;
  71418. /**
  71419. * The pivot point in the particle local space.
  71420. */
  71421. pivot: Vector3;
  71422. /**
  71423. * Must the particle be translated from its pivot point in its local space ?
  71424. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71425. * Default : false
  71426. */
  71427. translateFromPivot: boolean;
  71428. /**
  71429. * Index of this particle in the global "positions" array (Internal use)
  71430. * @hidden
  71431. */
  71432. _pos: number;
  71433. /**
  71434. * @hidden Index of this particle in the global "indices" array (Internal use)
  71435. */
  71436. _ind: number;
  71437. /**
  71438. * Group this particle belongs to
  71439. */
  71440. _group: PointsGroup;
  71441. /**
  71442. * Group id of this particle
  71443. */
  71444. groupId: number;
  71445. /**
  71446. * Index of the particle in its group id (Internal use)
  71447. */
  71448. idxInGroup: number;
  71449. /**
  71450. * @hidden Particle BoundingInfo object (Internal use)
  71451. */
  71452. _boundingInfo: BoundingInfo;
  71453. /**
  71454. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71455. */
  71456. _pcs: PointsCloudSystem;
  71457. /**
  71458. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71459. */
  71460. _stillInvisible: boolean;
  71461. /**
  71462. * @hidden Last computed particle rotation matrix
  71463. */
  71464. _rotationMatrix: number[];
  71465. /**
  71466. * Parent particle Id, if any.
  71467. * Default null.
  71468. */
  71469. parentId: Nullable<number>;
  71470. /**
  71471. * @hidden Internal global position in the PCS.
  71472. */
  71473. _globalPosition: Vector3;
  71474. /**
  71475. * Creates a Point Cloud object.
  71476. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71477. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71478. * @param group (PointsGroup) is the group the particle belongs to
  71479. * @param groupId (integer) is the group identifier in the PCS.
  71480. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71481. * @param pcs defines the PCS it is associated to
  71482. */
  71483. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71484. /**
  71485. * get point size
  71486. */
  71487. get size(): Vector3;
  71488. /**
  71489. * Set point size
  71490. */
  71491. set size(scale: Vector3);
  71492. /**
  71493. * Legacy support, changed quaternion to rotationQuaternion
  71494. */
  71495. get quaternion(): Nullable<Quaternion>;
  71496. /**
  71497. * Legacy support, changed quaternion to rotationQuaternion
  71498. */
  71499. set quaternion(q: Nullable<Quaternion>);
  71500. /**
  71501. * Returns a boolean. True if the particle intersects a mesh, else false
  71502. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71503. * @param target is the object (point or mesh) what the intersection is computed against
  71504. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71505. * @returns true if it intersects
  71506. */
  71507. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71508. /**
  71509. * get the rotation matrix of the particle
  71510. * @hidden
  71511. */
  71512. getRotationMatrix(m: Matrix): void;
  71513. }
  71514. /**
  71515. * Represents a group of points in a points cloud system
  71516. * * PCS internal tool, don't use it manually.
  71517. */
  71518. export class PointsGroup {
  71519. /**
  71520. * The group id
  71521. * @hidden
  71522. */
  71523. groupID: number;
  71524. /**
  71525. * image data for group (internal use)
  71526. * @hidden
  71527. */
  71528. _groupImageData: Nullable<ArrayBufferView>;
  71529. /**
  71530. * Image Width (internal use)
  71531. * @hidden
  71532. */
  71533. _groupImgWidth: number;
  71534. /**
  71535. * Image Height (internal use)
  71536. * @hidden
  71537. */
  71538. _groupImgHeight: number;
  71539. /**
  71540. * Custom position function (internal use)
  71541. * @hidden
  71542. */
  71543. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71544. /**
  71545. * density per facet for surface points
  71546. * @hidden
  71547. */
  71548. _groupDensity: number[];
  71549. /**
  71550. * Only when points are colored by texture carries pointer to texture list array
  71551. * @hidden
  71552. */
  71553. _textureNb: number;
  71554. /**
  71555. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71556. * PCS internal tool, don't use it manually.
  71557. * @hidden
  71558. */
  71559. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71560. }
  71561. }
  71562. declare module "babylonjs/Particles/index" {
  71563. export * from "babylonjs/Particles/baseParticleSystem";
  71564. export * from "babylonjs/Particles/EmitterTypes/index";
  71565. export * from "babylonjs/Particles/gpuParticleSystem";
  71566. export * from "babylonjs/Particles/IParticleSystem";
  71567. export * from "babylonjs/Particles/particle";
  71568. export * from "babylonjs/Particles/particleHelper";
  71569. export * from "babylonjs/Particles/particleSystem";
  71570. import "babylonjs/Particles/particleSystemComponent";
  71571. export * from "babylonjs/Particles/particleSystemComponent";
  71572. export * from "babylonjs/Particles/particleSystemSet";
  71573. export * from "babylonjs/Particles/solidParticle";
  71574. export * from "babylonjs/Particles/solidParticleSystem";
  71575. export * from "babylonjs/Particles/cloudPoint";
  71576. export * from "babylonjs/Particles/pointsCloudSystem";
  71577. export * from "babylonjs/Particles/subEmitter";
  71578. }
  71579. declare module "babylonjs/Physics/physicsEngineComponent" {
  71580. import { Nullable } from "babylonjs/types";
  71581. import { Observable, Observer } from "babylonjs/Misc/observable";
  71582. import { Vector3 } from "babylonjs/Maths/math.vector";
  71583. import { Mesh } from "babylonjs/Meshes/mesh";
  71584. import { ISceneComponent } from "babylonjs/sceneComponent";
  71585. import { Scene } from "babylonjs/scene";
  71586. import { Node } from "babylonjs/node";
  71587. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71588. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71589. module "babylonjs/scene" {
  71590. interface Scene {
  71591. /** @hidden (Backing field) */
  71592. _physicsEngine: Nullable<IPhysicsEngine>;
  71593. /** @hidden */
  71594. _physicsTimeAccumulator: number;
  71595. /**
  71596. * Gets the current physics engine
  71597. * @returns a IPhysicsEngine or null if none attached
  71598. */
  71599. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71600. /**
  71601. * Enables physics to the current scene
  71602. * @param gravity defines the scene's gravity for the physics engine
  71603. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71604. * @return a boolean indicating if the physics engine was initialized
  71605. */
  71606. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71607. /**
  71608. * Disables and disposes the physics engine associated with the scene
  71609. */
  71610. disablePhysicsEngine(): void;
  71611. /**
  71612. * Gets a boolean indicating if there is an active physics engine
  71613. * @returns a boolean indicating if there is an active physics engine
  71614. */
  71615. isPhysicsEnabled(): boolean;
  71616. /**
  71617. * Deletes a physics compound impostor
  71618. * @param compound defines the compound to delete
  71619. */
  71620. deleteCompoundImpostor(compound: any): void;
  71621. /**
  71622. * An event triggered when physic simulation is about to be run
  71623. */
  71624. onBeforePhysicsObservable: Observable<Scene>;
  71625. /**
  71626. * An event triggered when physic simulation has been done
  71627. */
  71628. onAfterPhysicsObservable: Observable<Scene>;
  71629. }
  71630. }
  71631. module "babylonjs/Meshes/abstractMesh" {
  71632. interface AbstractMesh {
  71633. /** @hidden */
  71634. _physicsImpostor: Nullable<PhysicsImpostor>;
  71635. /**
  71636. * Gets or sets impostor used for physic simulation
  71637. * @see https://doc.babylonjs.com/features/physics_engine
  71638. */
  71639. physicsImpostor: Nullable<PhysicsImpostor>;
  71640. /**
  71641. * Gets the current physics impostor
  71642. * @see https://doc.babylonjs.com/features/physics_engine
  71643. * @returns a physics impostor or null
  71644. */
  71645. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71646. /** Apply a physic impulse to the mesh
  71647. * @param force defines the force to apply
  71648. * @param contactPoint defines where to apply the force
  71649. * @returns the current mesh
  71650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71651. */
  71652. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71653. /**
  71654. * Creates a physic joint between two meshes
  71655. * @param otherMesh defines the other mesh to use
  71656. * @param pivot1 defines the pivot to use on this mesh
  71657. * @param pivot2 defines the pivot to use on the other mesh
  71658. * @param options defines additional options (can be plugin dependent)
  71659. * @returns the current mesh
  71660. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71661. */
  71662. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71663. /** @hidden */
  71664. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71665. }
  71666. }
  71667. /**
  71668. * Defines the physics engine scene component responsible to manage a physics engine
  71669. */
  71670. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71671. /**
  71672. * The component name helpful to identify the component in the list of scene components.
  71673. */
  71674. readonly name: string;
  71675. /**
  71676. * The scene the component belongs to.
  71677. */
  71678. scene: Scene;
  71679. /**
  71680. * Creates a new instance of the component for the given scene
  71681. * @param scene Defines the scene to register the component in
  71682. */
  71683. constructor(scene: Scene);
  71684. /**
  71685. * Registers the component in a given scene
  71686. */
  71687. register(): void;
  71688. /**
  71689. * Rebuilds the elements related to this component in case of
  71690. * context lost for instance.
  71691. */
  71692. rebuild(): void;
  71693. /**
  71694. * Disposes the component and the associated ressources
  71695. */
  71696. dispose(): void;
  71697. }
  71698. }
  71699. declare module "babylonjs/Physics/physicsHelper" {
  71700. import { Nullable } from "babylonjs/types";
  71701. import { Vector3 } from "babylonjs/Maths/math.vector";
  71702. import { Mesh } from "babylonjs/Meshes/mesh";
  71703. import { Scene } from "babylonjs/scene";
  71704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71705. /**
  71706. * A helper for physics simulations
  71707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71708. */
  71709. export class PhysicsHelper {
  71710. private _scene;
  71711. private _physicsEngine;
  71712. /**
  71713. * Initializes the Physics helper
  71714. * @param scene Babylon.js scene
  71715. */
  71716. constructor(scene: Scene);
  71717. /**
  71718. * Applies a radial explosion impulse
  71719. * @param origin the origin of the explosion
  71720. * @param radiusOrEventOptions the radius or the options of radial explosion
  71721. * @param strength the explosion strength
  71722. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71723. * @returns A physics radial explosion event, or null
  71724. */
  71725. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71726. /**
  71727. * Applies a radial explosion force
  71728. * @param origin the origin of the explosion
  71729. * @param radiusOrEventOptions the radius or the options of radial explosion
  71730. * @param strength the explosion strength
  71731. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71732. * @returns A physics radial explosion event, or null
  71733. */
  71734. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71735. /**
  71736. * Creates a gravitational field
  71737. * @param origin the origin of the explosion
  71738. * @param radiusOrEventOptions the radius or the options of radial explosion
  71739. * @param strength the explosion strength
  71740. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71741. * @returns A physics gravitational field event, or null
  71742. */
  71743. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71744. /**
  71745. * Creates a physics updraft event
  71746. * @param origin the origin of the updraft
  71747. * @param radiusOrEventOptions the radius or the options of the updraft
  71748. * @param strength the strength of the updraft
  71749. * @param height the height of the updraft
  71750. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71751. * @returns A physics updraft event, or null
  71752. */
  71753. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71754. /**
  71755. * Creates a physics vortex event
  71756. * @param origin the of the vortex
  71757. * @param radiusOrEventOptions the radius or the options of the vortex
  71758. * @param strength the strength of the vortex
  71759. * @param height the height of the vortex
  71760. * @returns a Physics vortex event, or null
  71761. * A physics vortex event or null
  71762. */
  71763. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71764. }
  71765. /**
  71766. * Represents a physics radial explosion event
  71767. */
  71768. class PhysicsRadialExplosionEvent {
  71769. private _scene;
  71770. private _options;
  71771. private _sphere;
  71772. private _dataFetched;
  71773. /**
  71774. * Initializes a radial explosioin event
  71775. * @param _scene BabylonJS scene
  71776. * @param _options The options for the vortex event
  71777. */
  71778. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71779. /**
  71780. * Returns the data related to the radial explosion event (sphere).
  71781. * @returns The radial explosion event data
  71782. */
  71783. getData(): PhysicsRadialExplosionEventData;
  71784. /**
  71785. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71786. * @param impostor A physics imposter
  71787. * @param origin the origin of the explosion
  71788. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71789. */
  71790. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71791. /**
  71792. * Triggers affecterd impostors callbacks
  71793. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71794. */
  71795. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71796. /**
  71797. * Disposes the sphere.
  71798. * @param force Specifies if the sphere should be disposed by force
  71799. */
  71800. dispose(force?: boolean): void;
  71801. /*** Helpers ***/
  71802. private _prepareSphere;
  71803. private _intersectsWithSphere;
  71804. }
  71805. /**
  71806. * Represents a gravitational field event
  71807. */
  71808. class PhysicsGravitationalFieldEvent {
  71809. private _physicsHelper;
  71810. private _scene;
  71811. private _origin;
  71812. private _options;
  71813. private _tickCallback;
  71814. private _sphere;
  71815. private _dataFetched;
  71816. /**
  71817. * Initializes the physics gravitational field event
  71818. * @param _physicsHelper A physics helper
  71819. * @param _scene BabylonJS scene
  71820. * @param _origin The origin position of the gravitational field event
  71821. * @param _options The options for the vortex event
  71822. */
  71823. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71824. /**
  71825. * Returns the data related to the gravitational field event (sphere).
  71826. * @returns A gravitational field event
  71827. */
  71828. getData(): PhysicsGravitationalFieldEventData;
  71829. /**
  71830. * Enables the gravitational field.
  71831. */
  71832. enable(): void;
  71833. /**
  71834. * Disables the gravitational field.
  71835. */
  71836. disable(): void;
  71837. /**
  71838. * Disposes the sphere.
  71839. * @param force The force to dispose from the gravitational field event
  71840. */
  71841. dispose(force?: boolean): void;
  71842. private _tick;
  71843. }
  71844. /**
  71845. * Represents a physics updraft event
  71846. */
  71847. class PhysicsUpdraftEvent {
  71848. private _scene;
  71849. private _origin;
  71850. private _options;
  71851. private _physicsEngine;
  71852. private _originTop;
  71853. private _originDirection;
  71854. private _tickCallback;
  71855. private _cylinder;
  71856. private _cylinderPosition;
  71857. private _dataFetched;
  71858. /**
  71859. * Initializes the physics updraft event
  71860. * @param _scene BabylonJS scene
  71861. * @param _origin The origin position of the updraft
  71862. * @param _options The options for the updraft event
  71863. */
  71864. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71865. /**
  71866. * Returns the data related to the updraft event (cylinder).
  71867. * @returns A physics updraft event
  71868. */
  71869. getData(): PhysicsUpdraftEventData;
  71870. /**
  71871. * Enables the updraft.
  71872. */
  71873. enable(): void;
  71874. /**
  71875. * Disables the updraft.
  71876. */
  71877. disable(): void;
  71878. /**
  71879. * Disposes the cylinder.
  71880. * @param force Specifies if the updraft should be disposed by force
  71881. */
  71882. dispose(force?: boolean): void;
  71883. private getImpostorHitData;
  71884. private _tick;
  71885. /*** Helpers ***/
  71886. private _prepareCylinder;
  71887. private _intersectsWithCylinder;
  71888. }
  71889. /**
  71890. * Represents a physics vortex event
  71891. */
  71892. class PhysicsVortexEvent {
  71893. private _scene;
  71894. private _origin;
  71895. private _options;
  71896. private _physicsEngine;
  71897. private _originTop;
  71898. private _tickCallback;
  71899. private _cylinder;
  71900. private _cylinderPosition;
  71901. private _dataFetched;
  71902. /**
  71903. * Initializes the physics vortex event
  71904. * @param _scene The BabylonJS scene
  71905. * @param _origin The origin position of the vortex
  71906. * @param _options The options for the vortex event
  71907. */
  71908. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71909. /**
  71910. * Returns the data related to the vortex event (cylinder).
  71911. * @returns The physics vortex event data
  71912. */
  71913. getData(): PhysicsVortexEventData;
  71914. /**
  71915. * Enables the vortex.
  71916. */
  71917. enable(): void;
  71918. /**
  71919. * Disables the cortex.
  71920. */
  71921. disable(): void;
  71922. /**
  71923. * Disposes the sphere.
  71924. * @param force
  71925. */
  71926. dispose(force?: boolean): void;
  71927. private getImpostorHitData;
  71928. private _tick;
  71929. /*** Helpers ***/
  71930. private _prepareCylinder;
  71931. private _intersectsWithCylinder;
  71932. }
  71933. /**
  71934. * Options fot the radial explosion event
  71935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71936. */
  71937. export class PhysicsRadialExplosionEventOptions {
  71938. /**
  71939. * The radius of the sphere for the radial explosion.
  71940. */
  71941. radius: number;
  71942. /**
  71943. * The strenth of the explosion.
  71944. */
  71945. strength: number;
  71946. /**
  71947. * The strenght of the force in correspondence to the distance of the affected object
  71948. */
  71949. falloff: PhysicsRadialImpulseFalloff;
  71950. /**
  71951. * Sphere options for the radial explosion.
  71952. */
  71953. sphere: {
  71954. segments: number;
  71955. diameter: number;
  71956. };
  71957. /**
  71958. * Sphere options for the radial explosion.
  71959. */
  71960. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71961. }
  71962. /**
  71963. * Options fot the updraft event
  71964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71965. */
  71966. export class PhysicsUpdraftEventOptions {
  71967. /**
  71968. * The radius of the cylinder for the vortex
  71969. */
  71970. radius: number;
  71971. /**
  71972. * The strenth of the updraft.
  71973. */
  71974. strength: number;
  71975. /**
  71976. * The height of the cylinder for the updraft.
  71977. */
  71978. height: number;
  71979. /**
  71980. * The mode for the the updraft.
  71981. */
  71982. updraftMode: PhysicsUpdraftMode;
  71983. }
  71984. /**
  71985. * Options fot the vortex event
  71986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71987. */
  71988. export class PhysicsVortexEventOptions {
  71989. /**
  71990. * The radius of the cylinder for the vortex
  71991. */
  71992. radius: number;
  71993. /**
  71994. * The strenth of the vortex.
  71995. */
  71996. strength: number;
  71997. /**
  71998. * The height of the cylinder for the vortex.
  71999. */
  72000. height: number;
  72001. /**
  72002. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72003. */
  72004. centripetalForceThreshold: number;
  72005. /**
  72006. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72007. */
  72008. centripetalForceMultiplier: number;
  72009. /**
  72010. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72011. */
  72012. centrifugalForceMultiplier: number;
  72013. /**
  72014. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72015. */
  72016. updraftForceMultiplier: number;
  72017. }
  72018. /**
  72019. * The strenght of the force in correspondence to the distance of the affected object
  72020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72021. */
  72022. export enum PhysicsRadialImpulseFalloff {
  72023. /** Defines that impulse is constant in strength across it's whole radius */
  72024. Constant = 0,
  72025. /** Defines that impulse gets weaker if it's further from the origin */
  72026. Linear = 1
  72027. }
  72028. /**
  72029. * The strength of the force in correspondence to the distance of the affected object
  72030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72031. */
  72032. export enum PhysicsUpdraftMode {
  72033. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72034. Center = 0,
  72035. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72036. Perpendicular = 1
  72037. }
  72038. /**
  72039. * Interface for a physics hit data
  72040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72041. */
  72042. export interface PhysicsHitData {
  72043. /**
  72044. * The force applied at the contact point
  72045. */
  72046. force: Vector3;
  72047. /**
  72048. * The contact point
  72049. */
  72050. contactPoint: Vector3;
  72051. /**
  72052. * The distance from the origin to the contact point
  72053. */
  72054. distanceFromOrigin: number;
  72055. }
  72056. /**
  72057. * Interface for radial explosion event data
  72058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72059. */
  72060. export interface PhysicsRadialExplosionEventData {
  72061. /**
  72062. * A sphere used for the radial explosion event
  72063. */
  72064. sphere: Mesh;
  72065. }
  72066. /**
  72067. * Interface for gravitational field event data
  72068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72069. */
  72070. export interface PhysicsGravitationalFieldEventData {
  72071. /**
  72072. * A sphere mesh used for the gravitational field event
  72073. */
  72074. sphere: Mesh;
  72075. }
  72076. /**
  72077. * Interface for updraft event data
  72078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72079. */
  72080. export interface PhysicsUpdraftEventData {
  72081. /**
  72082. * A cylinder used for the updraft event
  72083. */
  72084. cylinder: Mesh;
  72085. }
  72086. /**
  72087. * Interface for vortex event data
  72088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72089. */
  72090. export interface PhysicsVortexEventData {
  72091. /**
  72092. * A cylinder used for the vortex event
  72093. */
  72094. cylinder: Mesh;
  72095. }
  72096. /**
  72097. * Interface for an affected physics impostor
  72098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72099. */
  72100. export interface PhysicsAffectedImpostorWithData {
  72101. /**
  72102. * The impostor affected by the effect
  72103. */
  72104. impostor: PhysicsImpostor;
  72105. /**
  72106. * The data about the hit/horce from the explosion
  72107. */
  72108. hitData: PhysicsHitData;
  72109. }
  72110. }
  72111. declare module "babylonjs/Physics/Plugins/index" {
  72112. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72113. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72114. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72115. }
  72116. declare module "babylonjs/Physics/index" {
  72117. export * from "babylonjs/Physics/IPhysicsEngine";
  72118. export * from "babylonjs/Physics/physicsEngine";
  72119. export * from "babylonjs/Physics/physicsEngineComponent";
  72120. export * from "babylonjs/Physics/physicsHelper";
  72121. export * from "babylonjs/Physics/physicsImpostor";
  72122. export * from "babylonjs/Physics/physicsJoint";
  72123. export * from "babylonjs/Physics/Plugins/index";
  72124. }
  72125. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72126. /** @hidden */
  72127. export var blackAndWhitePixelShader: {
  72128. name: string;
  72129. shader: string;
  72130. };
  72131. }
  72132. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72134. import { Camera } from "babylonjs/Cameras/camera";
  72135. import { Engine } from "babylonjs/Engines/engine";
  72136. import "babylonjs/Shaders/blackAndWhite.fragment";
  72137. /**
  72138. * Post process used to render in black and white
  72139. */
  72140. export class BlackAndWhitePostProcess extends PostProcess {
  72141. /**
  72142. * Linear about to convert he result to black and white (default: 1)
  72143. */
  72144. degree: number;
  72145. /**
  72146. * Creates a black and white post process
  72147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72148. * @param name The name of the effect.
  72149. * @param options The required width/height ratio to downsize to before computing the render pass.
  72150. * @param camera The camera to apply the render pass to.
  72151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72152. * @param engine The engine which the post process will be applied. (default: current engine)
  72153. * @param reusable If the post process can be reused on the same frame. (default: false)
  72154. */
  72155. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72156. }
  72157. }
  72158. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72159. import { Nullable } from "babylonjs/types";
  72160. import { Camera } from "babylonjs/Cameras/camera";
  72161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72162. import { Engine } from "babylonjs/Engines/engine";
  72163. /**
  72164. * This represents a set of one or more post processes in Babylon.
  72165. * A post process can be used to apply a shader to a texture after it is rendered.
  72166. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72167. */
  72168. export class PostProcessRenderEffect {
  72169. private _postProcesses;
  72170. private _getPostProcesses;
  72171. private _singleInstance;
  72172. private _cameras;
  72173. private _indicesForCamera;
  72174. /**
  72175. * Name of the effect
  72176. * @hidden
  72177. */
  72178. _name: string;
  72179. /**
  72180. * Instantiates a post process render effect.
  72181. * A post process can be used to apply a shader to a texture after it is rendered.
  72182. * @param engine The engine the effect is tied to
  72183. * @param name The name of the effect
  72184. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72185. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72186. */
  72187. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72188. /**
  72189. * Checks if all the post processes in the effect are supported.
  72190. */
  72191. get isSupported(): boolean;
  72192. /**
  72193. * Updates the current state of the effect
  72194. * @hidden
  72195. */
  72196. _update(): void;
  72197. /**
  72198. * Attaches the effect on cameras
  72199. * @param cameras The camera to attach to.
  72200. * @hidden
  72201. */
  72202. _attachCameras(cameras: Camera): void;
  72203. /**
  72204. * Attaches the effect on cameras
  72205. * @param cameras The camera to attach to.
  72206. * @hidden
  72207. */
  72208. _attachCameras(cameras: Camera[]): void;
  72209. /**
  72210. * Detaches the effect on cameras
  72211. * @param cameras The camera to detatch from.
  72212. * @hidden
  72213. */
  72214. _detachCameras(cameras: Camera): void;
  72215. /**
  72216. * Detatches the effect on cameras
  72217. * @param cameras The camera to detatch from.
  72218. * @hidden
  72219. */
  72220. _detachCameras(cameras: Camera[]): void;
  72221. /**
  72222. * Enables the effect on given cameras
  72223. * @param cameras The camera to enable.
  72224. * @hidden
  72225. */
  72226. _enable(cameras: Camera): void;
  72227. /**
  72228. * Enables the effect on given cameras
  72229. * @param cameras The camera to enable.
  72230. * @hidden
  72231. */
  72232. _enable(cameras: Nullable<Camera[]>): void;
  72233. /**
  72234. * Disables the effect on the given cameras
  72235. * @param cameras The camera to disable.
  72236. * @hidden
  72237. */
  72238. _disable(cameras: Camera): void;
  72239. /**
  72240. * Disables the effect on the given cameras
  72241. * @param cameras The camera to disable.
  72242. * @hidden
  72243. */
  72244. _disable(cameras: Nullable<Camera[]>): void;
  72245. /**
  72246. * Gets a list of the post processes contained in the effect.
  72247. * @param camera The camera to get the post processes on.
  72248. * @returns The list of the post processes in the effect.
  72249. */
  72250. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72251. }
  72252. }
  72253. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72255. /** @hidden */
  72256. export var extractHighlightsPixelShader: {
  72257. name: string;
  72258. shader: string;
  72259. };
  72260. }
  72261. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72262. import { Nullable } from "babylonjs/types";
  72263. import { Camera } from "babylonjs/Cameras/camera";
  72264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72265. import { Engine } from "babylonjs/Engines/engine";
  72266. import "babylonjs/Shaders/extractHighlights.fragment";
  72267. /**
  72268. * 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.
  72269. */
  72270. export class ExtractHighlightsPostProcess extends PostProcess {
  72271. /**
  72272. * The luminance threshold, pixels below this value will be set to black.
  72273. */
  72274. threshold: number;
  72275. /** @hidden */
  72276. _exposure: number;
  72277. /**
  72278. * Post process which has the input texture to be used when performing highlight extraction
  72279. * @hidden
  72280. */
  72281. _inputPostProcess: Nullable<PostProcess>;
  72282. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72283. }
  72284. }
  72285. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72286. /** @hidden */
  72287. export var bloomMergePixelShader: {
  72288. name: string;
  72289. shader: string;
  72290. };
  72291. }
  72292. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72294. import { Nullable } from "babylonjs/types";
  72295. import { Engine } from "babylonjs/Engines/engine";
  72296. import { Camera } from "babylonjs/Cameras/camera";
  72297. import "babylonjs/Shaders/bloomMerge.fragment";
  72298. /**
  72299. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72300. */
  72301. export class BloomMergePostProcess extends PostProcess {
  72302. /** Weight of the bloom to be added to the original input. */
  72303. weight: number;
  72304. /**
  72305. * Creates a new instance of @see BloomMergePostProcess
  72306. * @param name The name of the effect.
  72307. * @param originalFromInput Post process which's input will be used for the merge.
  72308. * @param blurred Blurred highlights post process which's output will be used.
  72309. * @param weight Weight of the bloom to be added to the original input.
  72310. * @param options The required width/height ratio to downsize to before computing the render pass.
  72311. * @param camera The camera to apply the render pass to.
  72312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72313. * @param engine The engine which the post process will be applied. (default: current engine)
  72314. * @param reusable If the post process can be reused on the same frame. (default: false)
  72315. * @param textureType Type of textures used when performing the post process. (default: 0)
  72316. * @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)
  72317. */
  72318. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72319. /** Weight of the bloom to be added to the original input. */
  72320. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72321. }
  72322. }
  72323. declare module "babylonjs/PostProcesses/bloomEffect" {
  72324. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72325. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72326. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72327. import { Camera } from "babylonjs/Cameras/camera";
  72328. import { Scene } from "babylonjs/scene";
  72329. /**
  72330. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72331. */
  72332. export class BloomEffect extends PostProcessRenderEffect {
  72333. private bloomScale;
  72334. /**
  72335. * @hidden Internal
  72336. */
  72337. _effects: Array<PostProcess>;
  72338. /**
  72339. * @hidden Internal
  72340. */
  72341. _downscale: ExtractHighlightsPostProcess;
  72342. private _blurX;
  72343. private _blurY;
  72344. private _merge;
  72345. /**
  72346. * The luminance threshold to find bright areas of the image to bloom.
  72347. */
  72348. get threshold(): number;
  72349. set threshold(value: number);
  72350. /**
  72351. * The strength of the bloom.
  72352. */
  72353. get weight(): number;
  72354. set weight(value: number);
  72355. /**
  72356. * Specifies the size of the bloom blur kernel, relative to the final output size
  72357. */
  72358. get kernel(): number;
  72359. set kernel(value: number);
  72360. /**
  72361. * Creates a new instance of @see BloomEffect
  72362. * @param scene The scene the effect belongs to.
  72363. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72364. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72365. * @param bloomWeight The the strength of bloom.
  72366. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72367. * @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)
  72368. */
  72369. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72370. /**
  72371. * Disposes each of the internal effects for a given camera.
  72372. * @param camera The camera to dispose the effect on.
  72373. */
  72374. disposeEffects(camera: Camera): void;
  72375. /**
  72376. * @hidden Internal
  72377. */
  72378. _updateEffects(): void;
  72379. /**
  72380. * Internal
  72381. * @returns if all the contained post processes are ready.
  72382. * @hidden
  72383. */
  72384. _isReady(): boolean;
  72385. }
  72386. }
  72387. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72388. /** @hidden */
  72389. export var chromaticAberrationPixelShader: {
  72390. name: string;
  72391. shader: string;
  72392. };
  72393. }
  72394. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72395. import { Vector2 } from "babylonjs/Maths/math.vector";
  72396. import { Nullable } from "babylonjs/types";
  72397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72398. import { Camera } from "babylonjs/Cameras/camera";
  72399. import { Engine } from "babylonjs/Engines/engine";
  72400. import "babylonjs/Shaders/chromaticAberration.fragment";
  72401. /**
  72402. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72403. */
  72404. export class ChromaticAberrationPostProcess extends PostProcess {
  72405. /**
  72406. * The amount of seperation of rgb channels (default: 30)
  72407. */
  72408. aberrationAmount: number;
  72409. /**
  72410. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72411. */
  72412. radialIntensity: number;
  72413. /**
  72414. * 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))
  72415. */
  72416. direction: Vector2;
  72417. /**
  72418. * 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))
  72419. */
  72420. centerPosition: Vector2;
  72421. /**
  72422. * Creates a new instance ChromaticAberrationPostProcess
  72423. * @param name The name of the effect.
  72424. * @param screenWidth The width of the screen to apply the effect on.
  72425. * @param screenHeight The height of the screen to apply the effect on.
  72426. * @param options The required width/height ratio to downsize to before computing the render pass.
  72427. * @param camera The camera to apply the render pass to.
  72428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72429. * @param engine The engine which the post process will be applied. (default: current engine)
  72430. * @param reusable If the post process can be reused on the same frame. (default: false)
  72431. * @param textureType Type of textures used when performing the post process. (default: 0)
  72432. * @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)
  72433. */
  72434. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72435. }
  72436. }
  72437. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72438. /** @hidden */
  72439. export var circleOfConfusionPixelShader: {
  72440. name: string;
  72441. shader: string;
  72442. };
  72443. }
  72444. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72445. import { Nullable } from "babylonjs/types";
  72446. import { Engine } from "babylonjs/Engines/engine";
  72447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72449. import { Camera } from "babylonjs/Cameras/camera";
  72450. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72451. /**
  72452. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72453. */
  72454. export class CircleOfConfusionPostProcess extends PostProcess {
  72455. /**
  72456. * 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.
  72457. */
  72458. lensSize: number;
  72459. /**
  72460. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72461. */
  72462. fStop: number;
  72463. /**
  72464. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72465. */
  72466. focusDistance: number;
  72467. /**
  72468. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72469. */
  72470. focalLength: number;
  72471. private _depthTexture;
  72472. /**
  72473. * Creates a new instance CircleOfConfusionPostProcess
  72474. * @param name The name of the effect.
  72475. * @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.
  72476. * @param options The required width/height ratio to downsize to before computing the render pass.
  72477. * @param camera The camera to apply the render pass to.
  72478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72479. * @param engine The engine which the post process will be applied. (default: current engine)
  72480. * @param reusable If the post process can be reused on the same frame. (default: false)
  72481. * @param textureType Type of textures used when performing the post process. (default: 0)
  72482. * @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)
  72483. */
  72484. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72485. /**
  72486. * 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.
  72487. */
  72488. set depthTexture(value: RenderTargetTexture);
  72489. }
  72490. }
  72491. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72492. /** @hidden */
  72493. export var colorCorrectionPixelShader: {
  72494. name: string;
  72495. shader: string;
  72496. };
  72497. }
  72498. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72499. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72500. import { Engine } from "babylonjs/Engines/engine";
  72501. import { Camera } from "babylonjs/Cameras/camera";
  72502. import "babylonjs/Shaders/colorCorrection.fragment";
  72503. /**
  72504. *
  72505. * This post-process allows the modification of rendered colors by using
  72506. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72507. *
  72508. * The object needs to be provided an url to a texture containing the color
  72509. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72510. * Use an image editing software to tweak the LUT to match your needs.
  72511. *
  72512. * For an example of a color LUT, see here:
  72513. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72514. * For explanations on color grading, see here:
  72515. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72516. *
  72517. */
  72518. export class ColorCorrectionPostProcess extends PostProcess {
  72519. private _colorTableTexture;
  72520. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72521. }
  72522. }
  72523. declare module "babylonjs/Shaders/convolution.fragment" {
  72524. /** @hidden */
  72525. export var convolutionPixelShader: {
  72526. name: string;
  72527. shader: string;
  72528. };
  72529. }
  72530. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72532. import { Nullable } from "babylonjs/types";
  72533. import { Camera } from "babylonjs/Cameras/camera";
  72534. import { Engine } from "babylonjs/Engines/engine";
  72535. import "babylonjs/Shaders/convolution.fragment";
  72536. /**
  72537. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72538. * input texture to perform effects such as edge detection or sharpening
  72539. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72540. */
  72541. export class ConvolutionPostProcess extends PostProcess {
  72542. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72543. kernel: number[];
  72544. /**
  72545. * Creates a new instance ConvolutionPostProcess
  72546. * @param name The name of the effect.
  72547. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72548. * @param options The required width/height ratio to downsize to before computing the render pass.
  72549. * @param camera The camera to apply the render pass to.
  72550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72551. * @param engine The engine which the post process will be applied. (default: current engine)
  72552. * @param reusable If the post process can be reused on the same frame. (default: false)
  72553. * @param textureType Type of textures used when performing the post process. (default: 0)
  72554. */
  72555. constructor(name: string,
  72556. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72557. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72558. /**
  72559. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72560. */
  72561. static EdgeDetect0Kernel: number[];
  72562. /**
  72563. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72564. */
  72565. static EdgeDetect1Kernel: number[];
  72566. /**
  72567. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72568. */
  72569. static EdgeDetect2Kernel: number[];
  72570. /**
  72571. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72572. */
  72573. static SharpenKernel: number[];
  72574. /**
  72575. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72576. */
  72577. static EmbossKernel: number[];
  72578. /**
  72579. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72580. */
  72581. static GaussianKernel: number[];
  72582. }
  72583. }
  72584. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72585. import { Nullable } from "babylonjs/types";
  72586. import { Vector2 } from "babylonjs/Maths/math.vector";
  72587. import { Camera } from "babylonjs/Cameras/camera";
  72588. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72589. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72590. import { Engine } from "babylonjs/Engines/engine";
  72591. import { Scene } from "babylonjs/scene";
  72592. /**
  72593. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72594. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72595. * based on samples that have a large difference in distance than the center pixel.
  72596. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72597. */
  72598. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72599. direction: Vector2;
  72600. /**
  72601. * Creates a new instance CircleOfConfusionPostProcess
  72602. * @param name The name of the effect.
  72603. * @param scene The scene the effect belongs to.
  72604. * @param direction The direction the blur should be applied.
  72605. * @param kernel The size of the kernel used to blur.
  72606. * @param options The required width/height ratio to downsize to before computing the render pass.
  72607. * @param camera The camera to apply the render pass to.
  72608. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72609. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72611. * @param engine The engine which the post process will be applied. (default: current engine)
  72612. * @param reusable If the post process can be reused on the same frame. (default: false)
  72613. * @param textureType Type of textures used when performing the post process. (default: 0)
  72614. * @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)
  72615. */
  72616. 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);
  72617. }
  72618. }
  72619. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72620. /** @hidden */
  72621. export var depthOfFieldMergePixelShader: {
  72622. name: string;
  72623. shader: string;
  72624. };
  72625. }
  72626. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72627. import { Nullable } from "babylonjs/types";
  72628. import { Camera } from "babylonjs/Cameras/camera";
  72629. import { Effect } from "babylonjs/Materials/effect";
  72630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72631. import { Engine } from "babylonjs/Engines/engine";
  72632. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72633. /**
  72634. * Options to be set when merging outputs from the default pipeline.
  72635. */
  72636. export class DepthOfFieldMergePostProcessOptions {
  72637. /**
  72638. * The original image to merge on top of
  72639. */
  72640. originalFromInput: PostProcess;
  72641. /**
  72642. * Parameters to perform the merge of the depth of field effect
  72643. */
  72644. depthOfField?: {
  72645. circleOfConfusion: PostProcess;
  72646. blurSteps: Array<PostProcess>;
  72647. };
  72648. /**
  72649. * Parameters to perform the merge of bloom effect
  72650. */
  72651. bloom?: {
  72652. blurred: PostProcess;
  72653. weight: number;
  72654. };
  72655. }
  72656. /**
  72657. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72658. */
  72659. export class DepthOfFieldMergePostProcess extends PostProcess {
  72660. private blurSteps;
  72661. /**
  72662. * Creates a new instance of DepthOfFieldMergePostProcess
  72663. * @param name The name of the effect.
  72664. * @param originalFromInput Post process which's input will be used for the merge.
  72665. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72666. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72667. * @param options The required width/height ratio to downsize to before computing the render pass.
  72668. * @param camera The camera to apply the render pass to.
  72669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72670. * @param engine The engine which the post process will be applied. (default: current engine)
  72671. * @param reusable If the post process can be reused on the same frame. (default: false)
  72672. * @param textureType Type of textures used when performing the post process. (default: 0)
  72673. * @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)
  72674. */
  72675. 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);
  72676. /**
  72677. * Updates the effect with the current post process compile time values and recompiles the shader.
  72678. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72679. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72680. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72681. * @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
  72682. * @param onCompiled Called when the shader has been compiled.
  72683. * @param onError Called if there is an error when compiling a shader.
  72684. */
  72685. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72686. }
  72687. }
  72688. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72689. import { Nullable } from "babylonjs/types";
  72690. import { Camera } from "babylonjs/Cameras/camera";
  72691. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72693. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72694. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72695. import { Scene } from "babylonjs/scene";
  72696. /**
  72697. * Specifies the level of max blur that should be applied when using the depth of field effect
  72698. */
  72699. export enum DepthOfFieldEffectBlurLevel {
  72700. /**
  72701. * Subtle blur
  72702. */
  72703. Low = 0,
  72704. /**
  72705. * Medium blur
  72706. */
  72707. Medium = 1,
  72708. /**
  72709. * Large blur
  72710. */
  72711. High = 2
  72712. }
  72713. /**
  72714. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72715. */
  72716. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72717. private _circleOfConfusion;
  72718. /**
  72719. * @hidden Internal, blurs from high to low
  72720. */
  72721. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72722. private _depthOfFieldBlurY;
  72723. private _dofMerge;
  72724. /**
  72725. * @hidden Internal post processes in depth of field effect
  72726. */
  72727. _effects: Array<PostProcess>;
  72728. /**
  72729. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72730. */
  72731. set focalLength(value: number);
  72732. get focalLength(): number;
  72733. /**
  72734. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72735. */
  72736. set fStop(value: number);
  72737. get fStop(): number;
  72738. /**
  72739. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72740. */
  72741. set focusDistance(value: number);
  72742. get focusDistance(): number;
  72743. /**
  72744. * 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.
  72745. */
  72746. set lensSize(value: number);
  72747. get lensSize(): number;
  72748. /**
  72749. * Creates a new instance DepthOfFieldEffect
  72750. * @param scene The scene the effect belongs to.
  72751. * @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.
  72752. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72753. * @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)
  72754. */
  72755. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72756. /**
  72757. * Get the current class name of the current effet
  72758. * @returns "DepthOfFieldEffect"
  72759. */
  72760. getClassName(): string;
  72761. /**
  72762. * 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.
  72763. */
  72764. set depthTexture(value: RenderTargetTexture);
  72765. /**
  72766. * Disposes each of the internal effects for a given camera.
  72767. * @param camera The camera to dispose the effect on.
  72768. */
  72769. disposeEffects(camera: Camera): void;
  72770. /**
  72771. * @hidden Internal
  72772. */
  72773. _updateEffects(): void;
  72774. /**
  72775. * Internal
  72776. * @returns if all the contained post processes are ready.
  72777. * @hidden
  72778. */
  72779. _isReady(): boolean;
  72780. }
  72781. }
  72782. declare module "babylonjs/Shaders/displayPass.fragment" {
  72783. /** @hidden */
  72784. export var displayPassPixelShader: {
  72785. name: string;
  72786. shader: string;
  72787. };
  72788. }
  72789. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72790. import { Nullable } from "babylonjs/types";
  72791. import { Camera } from "babylonjs/Cameras/camera";
  72792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72793. import { Engine } from "babylonjs/Engines/engine";
  72794. import "babylonjs/Shaders/displayPass.fragment";
  72795. /**
  72796. * DisplayPassPostProcess which produces an output the same as it's input
  72797. */
  72798. export class DisplayPassPostProcess extends PostProcess {
  72799. /**
  72800. * Creates the DisplayPassPostProcess
  72801. * @param name The name of the effect.
  72802. * @param options The required width/height ratio to downsize to before computing the render pass.
  72803. * @param camera The camera to apply the render pass to.
  72804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72805. * @param engine The engine which the post process will be applied. (default: current engine)
  72806. * @param reusable If the post process can be reused on the same frame. (default: false)
  72807. */
  72808. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72809. }
  72810. }
  72811. declare module "babylonjs/Shaders/filter.fragment" {
  72812. /** @hidden */
  72813. export var filterPixelShader: {
  72814. name: string;
  72815. shader: string;
  72816. };
  72817. }
  72818. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72819. import { Nullable } from "babylonjs/types";
  72820. import { Matrix } from "babylonjs/Maths/math.vector";
  72821. import { Camera } from "babylonjs/Cameras/camera";
  72822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72823. import { Engine } from "babylonjs/Engines/engine";
  72824. import "babylonjs/Shaders/filter.fragment";
  72825. /**
  72826. * Applies a kernel filter to the image
  72827. */
  72828. export class FilterPostProcess extends PostProcess {
  72829. /** The matrix to be applied to the image */
  72830. kernelMatrix: Matrix;
  72831. /**
  72832. *
  72833. * @param name The name of the effect.
  72834. * @param kernelMatrix The matrix to be applied to the image
  72835. * @param options The required width/height ratio to downsize to before computing the render pass.
  72836. * @param camera The camera to apply the render pass to.
  72837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72838. * @param engine The engine which the post process will be applied. (default: current engine)
  72839. * @param reusable If the post process can be reused on the same frame. (default: false)
  72840. */
  72841. constructor(name: string,
  72842. /** The matrix to be applied to the image */
  72843. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72844. }
  72845. }
  72846. declare module "babylonjs/Shaders/fxaa.fragment" {
  72847. /** @hidden */
  72848. export var fxaaPixelShader: {
  72849. name: string;
  72850. shader: string;
  72851. };
  72852. }
  72853. declare module "babylonjs/Shaders/fxaa.vertex" {
  72854. /** @hidden */
  72855. export var fxaaVertexShader: {
  72856. name: string;
  72857. shader: string;
  72858. };
  72859. }
  72860. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72861. import { Nullable } from "babylonjs/types";
  72862. import { Camera } from "babylonjs/Cameras/camera";
  72863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72864. import { Engine } from "babylonjs/Engines/engine";
  72865. import "babylonjs/Shaders/fxaa.fragment";
  72866. import "babylonjs/Shaders/fxaa.vertex";
  72867. /**
  72868. * Fxaa post process
  72869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72870. */
  72871. export class FxaaPostProcess extends PostProcess {
  72872. /** @hidden */
  72873. texelWidth: number;
  72874. /** @hidden */
  72875. texelHeight: number;
  72876. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72877. private _getDefines;
  72878. }
  72879. }
  72880. declare module "babylonjs/Shaders/grain.fragment" {
  72881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72882. /** @hidden */
  72883. export var grainPixelShader: {
  72884. name: string;
  72885. shader: string;
  72886. };
  72887. }
  72888. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72889. import { Nullable } from "babylonjs/types";
  72890. import { Camera } from "babylonjs/Cameras/camera";
  72891. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72892. import { Engine } from "babylonjs/Engines/engine";
  72893. import "babylonjs/Shaders/grain.fragment";
  72894. /**
  72895. * The GrainPostProcess adds noise to the image at mid luminance levels
  72896. */
  72897. export class GrainPostProcess extends PostProcess {
  72898. /**
  72899. * The intensity of the grain added (default: 30)
  72900. */
  72901. intensity: number;
  72902. /**
  72903. * If the grain should be randomized on every frame
  72904. */
  72905. animated: boolean;
  72906. /**
  72907. * Creates a new instance of @see GrainPostProcess
  72908. * @param name The name of the effect.
  72909. * @param options The required width/height ratio to downsize to before computing the render pass.
  72910. * @param camera The camera to apply the render pass to.
  72911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72912. * @param engine The engine which the post process will be applied. (default: current engine)
  72913. * @param reusable If the post process can be reused on the same frame. (default: false)
  72914. * @param textureType Type of textures used when performing the post process. (default: 0)
  72915. * @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)
  72916. */
  72917. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72918. }
  72919. }
  72920. declare module "babylonjs/Shaders/highlights.fragment" {
  72921. /** @hidden */
  72922. export var highlightsPixelShader: {
  72923. name: string;
  72924. shader: string;
  72925. };
  72926. }
  72927. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72928. import { Nullable } from "babylonjs/types";
  72929. import { Camera } from "babylonjs/Cameras/camera";
  72930. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72931. import { Engine } from "babylonjs/Engines/engine";
  72932. import "babylonjs/Shaders/highlights.fragment";
  72933. /**
  72934. * Extracts highlights from the image
  72935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72936. */
  72937. export class HighlightsPostProcess extends PostProcess {
  72938. /**
  72939. * Extracts highlights from the image
  72940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72941. * @param name The name of the effect.
  72942. * @param options The required width/height ratio to downsize to before computing the render pass.
  72943. * @param camera The camera to apply the render pass to.
  72944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72945. * @param engine The engine which the post process will be applied. (default: current engine)
  72946. * @param reusable If the post process can be reused on the same frame. (default: false)
  72947. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72948. */
  72949. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72950. }
  72951. }
  72952. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72953. /** @hidden */
  72954. export var mrtFragmentDeclaration: {
  72955. name: string;
  72956. shader: string;
  72957. };
  72958. }
  72959. declare module "babylonjs/Shaders/geometry.fragment" {
  72960. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72961. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72962. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72963. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72964. /** @hidden */
  72965. export var geometryPixelShader: {
  72966. name: string;
  72967. shader: string;
  72968. };
  72969. }
  72970. declare module "babylonjs/Shaders/geometry.vertex" {
  72971. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72972. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72974. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72975. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72976. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72977. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72978. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72979. /** @hidden */
  72980. export var geometryVertexShader: {
  72981. name: string;
  72982. shader: string;
  72983. };
  72984. }
  72985. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72986. import { Matrix } from "babylonjs/Maths/math.vector";
  72987. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72988. import { Mesh } from "babylonjs/Meshes/mesh";
  72989. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72990. import { Effect } from "babylonjs/Materials/effect";
  72991. import { Scene } from "babylonjs/scene";
  72992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72993. import "babylonjs/Shaders/geometry.fragment";
  72994. import "babylonjs/Shaders/geometry.vertex";
  72995. /** @hidden */
  72996. interface ISavedTransformationMatrix {
  72997. world: Matrix;
  72998. viewProjection: Matrix;
  72999. }
  73000. /**
  73001. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73002. */
  73003. export class GeometryBufferRenderer {
  73004. /**
  73005. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73006. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73007. */
  73008. static readonly POSITION_TEXTURE_TYPE: number;
  73009. /**
  73010. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73011. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73012. */
  73013. static readonly VELOCITY_TEXTURE_TYPE: number;
  73014. /**
  73015. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73016. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73017. */
  73018. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73019. /**
  73020. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73021. * in order to compute objects velocities when enableVelocity is set to "true"
  73022. * @hidden
  73023. */
  73024. _previousTransformationMatrices: {
  73025. [index: number]: ISavedTransformationMatrix;
  73026. };
  73027. /**
  73028. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73029. * in order to compute objects velocities when enableVelocity is set to "true"
  73030. * @hidden
  73031. */
  73032. _previousBonesTransformationMatrices: {
  73033. [index: number]: Float32Array;
  73034. };
  73035. /**
  73036. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73037. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73038. */
  73039. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73040. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73041. renderTransparentMeshes: boolean;
  73042. private _scene;
  73043. private _resizeObserver;
  73044. private _multiRenderTarget;
  73045. private _ratio;
  73046. private _enablePosition;
  73047. private _enableVelocity;
  73048. private _enableReflectivity;
  73049. private _positionIndex;
  73050. private _velocityIndex;
  73051. private _reflectivityIndex;
  73052. protected _effect: Effect;
  73053. protected _cachedDefines: string;
  73054. /**
  73055. * Set the render list (meshes to be rendered) used in the G buffer.
  73056. */
  73057. set renderList(meshes: Mesh[]);
  73058. /**
  73059. * Gets wether or not G buffer are supported by the running hardware.
  73060. * This requires draw buffer supports
  73061. */
  73062. get isSupported(): boolean;
  73063. /**
  73064. * Returns the index of the given texture type in the G-Buffer textures array
  73065. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73066. * @returns the index of the given texture type in the G-Buffer textures array
  73067. */
  73068. getTextureIndex(textureType: number): number;
  73069. /**
  73070. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73071. */
  73072. get enablePosition(): boolean;
  73073. /**
  73074. * Sets whether or not objects positions are enabled for the G buffer.
  73075. */
  73076. set enablePosition(enable: boolean);
  73077. /**
  73078. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73079. */
  73080. get enableVelocity(): boolean;
  73081. /**
  73082. * Sets wether or not objects velocities are enabled for the G buffer.
  73083. */
  73084. set enableVelocity(enable: boolean);
  73085. /**
  73086. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73087. */
  73088. get enableReflectivity(): boolean;
  73089. /**
  73090. * Sets wether or not objects roughness are enabled for the G buffer.
  73091. */
  73092. set enableReflectivity(enable: boolean);
  73093. /**
  73094. * Gets the scene associated with the buffer.
  73095. */
  73096. get scene(): Scene;
  73097. /**
  73098. * Gets the ratio used by the buffer during its creation.
  73099. * How big is the buffer related to the main canvas.
  73100. */
  73101. get ratio(): number;
  73102. /** @hidden */
  73103. static _SceneComponentInitialization: (scene: Scene) => void;
  73104. /**
  73105. * Creates a new G Buffer for the scene
  73106. * @param scene The scene the buffer belongs to
  73107. * @param ratio How big is the buffer related to the main canvas.
  73108. */
  73109. constructor(scene: Scene, ratio?: number);
  73110. /**
  73111. * Checks wether everything is ready to render a submesh to the G buffer.
  73112. * @param subMesh the submesh to check readiness for
  73113. * @param useInstances is the mesh drawn using instance or not
  73114. * @returns true if ready otherwise false
  73115. */
  73116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73117. /**
  73118. * Gets the current underlying G Buffer.
  73119. * @returns the buffer
  73120. */
  73121. getGBuffer(): MultiRenderTarget;
  73122. /**
  73123. * Gets the number of samples used to render the buffer (anti aliasing).
  73124. */
  73125. get samples(): number;
  73126. /**
  73127. * Sets the number of samples used to render the buffer (anti aliasing).
  73128. */
  73129. set samples(value: number);
  73130. /**
  73131. * Disposes the renderer and frees up associated resources.
  73132. */
  73133. dispose(): void;
  73134. protected _createRenderTargets(): void;
  73135. private _copyBonesTransformationMatrices;
  73136. }
  73137. }
  73138. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73139. import { Nullable } from "babylonjs/types";
  73140. import { Scene } from "babylonjs/scene";
  73141. import { ISceneComponent } from "babylonjs/sceneComponent";
  73142. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73143. module "babylonjs/scene" {
  73144. interface Scene {
  73145. /** @hidden (Backing field) */
  73146. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73147. /**
  73148. * Gets or Sets the current geometry buffer associated to the scene.
  73149. */
  73150. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73151. /**
  73152. * Enables a GeometryBufferRender and associates it with the scene
  73153. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73154. * @returns the GeometryBufferRenderer
  73155. */
  73156. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73157. /**
  73158. * Disables the GeometryBufferRender associated with the scene
  73159. */
  73160. disableGeometryBufferRenderer(): void;
  73161. }
  73162. }
  73163. /**
  73164. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73165. * in several rendering techniques.
  73166. */
  73167. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73168. /**
  73169. * The component name helpful to identify the component in the list of scene components.
  73170. */
  73171. readonly name: string;
  73172. /**
  73173. * The scene the component belongs to.
  73174. */
  73175. scene: Scene;
  73176. /**
  73177. * Creates a new instance of the component for the given scene
  73178. * @param scene Defines the scene to register the component in
  73179. */
  73180. constructor(scene: Scene);
  73181. /**
  73182. * Registers the component in a given scene
  73183. */
  73184. register(): void;
  73185. /**
  73186. * Rebuilds the elements related to this component in case of
  73187. * context lost for instance.
  73188. */
  73189. rebuild(): void;
  73190. /**
  73191. * Disposes the component and the associated ressources
  73192. */
  73193. dispose(): void;
  73194. private _gatherRenderTargets;
  73195. }
  73196. }
  73197. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73198. /** @hidden */
  73199. export var motionBlurPixelShader: {
  73200. name: string;
  73201. shader: string;
  73202. };
  73203. }
  73204. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73205. import { Nullable } from "babylonjs/types";
  73206. import { Camera } from "babylonjs/Cameras/camera";
  73207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73208. import { Scene } from "babylonjs/scene";
  73209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73210. import "babylonjs/Animations/animatable";
  73211. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73212. import "babylonjs/Shaders/motionBlur.fragment";
  73213. import { Engine } from "babylonjs/Engines/engine";
  73214. /**
  73215. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73216. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73217. * As an example, all you have to do is to create the post-process:
  73218. * var mb = new BABYLON.MotionBlurPostProcess(
  73219. * 'mb', // The name of the effect.
  73220. * scene, // The scene containing the objects to blur according to their velocity.
  73221. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73222. * camera // The camera to apply the render pass to.
  73223. * );
  73224. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73225. */
  73226. export class MotionBlurPostProcess extends PostProcess {
  73227. /**
  73228. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73229. */
  73230. motionStrength: number;
  73231. /**
  73232. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73233. */
  73234. get motionBlurSamples(): number;
  73235. /**
  73236. * Sets the number of iterations to be used for motion blur quality
  73237. */
  73238. set motionBlurSamples(samples: number);
  73239. private _motionBlurSamples;
  73240. private _geometryBufferRenderer;
  73241. /**
  73242. * Creates a new instance MotionBlurPostProcess
  73243. * @param name The name of the effect.
  73244. * @param scene The scene containing the objects to blur according to their velocity.
  73245. * @param options The required width/height ratio to downsize to before computing the render pass.
  73246. * @param camera The camera to apply the render pass to.
  73247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73248. * @param engine The engine which the post process will be applied. (default: current engine)
  73249. * @param reusable If the post process can be reused on the same frame. (default: false)
  73250. * @param textureType Type of textures used when performing the post process. (default: 0)
  73251. * @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)
  73252. */
  73253. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73254. /**
  73255. * Excludes the given skinned mesh from computing bones velocities.
  73256. * 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.
  73257. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73258. */
  73259. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73260. /**
  73261. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73262. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73263. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73264. */
  73265. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73266. /**
  73267. * Disposes the post process.
  73268. * @param camera The camera to dispose the post process on.
  73269. */
  73270. dispose(camera?: Camera): void;
  73271. }
  73272. }
  73273. declare module "babylonjs/Shaders/refraction.fragment" {
  73274. /** @hidden */
  73275. export var refractionPixelShader: {
  73276. name: string;
  73277. shader: string;
  73278. };
  73279. }
  73280. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73281. import { Color3 } from "babylonjs/Maths/math.color";
  73282. import { Camera } from "babylonjs/Cameras/camera";
  73283. import { Texture } from "babylonjs/Materials/Textures/texture";
  73284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73285. import { Engine } from "babylonjs/Engines/engine";
  73286. import "babylonjs/Shaders/refraction.fragment";
  73287. /**
  73288. * Post process which applies a refractin texture
  73289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73290. */
  73291. export class RefractionPostProcess extends PostProcess {
  73292. /** the base color of the refraction (used to taint the rendering) */
  73293. color: Color3;
  73294. /** simulated refraction depth */
  73295. depth: number;
  73296. /** the coefficient of the base color (0 to remove base color tainting) */
  73297. colorLevel: number;
  73298. private _refTexture;
  73299. private _ownRefractionTexture;
  73300. /**
  73301. * Gets or sets the refraction texture
  73302. * Please note that you are responsible for disposing the texture if you set it manually
  73303. */
  73304. get refractionTexture(): Texture;
  73305. set refractionTexture(value: Texture);
  73306. /**
  73307. * Initializes the RefractionPostProcess
  73308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73309. * @param name The name of the effect.
  73310. * @param refractionTextureUrl Url of the refraction texture to use
  73311. * @param color the base color of the refraction (used to taint the rendering)
  73312. * @param depth simulated refraction depth
  73313. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73314. * @param camera The camera to apply the render pass to.
  73315. * @param options The required width/height ratio to downsize to before computing the render pass.
  73316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73317. * @param engine The engine which the post process will be applied. (default: current engine)
  73318. * @param reusable If the post process can be reused on the same frame. (default: false)
  73319. */
  73320. constructor(name: string, refractionTextureUrl: string,
  73321. /** the base color of the refraction (used to taint the rendering) */
  73322. color: Color3,
  73323. /** simulated refraction depth */
  73324. depth: number,
  73325. /** the coefficient of the base color (0 to remove base color tainting) */
  73326. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73327. /**
  73328. * Disposes of the post process
  73329. * @param camera Camera to dispose post process on
  73330. */
  73331. dispose(camera: Camera): void;
  73332. }
  73333. }
  73334. declare module "babylonjs/Shaders/sharpen.fragment" {
  73335. /** @hidden */
  73336. export var sharpenPixelShader: {
  73337. name: string;
  73338. shader: string;
  73339. };
  73340. }
  73341. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73342. import { Nullable } from "babylonjs/types";
  73343. import { Camera } from "babylonjs/Cameras/camera";
  73344. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73345. import "babylonjs/Shaders/sharpen.fragment";
  73346. import { Engine } from "babylonjs/Engines/engine";
  73347. /**
  73348. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73349. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73350. */
  73351. export class SharpenPostProcess extends PostProcess {
  73352. /**
  73353. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73354. */
  73355. colorAmount: number;
  73356. /**
  73357. * How much sharpness should be applied (default: 0.3)
  73358. */
  73359. edgeAmount: number;
  73360. /**
  73361. * Creates a new instance ConvolutionPostProcess
  73362. * @param name The name of the effect.
  73363. * @param options The required width/height ratio to downsize to before computing the render pass.
  73364. * @param camera The camera to apply the render pass to.
  73365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73366. * @param engine The engine which the post process will be applied. (default: current engine)
  73367. * @param reusable If the post process can be reused on the same frame. (default: false)
  73368. * @param textureType Type of textures used when performing the post process. (default: 0)
  73369. * @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)
  73370. */
  73371. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73372. }
  73373. }
  73374. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73375. import { Nullable } from "babylonjs/types";
  73376. import { Camera } from "babylonjs/Cameras/camera";
  73377. import { Engine } from "babylonjs/Engines/engine";
  73378. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73379. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73380. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73381. /**
  73382. * PostProcessRenderPipeline
  73383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73384. */
  73385. export class PostProcessRenderPipeline {
  73386. private engine;
  73387. private _renderEffects;
  73388. private _renderEffectsForIsolatedPass;
  73389. /**
  73390. * List of inspectable custom properties (used by the Inspector)
  73391. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73392. */
  73393. inspectableCustomProperties: IInspectable[];
  73394. /**
  73395. * @hidden
  73396. */
  73397. protected _cameras: Camera[];
  73398. /** @hidden */
  73399. _name: string;
  73400. /**
  73401. * Gets pipeline name
  73402. */
  73403. get name(): string;
  73404. /** Gets the list of attached cameras */
  73405. get cameras(): Camera[];
  73406. /**
  73407. * Initializes a PostProcessRenderPipeline
  73408. * @param engine engine to add the pipeline to
  73409. * @param name name of the pipeline
  73410. */
  73411. constructor(engine: Engine, name: string);
  73412. /**
  73413. * Gets the class name
  73414. * @returns "PostProcessRenderPipeline"
  73415. */
  73416. getClassName(): string;
  73417. /**
  73418. * If all the render effects in the pipeline are supported
  73419. */
  73420. get isSupported(): boolean;
  73421. /**
  73422. * Adds an effect to the pipeline
  73423. * @param renderEffect the effect to add
  73424. */
  73425. addEffect(renderEffect: PostProcessRenderEffect): void;
  73426. /** @hidden */
  73427. _rebuild(): void;
  73428. /** @hidden */
  73429. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73430. /** @hidden */
  73431. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73432. /** @hidden */
  73433. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73434. /** @hidden */
  73435. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73436. /** @hidden */
  73437. _attachCameras(cameras: Camera, unique: boolean): void;
  73438. /** @hidden */
  73439. _attachCameras(cameras: Camera[], unique: boolean): void;
  73440. /** @hidden */
  73441. _detachCameras(cameras: Camera): void;
  73442. /** @hidden */
  73443. _detachCameras(cameras: Nullable<Camera[]>): void;
  73444. /** @hidden */
  73445. _update(): void;
  73446. /** @hidden */
  73447. _reset(): void;
  73448. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73449. /**
  73450. * Sets the required values to the prepass renderer.
  73451. * @param prePassRenderer defines the prepass renderer to setup.
  73452. * @returns true if the pre pass is needed.
  73453. */
  73454. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73455. /**
  73456. * Disposes of the pipeline
  73457. */
  73458. dispose(): void;
  73459. }
  73460. }
  73461. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73462. import { Camera } from "babylonjs/Cameras/camera";
  73463. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73464. /**
  73465. * PostProcessRenderPipelineManager class
  73466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73467. */
  73468. export class PostProcessRenderPipelineManager {
  73469. private _renderPipelines;
  73470. /**
  73471. * Initializes a PostProcessRenderPipelineManager
  73472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73473. */
  73474. constructor();
  73475. /**
  73476. * Gets the list of supported render pipelines
  73477. */
  73478. get supportedPipelines(): PostProcessRenderPipeline[];
  73479. /**
  73480. * Adds a pipeline to the manager
  73481. * @param renderPipeline The pipeline to add
  73482. */
  73483. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73484. /**
  73485. * Attaches a camera to the pipeline
  73486. * @param renderPipelineName The name of the pipeline to attach to
  73487. * @param cameras the camera to attach
  73488. * @param unique if the camera can be attached multiple times to the pipeline
  73489. */
  73490. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73491. /**
  73492. * Detaches a camera from the pipeline
  73493. * @param renderPipelineName The name of the pipeline to detach from
  73494. * @param cameras the camera to detach
  73495. */
  73496. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73497. /**
  73498. * Enables an effect by name on a pipeline
  73499. * @param renderPipelineName the name of the pipeline to enable the effect in
  73500. * @param renderEffectName the name of the effect to enable
  73501. * @param cameras the cameras that the effect should be enabled on
  73502. */
  73503. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73504. /**
  73505. * Disables an effect by name on a pipeline
  73506. * @param renderPipelineName the name of the pipeline to disable the effect in
  73507. * @param renderEffectName the name of the effect to disable
  73508. * @param cameras the cameras that the effect should be disabled on
  73509. */
  73510. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73511. /**
  73512. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73513. */
  73514. update(): void;
  73515. /** @hidden */
  73516. _rebuild(): void;
  73517. /**
  73518. * Disposes of the manager and pipelines
  73519. */
  73520. dispose(): void;
  73521. }
  73522. }
  73523. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73524. import { ISceneComponent } from "babylonjs/sceneComponent";
  73525. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73526. import { Scene } from "babylonjs/scene";
  73527. module "babylonjs/scene" {
  73528. interface Scene {
  73529. /** @hidden (Backing field) */
  73530. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73531. /**
  73532. * Gets the postprocess render pipeline manager
  73533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73534. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73535. */
  73536. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73537. }
  73538. }
  73539. /**
  73540. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73541. */
  73542. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73543. /**
  73544. * The component name helpfull to identify the component in the list of scene components.
  73545. */
  73546. readonly name: string;
  73547. /**
  73548. * The scene the component belongs to.
  73549. */
  73550. scene: Scene;
  73551. /**
  73552. * Creates a new instance of the component for the given scene
  73553. * @param scene Defines the scene to register the component in
  73554. */
  73555. constructor(scene: Scene);
  73556. /**
  73557. * Registers the component in a given scene
  73558. */
  73559. register(): void;
  73560. /**
  73561. * Rebuilds the elements related to this component in case of
  73562. * context lost for instance.
  73563. */
  73564. rebuild(): void;
  73565. /**
  73566. * Disposes the component and the associated ressources
  73567. */
  73568. dispose(): void;
  73569. private _gatherRenderTargets;
  73570. }
  73571. }
  73572. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73573. import { Nullable } from "babylonjs/types";
  73574. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73575. import { Camera } from "babylonjs/Cameras/camera";
  73576. import { IDisposable } from "babylonjs/scene";
  73577. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73578. import { Scene } from "babylonjs/scene";
  73579. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73580. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73581. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73582. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73583. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73584. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73585. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73586. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73587. import { Animation } from "babylonjs/Animations/animation";
  73588. /**
  73589. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73590. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73591. */
  73592. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73593. private _scene;
  73594. private _camerasToBeAttached;
  73595. /**
  73596. * ID of the sharpen post process,
  73597. */
  73598. private readonly SharpenPostProcessId;
  73599. /**
  73600. * @ignore
  73601. * ID of the image processing post process;
  73602. */
  73603. readonly ImageProcessingPostProcessId: string;
  73604. /**
  73605. * @ignore
  73606. * ID of the Fast Approximate Anti-Aliasing post process;
  73607. */
  73608. readonly FxaaPostProcessId: string;
  73609. /**
  73610. * ID of the chromatic aberration post process,
  73611. */
  73612. private readonly ChromaticAberrationPostProcessId;
  73613. /**
  73614. * ID of the grain post process
  73615. */
  73616. private readonly GrainPostProcessId;
  73617. /**
  73618. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73619. */
  73620. sharpen: SharpenPostProcess;
  73621. private _sharpenEffect;
  73622. private bloom;
  73623. /**
  73624. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73625. */
  73626. depthOfField: DepthOfFieldEffect;
  73627. /**
  73628. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73629. */
  73630. fxaa: FxaaPostProcess;
  73631. /**
  73632. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73633. */
  73634. imageProcessing: ImageProcessingPostProcess;
  73635. /**
  73636. * Chromatic aberration post process which will shift rgb colors in the image
  73637. */
  73638. chromaticAberration: ChromaticAberrationPostProcess;
  73639. private _chromaticAberrationEffect;
  73640. /**
  73641. * Grain post process which add noise to the image
  73642. */
  73643. grain: GrainPostProcess;
  73644. private _grainEffect;
  73645. /**
  73646. * Glow post process which adds a glow to emissive areas of the image
  73647. */
  73648. private _glowLayer;
  73649. /**
  73650. * Animations which can be used to tweak settings over a period of time
  73651. */
  73652. animations: Animation[];
  73653. private _imageProcessingConfigurationObserver;
  73654. private _sharpenEnabled;
  73655. private _bloomEnabled;
  73656. private _depthOfFieldEnabled;
  73657. private _depthOfFieldBlurLevel;
  73658. private _fxaaEnabled;
  73659. private _imageProcessingEnabled;
  73660. private _defaultPipelineTextureType;
  73661. private _bloomScale;
  73662. private _chromaticAberrationEnabled;
  73663. private _grainEnabled;
  73664. private _buildAllowed;
  73665. /**
  73666. * Gets active scene
  73667. */
  73668. get scene(): Scene;
  73669. /**
  73670. * Enable or disable the sharpen process from the pipeline
  73671. */
  73672. set sharpenEnabled(enabled: boolean);
  73673. get sharpenEnabled(): boolean;
  73674. private _resizeObserver;
  73675. private _hardwareScaleLevel;
  73676. private _bloomKernel;
  73677. /**
  73678. * Specifies the size of the bloom blur kernel, relative to the final output size
  73679. */
  73680. get bloomKernel(): number;
  73681. set bloomKernel(value: number);
  73682. /**
  73683. * Specifies the weight of the bloom in the final rendering
  73684. */
  73685. private _bloomWeight;
  73686. /**
  73687. * Specifies the luma threshold for the area that will be blurred by the bloom
  73688. */
  73689. private _bloomThreshold;
  73690. private _hdr;
  73691. /**
  73692. * The strength of the bloom.
  73693. */
  73694. set bloomWeight(value: number);
  73695. get bloomWeight(): number;
  73696. /**
  73697. * The strength of the bloom.
  73698. */
  73699. set bloomThreshold(value: number);
  73700. get bloomThreshold(): number;
  73701. /**
  73702. * The scale of the bloom, lower value will provide better performance.
  73703. */
  73704. set bloomScale(value: number);
  73705. get bloomScale(): number;
  73706. /**
  73707. * Enable or disable the bloom from the pipeline
  73708. */
  73709. set bloomEnabled(enabled: boolean);
  73710. get bloomEnabled(): boolean;
  73711. private _rebuildBloom;
  73712. /**
  73713. * If the depth of field is enabled.
  73714. */
  73715. get depthOfFieldEnabled(): boolean;
  73716. set depthOfFieldEnabled(enabled: boolean);
  73717. /**
  73718. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73719. */
  73720. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73721. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73722. /**
  73723. * If the anti aliasing is enabled.
  73724. */
  73725. set fxaaEnabled(enabled: boolean);
  73726. get fxaaEnabled(): boolean;
  73727. private _samples;
  73728. /**
  73729. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73730. */
  73731. set samples(sampleCount: number);
  73732. get samples(): number;
  73733. /**
  73734. * If image processing is enabled.
  73735. */
  73736. set imageProcessingEnabled(enabled: boolean);
  73737. get imageProcessingEnabled(): boolean;
  73738. /**
  73739. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73740. */
  73741. set glowLayerEnabled(enabled: boolean);
  73742. get glowLayerEnabled(): boolean;
  73743. /**
  73744. * Gets the glow layer (or null if not defined)
  73745. */
  73746. get glowLayer(): Nullable<GlowLayer>;
  73747. /**
  73748. * Enable or disable the chromaticAberration process from the pipeline
  73749. */
  73750. set chromaticAberrationEnabled(enabled: boolean);
  73751. get chromaticAberrationEnabled(): boolean;
  73752. /**
  73753. * Enable or disable the grain process from the pipeline
  73754. */
  73755. set grainEnabled(enabled: boolean);
  73756. get grainEnabled(): boolean;
  73757. /**
  73758. * @constructor
  73759. * @param name - The rendering pipeline name (default: "")
  73760. * @param hdr - If high dynamic range textures should be used (default: true)
  73761. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73762. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73763. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73764. */
  73765. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73766. /**
  73767. * Get the class name
  73768. * @returns "DefaultRenderingPipeline"
  73769. */
  73770. getClassName(): string;
  73771. /**
  73772. * Force the compilation of the entire pipeline.
  73773. */
  73774. prepare(): void;
  73775. private _hasCleared;
  73776. private _prevPostProcess;
  73777. private _prevPrevPostProcess;
  73778. private _setAutoClearAndTextureSharing;
  73779. private _depthOfFieldSceneObserver;
  73780. private _buildPipeline;
  73781. private _disposePostProcesses;
  73782. /**
  73783. * Adds a camera to the pipeline
  73784. * @param camera the camera to be added
  73785. */
  73786. addCamera(camera: Camera): void;
  73787. /**
  73788. * Removes a camera from the pipeline
  73789. * @param camera the camera to remove
  73790. */
  73791. removeCamera(camera: Camera): void;
  73792. /**
  73793. * Dispose of the pipeline and stop all post processes
  73794. */
  73795. dispose(): void;
  73796. /**
  73797. * Serialize the rendering pipeline (Used when exporting)
  73798. * @returns the serialized object
  73799. */
  73800. serialize(): any;
  73801. /**
  73802. * Parse the serialized pipeline
  73803. * @param source Source pipeline.
  73804. * @param scene The scene to load the pipeline to.
  73805. * @param rootUrl The URL of the serialized pipeline.
  73806. * @returns An instantiated pipeline from the serialized object.
  73807. */
  73808. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73809. }
  73810. }
  73811. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73812. /** @hidden */
  73813. export var lensHighlightsPixelShader: {
  73814. name: string;
  73815. shader: string;
  73816. };
  73817. }
  73818. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73819. /** @hidden */
  73820. export var depthOfFieldPixelShader: {
  73821. name: string;
  73822. shader: string;
  73823. };
  73824. }
  73825. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73826. import { Camera } from "babylonjs/Cameras/camera";
  73827. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73828. import { Scene } from "babylonjs/scene";
  73829. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73830. import "babylonjs/Shaders/chromaticAberration.fragment";
  73831. import "babylonjs/Shaders/lensHighlights.fragment";
  73832. import "babylonjs/Shaders/depthOfField.fragment";
  73833. /**
  73834. * BABYLON.JS Chromatic Aberration GLSL Shader
  73835. * Author: Olivier Guyot
  73836. * Separates very slightly R, G and B colors on the edges of the screen
  73837. * Inspired by Francois Tarlier & Martins Upitis
  73838. */
  73839. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73840. /**
  73841. * @ignore
  73842. * The chromatic aberration PostProcess id in the pipeline
  73843. */
  73844. LensChromaticAberrationEffect: string;
  73845. /**
  73846. * @ignore
  73847. * The highlights enhancing PostProcess id in the pipeline
  73848. */
  73849. HighlightsEnhancingEffect: string;
  73850. /**
  73851. * @ignore
  73852. * The depth-of-field PostProcess id in the pipeline
  73853. */
  73854. LensDepthOfFieldEffect: string;
  73855. private _scene;
  73856. private _depthTexture;
  73857. private _grainTexture;
  73858. private _chromaticAberrationPostProcess;
  73859. private _highlightsPostProcess;
  73860. private _depthOfFieldPostProcess;
  73861. private _edgeBlur;
  73862. private _grainAmount;
  73863. private _chromaticAberration;
  73864. private _distortion;
  73865. private _highlightsGain;
  73866. private _highlightsThreshold;
  73867. private _dofDistance;
  73868. private _dofAperture;
  73869. private _dofDarken;
  73870. private _dofPentagon;
  73871. private _blurNoise;
  73872. /**
  73873. * @constructor
  73874. *
  73875. * Effect parameters are as follow:
  73876. * {
  73877. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73878. * edge_blur: number; // from 0 to x (1 for realism)
  73879. * distortion: number; // from 0 to x (1 for realism)
  73880. * grain_amount: number; // from 0 to 1
  73881. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73882. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73883. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73884. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73885. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73886. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73887. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73888. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73889. * }
  73890. * Note: if an effect parameter is unset, effect is disabled
  73891. *
  73892. * @param name The rendering pipeline name
  73893. * @param parameters - An object containing all parameters (see above)
  73894. * @param scene The scene linked to this pipeline
  73895. * @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)
  73896. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73897. */
  73898. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73899. /**
  73900. * Get the class name
  73901. * @returns "LensRenderingPipeline"
  73902. */
  73903. getClassName(): string;
  73904. /**
  73905. * Gets associated scene
  73906. */
  73907. get scene(): Scene;
  73908. /**
  73909. * Gets or sets the edge blur
  73910. */
  73911. get edgeBlur(): number;
  73912. set edgeBlur(value: number);
  73913. /**
  73914. * Gets or sets the grain amount
  73915. */
  73916. get grainAmount(): number;
  73917. set grainAmount(value: number);
  73918. /**
  73919. * Gets or sets the chromatic aberration amount
  73920. */
  73921. get chromaticAberration(): number;
  73922. set chromaticAberration(value: number);
  73923. /**
  73924. * Gets or sets the depth of field aperture
  73925. */
  73926. get dofAperture(): number;
  73927. set dofAperture(value: number);
  73928. /**
  73929. * Gets or sets the edge distortion
  73930. */
  73931. get edgeDistortion(): number;
  73932. set edgeDistortion(value: number);
  73933. /**
  73934. * Gets or sets the depth of field distortion
  73935. */
  73936. get dofDistortion(): number;
  73937. set dofDistortion(value: number);
  73938. /**
  73939. * Gets or sets the darken out of focus amount
  73940. */
  73941. get darkenOutOfFocus(): number;
  73942. set darkenOutOfFocus(value: number);
  73943. /**
  73944. * Gets or sets a boolean indicating if blur noise is enabled
  73945. */
  73946. get blurNoise(): boolean;
  73947. set blurNoise(value: boolean);
  73948. /**
  73949. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73950. */
  73951. get pentagonBokeh(): boolean;
  73952. set pentagonBokeh(value: boolean);
  73953. /**
  73954. * Gets or sets the highlight grain amount
  73955. */
  73956. get highlightsGain(): number;
  73957. set highlightsGain(value: number);
  73958. /**
  73959. * Gets or sets the highlight threshold
  73960. */
  73961. get highlightsThreshold(): number;
  73962. set highlightsThreshold(value: number);
  73963. /**
  73964. * Sets the amount of blur at the edges
  73965. * @param amount blur amount
  73966. */
  73967. setEdgeBlur(amount: number): void;
  73968. /**
  73969. * Sets edge blur to 0
  73970. */
  73971. disableEdgeBlur(): void;
  73972. /**
  73973. * Sets the amout of grain
  73974. * @param amount Amount of grain
  73975. */
  73976. setGrainAmount(amount: number): void;
  73977. /**
  73978. * Set grain amount to 0
  73979. */
  73980. disableGrain(): void;
  73981. /**
  73982. * Sets the chromatic aberration amount
  73983. * @param amount amount of chromatic aberration
  73984. */
  73985. setChromaticAberration(amount: number): void;
  73986. /**
  73987. * Sets chromatic aberration amount to 0
  73988. */
  73989. disableChromaticAberration(): void;
  73990. /**
  73991. * Sets the EdgeDistortion amount
  73992. * @param amount amount of EdgeDistortion
  73993. */
  73994. setEdgeDistortion(amount: number): void;
  73995. /**
  73996. * Sets edge distortion to 0
  73997. */
  73998. disableEdgeDistortion(): void;
  73999. /**
  74000. * Sets the FocusDistance amount
  74001. * @param amount amount of FocusDistance
  74002. */
  74003. setFocusDistance(amount: number): void;
  74004. /**
  74005. * Disables depth of field
  74006. */
  74007. disableDepthOfField(): void;
  74008. /**
  74009. * Sets the Aperture amount
  74010. * @param amount amount of Aperture
  74011. */
  74012. setAperture(amount: number): void;
  74013. /**
  74014. * Sets the DarkenOutOfFocus amount
  74015. * @param amount amount of DarkenOutOfFocus
  74016. */
  74017. setDarkenOutOfFocus(amount: number): void;
  74018. private _pentagonBokehIsEnabled;
  74019. /**
  74020. * Creates a pentagon bokeh effect
  74021. */
  74022. enablePentagonBokeh(): void;
  74023. /**
  74024. * Disables the pentagon bokeh effect
  74025. */
  74026. disablePentagonBokeh(): void;
  74027. /**
  74028. * Enables noise blur
  74029. */
  74030. enableNoiseBlur(): void;
  74031. /**
  74032. * Disables noise blur
  74033. */
  74034. disableNoiseBlur(): void;
  74035. /**
  74036. * Sets the HighlightsGain amount
  74037. * @param amount amount of HighlightsGain
  74038. */
  74039. setHighlightsGain(amount: number): void;
  74040. /**
  74041. * Sets the HighlightsThreshold amount
  74042. * @param amount amount of HighlightsThreshold
  74043. */
  74044. setHighlightsThreshold(amount: number): void;
  74045. /**
  74046. * Disables highlights
  74047. */
  74048. disableHighlights(): void;
  74049. /**
  74050. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74051. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74052. */
  74053. dispose(disableDepthRender?: boolean): void;
  74054. private _createChromaticAberrationPostProcess;
  74055. private _createHighlightsPostProcess;
  74056. private _createDepthOfFieldPostProcess;
  74057. private _createGrainTexture;
  74058. }
  74059. }
  74060. declare module "babylonjs/Shaders/ssao2.fragment" {
  74061. /** @hidden */
  74062. export var ssao2PixelShader: {
  74063. name: string;
  74064. shader: string;
  74065. };
  74066. }
  74067. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74068. /** @hidden */
  74069. export var ssaoCombinePixelShader: {
  74070. name: string;
  74071. shader: string;
  74072. };
  74073. }
  74074. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74075. import { Camera } from "babylonjs/Cameras/camera";
  74076. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74077. import { Scene } from "babylonjs/scene";
  74078. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74079. import "babylonjs/Shaders/ssao2.fragment";
  74080. import "babylonjs/Shaders/ssaoCombine.fragment";
  74081. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74082. /**
  74083. * Render pipeline to produce ssao effect
  74084. */
  74085. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74086. /**
  74087. * @ignore
  74088. * The PassPostProcess id in the pipeline that contains the original scene color
  74089. */
  74090. SSAOOriginalSceneColorEffect: string;
  74091. /**
  74092. * @ignore
  74093. * The SSAO PostProcess id in the pipeline
  74094. */
  74095. SSAORenderEffect: string;
  74096. /**
  74097. * @ignore
  74098. * The horizontal blur PostProcess id in the pipeline
  74099. */
  74100. SSAOBlurHRenderEffect: string;
  74101. /**
  74102. * @ignore
  74103. * The vertical blur PostProcess id in the pipeline
  74104. */
  74105. SSAOBlurVRenderEffect: string;
  74106. /**
  74107. * @ignore
  74108. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74109. */
  74110. SSAOCombineRenderEffect: string;
  74111. /**
  74112. * The output strength of the SSAO post-process. Default value is 1.0.
  74113. */
  74114. totalStrength: number;
  74115. /**
  74116. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74117. */
  74118. maxZ: number;
  74119. /**
  74120. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74121. */
  74122. minZAspect: number;
  74123. private _samples;
  74124. /**
  74125. * Number of samples used for the SSAO calculations. Default value is 8
  74126. */
  74127. set samples(n: number);
  74128. get samples(): number;
  74129. private _textureSamples;
  74130. /**
  74131. * Number of samples to use for antialiasing
  74132. */
  74133. set textureSamples(n: number);
  74134. get textureSamples(): number;
  74135. /**
  74136. * Force rendering the geometry through geometry buffer
  74137. */
  74138. private _forceGeometryBuffer;
  74139. /**
  74140. * Ratio object used for SSAO ratio and blur ratio
  74141. */
  74142. private _ratio;
  74143. /**
  74144. * Dynamically generated sphere sampler.
  74145. */
  74146. private _sampleSphere;
  74147. /**
  74148. * Blur filter offsets
  74149. */
  74150. private _samplerOffsets;
  74151. private _expensiveBlur;
  74152. /**
  74153. * If bilateral blur should be used
  74154. */
  74155. set expensiveBlur(b: boolean);
  74156. get expensiveBlur(): boolean;
  74157. /**
  74158. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74159. */
  74160. radius: number;
  74161. /**
  74162. * The base color of the SSAO post-process
  74163. * The final result is "base + ssao" between [0, 1]
  74164. */
  74165. base: number;
  74166. /**
  74167. * Support test.
  74168. */
  74169. static get IsSupported(): boolean;
  74170. private _scene;
  74171. private _randomTexture;
  74172. private _originalColorPostProcess;
  74173. private _ssaoPostProcess;
  74174. private _blurHPostProcess;
  74175. private _blurVPostProcess;
  74176. private _ssaoCombinePostProcess;
  74177. private _prePassRenderer;
  74178. /**
  74179. * Gets active scene
  74180. */
  74181. get scene(): Scene;
  74182. /**
  74183. * @constructor
  74184. * @param name The rendering pipeline name
  74185. * @param scene The scene linked to this pipeline
  74186. * @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 }
  74187. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74188. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74189. */
  74190. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74191. /**
  74192. * Get the class name
  74193. * @returns "SSAO2RenderingPipeline"
  74194. */
  74195. getClassName(): string;
  74196. /**
  74197. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74198. */
  74199. dispose(disableGeometryBufferRenderer?: boolean): void;
  74200. private _createBlurPostProcess;
  74201. /** @hidden */
  74202. _rebuild(): void;
  74203. private _bits;
  74204. private _radicalInverse_VdC;
  74205. private _hammersley;
  74206. private _hemisphereSample_uniform;
  74207. private _generateHemisphere;
  74208. private _getDefinesForSSAO;
  74209. private _createSSAOPostProcess;
  74210. private _createSSAOCombinePostProcess;
  74211. private _createRandomTexture;
  74212. /**
  74213. * Serialize the rendering pipeline (Used when exporting)
  74214. * @returns the serialized object
  74215. */
  74216. serialize(): any;
  74217. /**
  74218. * Parse the serialized pipeline
  74219. * @param source Source pipeline.
  74220. * @param scene The scene to load the pipeline to.
  74221. * @param rootUrl The URL of the serialized pipeline.
  74222. * @returns An instantiated pipeline from the serialized object.
  74223. */
  74224. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74225. /**
  74226. * Sets the required values to the prepass renderer.
  74227. * @param prePassRenderer defines the prepass renderer to setup
  74228. * @returns true if the pre pass is needed.
  74229. */
  74230. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74231. }
  74232. }
  74233. declare module "babylonjs/Shaders/ssao.fragment" {
  74234. /** @hidden */
  74235. export var ssaoPixelShader: {
  74236. name: string;
  74237. shader: string;
  74238. };
  74239. }
  74240. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74241. import { Camera } from "babylonjs/Cameras/camera";
  74242. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74243. import { Scene } from "babylonjs/scene";
  74244. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74245. import "babylonjs/Shaders/ssao.fragment";
  74246. import "babylonjs/Shaders/ssaoCombine.fragment";
  74247. /**
  74248. * Render pipeline to produce ssao effect
  74249. */
  74250. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74251. /**
  74252. * @ignore
  74253. * The PassPostProcess id in the pipeline that contains the original scene color
  74254. */
  74255. SSAOOriginalSceneColorEffect: string;
  74256. /**
  74257. * @ignore
  74258. * The SSAO PostProcess id in the pipeline
  74259. */
  74260. SSAORenderEffect: string;
  74261. /**
  74262. * @ignore
  74263. * The horizontal blur PostProcess id in the pipeline
  74264. */
  74265. SSAOBlurHRenderEffect: string;
  74266. /**
  74267. * @ignore
  74268. * The vertical blur PostProcess id in the pipeline
  74269. */
  74270. SSAOBlurVRenderEffect: string;
  74271. /**
  74272. * @ignore
  74273. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74274. */
  74275. SSAOCombineRenderEffect: string;
  74276. /**
  74277. * The output strength of the SSAO post-process. Default value is 1.0.
  74278. */
  74279. totalStrength: number;
  74280. /**
  74281. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74282. */
  74283. radius: number;
  74284. /**
  74285. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74286. * Must not be equal to fallOff and superior to fallOff.
  74287. * Default value is 0.0075
  74288. */
  74289. area: number;
  74290. /**
  74291. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74292. * Must not be equal to area and inferior to area.
  74293. * Default value is 0.000001
  74294. */
  74295. fallOff: number;
  74296. /**
  74297. * The base color of the SSAO post-process
  74298. * The final result is "base + ssao" between [0, 1]
  74299. */
  74300. base: number;
  74301. private _scene;
  74302. private _depthTexture;
  74303. private _randomTexture;
  74304. private _originalColorPostProcess;
  74305. private _ssaoPostProcess;
  74306. private _blurHPostProcess;
  74307. private _blurVPostProcess;
  74308. private _ssaoCombinePostProcess;
  74309. private _firstUpdate;
  74310. /**
  74311. * Gets active scene
  74312. */
  74313. get scene(): Scene;
  74314. /**
  74315. * @constructor
  74316. * @param name - The rendering pipeline name
  74317. * @param scene - The scene linked to this pipeline
  74318. * @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 }
  74319. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74320. */
  74321. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74322. /**
  74323. * Get the class name
  74324. * @returns "SSAORenderingPipeline"
  74325. */
  74326. getClassName(): string;
  74327. /**
  74328. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74329. */
  74330. dispose(disableDepthRender?: boolean): void;
  74331. private _createBlurPostProcess;
  74332. /** @hidden */
  74333. _rebuild(): void;
  74334. private _createSSAOPostProcess;
  74335. private _createSSAOCombinePostProcess;
  74336. private _createRandomTexture;
  74337. }
  74338. }
  74339. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74340. /** @hidden */
  74341. export var screenSpaceReflectionPixelShader: {
  74342. name: string;
  74343. shader: string;
  74344. };
  74345. }
  74346. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74347. import { Nullable } from "babylonjs/types";
  74348. import { Camera } from "babylonjs/Cameras/camera";
  74349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74350. import { Scene } from "babylonjs/scene";
  74351. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74352. import { Engine } from "babylonjs/Engines/engine";
  74353. /**
  74354. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74355. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74356. */
  74357. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74358. /**
  74359. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74360. */
  74361. threshold: number;
  74362. /**
  74363. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74364. */
  74365. strength: number;
  74366. /**
  74367. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74368. */
  74369. reflectionSpecularFalloffExponent: number;
  74370. /**
  74371. * 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]
  74372. */
  74373. step: number;
  74374. /**
  74375. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74376. */
  74377. roughnessFactor: number;
  74378. private _geometryBufferRenderer;
  74379. private _enableSmoothReflections;
  74380. private _reflectionSamples;
  74381. private _smoothSteps;
  74382. /**
  74383. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74384. * @param name The name of the effect.
  74385. * @param scene The scene containing the objects to calculate reflections.
  74386. * @param options The required width/height ratio to downsize to before computing the render pass.
  74387. * @param camera The camera to apply the render pass to.
  74388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74389. * @param engine The engine which the post process will be applied. (default: current engine)
  74390. * @param reusable If the post process can be reused on the same frame. (default: false)
  74391. * @param textureType Type of textures used when performing the post process. (default: 0)
  74392. * @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)
  74393. */
  74394. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74395. /**
  74396. * Gets wether or not smoothing reflections is enabled.
  74397. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74398. */
  74399. get enableSmoothReflections(): boolean;
  74400. /**
  74401. * Sets wether or not smoothing reflections is enabled.
  74402. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74403. */
  74404. set enableSmoothReflections(enabled: boolean);
  74405. /**
  74406. * Gets the number of samples taken while computing reflections. More samples count is high,
  74407. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74408. */
  74409. get reflectionSamples(): number;
  74410. /**
  74411. * Sets the number of samples taken while computing reflections. More samples count is high,
  74412. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74413. */
  74414. set reflectionSamples(samples: number);
  74415. /**
  74416. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74417. * more the post-process will require GPU power and can generate a drop in FPS.
  74418. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74419. */
  74420. get smoothSteps(): number;
  74421. set smoothSteps(steps: number);
  74422. private _updateEffectDefines;
  74423. }
  74424. }
  74425. declare module "babylonjs/Shaders/standard.fragment" {
  74426. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74427. /** @hidden */
  74428. export var standardPixelShader: {
  74429. name: string;
  74430. shader: string;
  74431. };
  74432. }
  74433. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74434. import { Nullable } from "babylonjs/types";
  74435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74436. import { Camera } from "babylonjs/Cameras/camera";
  74437. import { Texture } from "babylonjs/Materials/Textures/texture";
  74438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74439. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74440. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74441. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74442. import { IDisposable } from "babylonjs/scene";
  74443. import { SpotLight } from "babylonjs/Lights/spotLight";
  74444. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74445. import { Scene } from "babylonjs/scene";
  74446. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74447. import { Animation } from "babylonjs/Animations/animation";
  74448. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74449. import "babylonjs/Shaders/standard.fragment";
  74450. /**
  74451. * Standard rendering pipeline
  74452. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74453. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74454. */
  74455. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74456. /**
  74457. * Public members
  74458. */
  74459. /**
  74460. * Post-process which contains the original scene color before the pipeline applies all the effects
  74461. */
  74462. originalPostProcess: Nullable<PostProcess>;
  74463. /**
  74464. * Post-process used to down scale an image x4
  74465. */
  74466. downSampleX4PostProcess: Nullable<PostProcess>;
  74467. /**
  74468. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74469. */
  74470. brightPassPostProcess: Nullable<PostProcess>;
  74471. /**
  74472. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74473. */
  74474. blurHPostProcesses: PostProcess[];
  74475. /**
  74476. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74477. */
  74478. blurVPostProcesses: PostProcess[];
  74479. /**
  74480. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74481. */
  74482. textureAdderPostProcess: Nullable<PostProcess>;
  74483. /**
  74484. * Post-process used to create volumetric lighting effect
  74485. */
  74486. volumetricLightPostProcess: Nullable<PostProcess>;
  74487. /**
  74488. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74489. */
  74490. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74491. /**
  74492. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74493. */
  74494. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74495. /**
  74496. * Post-process used to merge the volumetric light effect and the real scene color
  74497. */
  74498. volumetricLightMergePostProces: Nullable<PostProcess>;
  74499. /**
  74500. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74501. */
  74502. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74503. /**
  74504. * Base post-process used to calculate the average luminance of the final image for HDR
  74505. */
  74506. luminancePostProcess: Nullable<PostProcess>;
  74507. /**
  74508. * Post-processes used to create down sample post-processes in order to get
  74509. * the average luminance of the final image for HDR
  74510. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74511. */
  74512. luminanceDownSamplePostProcesses: PostProcess[];
  74513. /**
  74514. * Post-process used to create a HDR effect (light adaptation)
  74515. */
  74516. hdrPostProcess: Nullable<PostProcess>;
  74517. /**
  74518. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74519. */
  74520. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74521. /**
  74522. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74523. */
  74524. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74525. /**
  74526. * Post-process used to merge the final HDR post-process and the real scene color
  74527. */
  74528. hdrFinalPostProcess: Nullable<PostProcess>;
  74529. /**
  74530. * Post-process used to create a lens flare effect
  74531. */
  74532. lensFlarePostProcess: Nullable<PostProcess>;
  74533. /**
  74534. * Post-process that merges the result of the lens flare post-process and the real scene color
  74535. */
  74536. lensFlareComposePostProcess: Nullable<PostProcess>;
  74537. /**
  74538. * Post-process used to create a motion blur effect
  74539. */
  74540. motionBlurPostProcess: Nullable<PostProcess>;
  74541. /**
  74542. * Post-process used to create a depth of field effect
  74543. */
  74544. depthOfFieldPostProcess: Nullable<PostProcess>;
  74545. /**
  74546. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74547. */
  74548. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74549. /**
  74550. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74551. */
  74552. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74553. /**
  74554. * Represents the brightness threshold in order to configure the illuminated surfaces
  74555. */
  74556. brightThreshold: number;
  74557. /**
  74558. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74559. */
  74560. blurWidth: number;
  74561. /**
  74562. * Sets if the blur for highlighted surfaces must be only horizontal
  74563. */
  74564. horizontalBlur: boolean;
  74565. /**
  74566. * Gets the overall exposure used by the pipeline
  74567. */
  74568. get exposure(): number;
  74569. /**
  74570. * Sets the overall exposure used by the pipeline
  74571. */
  74572. set exposure(value: number);
  74573. /**
  74574. * Texture used typically to simulate "dirty" on camera lens
  74575. */
  74576. lensTexture: Nullable<Texture>;
  74577. /**
  74578. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74579. */
  74580. volumetricLightCoefficient: number;
  74581. /**
  74582. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74583. */
  74584. volumetricLightPower: number;
  74585. /**
  74586. * Used the set the blur intensity to smooth the volumetric lights
  74587. */
  74588. volumetricLightBlurScale: number;
  74589. /**
  74590. * Light (spot or directional) used to generate the volumetric lights rays
  74591. * The source light must have a shadow generate so the pipeline can get its
  74592. * depth map
  74593. */
  74594. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74595. /**
  74596. * For eye adaptation, represents the minimum luminance the eye can see
  74597. */
  74598. hdrMinimumLuminance: number;
  74599. /**
  74600. * For eye adaptation, represents the decrease luminance speed
  74601. */
  74602. hdrDecreaseRate: number;
  74603. /**
  74604. * For eye adaptation, represents the increase luminance speed
  74605. */
  74606. hdrIncreaseRate: number;
  74607. /**
  74608. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74609. */
  74610. get hdrAutoExposure(): boolean;
  74611. /**
  74612. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74613. */
  74614. set hdrAutoExposure(value: boolean);
  74615. /**
  74616. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74617. */
  74618. lensColorTexture: Nullable<Texture>;
  74619. /**
  74620. * The overall strengh for the lens flare effect
  74621. */
  74622. lensFlareStrength: number;
  74623. /**
  74624. * Dispersion coefficient for lens flare ghosts
  74625. */
  74626. lensFlareGhostDispersal: number;
  74627. /**
  74628. * Main lens flare halo width
  74629. */
  74630. lensFlareHaloWidth: number;
  74631. /**
  74632. * Based on the lens distortion effect, defines how much the lens flare result
  74633. * is distorted
  74634. */
  74635. lensFlareDistortionStrength: number;
  74636. /**
  74637. * Configures the blur intensity used for for lens flare (halo)
  74638. */
  74639. lensFlareBlurWidth: number;
  74640. /**
  74641. * Lens star texture must be used to simulate rays on the flares and is available
  74642. * in the documentation
  74643. */
  74644. lensStarTexture: Nullable<Texture>;
  74645. /**
  74646. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74647. * flare effect by taking account of the dirt texture
  74648. */
  74649. lensFlareDirtTexture: Nullable<Texture>;
  74650. /**
  74651. * Represents the focal length for the depth of field effect
  74652. */
  74653. depthOfFieldDistance: number;
  74654. /**
  74655. * Represents the blur intensity for the blurred part of the depth of field effect
  74656. */
  74657. depthOfFieldBlurWidth: number;
  74658. /**
  74659. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74660. */
  74661. get motionStrength(): number;
  74662. /**
  74663. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74664. */
  74665. set motionStrength(strength: number);
  74666. /**
  74667. * Gets wether or not the motion blur post-process is object based or screen based.
  74668. */
  74669. get objectBasedMotionBlur(): boolean;
  74670. /**
  74671. * Sets wether or not the motion blur post-process should be object based or screen based
  74672. */
  74673. set objectBasedMotionBlur(value: boolean);
  74674. /**
  74675. * List of animations for the pipeline (IAnimatable implementation)
  74676. */
  74677. animations: Animation[];
  74678. /**
  74679. * Private members
  74680. */
  74681. private _scene;
  74682. private _currentDepthOfFieldSource;
  74683. private _basePostProcess;
  74684. private _fixedExposure;
  74685. private _currentExposure;
  74686. private _hdrAutoExposure;
  74687. private _hdrCurrentLuminance;
  74688. private _motionStrength;
  74689. private _isObjectBasedMotionBlur;
  74690. private _floatTextureType;
  74691. private _camerasToBeAttached;
  74692. private _ratio;
  74693. private _bloomEnabled;
  74694. private _depthOfFieldEnabled;
  74695. private _vlsEnabled;
  74696. private _lensFlareEnabled;
  74697. private _hdrEnabled;
  74698. private _motionBlurEnabled;
  74699. private _fxaaEnabled;
  74700. private _screenSpaceReflectionsEnabled;
  74701. private _motionBlurSamples;
  74702. private _volumetricLightStepsCount;
  74703. private _samples;
  74704. /**
  74705. * @ignore
  74706. * Specifies if the bloom pipeline is enabled
  74707. */
  74708. get BloomEnabled(): boolean;
  74709. set BloomEnabled(enabled: boolean);
  74710. /**
  74711. * @ignore
  74712. * Specifies if the depth of field pipeline is enabed
  74713. */
  74714. get DepthOfFieldEnabled(): boolean;
  74715. set DepthOfFieldEnabled(enabled: boolean);
  74716. /**
  74717. * @ignore
  74718. * Specifies if the lens flare pipeline is enabed
  74719. */
  74720. get LensFlareEnabled(): boolean;
  74721. set LensFlareEnabled(enabled: boolean);
  74722. /**
  74723. * @ignore
  74724. * Specifies if the HDR pipeline is enabled
  74725. */
  74726. get HDREnabled(): boolean;
  74727. set HDREnabled(enabled: boolean);
  74728. /**
  74729. * @ignore
  74730. * Specifies if the volumetric lights scattering effect is enabled
  74731. */
  74732. get VLSEnabled(): boolean;
  74733. set VLSEnabled(enabled: boolean);
  74734. /**
  74735. * @ignore
  74736. * Specifies if the motion blur effect is enabled
  74737. */
  74738. get MotionBlurEnabled(): boolean;
  74739. set MotionBlurEnabled(enabled: boolean);
  74740. /**
  74741. * Specifies if anti-aliasing is enabled
  74742. */
  74743. get fxaaEnabled(): boolean;
  74744. set fxaaEnabled(enabled: boolean);
  74745. /**
  74746. * Specifies if screen space reflections are enabled.
  74747. */
  74748. get screenSpaceReflectionsEnabled(): boolean;
  74749. set screenSpaceReflectionsEnabled(enabled: boolean);
  74750. /**
  74751. * Specifies the number of steps used to calculate the volumetric lights
  74752. * Typically in interval [50, 200]
  74753. */
  74754. get volumetricLightStepsCount(): number;
  74755. set volumetricLightStepsCount(count: number);
  74756. /**
  74757. * Specifies the number of samples used for the motion blur effect
  74758. * Typically in interval [16, 64]
  74759. */
  74760. get motionBlurSamples(): number;
  74761. set motionBlurSamples(samples: number);
  74762. /**
  74763. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74764. */
  74765. get samples(): number;
  74766. set samples(sampleCount: number);
  74767. /**
  74768. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74769. * @constructor
  74770. * @param name The rendering pipeline name
  74771. * @param scene The scene linked to this pipeline
  74772. * @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)
  74773. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74774. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74775. */
  74776. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74777. private _buildPipeline;
  74778. private _createDownSampleX4PostProcess;
  74779. private _createBrightPassPostProcess;
  74780. private _createBlurPostProcesses;
  74781. private _createTextureAdderPostProcess;
  74782. private _createVolumetricLightPostProcess;
  74783. private _createLuminancePostProcesses;
  74784. private _createHdrPostProcess;
  74785. private _createLensFlarePostProcess;
  74786. private _createDepthOfFieldPostProcess;
  74787. private _createMotionBlurPostProcess;
  74788. private _getDepthTexture;
  74789. private _disposePostProcesses;
  74790. /**
  74791. * Dispose of the pipeline and stop all post processes
  74792. */
  74793. dispose(): void;
  74794. /**
  74795. * Serialize the rendering pipeline (Used when exporting)
  74796. * @returns the serialized object
  74797. */
  74798. serialize(): any;
  74799. /**
  74800. * Parse the serialized pipeline
  74801. * @param source Source pipeline.
  74802. * @param scene The scene to load the pipeline to.
  74803. * @param rootUrl The URL of the serialized pipeline.
  74804. * @returns An instantiated pipeline from the serialized object.
  74805. */
  74806. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74807. /**
  74808. * Luminance steps
  74809. */
  74810. static LuminanceSteps: number;
  74811. }
  74812. }
  74813. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74814. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74815. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74816. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74817. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74818. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74819. }
  74820. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74821. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74822. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74823. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74824. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74825. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74826. }
  74827. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74828. /** @hidden */
  74829. export var stereoscopicInterlacePixelShader: {
  74830. name: string;
  74831. shader: string;
  74832. };
  74833. }
  74834. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74835. import { Camera } from "babylonjs/Cameras/camera";
  74836. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74837. import { Engine } from "babylonjs/Engines/engine";
  74838. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74839. /**
  74840. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74841. */
  74842. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74843. private _stepSize;
  74844. private _passedProcess;
  74845. /**
  74846. * Initializes a StereoscopicInterlacePostProcessI
  74847. * @param name The name of the effect.
  74848. * @param rigCameras The rig cameras to be appled to the post process
  74849. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74850. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74852. * @param engine The engine which the post process will be applied. (default: current engine)
  74853. * @param reusable If the post process can be reused on the same frame. (default: false)
  74854. */
  74855. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74856. }
  74857. /**
  74858. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74859. */
  74860. export class StereoscopicInterlacePostProcess extends PostProcess {
  74861. private _stepSize;
  74862. private _passedProcess;
  74863. /**
  74864. * Initializes a StereoscopicInterlacePostProcess
  74865. * @param name The name of the effect.
  74866. * @param rigCameras The rig cameras to be appled to the post process
  74867. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74869. * @param engine The engine which the post process will be applied. (default: current engine)
  74870. * @param reusable If the post process can be reused on the same frame. (default: false)
  74871. */
  74872. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74873. }
  74874. }
  74875. declare module "babylonjs/Shaders/tonemap.fragment" {
  74876. /** @hidden */
  74877. export var tonemapPixelShader: {
  74878. name: string;
  74879. shader: string;
  74880. };
  74881. }
  74882. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74883. import { Camera } from "babylonjs/Cameras/camera";
  74884. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74885. import "babylonjs/Shaders/tonemap.fragment";
  74886. import { Engine } from "babylonjs/Engines/engine";
  74887. /** Defines operator used for tonemapping */
  74888. export enum TonemappingOperator {
  74889. /** Hable */
  74890. Hable = 0,
  74891. /** Reinhard */
  74892. Reinhard = 1,
  74893. /** HejiDawson */
  74894. HejiDawson = 2,
  74895. /** Photographic */
  74896. Photographic = 3
  74897. }
  74898. /**
  74899. * Defines a post process to apply tone mapping
  74900. */
  74901. export class TonemapPostProcess extends PostProcess {
  74902. private _operator;
  74903. /** Defines the required exposure adjustement */
  74904. exposureAdjustment: number;
  74905. /**
  74906. * Creates a new TonemapPostProcess
  74907. * @param name defines the name of the postprocess
  74908. * @param _operator defines the operator to use
  74909. * @param exposureAdjustment defines the required exposure adjustement
  74910. * @param camera defines the camera to use (can be null)
  74911. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74912. * @param engine defines the hosting engine (can be ignore if camera is set)
  74913. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74914. */
  74915. constructor(name: string, _operator: TonemappingOperator,
  74916. /** Defines the required exposure adjustement */
  74917. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74918. }
  74919. }
  74920. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74921. /** @hidden */
  74922. export var volumetricLightScatteringPixelShader: {
  74923. name: string;
  74924. shader: string;
  74925. };
  74926. }
  74927. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74928. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74929. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74930. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74931. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74932. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74933. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74934. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74935. /** @hidden */
  74936. export var volumetricLightScatteringPassVertexShader: {
  74937. name: string;
  74938. shader: string;
  74939. };
  74940. }
  74941. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74942. /** @hidden */
  74943. export var volumetricLightScatteringPassPixelShader: {
  74944. name: string;
  74945. shader: string;
  74946. };
  74947. }
  74948. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74949. import { Vector3 } from "babylonjs/Maths/math.vector";
  74950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74951. import { Mesh } from "babylonjs/Meshes/mesh";
  74952. import { Camera } from "babylonjs/Cameras/camera";
  74953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74954. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74955. import { Scene } from "babylonjs/scene";
  74956. import "babylonjs/Meshes/Builders/planeBuilder";
  74957. import "babylonjs/Shaders/depth.vertex";
  74958. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74959. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74960. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74961. import { Engine } from "babylonjs/Engines/engine";
  74962. /**
  74963. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74964. */
  74965. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74966. private _volumetricLightScatteringPass;
  74967. private _volumetricLightScatteringRTT;
  74968. private _viewPort;
  74969. private _screenCoordinates;
  74970. private _cachedDefines;
  74971. /**
  74972. * If not undefined, the mesh position is computed from the attached node position
  74973. */
  74974. attachedNode: {
  74975. position: Vector3;
  74976. };
  74977. /**
  74978. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74979. */
  74980. customMeshPosition: Vector3;
  74981. /**
  74982. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74983. */
  74984. useCustomMeshPosition: boolean;
  74985. /**
  74986. * If the post-process should inverse the light scattering direction
  74987. */
  74988. invert: boolean;
  74989. /**
  74990. * The internal mesh used by the post-process
  74991. */
  74992. mesh: Mesh;
  74993. /**
  74994. * @hidden
  74995. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74996. */
  74997. get useDiffuseColor(): boolean;
  74998. set useDiffuseColor(useDiffuseColor: boolean);
  74999. /**
  75000. * Array containing the excluded meshes not rendered in the internal pass
  75001. */
  75002. excludedMeshes: AbstractMesh[];
  75003. /**
  75004. * Controls the overall intensity of the post-process
  75005. */
  75006. exposure: number;
  75007. /**
  75008. * Dissipates each sample's contribution in range [0, 1]
  75009. */
  75010. decay: number;
  75011. /**
  75012. * Controls the overall intensity of each sample
  75013. */
  75014. weight: number;
  75015. /**
  75016. * Controls the density of each sample
  75017. */
  75018. density: number;
  75019. /**
  75020. * @constructor
  75021. * @param name The post-process name
  75022. * @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)
  75023. * @param camera The camera that the post-process will be attached to
  75024. * @param mesh The mesh used to create the light scattering
  75025. * @param samples The post-process quality, default 100
  75026. * @param samplingModeThe post-process filtering mode
  75027. * @param engine The babylon engine
  75028. * @param reusable If the post-process is reusable
  75029. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75030. */
  75031. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75032. /**
  75033. * Returns the string "VolumetricLightScatteringPostProcess"
  75034. * @returns "VolumetricLightScatteringPostProcess"
  75035. */
  75036. getClassName(): string;
  75037. private _isReady;
  75038. /**
  75039. * Sets the new light position for light scattering effect
  75040. * @param position The new custom light position
  75041. */
  75042. setCustomMeshPosition(position: Vector3): void;
  75043. /**
  75044. * Returns the light position for light scattering effect
  75045. * @return Vector3 The custom light position
  75046. */
  75047. getCustomMeshPosition(): Vector3;
  75048. /**
  75049. * Disposes the internal assets and detaches the post-process from the camera
  75050. */
  75051. dispose(camera: Camera): void;
  75052. /**
  75053. * Returns the render target texture used by the post-process
  75054. * @return the render target texture used by the post-process
  75055. */
  75056. getPass(): RenderTargetTexture;
  75057. private _meshExcluded;
  75058. private _createPass;
  75059. private _updateMeshScreenCoordinates;
  75060. /**
  75061. * Creates a default mesh for the Volumeric Light Scattering post-process
  75062. * @param name The mesh name
  75063. * @param scene The scene where to create the mesh
  75064. * @return the default mesh
  75065. */
  75066. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75067. }
  75068. }
  75069. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75070. /** @hidden */
  75071. export var screenSpaceCurvaturePixelShader: {
  75072. name: string;
  75073. shader: string;
  75074. };
  75075. }
  75076. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75077. import { Nullable } from "babylonjs/types";
  75078. import { Camera } from "babylonjs/Cameras/camera";
  75079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75080. import { Scene } from "babylonjs/scene";
  75081. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75082. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75083. import { Engine } from "babylonjs/Engines/engine";
  75084. /**
  75085. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75086. */
  75087. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75088. /**
  75089. * Defines how much ridge the curvature effect displays.
  75090. */
  75091. ridge: number;
  75092. /**
  75093. * Defines how much valley the curvature effect displays.
  75094. */
  75095. valley: number;
  75096. private _geometryBufferRenderer;
  75097. /**
  75098. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75099. * @param name The name of the effect.
  75100. * @param scene The scene containing the objects to blur according to their velocity.
  75101. * @param options The required width/height ratio to downsize to before computing the render pass.
  75102. * @param camera The camera to apply the render pass to.
  75103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75104. * @param engine The engine which the post process will be applied. (default: current engine)
  75105. * @param reusable If the post process can be reused on the same frame. (default: false)
  75106. * @param textureType Type of textures used when performing the post process. (default: 0)
  75107. * @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)
  75108. */
  75109. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75110. /**
  75111. * Support test.
  75112. */
  75113. static get IsSupported(): boolean;
  75114. }
  75115. }
  75116. declare module "babylonjs/PostProcesses/index" {
  75117. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75118. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75119. export * from "babylonjs/PostProcesses/bloomEffect";
  75120. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75121. export * from "babylonjs/PostProcesses/blurPostProcess";
  75122. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75123. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75124. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75125. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75126. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75127. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75128. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75129. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75130. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75131. export * from "babylonjs/PostProcesses/filterPostProcess";
  75132. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75133. export * from "babylonjs/PostProcesses/grainPostProcess";
  75134. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75135. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75136. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75137. export * from "babylonjs/PostProcesses/passPostProcess";
  75138. export * from "babylonjs/PostProcesses/postProcess";
  75139. export * from "babylonjs/PostProcesses/postProcessManager";
  75140. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75141. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75142. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75143. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75144. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75145. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75146. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75147. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75148. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75149. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75150. }
  75151. declare module "babylonjs/Probes/index" {
  75152. export * from "babylonjs/Probes/reflectionProbe";
  75153. }
  75154. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75155. import { Scene } from "babylonjs/scene";
  75156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75157. import { SmartArray } from "babylonjs/Misc/smartArray";
  75158. import { ISceneComponent } from "babylonjs/sceneComponent";
  75159. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75160. import "babylonjs/Meshes/Builders/boxBuilder";
  75161. import "babylonjs/Shaders/color.fragment";
  75162. import "babylonjs/Shaders/color.vertex";
  75163. import { Color3 } from "babylonjs/Maths/math.color";
  75164. import { Observable } from "babylonjs/Misc/observable";
  75165. module "babylonjs/scene" {
  75166. interface Scene {
  75167. /** @hidden (Backing field) */
  75168. _boundingBoxRenderer: BoundingBoxRenderer;
  75169. /** @hidden (Backing field) */
  75170. _forceShowBoundingBoxes: boolean;
  75171. /**
  75172. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75173. */
  75174. forceShowBoundingBoxes: boolean;
  75175. /**
  75176. * Gets the bounding box renderer associated with the scene
  75177. * @returns a BoundingBoxRenderer
  75178. */
  75179. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75180. }
  75181. }
  75182. module "babylonjs/Meshes/abstractMesh" {
  75183. interface AbstractMesh {
  75184. /** @hidden (Backing field) */
  75185. _showBoundingBox: boolean;
  75186. /**
  75187. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75188. */
  75189. showBoundingBox: boolean;
  75190. }
  75191. }
  75192. /**
  75193. * Component responsible of rendering the bounding box of the meshes in a scene.
  75194. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75195. */
  75196. export class BoundingBoxRenderer implements ISceneComponent {
  75197. /**
  75198. * The component name helpfull to identify the component in the list of scene components.
  75199. */
  75200. readonly name: string;
  75201. /**
  75202. * The scene the component belongs to.
  75203. */
  75204. scene: Scene;
  75205. /**
  75206. * Color of the bounding box lines placed in front of an object
  75207. */
  75208. frontColor: Color3;
  75209. /**
  75210. * Color of the bounding box lines placed behind an object
  75211. */
  75212. backColor: Color3;
  75213. /**
  75214. * Defines if the renderer should show the back lines or not
  75215. */
  75216. showBackLines: boolean;
  75217. /**
  75218. * Observable raised before rendering a bounding box
  75219. */
  75220. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75221. /**
  75222. * Observable raised after rendering a bounding box
  75223. */
  75224. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75225. /**
  75226. * @hidden
  75227. */
  75228. renderList: SmartArray<BoundingBox>;
  75229. private _colorShader;
  75230. private _vertexBuffers;
  75231. private _indexBuffer;
  75232. private _fillIndexBuffer;
  75233. private _fillIndexData;
  75234. /**
  75235. * Instantiates a new bounding box renderer in a scene.
  75236. * @param scene the scene the renderer renders in
  75237. */
  75238. constructor(scene: Scene);
  75239. /**
  75240. * Registers the component in a given scene
  75241. */
  75242. register(): void;
  75243. private _evaluateSubMesh;
  75244. private _activeMesh;
  75245. private _prepareRessources;
  75246. private _createIndexBuffer;
  75247. /**
  75248. * Rebuilds the elements related to this component in case of
  75249. * context lost for instance.
  75250. */
  75251. rebuild(): void;
  75252. /**
  75253. * @hidden
  75254. */
  75255. reset(): void;
  75256. /**
  75257. * Render the bounding boxes of a specific rendering group
  75258. * @param renderingGroupId defines the rendering group to render
  75259. */
  75260. render(renderingGroupId: number): void;
  75261. /**
  75262. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75263. * @param mesh Define the mesh to render the occlusion bounding box for
  75264. */
  75265. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75266. /**
  75267. * Dispose and release the resources attached to this renderer.
  75268. */
  75269. dispose(): void;
  75270. }
  75271. }
  75272. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75273. import { Nullable } from "babylonjs/types";
  75274. import { Scene } from "babylonjs/scene";
  75275. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75276. import { Camera } from "babylonjs/Cameras/camera";
  75277. import { ISceneComponent } from "babylonjs/sceneComponent";
  75278. module "babylonjs/scene" {
  75279. interface Scene {
  75280. /** @hidden (Backing field) */
  75281. _depthRenderer: {
  75282. [id: string]: DepthRenderer;
  75283. };
  75284. /**
  75285. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75286. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75287. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75288. * @returns the created depth renderer
  75289. */
  75290. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75291. /**
  75292. * Disables a depth renderer for a given camera
  75293. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75294. */
  75295. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75296. }
  75297. }
  75298. /**
  75299. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75300. * in several rendering techniques.
  75301. */
  75302. export class DepthRendererSceneComponent implements ISceneComponent {
  75303. /**
  75304. * The component name helpfull to identify the component in the list of scene components.
  75305. */
  75306. readonly name: string;
  75307. /**
  75308. * The scene the component belongs to.
  75309. */
  75310. scene: Scene;
  75311. /**
  75312. * Creates a new instance of the component for the given scene
  75313. * @param scene Defines the scene to register the component in
  75314. */
  75315. constructor(scene: Scene);
  75316. /**
  75317. * Registers the component in a given scene
  75318. */
  75319. register(): void;
  75320. /**
  75321. * Rebuilds the elements related to this component in case of
  75322. * context lost for instance.
  75323. */
  75324. rebuild(): void;
  75325. /**
  75326. * Disposes the component and the associated ressources
  75327. */
  75328. dispose(): void;
  75329. private _gatherRenderTargets;
  75330. private _gatherActiveCameraRenderTargets;
  75331. }
  75332. }
  75333. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75334. import { Nullable } from "babylonjs/types";
  75335. import { Scene } from "babylonjs/scene";
  75336. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75337. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75338. import { AbstractScene } from "babylonjs/abstractScene";
  75339. module "babylonjs/abstractScene" {
  75340. interface AbstractScene {
  75341. /** @hidden (Backing field) */
  75342. _prePassRenderer: Nullable<PrePassRenderer>;
  75343. /**
  75344. * Gets or Sets the current prepass renderer associated to the scene.
  75345. */
  75346. prePassRenderer: Nullable<PrePassRenderer>;
  75347. /**
  75348. * Enables the prepass and associates it with the scene
  75349. * @returns the PrePassRenderer
  75350. */
  75351. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75352. /**
  75353. * Disables the prepass associated with the scene
  75354. */
  75355. disablePrePassRenderer(): void;
  75356. }
  75357. }
  75358. /**
  75359. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75360. * in several rendering techniques.
  75361. */
  75362. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75363. /**
  75364. * The component name helpful to identify the component in the list of scene components.
  75365. */
  75366. readonly name: string;
  75367. /**
  75368. * The scene the component belongs to.
  75369. */
  75370. scene: Scene;
  75371. /**
  75372. * Creates a new instance of the component for the given scene
  75373. * @param scene Defines the scene to register the component in
  75374. */
  75375. constructor(scene: Scene);
  75376. /**
  75377. * Registers the component in a given scene
  75378. */
  75379. register(): void;
  75380. private _beforeCameraDraw;
  75381. private _afterCameraDraw;
  75382. private _beforeClearStage;
  75383. /**
  75384. * Serializes the component data to the specified json object
  75385. * @param serializationObject The object to serialize to
  75386. */
  75387. serialize(serializationObject: any): void;
  75388. /**
  75389. * Adds all the elements from the container to the scene
  75390. * @param container the container holding the elements
  75391. */
  75392. addFromContainer(container: AbstractScene): void;
  75393. /**
  75394. * Removes all the elements in the container from the scene
  75395. * @param container contains the elements to remove
  75396. * @param dispose if the removed element should be disposed (default: false)
  75397. */
  75398. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75399. /**
  75400. * Rebuilds the elements related to this component in case of
  75401. * context lost for instance.
  75402. */
  75403. rebuild(): void;
  75404. /**
  75405. * Disposes the component and the associated ressources
  75406. */
  75407. dispose(): void;
  75408. }
  75409. }
  75410. declare module "babylonjs/Shaders/outline.fragment" {
  75411. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75412. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75413. /** @hidden */
  75414. export var outlinePixelShader: {
  75415. name: string;
  75416. shader: string;
  75417. };
  75418. }
  75419. declare module "babylonjs/Shaders/outline.vertex" {
  75420. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75423. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75424. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75426. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75427. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75428. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75429. /** @hidden */
  75430. export var outlineVertexShader: {
  75431. name: string;
  75432. shader: string;
  75433. };
  75434. }
  75435. declare module "babylonjs/Rendering/outlineRenderer" {
  75436. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75437. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75438. import { Scene } from "babylonjs/scene";
  75439. import { ISceneComponent } from "babylonjs/sceneComponent";
  75440. import "babylonjs/Shaders/outline.fragment";
  75441. import "babylonjs/Shaders/outline.vertex";
  75442. module "babylonjs/scene" {
  75443. interface Scene {
  75444. /** @hidden */
  75445. _outlineRenderer: OutlineRenderer;
  75446. /**
  75447. * Gets the outline renderer associated with the scene
  75448. * @returns a OutlineRenderer
  75449. */
  75450. getOutlineRenderer(): OutlineRenderer;
  75451. }
  75452. }
  75453. module "babylonjs/Meshes/abstractMesh" {
  75454. interface AbstractMesh {
  75455. /** @hidden (Backing field) */
  75456. _renderOutline: boolean;
  75457. /**
  75458. * Gets or sets a boolean indicating if the outline must be rendered as well
  75459. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75460. */
  75461. renderOutline: boolean;
  75462. /** @hidden (Backing field) */
  75463. _renderOverlay: boolean;
  75464. /**
  75465. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75466. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75467. */
  75468. renderOverlay: boolean;
  75469. }
  75470. }
  75471. /**
  75472. * This class is responsible to draw bothe outline/overlay of meshes.
  75473. * It should not be used directly but through the available method on mesh.
  75474. */
  75475. export class OutlineRenderer implements ISceneComponent {
  75476. /**
  75477. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75478. */
  75479. private static _StencilReference;
  75480. /**
  75481. * The name of the component. Each component must have a unique name.
  75482. */
  75483. name: string;
  75484. /**
  75485. * The scene the component belongs to.
  75486. */
  75487. scene: Scene;
  75488. /**
  75489. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75490. */
  75491. zOffset: number;
  75492. private _engine;
  75493. private _effect;
  75494. private _cachedDefines;
  75495. private _savedDepthWrite;
  75496. /**
  75497. * Instantiates a new outline renderer. (There could be only one per scene).
  75498. * @param scene Defines the scene it belongs to
  75499. */
  75500. constructor(scene: Scene);
  75501. /**
  75502. * Register the component to one instance of a scene.
  75503. */
  75504. register(): void;
  75505. /**
  75506. * Rebuilds the elements related to this component in case of
  75507. * context lost for instance.
  75508. */
  75509. rebuild(): void;
  75510. /**
  75511. * Disposes the component and the associated ressources.
  75512. */
  75513. dispose(): void;
  75514. /**
  75515. * Renders the outline in the canvas.
  75516. * @param subMesh Defines the sumesh to render
  75517. * @param batch Defines the batch of meshes in case of instances
  75518. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75519. */
  75520. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75521. /**
  75522. * Returns whether or not the outline renderer is ready for a given submesh.
  75523. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75524. * @param subMesh Defines the submesh to check readyness for
  75525. * @param useInstances Defines wheter wee are trying to render instances or not
  75526. * @returns true if ready otherwise false
  75527. */
  75528. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75529. private _beforeRenderingMesh;
  75530. private _afterRenderingMesh;
  75531. }
  75532. }
  75533. declare module "babylonjs/Rendering/index" {
  75534. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75535. export * from "babylonjs/Rendering/depthRenderer";
  75536. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75537. export * from "babylonjs/Rendering/edgesRenderer";
  75538. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75539. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75540. export * from "babylonjs/Rendering/prePassRenderer";
  75541. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75542. export * from "babylonjs/Rendering/outlineRenderer";
  75543. export * from "babylonjs/Rendering/renderingGroup";
  75544. export * from "babylonjs/Rendering/renderingManager";
  75545. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75546. }
  75547. declare module "babylonjs/Sprites/ISprites" {
  75548. /**
  75549. * Defines the basic options interface of a Sprite Frame Source Size.
  75550. */
  75551. export interface ISpriteJSONSpriteSourceSize {
  75552. /**
  75553. * number of the original width of the Frame
  75554. */
  75555. w: number;
  75556. /**
  75557. * number of the original height of the Frame
  75558. */
  75559. h: number;
  75560. }
  75561. /**
  75562. * Defines the basic options interface of a Sprite Frame Data.
  75563. */
  75564. export interface ISpriteJSONSpriteFrameData {
  75565. /**
  75566. * number of the x offset of the Frame
  75567. */
  75568. x: number;
  75569. /**
  75570. * number of the y offset of the Frame
  75571. */
  75572. y: number;
  75573. /**
  75574. * number of the width of the Frame
  75575. */
  75576. w: number;
  75577. /**
  75578. * number of the height of the Frame
  75579. */
  75580. h: number;
  75581. }
  75582. /**
  75583. * Defines the basic options interface of a JSON Sprite.
  75584. */
  75585. export interface ISpriteJSONSprite {
  75586. /**
  75587. * string name of the Frame
  75588. */
  75589. filename: string;
  75590. /**
  75591. * ISpriteJSONSpriteFrame basic object of the frame data
  75592. */
  75593. frame: ISpriteJSONSpriteFrameData;
  75594. /**
  75595. * boolean to flag is the frame was rotated.
  75596. */
  75597. rotated: boolean;
  75598. /**
  75599. * boolean to flag is the frame was trimmed.
  75600. */
  75601. trimmed: boolean;
  75602. /**
  75603. * ISpriteJSONSpriteFrame basic object of the source data
  75604. */
  75605. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75606. /**
  75607. * ISpriteJSONSpriteFrame basic object of the source data
  75608. */
  75609. sourceSize: ISpriteJSONSpriteSourceSize;
  75610. }
  75611. /**
  75612. * Defines the basic options interface of a JSON atlas.
  75613. */
  75614. export interface ISpriteJSONAtlas {
  75615. /**
  75616. * Array of objects that contain the frame data.
  75617. */
  75618. frames: Array<ISpriteJSONSprite>;
  75619. /**
  75620. * object basic object containing the sprite meta data.
  75621. */
  75622. meta?: object;
  75623. }
  75624. }
  75625. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75626. /** @hidden */
  75627. export var spriteMapPixelShader: {
  75628. name: string;
  75629. shader: string;
  75630. };
  75631. }
  75632. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75633. /** @hidden */
  75634. export var spriteMapVertexShader: {
  75635. name: string;
  75636. shader: string;
  75637. };
  75638. }
  75639. declare module "babylonjs/Sprites/spriteMap" {
  75640. import { IDisposable, Scene } from "babylonjs/scene";
  75641. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75642. import { Texture } from "babylonjs/Materials/Textures/texture";
  75643. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75644. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75645. import "babylonjs/Meshes/Builders/planeBuilder";
  75646. import "babylonjs/Shaders/spriteMap.fragment";
  75647. import "babylonjs/Shaders/spriteMap.vertex";
  75648. /**
  75649. * Defines the basic options interface of a SpriteMap
  75650. */
  75651. export interface ISpriteMapOptions {
  75652. /**
  75653. * Vector2 of the number of cells in the grid.
  75654. */
  75655. stageSize?: Vector2;
  75656. /**
  75657. * Vector2 of the size of the output plane in World Units.
  75658. */
  75659. outputSize?: Vector2;
  75660. /**
  75661. * Vector3 of the position of the output plane in World Units.
  75662. */
  75663. outputPosition?: Vector3;
  75664. /**
  75665. * Vector3 of the rotation of the output plane.
  75666. */
  75667. outputRotation?: Vector3;
  75668. /**
  75669. * number of layers that the system will reserve in resources.
  75670. */
  75671. layerCount?: number;
  75672. /**
  75673. * number of max animation frames a single cell will reserve in resources.
  75674. */
  75675. maxAnimationFrames?: number;
  75676. /**
  75677. * number cell index of the base tile when the system compiles.
  75678. */
  75679. baseTile?: number;
  75680. /**
  75681. * boolean flip the sprite after its been repositioned by the framing data.
  75682. */
  75683. flipU?: boolean;
  75684. /**
  75685. * Vector3 scalar of the global RGB values of the SpriteMap.
  75686. */
  75687. colorMultiply?: Vector3;
  75688. }
  75689. /**
  75690. * Defines the IDisposable interface in order to be cleanable from resources.
  75691. */
  75692. export interface ISpriteMap extends IDisposable {
  75693. /**
  75694. * String name of the SpriteMap.
  75695. */
  75696. name: string;
  75697. /**
  75698. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75699. */
  75700. atlasJSON: ISpriteJSONAtlas;
  75701. /**
  75702. * Texture of the SpriteMap.
  75703. */
  75704. spriteSheet: Texture;
  75705. /**
  75706. * The parameters to initialize the SpriteMap with.
  75707. */
  75708. options: ISpriteMapOptions;
  75709. }
  75710. /**
  75711. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75712. */
  75713. export class SpriteMap implements ISpriteMap {
  75714. /** The Name of the spriteMap */
  75715. name: string;
  75716. /** The JSON file with the frame and meta data */
  75717. atlasJSON: ISpriteJSONAtlas;
  75718. /** The systems Sprite Sheet Texture */
  75719. spriteSheet: Texture;
  75720. /** Arguments passed with the Constructor */
  75721. options: ISpriteMapOptions;
  75722. /** Public Sprite Storage array, parsed from atlasJSON */
  75723. sprites: Array<ISpriteJSONSprite>;
  75724. /** Returns the Number of Sprites in the System */
  75725. get spriteCount(): number;
  75726. /** Returns the Position of Output Plane*/
  75727. get position(): Vector3;
  75728. /** Returns the Position of Output Plane*/
  75729. set position(v: Vector3);
  75730. /** Returns the Rotation of Output Plane*/
  75731. get rotation(): Vector3;
  75732. /** Returns the Rotation of Output Plane*/
  75733. set rotation(v: Vector3);
  75734. /** Sets the AnimationMap*/
  75735. get animationMap(): RawTexture;
  75736. /** Sets the AnimationMap*/
  75737. set animationMap(v: RawTexture);
  75738. /** Scene that the SpriteMap was created in */
  75739. private _scene;
  75740. /** Texture Buffer of Float32 that holds tile frame data*/
  75741. private _frameMap;
  75742. /** Texture Buffers of Float32 that holds tileMap data*/
  75743. private _tileMaps;
  75744. /** Texture Buffer of Float32 that holds Animation Data*/
  75745. private _animationMap;
  75746. /** Custom ShaderMaterial Central to the System*/
  75747. private _material;
  75748. /** Custom ShaderMaterial Central to the System*/
  75749. private _output;
  75750. /** Systems Time Ticker*/
  75751. private _time;
  75752. /**
  75753. * Creates a new SpriteMap
  75754. * @param name defines the SpriteMaps Name
  75755. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75756. * @param spriteSheet is the Texture that the Sprites are on.
  75757. * @param options a basic deployment configuration
  75758. * @param scene The Scene that the map is deployed on
  75759. */
  75760. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75761. /**
  75762. * Returns tileID location
  75763. * @returns Vector2 the cell position ID
  75764. */
  75765. getTileID(): Vector2;
  75766. /**
  75767. * Gets the UV location of the mouse over the SpriteMap.
  75768. * @returns Vector2 the UV position of the mouse interaction
  75769. */
  75770. getMousePosition(): Vector2;
  75771. /**
  75772. * Creates the "frame" texture Buffer
  75773. * -------------------------------------
  75774. * Structure of frames
  75775. * "filename": "Falling-Water-2.png",
  75776. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75777. * "rotated": true,
  75778. * "trimmed": true,
  75779. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75780. * "sourceSize": {"w":32,"h":32}
  75781. * @returns RawTexture of the frameMap
  75782. */
  75783. private _createFrameBuffer;
  75784. /**
  75785. * Creates the tileMap texture Buffer
  75786. * @param buffer normally and array of numbers, or a false to generate from scratch
  75787. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75788. * @returns RawTexture of the tileMap
  75789. */
  75790. private _createTileBuffer;
  75791. /**
  75792. * Modifies the data of the tileMaps
  75793. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75794. * @param pos is the iVector2 Coordinates of the Tile
  75795. * @param tile The SpriteIndex of the new Tile
  75796. */
  75797. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75798. /**
  75799. * Creates the animationMap texture Buffer
  75800. * @param buffer normally and array of numbers, or a false to generate from scratch
  75801. * @returns RawTexture of the animationMap
  75802. */
  75803. private _createTileAnimationBuffer;
  75804. /**
  75805. * Modifies the data of the animationMap
  75806. * @param cellID is the Index of the Sprite
  75807. * @param _frame is the target Animation frame
  75808. * @param toCell is the Target Index of the next frame of the animation
  75809. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75810. * @param speed is a global scalar of the time variable on the map.
  75811. */
  75812. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75813. /**
  75814. * Exports the .tilemaps file
  75815. */
  75816. saveTileMaps(): void;
  75817. /**
  75818. * Imports the .tilemaps file
  75819. * @param url of the .tilemaps file
  75820. */
  75821. loadTileMaps(url: string): void;
  75822. /**
  75823. * Release associated resources
  75824. */
  75825. dispose(): void;
  75826. }
  75827. }
  75828. declare module "babylonjs/Sprites/spritePackedManager" {
  75829. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75830. import { Scene } from "babylonjs/scene";
  75831. /**
  75832. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75833. * @see https://doc.babylonjs.com/babylon101/sprites
  75834. */
  75835. export class SpritePackedManager extends SpriteManager {
  75836. /** defines the packed manager's name */
  75837. name: string;
  75838. /**
  75839. * Creates a new sprite manager from a packed sprite sheet
  75840. * @param name defines the manager's name
  75841. * @param imgUrl defines the sprite sheet url
  75842. * @param capacity defines the maximum allowed number of sprites
  75843. * @param scene defines the hosting scene
  75844. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75845. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75846. * @param samplingMode defines the smapling mode to use with spritesheet
  75847. * @param fromPacked set to true; do not alter
  75848. */
  75849. constructor(
  75850. /** defines the packed manager's name */
  75851. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75852. }
  75853. }
  75854. declare module "babylonjs/Sprites/index" {
  75855. export * from "babylonjs/Sprites/sprite";
  75856. export * from "babylonjs/Sprites/ISprites";
  75857. export * from "babylonjs/Sprites/spriteManager";
  75858. export * from "babylonjs/Sprites/spriteMap";
  75859. export * from "babylonjs/Sprites/spritePackedManager";
  75860. export * from "babylonjs/Sprites/spriteSceneComponent";
  75861. }
  75862. declare module "babylonjs/States/index" {
  75863. export * from "babylonjs/States/alphaCullingState";
  75864. export * from "babylonjs/States/depthCullingState";
  75865. export * from "babylonjs/States/stencilState";
  75866. }
  75867. declare module "babylonjs/Misc/assetsManager" {
  75868. import { Scene } from "babylonjs/scene";
  75869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75870. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75871. import { Skeleton } from "babylonjs/Bones/skeleton";
  75872. import { Observable } from "babylonjs/Misc/observable";
  75873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75874. import { Texture } from "babylonjs/Materials/Textures/texture";
  75875. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75876. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75877. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75878. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75879. import { AssetContainer } from "babylonjs/assetContainer";
  75880. /**
  75881. * Defines the list of states available for a task inside a AssetsManager
  75882. */
  75883. export enum AssetTaskState {
  75884. /**
  75885. * Initialization
  75886. */
  75887. INIT = 0,
  75888. /**
  75889. * Running
  75890. */
  75891. RUNNING = 1,
  75892. /**
  75893. * Done
  75894. */
  75895. DONE = 2,
  75896. /**
  75897. * Error
  75898. */
  75899. ERROR = 3
  75900. }
  75901. /**
  75902. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75903. */
  75904. export abstract class AbstractAssetTask {
  75905. /**
  75906. * Task name
  75907. */ name: string;
  75908. /**
  75909. * Callback called when the task is successful
  75910. */
  75911. onSuccess: (task: any) => void;
  75912. /**
  75913. * Callback called when the task is not successful
  75914. */
  75915. onError: (task: any, message?: string, exception?: any) => void;
  75916. /**
  75917. * Creates a new AssetsManager
  75918. * @param name defines the name of the task
  75919. */
  75920. constructor(
  75921. /**
  75922. * Task name
  75923. */ name: string);
  75924. private _isCompleted;
  75925. private _taskState;
  75926. private _errorObject;
  75927. /**
  75928. * Get if the task is completed
  75929. */
  75930. get isCompleted(): boolean;
  75931. /**
  75932. * Gets the current state of the task
  75933. */
  75934. get taskState(): AssetTaskState;
  75935. /**
  75936. * Gets the current error object (if task is in error)
  75937. */
  75938. get errorObject(): {
  75939. message?: string;
  75940. exception?: any;
  75941. };
  75942. /**
  75943. * Internal only
  75944. * @hidden
  75945. */
  75946. _setErrorObject(message?: string, exception?: any): void;
  75947. /**
  75948. * Execute the current task
  75949. * @param scene defines the scene where you want your assets to be loaded
  75950. * @param onSuccess is a callback called when the task is successfully executed
  75951. * @param onError is a callback called if an error occurs
  75952. */
  75953. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75954. /**
  75955. * Execute the current task
  75956. * @param scene defines the scene where you want your assets to be loaded
  75957. * @param onSuccess is a callback called when the task is successfully executed
  75958. * @param onError is a callback called if an error occurs
  75959. */
  75960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75961. /**
  75962. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75963. * This can be used with failed tasks that have the reason for failure fixed.
  75964. */
  75965. reset(): void;
  75966. private onErrorCallback;
  75967. private onDoneCallback;
  75968. }
  75969. /**
  75970. * Define the interface used by progress events raised during assets loading
  75971. */
  75972. export interface IAssetsProgressEvent {
  75973. /**
  75974. * Defines the number of remaining tasks to process
  75975. */
  75976. remainingCount: number;
  75977. /**
  75978. * Defines the total number of tasks
  75979. */
  75980. totalCount: number;
  75981. /**
  75982. * Defines the task that was just processed
  75983. */
  75984. task: AbstractAssetTask;
  75985. }
  75986. /**
  75987. * Class used to share progress information about assets loading
  75988. */
  75989. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75990. /**
  75991. * Defines the number of remaining tasks to process
  75992. */
  75993. remainingCount: number;
  75994. /**
  75995. * Defines the total number of tasks
  75996. */
  75997. totalCount: number;
  75998. /**
  75999. * Defines the task that was just processed
  76000. */
  76001. task: AbstractAssetTask;
  76002. /**
  76003. * Creates a AssetsProgressEvent
  76004. * @param remainingCount defines the number of remaining tasks to process
  76005. * @param totalCount defines the total number of tasks
  76006. * @param task defines the task that was just processed
  76007. */
  76008. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76009. }
  76010. /**
  76011. * Define a task used by AssetsManager to load assets into a container
  76012. */
  76013. export class ContainerAssetTask extends AbstractAssetTask {
  76014. /**
  76015. * Defines the name of the task
  76016. */
  76017. name: string;
  76018. /**
  76019. * Defines the list of mesh's names you want to load
  76020. */
  76021. meshesNames: any;
  76022. /**
  76023. * Defines the root url to use as a base to load your meshes and associated resources
  76024. */
  76025. rootUrl: string;
  76026. /**
  76027. * Defines the filename or File of the scene to load from
  76028. */
  76029. sceneFilename: string | File;
  76030. /**
  76031. * Get the loaded asset container
  76032. */
  76033. loadedContainer: AssetContainer;
  76034. /**
  76035. * Gets the list of loaded meshes
  76036. */
  76037. loadedMeshes: Array<AbstractMesh>;
  76038. /**
  76039. * Gets the list of loaded particle systems
  76040. */
  76041. loadedParticleSystems: Array<IParticleSystem>;
  76042. /**
  76043. * Gets the list of loaded skeletons
  76044. */
  76045. loadedSkeletons: Array<Skeleton>;
  76046. /**
  76047. * Gets the list of loaded animation groups
  76048. */
  76049. loadedAnimationGroups: Array<AnimationGroup>;
  76050. /**
  76051. * Callback called when the task is successful
  76052. */
  76053. onSuccess: (task: ContainerAssetTask) => void;
  76054. /**
  76055. * Callback called when the task is successful
  76056. */
  76057. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76058. /**
  76059. * Creates a new ContainerAssetTask
  76060. * @param name defines the name of the task
  76061. * @param meshesNames defines the list of mesh's names you want to load
  76062. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76063. * @param sceneFilename defines the filename or File of the scene to load from
  76064. */
  76065. constructor(
  76066. /**
  76067. * Defines the name of the task
  76068. */
  76069. name: string,
  76070. /**
  76071. * Defines the list of mesh's names you want to load
  76072. */
  76073. meshesNames: any,
  76074. /**
  76075. * Defines the root url to use as a base to load your meshes and associated resources
  76076. */
  76077. rootUrl: string,
  76078. /**
  76079. * Defines the filename or File of the scene to load from
  76080. */
  76081. sceneFilename: string | File);
  76082. /**
  76083. * Execute the current task
  76084. * @param scene defines the scene where you want your assets to be loaded
  76085. * @param onSuccess is a callback called when the task is successfully executed
  76086. * @param onError is a callback called if an error occurs
  76087. */
  76088. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76089. }
  76090. /**
  76091. * Define a task used by AssetsManager to load meshes
  76092. */
  76093. export class MeshAssetTask extends AbstractAssetTask {
  76094. /**
  76095. * Defines the name of the task
  76096. */
  76097. name: string;
  76098. /**
  76099. * Defines the list of mesh's names you want to load
  76100. */
  76101. meshesNames: any;
  76102. /**
  76103. * Defines the root url to use as a base to load your meshes and associated resources
  76104. */
  76105. rootUrl: string;
  76106. /**
  76107. * Defines the filename or File of the scene to load from
  76108. */
  76109. sceneFilename: string | File;
  76110. /**
  76111. * Gets the list of loaded meshes
  76112. */
  76113. loadedMeshes: Array<AbstractMesh>;
  76114. /**
  76115. * Gets the list of loaded particle systems
  76116. */
  76117. loadedParticleSystems: Array<IParticleSystem>;
  76118. /**
  76119. * Gets the list of loaded skeletons
  76120. */
  76121. loadedSkeletons: Array<Skeleton>;
  76122. /**
  76123. * Gets the list of loaded animation groups
  76124. */
  76125. loadedAnimationGroups: Array<AnimationGroup>;
  76126. /**
  76127. * Callback called when the task is successful
  76128. */
  76129. onSuccess: (task: MeshAssetTask) => void;
  76130. /**
  76131. * Callback called when the task is successful
  76132. */
  76133. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76134. /**
  76135. * Creates a new MeshAssetTask
  76136. * @param name defines the name of the task
  76137. * @param meshesNames defines the list of mesh's names you want to load
  76138. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76139. * @param sceneFilename defines the filename or File of the scene to load from
  76140. */
  76141. constructor(
  76142. /**
  76143. * Defines the name of the task
  76144. */
  76145. name: string,
  76146. /**
  76147. * Defines the list of mesh's names you want to load
  76148. */
  76149. meshesNames: any,
  76150. /**
  76151. * Defines the root url to use as a base to load your meshes and associated resources
  76152. */
  76153. rootUrl: string,
  76154. /**
  76155. * Defines the filename or File of the scene to load from
  76156. */
  76157. sceneFilename: string | File);
  76158. /**
  76159. * Execute the current task
  76160. * @param scene defines the scene where you want your assets to be loaded
  76161. * @param onSuccess is a callback called when the task is successfully executed
  76162. * @param onError is a callback called if an error occurs
  76163. */
  76164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76165. }
  76166. /**
  76167. * Define a task used by AssetsManager to load text content
  76168. */
  76169. export class TextFileAssetTask extends AbstractAssetTask {
  76170. /**
  76171. * Defines the name of the task
  76172. */
  76173. name: string;
  76174. /**
  76175. * Defines the location of the file to load
  76176. */
  76177. url: string;
  76178. /**
  76179. * Gets the loaded text string
  76180. */
  76181. text: string;
  76182. /**
  76183. * Callback called when the task is successful
  76184. */
  76185. onSuccess: (task: TextFileAssetTask) => void;
  76186. /**
  76187. * Callback called when the task is successful
  76188. */
  76189. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76190. /**
  76191. * Creates a new TextFileAssetTask object
  76192. * @param name defines the name of the task
  76193. * @param url defines the location of the file to load
  76194. */
  76195. constructor(
  76196. /**
  76197. * Defines the name of the task
  76198. */
  76199. name: string,
  76200. /**
  76201. * Defines the location of the file to load
  76202. */
  76203. url: string);
  76204. /**
  76205. * Execute the current task
  76206. * @param scene defines the scene where you want your assets to be loaded
  76207. * @param onSuccess is a callback called when the task is successfully executed
  76208. * @param onError is a callback called if an error occurs
  76209. */
  76210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76211. }
  76212. /**
  76213. * Define a task used by AssetsManager to load binary data
  76214. */
  76215. export class BinaryFileAssetTask extends AbstractAssetTask {
  76216. /**
  76217. * Defines the name of the task
  76218. */
  76219. name: string;
  76220. /**
  76221. * Defines the location of the file to load
  76222. */
  76223. url: string;
  76224. /**
  76225. * Gets the lodaded data (as an array buffer)
  76226. */
  76227. data: ArrayBuffer;
  76228. /**
  76229. * Callback called when the task is successful
  76230. */
  76231. onSuccess: (task: BinaryFileAssetTask) => void;
  76232. /**
  76233. * Callback called when the task is successful
  76234. */
  76235. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76236. /**
  76237. * Creates a new BinaryFileAssetTask object
  76238. * @param name defines the name of the new task
  76239. * @param url defines the location of the file to load
  76240. */
  76241. constructor(
  76242. /**
  76243. * Defines the name of the task
  76244. */
  76245. name: string,
  76246. /**
  76247. * Defines the location of the file to load
  76248. */
  76249. url: string);
  76250. /**
  76251. * Execute the current task
  76252. * @param scene defines the scene where you want your assets to be loaded
  76253. * @param onSuccess is a callback called when the task is successfully executed
  76254. * @param onError is a callback called if an error occurs
  76255. */
  76256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76257. }
  76258. /**
  76259. * Define a task used by AssetsManager to load images
  76260. */
  76261. export class ImageAssetTask extends AbstractAssetTask {
  76262. /**
  76263. * Defines the name of the task
  76264. */
  76265. name: string;
  76266. /**
  76267. * Defines the location of the image to load
  76268. */
  76269. url: string;
  76270. /**
  76271. * Gets the loaded images
  76272. */
  76273. image: HTMLImageElement;
  76274. /**
  76275. * Callback called when the task is successful
  76276. */
  76277. onSuccess: (task: ImageAssetTask) => void;
  76278. /**
  76279. * Callback called when the task is successful
  76280. */
  76281. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76282. /**
  76283. * Creates a new ImageAssetTask
  76284. * @param name defines the name of the task
  76285. * @param url defines the location of the image to load
  76286. */
  76287. constructor(
  76288. /**
  76289. * Defines the name of the task
  76290. */
  76291. name: string,
  76292. /**
  76293. * Defines the location of the image to load
  76294. */
  76295. url: string);
  76296. /**
  76297. * Execute the current task
  76298. * @param scene defines the scene where you want your assets to be loaded
  76299. * @param onSuccess is a callback called when the task is successfully executed
  76300. * @param onError is a callback called if an error occurs
  76301. */
  76302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76303. }
  76304. /**
  76305. * Defines the interface used by texture loading tasks
  76306. */
  76307. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76308. /**
  76309. * Gets the loaded texture
  76310. */
  76311. texture: TEX;
  76312. }
  76313. /**
  76314. * Define a task used by AssetsManager to load 2D textures
  76315. */
  76316. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76317. /**
  76318. * Defines the name of the task
  76319. */
  76320. name: string;
  76321. /**
  76322. * Defines the location of the file to load
  76323. */
  76324. url: string;
  76325. /**
  76326. * Defines if mipmap should not be generated (default is false)
  76327. */
  76328. noMipmap?: boolean | undefined;
  76329. /**
  76330. * Defines if texture must be inverted on Y axis (default is true)
  76331. */
  76332. invertY: boolean;
  76333. /**
  76334. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76335. */
  76336. samplingMode: number;
  76337. /**
  76338. * Gets the loaded texture
  76339. */
  76340. texture: Texture;
  76341. /**
  76342. * Callback called when the task is successful
  76343. */
  76344. onSuccess: (task: TextureAssetTask) => void;
  76345. /**
  76346. * Callback called when the task is successful
  76347. */
  76348. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76349. /**
  76350. * Creates a new TextureAssetTask object
  76351. * @param name defines the name of the task
  76352. * @param url defines the location of the file to load
  76353. * @param noMipmap defines if mipmap should not be generated (default is false)
  76354. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76355. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76356. */
  76357. constructor(
  76358. /**
  76359. * Defines the name of the task
  76360. */
  76361. name: string,
  76362. /**
  76363. * Defines the location of the file to load
  76364. */
  76365. url: string,
  76366. /**
  76367. * Defines if mipmap should not be generated (default is false)
  76368. */
  76369. noMipmap?: boolean | undefined,
  76370. /**
  76371. * Defines if texture must be inverted on Y axis (default is true)
  76372. */
  76373. invertY?: boolean,
  76374. /**
  76375. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76376. */
  76377. samplingMode?: number);
  76378. /**
  76379. * Execute the current task
  76380. * @param scene defines the scene where you want your assets to be loaded
  76381. * @param onSuccess is a callback called when the task is successfully executed
  76382. * @param onError is a callback called if an error occurs
  76383. */
  76384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76385. }
  76386. /**
  76387. * Define a task used by AssetsManager to load cube textures
  76388. */
  76389. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76390. /**
  76391. * Defines the name of the task
  76392. */
  76393. name: string;
  76394. /**
  76395. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76396. */
  76397. url: string;
  76398. /**
  76399. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76400. */
  76401. extensions?: string[] | undefined;
  76402. /**
  76403. * Defines if mipmaps should not be generated (default is false)
  76404. */
  76405. noMipmap?: boolean | undefined;
  76406. /**
  76407. * Defines the explicit list of files (undefined by default)
  76408. */
  76409. files?: string[] | undefined;
  76410. /**
  76411. * Gets the loaded texture
  76412. */
  76413. texture: CubeTexture;
  76414. /**
  76415. * Callback called when the task is successful
  76416. */
  76417. onSuccess: (task: CubeTextureAssetTask) => void;
  76418. /**
  76419. * Callback called when the task is successful
  76420. */
  76421. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76422. /**
  76423. * Creates a new CubeTextureAssetTask
  76424. * @param name defines the name of the task
  76425. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76426. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76427. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76428. * @param files defines the explicit list of files (undefined by default)
  76429. */
  76430. constructor(
  76431. /**
  76432. * Defines the name of the task
  76433. */
  76434. name: string,
  76435. /**
  76436. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76437. */
  76438. url: string,
  76439. /**
  76440. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76441. */
  76442. extensions?: string[] | undefined,
  76443. /**
  76444. * Defines if mipmaps should not be generated (default is false)
  76445. */
  76446. noMipmap?: boolean | undefined,
  76447. /**
  76448. * Defines the explicit list of files (undefined by default)
  76449. */
  76450. files?: string[] | undefined);
  76451. /**
  76452. * Execute the current task
  76453. * @param scene defines the scene where you want your assets to be loaded
  76454. * @param onSuccess is a callback called when the task is successfully executed
  76455. * @param onError is a callback called if an error occurs
  76456. */
  76457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76458. }
  76459. /**
  76460. * Define a task used by AssetsManager to load HDR cube textures
  76461. */
  76462. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76463. /**
  76464. * Defines the name of the task
  76465. */
  76466. name: string;
  76467. /**
  76468. * Defines the location of the file to load
  76469. */
  76470. url: string;
  76471. /**
  76472. * Defines the desired size (the more it increases the longer the generation will be)
  76473. */
  76474. size: number;
  76475. /**
  76476. * Defines if mipmaps should not be generated (default is false)
  76477. */
  76478. noMipmap: boolean;
  76479. /**
  76480. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76481. */
  76482. generateHarmonics: boolean;
  76483. /**
  76484. * 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)
  76485. */
  76486. gammaSpace: boolean;
  76487. /**
  76488. * Internal Use Only
  76489. */
  76490. reserved: boolean;
  76491. /**
  76492. * Gets the loaded texture
  76493. */
  76494. texture: HDRCubeTexture;
  76495. /**
  76496. * Callback called when the task is successful
  76497. */
  76498. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76499. /**
  76500. * Callback called when the task is successful
  76501. */
  76502. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76503. /**
  76504. * Creates a new HDRCubeTextureAssetTask object
  76505. * @param name defines the name of the task
  76506. * @param url defines the location of the file to load
  76507. * @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.
  76508. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76509. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76510. * @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)
  76511. * @param reserved Internal use only
  76512. */
  76513. constructor(
  76514. /**
  76515. * Defines the name of the task
  76516. */
  76517. name: string,
  76518. /**
  76519. * Defines the location of the file to load
  76520. */
  76521. url: string,
  76522. /**
  76523. * Defines the desired size (the more it increases the longer the generation will be)
  76524. */
  76525. size: number,
  76526. /**
  76527. * Defines if mipmaps should not be generated (default is false)
  76528. */
  76529. noMipmap?: boolean,
  76530. /**
  76531. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76532. */
  76533. generateHarmonics?: boolean,
  76534. /**
  76535. * 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)
  76536. */
  76537. gammaSpace?: boolean,
  76538. /**
  76539. * Internal Use Only
  76540. */
  76541. reserved?: boolean);
  76542. /**
  76543. * Execute the current task
  76544. * @param scene defines the scene where you want your assets to be loaded
  76545. * @param onSuccess is a callback called when the task is successfully executed
  76546. * @param onError is a callback called if an error occurs
  76547. */
  76548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76549. }
  76550. /**
  76551. * Define a task used by AssetsManager to load Equirectangular cube textures
  76552. */
  76553. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76554. /**
  76555. * Defines the name of the task
  76556. */
  76557. name: string;
  76558. /**
  76559. * Defines the location of the file to load
  76560. */
  76561. url: string;
  76562. /**
  76563. * Defines the desired size (the more it increases the longer the generation will be)
  76564. */
  76565. size: number;
  76566. /**
  76567. * Defines if mipmaps should not be generated (default is false)
  76568. */
  76569. noMipmap: boolean;
  76570. /**
  76571. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76572. * but the standard material would require them in Gamma space) (default is true)
  76573. */
  76574. gammaSpace: boolean;
  76575. /**
  76576. * Gets the loaded texture
  76577. */
  76578. texture: EquiRectangularCubeTexture;
  76579. /**
  76580. * Callback called when the task is successful
  76581. */
  76582. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76583. /**
  76584. * Callback called when the task is successful
  76585. */
  76586. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76587. /**
  76588. * Creates a new EquiRectangularCubeTextureAssetTask object
  76589. * @param name defines the name of the task
  76590. * @param url defines the location of the file to load
  76591. * @param size defines the desired size (the more it increases the longer the generation will be)
  76592. * If the size is omitted this implies you are using a preprocessed cubemap.
  76593. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76594. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76595. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76596. * (default is true)
  76597. */
  76598. constructor(
  76599. /**
  76600. * Defines the name of the task
  76601. */
  76602. name: string,
  76603. /**
  76604. * Defines the location of the file to load
  76605. */
  76606. url: string,
  76607. /**
  76608. * Defines the desired size (the more it increases the longer the generation will be)
  76609. */
  76610. size: number,
  76611. /**
  76612. * Defines if mipmaps should not be generated (default is false)
  76613. */
  76614. noMipmap?: boolean,
  76615. /**
  76616. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76617. * but the standard material would require them in Gamma space) (default is true)
  76618. */
  76619. gammaSpace?: boolean);
  76620. /**
  76621. * Execute the current task
  76622. * @param scene defines the scene where you want your assets to be loaded
  76623. * @param onSuccess is a callback called when the task is successfully executed
  76624. * @param onError is a callback called if an error occurs
  76625. */
  76626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76627. }
  76628. /**
  76629. * This class can be used to easily import assets into a scene
  76630. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76631. */
  76632. export class AssetsManager {
  76633. private _scene;
  76634. private _isLoading;
  76635. protected _tasks: AbstractAssetTask[];
  76636. protected _waitingTasksCount: number;
  76637. protected _totalTasksCount: number;
  76638. /**
  76639. * Callback called when all tasks are processed
  76640. */
  76641. onFinish: (tasks: AbstractAssetTask[]) => void;
  76642. /**
  76643. * Callback called when a task is successful
  76644. */
  76645. onTaskSuccess: (task: AbstractAssetTask) => void;
  76646. /**
  76647. * Callback called when a task had an error
  76648. */
  76649. onTaskError: (task: AbstractAssetTask) => void;
  76650. /**
  76651. * Callback called when a task is done (whatever the result is)
  76652. */
  76653. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76654. /**
  76655. * Observable called when all tasks are processed
  76656. */
  76657. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76658. /**
  76659. * Observable called when a task had an error
  76660. */
  76661. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76662. /**
  76663. * Observable called when all tasks were executed
  76664. */
  76665. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76666. /**
  76667. * Observable called when a task is done (whatever the result is)
  76668. */
  76669. onProgressObservable: Observable<IAssetsProgressEvent>;
  76670. /**
  76671. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76672. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76673. */
  76674. useDefaultLoadingScreen: boolean;
  76675. /**
  76676. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76677. * when all assets have been downloaded.
  76678. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76679. */
  76680. autoHideLoadingUI: boolean;
  76681. /**
  76682. * Creates a new AssetsManager
  76683. * @param scene defines the scene to work on
  76684. */
  76685. constructor(scene: Scene);
  76686. /**
  76687. * Add a ContainerAssetTask to the list of active tasks
  76688. * @param taskName defines the name of the new task
  76689. * @param meshesNames defines the name of meshes to load
  76690. * @param rootUrl defines the root url to use to locate files
  76691. * @param sceneFilename defines the filename of the scene file
  76692. * @returns a new ContainerAssetTask object
  76693. */
  76694. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  76695. /**
  76696. * Add a MeshAssetTask to the list of active tasks
  76697. * @param taskName defines the name of the new task
  76698. * @param meshesNames defines the name of meshes to load
  76699. * @param rootUrl defines the root url to use to locate files
  76700. * @param sceneFilename defines the filename of the scene file
  76701. * @returns a new MeshAssetTask object
  76702. */
  76703. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76704. /**
  76705. * Add a TextFileAssetTask to the list of active tasks
  76706. * @param taskName defines the name of the new task
  76707. * @param url defines the url of the file to load
  76708. * @returns a new TextFileAssetTask object
  76709. */
  76710. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76711. /**
  76712. * Add a BinaryFileAssetTask to the list of active tasks
  76713. * @param taskName defines the name of the new task
  76714. * @param url defines the url of the file to load
  76715. * @returns a new BinaryFileAssetTask object
  76716. */
  76717. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76718. /**
  76719. * Add a ImageAssetTask to the list of active tasks
  76720. * @param taskName defines the name of the new task
  76721. * @param url defines the url of the file to load
  76722. * @returns a new ImageAssetTask object
  76723. */
  76724. addImageTask(taskName: string, url: string): ImageAssetTask;
  76725. /**
  76726. * Add a TextureAssetTask to the list of active tasks
  76727. * @param taskName defines the name of the new task
  76728. * @param url defines the url of the file to load
  76729. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76730. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76731. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76732. * @returns a new TextureAssetTask object
  76733. */
  76734. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76735. /**
  76736. * Add a CubeTextureAssetTask to the list of active tasks
  76737. * @param taskName defines the name of the new task
  76738. * @param url defines the url of the file to load
  76739. * @param extensions defines the extension to use to load the cube map (can be null)
  76740. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76741. * @param files defines the list of files to load (can be null)
  76742. * @returns a new CubeTextureAssetTask object
  76743. */
  76744. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76745. /**
  76746. *
  76747. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76748. * @param taskName defines the name of the new task
  76749. * @param url defines the url of the file to load
  76750. * @param size defines the size you want for the cubemap (can be null)
  76751. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76752. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76753. * @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)
  76754. * @param reserved Internal use only
  76755. * @returns a new HDRCubeTextureAssetTask object
  76756. */
  76757. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76758. /**
  76759. *
  76760. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76761. * @param taskName defines the name of the new task
  76762. * @param url defines the url of the file to load
  76763. * @param size defines the size you want for the cubemap (can be null)
  76764. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76765. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76766. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76767. * @returns a new EquiRectangularCubeTextureAssetTask object
  76768. */
  76769. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76770. /**
  76771. * Remove a task from the assets manager.
  76772. * @param task the task to remove
  76773. */
  76774. removeTask(task: AbstractAssetTask): void;
  76775. private _decreaseWaitingTasksCount;
  76776. private _runTask;
  76777. /**
  76778. * Reset the AssetsManager and remove all tasks
  76779. * @return the current instance of the AssetsManager
  76780. */
  76781. reset(): AssetsManager;
  76782. /**
  76783. * Start the loading process
  76784. * @return the current instance of the AssetsManager
  76785. */
  76786. load(): AssetsManager;
  76787. /**
  76788. * Start the loading process as an async operation
  76789. * @return a promise returning the list of failed tasks
  76790. */
  76791. loadAsync(): Promise<void>;
  76792. }
  76793. }
  76794. declare module "babylonjs/Misc/deferred" {
  76795. /**
  76796. * Wrapper class for promise with external resolve and reject.
  76797. */
  76798. export class Deferred<T> {
  76799. /**
  76800. * The promise associated with this deferred object.
  76801. */
  76802. readonly promise: Promise<T>;
  76803. private _resolve;
  76804. private _reject;
  76805. /**
  76806. * The resolve method of the promise associated with this deferred object.
  76807. */
  76808. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76809. /**
  76810. * The reject method of the promise associated with this deferred object.
  76811. */
  76812. get reject(): (reason?: any) => void;
  76813. /**
  76814. * Constructor for this deferred object.
  76815. */
  76816. constructor();
  76817. }
  76818. }
  76819. declare module "babylonjs/Misc/meshExploder" {
  76820. import { Mesh } from "babylonjs/Meshes/mesh";
  76821. /**
  76822. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76823. */
  76824. export class MeshExploder {
  76825. private _centerMesh;
  76826. private _meshes;
  76827. private _meshesOrigins;
  76828. private _toCenterVectors;
  76829. private _scaledDirection;
  76830. private _newPosition;
  76831. private _centerPosition;
  76832. /**
  76833. * Explodes meshes from a center mesh.
  76834. * @param meshes The meshes to explode.
  76835. * @param centerMesh The mesh to be center of explosion.
  76836. */
  76837. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76838. private _setCenterMesh;
  76839. /**
  76840. * Get class name
  76841. * @returns "MeshExploder"
  76842. */
  76843. getClassName(): string;
  76844. /**
  76845. * "Exploded meshes"
  76846. * @returns Array of meshes with the centerMesh at index 0.
  76847. */
  76848. getMeshes(): Array<Mesh>;
  76849. /**
  76850. * Explodes meshes giving a specific direction
  76851. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76852. */
  76853. explode(direction?: number): void;
  76854. }
  76855. }
  76856. declare module "babylonjs/Misc/filesInput" {
  76857. import { Engine } from "babylonjs/Engines/engine";
  76858. import { Scene } from "babylonjs/scene";
  76859. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76860. import { Nullable } from "babylonjs/types";
  76861. /**
  76862. * Class used to help managing file picking and drag'n'drop
  76863. */
  76864. export class FilesInput {
  76865. /**
  76866. * List of files ready to be loaded
  76867. */
  76868. static get FilesToLoad(): {
  76869. [key: string]: File;
  76870. };
  76871. /**
  76872. * Callback called when a file is processed
  76873. */
  76874. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76875. private _engine;
  76876. private _currentScene;
  76877. private _sceneLoadedCallback;
  76878. private _progressCallback;
  76879. private _additionalRenderLoopLogicCallback;
  76880. private _textureLoadingCallback;
  76881. private _startingProcessingFilesCallback;
  76882. private _onReloadCallback;
  76883. private _errorCallback;
  76884. private _elementToMonitor;
  76885. private _sceneFileToLoad;
  76886. private _filesToLoad;
  76887. /**
  76888. * Creates a new FilesInput
  76889. * @param engine defines the rendering engine
  76890. * @param scene defines the hosting scene
  76891. * @param sceneLoadedCallback callback called when scene is loaded
  76892. * @param progressCallback callback called to track progress
  76893. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76894. * @param textureLoadingCallback callback called when a texture is loading
  76895. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76896. * @param onReloadCallback callback called when a reload is requested
  76897. * @param errorCallback callback call if an error occurs
  76898. */
  76899. 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>);
  76900. private _dragEnterHandler;
  76901. private _dragOverHandler;
  76902. private _dropHandler;
  76903. /**
  76904. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76905. * @param elementToMonitor defines the DOM element to track
  76906. */
  76907. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76908. /** Gets the current list of files to load */
  76909. get filesToLoad(): File[];
  76910. /**
  76911. * Release all associated resources
  76912. */
  76913. dispose(): void;
  76914. private renderFunction;
  76915. private drag;
  76916. private drop;
  76917. private _traverseFolder;
  76918. private _processFiles;
  76919. /**
  76920. * Load files from a drop event
  76921. * @param event defines the drop event to use as source
  76922. */
  76923. loadFiles(event: any): void;
  76924. private _processReload;
  76925. /**
  76926. * Reload the current scene from the loaded files
  76927. */
  76928. reload(): void;
  76929. }
  76930. }
  76931. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76932. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76933. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76934. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76935. }
  76936. declare module "babylonjs/Misc/sceneOptimizer" {
  76937. import { Scene, IDisposable } from "babylonjs/scene";
  76938. import { Observable } from "babylonjs/Misc/observable";
  76939. /**
  76940. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76941. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76942. */
  76943. export class SceneOptimization {
  76944. /**
  76945. * Defines the priority of this optimization (0 by default which means first in the list)
  76946. */
  76947. priority: number;
  76948. /**
  76949. * Gets a string describing the action executed by the current optimization
  76950. * @returns description string
  76951. */
  76952. getDescription(): string;
  76953. /**
  76954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76955. * @param scene defines the current scene where to apply this optimization
  76956. * @param optimizer defines the current optimizer
  76957. * @returns true if everything that can be done was applied
  76958. */
  76959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76960. /**
  76961. * Creates the SceneOptimization object
  76962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76963. * @param desc defines the description associated with the optimization
  76964. */
  76965. constructor(
  76966. /**
  76967. * Defines the priority of this optimization (0 by default which means first in the list)
  76968. */
  76969. priority?: number);
  76970. }
  76971. /**
  76972. * Defines an optimization used to reduce the size of render target textures
  76973. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76974. */
  76975. export class TextureOptimization extends SceneOptimization {
  76976. /**
  76977. * Defines the priority of this optimization (0 by default which means first in the list)
  76978. */
  76979. priority: number;
  76980. /**
  76981. * 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
  76982. */
  76983. maximumSize: number;
  76984. /**
  76985. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76986. */
  76987. step: number;
  76988. /**
  76989. * Gets a string describing the action executed by the current optimization
  76990. * @returns description string
  76991. */
  76992. getDescription(): string;
  76993. /**
  76994. * Creates the TextureOptimization object
  76995. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76996. * @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
  76997. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76998. */
  76999. constructor(
  77000. /**
  77001. * Defines the priority of this optimization (0 by default which means first in the list)
  77002. */
  77003. priority?: number,
  77004. /**
  77005. * 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
  77006. */
  77007. maximumSize?: number,
  77008. /**
  77009. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77010. */
  77011. step?: number);
  77012. /**
  77013. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77014. * @param scene defines the current scene where to apply this optimization
  77015. * @param optimizer defines the current optimizer
  77016. * @returns true if everything that can be done was applied
  77017. */
  77018. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77019. }
  77020. /**
  77021. * Defines an optimization used to increase or decrease the rendering resolution
  77022. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77023. */
  77024. export class HardwareScalingOptimization extends SceneOptimization {
  77025. /**
  77026. * Defines the priority of this optimization (0 by default which means first in the list)
  77027. */
  77028. priority: number;
  77029. /**
  77030. * Defines the maximum scale to use (2 by default)
  77031. */
  77032. maximumScale: number;
  77033. /**
  77034. * Defines the step to use between two passes (0.5 by default)
  77035. */
  77036. step: number;
  77037. private _currentScale;
  77038. private _directionOffset;
  77039. /**
  77040. * Gets a string describing the action executed by the current optimization
  77041. * @return description string
  77042. */
  77043. getDescription(): string;
  77044. /**
  77045. * Creates the HardwareScalingOptimization object
  77046. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77047. * @param maximumScale defines the maximum scale to use (2 by default)
  77048. * @param step defines the step to use between two passes (0.5 by default)
  77049. */
  77050. constructor(
  77051. /**
  77052. * Defines the priority of this optimization (0 by default which means first in the list)
  77053. */
  77054. priority?: number,
  77055. /**
  77056. * Defines the maximum scale to use (2 by default)
  77057. */
  77058. maximumScale?: number,
  77059. /**
  77060. * Defines the step to use between two passes (0.5 by default)
  77061. */
  77062. step?: number);
  77063. /**
  77064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77065. * @param scene defines the current scene where to apply this optimization
  77066. * @param optimizer defines the current optimizer
  77067. * @returns true if everything that can be done was applied
  77068. */
  77069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77070. }
  77071. /**
  77072. * Defines an optimization used to remove shadows
  77073. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77074. */
  77075. export class ShadowsOptimization extends SceneOptimization {
  77076. /**
  77077. * Gets a string describing the action executed by the current optimization
  77078. * @return description string
  77079. */
  77080. getDescription(): string;
  77081. /**
  77082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77083. * @param scene defines the current scene where to apply this optimization
  77084. * @param optimizer defines the current optimizer
  77085. * @returns true if everything that can be done was applied
  77086. */
  77087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77088. }
  77089. /**
  77090. * Defines an optimization used to turn post-processes off
  77091. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77092. */
  77093. export class PostProcessesOptimization extends SceneOptimization {
  77094. /**
  77095. * Gets a string describing the action executed by the current optimization
  77096. * @return description string
  77097. */
  77098. getDescription(): string;
  77099. /**
  77100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77101. * @param scene defines the current scene where to apply this optimization
  77102. * @param optimizer defines the current optimizer
  77103. * @returns true if everything that can be done was applied
  77104. */
  77105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77106. }
  77107. /**
  77108. * Defines an optimization used to turn lens flares off
  77109. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77110. */
  77111. export class LensFlaresOptimization extends SceneOptimization {
  77112. /**
  77113. * Gets a string describing the action executed by the current optimization
  77114. * @return description string
  77115. */
  77116. getDescription(): string;
  77117. /**
  77118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77119. * @param scene defines the current scene where to apply this optimization
  77120. * @param optimizer defines the current optimizer
  77121. * @returns true if everything that can be done was applied
  77122. */
  77123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77124. }
  77125. /**
  77126. * Defines an optimization based on user defined callback.
  77127. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77128. */
  77129. export class CustomOptimization extends SceneOptimization {
  77130. /**
  77131. * Callback called to apply the custom optimization.
  77132. */
  77133. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77134. /**
  77135. * Callback called to get custom description
  77136. */
  77137. onGetDescription: () => string;
  77138. /**
  77139. * Gets a string describing the action executed by the current optimization
  77140. * @returns description string
  77141. */
  77142. getDescription(): string;
  77143. /**
  77144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77145. * @param scene defines the current scene where to apply this optimization
  77146. * @param optimizer defines the current optimizer
  77147. * @returns true if everything that can be done was applied
  77148. */
  77149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77150. }
  77151. /**
  77152. * Defines an optimization used to turn particles off
  77153. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77154. */
  77155. export class ParticlesOptimization extends SceneOptimization {
  77156. /**
  77157. * Gets a string describing the action executed by the current optimization
  77158. * @return description string
  77159. */
  77160. getDescription(): string;
  77161. /**
  77162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77163. * @param scene defines the current scene where to apply this optimization
  77164. * @param optimizer defines the current optimizer
  77165. * @returns true if everything that can be done was applied
  77166. */
  77167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77168. }
  77169. /**
  77170. * Defines an optimization used to turn render targets off
  77171. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77172. */
  77173. export class RenderTargetsOptimization extends SceneOptimization {
  77174. /**
  77175. * Gets a string describing the action executed by the current optimization
  77176. * @return description string
  77177. */
  77178. getDescription(): string;
  77179. /**
  77180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77181. * @param scene defines the current scene where to apply this optimization
  77182. * @param optimizer defines the current optimizer
  77183. * @returns true if everything that can be done was applied
  77184. */
  77185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77186. }
  77187. /**
  77188. * Defines an optimization used to merge meshes with compatible materials
  77189. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77190. */
  77191. export class MergeMeshesOptimization extends SceneOptimization {
  77192. private static _UpdateSelectionTree;
  77193. /**
  77194. * Gets or sets a boolean which defines if optimization octree has to be updated
  77195. */
  77196. static get UpdateSelectionTree(): boolean;
  77197. /**
  77198. * Gets or sets a boolean which defines if optimization octree has to be updated
  77199. */
  77200. static set UpdateSelectionTree(value: boolean);
  77201. /**
  77202. * Gets a string describing the action executed by the current optimization
  77203. * @return description string
  77204. */
  77205. getDescription(): string;
  77206. private _canBeMerged;
  77207. /**
  77208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77209. * @param scene defines the current scene where to apply this optimization
  77210. * @param optimizer defines the current optimizer
  77211. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77212. * @returns true if everything that can be done was applied
  77213. */
  77214. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77215. }
  77216. /**
  77217. * Defines a list of options used by SceneOptimizer
  77218. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77219. */
  77220. export class SceneOptimizerOptions {
  77221. /**
  77222. * Defines the target frame rate to reach (60 by default)
  77223. */
  77224. targetFrameRate: number;
  77225. /**
  77226. * Defines the interval between two checkes (2000ms by default)
  77227. */
  77228. trackerDuration: number;
  77229. /**
  77230. * Gets the list of optimizations to apply
  77231. */
  77232. optimizations: SceneOptimization[];
  77233. /**
  77234. * Creates a new list of options used by SceneOptimizer
  77235. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77236. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77237. */
  77238. constructor(
  77239. /**
  77240. * Defines the target frame rate to reach (60 by default)
  77241. */
  77242. targetFrameRate?: number,
  77243. /**
  77244. * Defines the interval between two checkes (2000ms by default)
  77245. */
  77246. trackerDuration?: number);
  77247. /**
  77248. * Add a new optimization
  77249. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77250. * @returns the current SceneOptimizerOptions
  77251. */
  77252. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77253. /**
  77254. * Add a new custom optimization
  77255. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77256. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77257. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77258. * @returns the current SceneOptimizerOptions
  77259. */
  77260. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77261. /**
  77262. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77263. * @param targetFrameRate defines the target frame rate (60 by default)
  77264. * @returns a SceneOptimizerOptions object
  77265. */
  77266. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77267. /**
  77268. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77269. * @param targetFrameRate defines the target frame rate (60 by default)
  77270. * @returns a SceneOptimizerOptions object
  77271. */
  77272. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77273. /**
  77274. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77275. * @param targetFrameRate defines the target frame rate (60 by default)
  77276. * @returns a SceneOptimizerOptions object
  77277. */
  77278. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77279. }
  77280. /**
  77281. * Class used to run optimizations in order to reach a target frame rate
  77282. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77283. */
  77284. export class SceneOptimizer implements IDisposable {
  77285. private _isRunning;
  77286. private _options;
  77287. private _scene;
  77288. private _currentPriorityLevel;
  77289. private _targetFrameRate;
  77290. private _trackerDuration;
  77291. private _currentFrameRate;
  77292. private _sceneDisposeObserver;
  77293. private _improvementMode;
  77294. /**
  77295. * Defines an observable called when the optimizer reaches the target frame rate
  77296. */
  77297. onSuccessObservable: Observable<SceneOptimizer>;
  77298. /**
  77299. * Defines an observable called when the optimizer enables an optimization
  77300. */
  77301. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77302. /**
  77303. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77304. */
  77305. onFailureObservable: Observable<SceneOptimizer>;
  77306. /**
  77307. * Gets a boolean indicating if the optimizer is in improvement mode
  77308. */
  77309. get isInImprovementMode(): boolean;
  77310. /**
  77311. * Gets the current priority level (0 at start)
  77312. */
  77313. get currentPriorityLevel(): number;
  77314. /**
  77315. * Gets the current frame rate checked by the SceneOptimizer
  77316. */
  77317. get currentFrameRate(): number;
  77318. /**
  77319. * Gets or sets the current target frame rate (60 by default)
  77320. */
  77321. get targetFrameRate(): number;
  77322. /**
  77323. * Gets or sets the current target frame rate (60 by default)
  77324. */
  77325. set targetFrameRate(value: number);
  77326. /**
  77327. * Gets or sets the current interval between two checks (every 2000ms by default)
  77328. */
  77329. get trackerDuration(): number;
  77330. /**
  77331. * Gets or sets the current interval between two checks (every 2000ms by default)
  77332. */
  77333. set trackerDuration(value: number);
  77334. /**
  77335. * Gets the list of active optimizations
  77336. */
  77337. get optimizations(): SceneOptimization[];
  77338. /**
  77339. * Creates a new SceneOptimizer
  77340. * @param scene defines the scene to work on
  77341. * @param options defines the options to use with the SceneOptimizer
  77342. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77343. * @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)
  77344. */
  77345. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77346. /**
  77347. * Stops the current optimizer
  77348. */
  77349. stop(): void;
  77350. /**
  77351. * Reset the optimizer to initial step (current priority level = 0)
  77352. */
  77353. reset(): void;
  77354. /**
  77355. * Start the optimizer. By default it will try to reach a specific framerate
  77356. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77357. */
  77358. start(): void;
  77359. private _checkCurrentState;
  77360. /**
  77361. * Release all resources
  77362. */
  77363. dispose(): void;
  77364. /**
  77365. * Helper function to create a SceneOptimizer with one single line of code
  77366. * @param scene defines the scene to work on
  77367. * @param options defines the options to use with the SceneOptimizer
  77368. * @param onSuccess defines a callback to call on success
  77369. * @param onFailure defines a callback to call on failure
  77370. * @returns the new SceneOptimizer object
  77371. */
  77372. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77373. }
  77374. }
  77375. declare module "babylonjs/Misc/sceneSerializer" {
  77376. import { Scene } from "babylonjs/scene";
  77377. /**
  77378. * Class used to serialize a scene into a string
  77379. */
  77380. export class SceneSerializer {
  77381. /**
  77382. * Clear cache used by a previous serialization
  77383. */
  77384. static ClearCache(): void;
  77385. /**
  77386. * Serialize a scene into a JSON compatible object
  77387. * @param scene defines the scene to serialize
  77388. * @returns a JSON compatible object
  77389. */
  77390. static Serialize(scene: Scene): any;
  77391. /**
  77392. * Serialize a mesh into a JSON compatible object
  77393. * @param toSerialize defines the mesh to serialize
  77394. * @param withParents defines if parents must be serialized as well
  77395. * @param withChildren defines if children must be serialized as well
  77396. * @returns a JSON compatible object
  77397. */
  77398. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77399. }
  77400. }
  77401. declare module "babylonjs/Misc/textureTools" {
  77402. import { Texture } from "babylonjs/Materials/Textures/texture";
  77403. /**
  77404. * Class used to host texture specific utilities
  77405. */
  77406. export class TextureTools {
  77407. /**
  77408. * Uses the GPU to create a copy texture rescaled at a given size
  77409. * @param texture Texture to copy from
  77410. * @param width defines the desired width
  77411. * @param height defines the desired height
  77412. * @param useBilinearMode defines if bilinear mode has to be used
  77413. * @return the generated texture
  77414. */
  77415. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77416. }
  77417. }
  77418. declare module "babylonjs/Misc/videoRecorder" {
  77419. import { Nullable } from "babylonjs/types";
  77420. import { Engine } from "babylonjs/Engines/engine";
  77421. /**
  77422. * This represents the different options available for the video capture.
  77423. */
  77424. export interface VideoRecorderOptions {
  77425. /** Defines the mime type of the video. */
  77426. mimeType: string;
  77427. /** Defines the FPS the video should be recorded at. */
  77428. fps: number;
  77429. /** Defines the chunk size for the recording data. */
  77430. recordChunckSize: number;
  77431. /** The audio tracks to attach to the recording. */
  77432. audioTracks?: MediaStreamTrack[];
  77433. }
  77434. /**
  77435. * This can help with recording videos from BabylonJS.
  77436. * This is based on the available WebRTC functionalities of the browser.
  77437. *
  77438. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77439. */
  77440. export class VideoRecorder {
  77441. private static readonly _defaultOptions;
  77442. /**
  77443. * Returns whether or not the VideoRecorder is available in your browser.
  77444. * @param engine Defines the Babylon Engine.
  77445. * @returns true if supported otherwise false.
  77446. */
  77447. static IsSupported(engine: Engine): boolean;
  77448. private readonly _options;
  77449. private _canvas;
  77450. private _mediaRecorder;
  77451. private _recordedChunks;
  77452. private _fileName;
  77453. private _resolve;
  77454. private _reject;
  77455. /**
  77456. * True when a recording is already in progress.
  77457. */
  77458. get isRecording(): boolean;
  77459. /**
  77460. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77461. * @param engine Defines the BabylonJS Engine you wish to record.
  77462. * @param options Defines options that can be used to customize the capture.
  77463. */
  77464. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77465. /**
  77466. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77467. */
  77468. stopRecording(): void;
  77469. /**
  77470. * Starts recording the canvas for a max duration specified in parameters.
  77471. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77472. * If null no automatic download will start and you can rely on the promise to get the data back.
  77473. * @param maxDuration Defines the maximum recording time in seconds.
  77474. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77475. * @return A promise callback at the end of the recording with the video data in Blob.
  77476. */
  77477. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77478. /**
  77479. * Releases internal resources used during the recording.
  77480. */
  77481. dispose(): void;
  77482. private _handleDataAvailable;
  77483. private _handleError;
  77484. private _handleStop;
  77485. }
  77486. }
  77487. declare module "babylonjs/Misc/screenshotTools" {
  77488. import { Camera } from "babylonjs/Cameras/camera";
  77489. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77490. import { Engine } from "babylonjs/Engines/engine";
  77491. /**
  77492. * Class containing a set of static utilities functions for screenshots
  77493. */
  77494. export class ScreenshotTools {
  77495. /**
  77496. * Captures a screenshot of the current rendering
  77497. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77498. * @param engine defines the rendering engine
  77499. * @param camera defines the source camera
  77500. * @param size This parameter can be set to a single number or to an object with the
  77501. * following (optional) properties: precision, width, height. If a single number is passed,
  77502. * it will be used for both width and height. If an object is passed, the screenshot size
  77503. * will be derived from the parameters. The precision property is a multiplier allowing
  77504. * rendering at a higher or lower resolution
  77505. * @param successCallback defines the callback receives a single parameter which contains the
  77506. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77507. * src parameter of an <img> to display it
  77508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77509. * Check your browser for supported MIME types
  77510. */
  77511. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77512. /**
  77513. * Captures a screenshot of the current rendering
  77514. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77515. * @param engine defines the rendering engine
  77516. * @param camera defines the source camera
  77517. * @param size This parameter can be set to a single number or to an object with the
  77518. * following (optional) properties: precision, width, height. If a single number is passed,
  77519. * it will be used for both width and height. If an object is passed, the screenshot size
  77520. * will be derived from the parameters. The precision property is a multiplier allowing
  77521. * rendering at a higher or lower resolution
  77522. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77523. * Check your browser for supported MIME types
  77524. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77525. * to the src parameter of an <img> to display it
  77526. */
  77527. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77528. /**
  77529. * Generates an image screenshot from the specified camera.
  77530. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77531. * @param engine The engine to use for rendering
  77532. * @param camera The camera to use for rendering
  77533. * @param size This parameter can be set to a single number or to an object with the
  77534. * following (optional) properties: precision, width, height. If a single number is passed,
  77535. * it will be used for both width and height. If an object is passed, the screenshot size
  77536. * will be derived from the parameters. The precision property is a multiplier allowing
  77537. * rendering at a higher or lower resolution
  77538. * @param successCallback The callback receives a single parameter which contains the
  77539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77540. * src parameter of an <img> to display it
  77541. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77542. * Check your browser for supported MIME types
  77543. * @param samples Texture samples (default: 1)
  77544. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77545. * @param fileName A name for for the downloaded file.
  77546. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77547. */
  77548. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77549. /**
  77550. * Generates an image screenshot from the specified camera.
  77551. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77552. * @param engine The engine to use for rendering
  77553. * @param camera The camera to use for rendering
  77554. * @param size This parameter can be set to a single number or to an object with the
  77555. * following (optional) properties: precision, width, height. If a single number is passed,
  77556. * it will be used for both width and height. If an object is passed, the screenshot size
  77557. * will be derived from the parameters. The precision property is a multiplier allowing
  77558. * rendering at a higher or lower resolution
  77559. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77560. * Check your browser for supported MIME types
  77561. * @param samples Texture samples (default: 1)
  77562. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77563. * @param fileName A name for for the downloaded file.
  77564. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77565. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77566. * to the src parameter of an <img> to display it
  77567. */
  77568. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77569. /**
  77570. * Gets height and width for screenshot size
  77571. * @private
  77572. */
  77573. private static _getScreenshotSize;
  77574. }
  77575. }
  77576. declare module "babylonjs/Misc/dataReader" {
  77577. /**
  77578. * Interface for a data buffer
  77579. */
  77580. export interface IDataBuffer {
  77581. /**
  77582. * Reads bytes from the data buffer.
  77583. * @param byteOffset The byte offset to read
  77584. * @param byteLength The byte length to read
  77585. * @returns A promise that resolves when the bytes are read
  77586. */
  77587. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77588. /**
  77589. * The byte length of the buffer.
  77590. */
  77591. readonly byteLength: number;
  77592. }
  77593. /**
  77594. * Utility class for reading from a data buffer
  77595. */
  77596. export class DataReader {
  77597. /**
  77598. * The data buffer associated with this data reader.
  77599. */
  77600. readonly buffer: IDataBuffer;
  77601. /**
  77602. * The current byte offset from the beginning of the data buffer.
  77603. */
  77604. byteOffset: number;
  77605. private _dataView;
  77606. private _dataByteOffset;
  77607. /**
  77608. * Constructor
  77609. * @param buffer The buffer to read
  77610. */
  77611. constructor(buffer: IDataBuffer);
  77612. /**
  77613. * Loads the given byte length.
  77614. * @param byteLength The byte length to load
  77615. * @returns A promise that resolves when the load is complete
  77616. */
  77617. loadAsync(byteLength: number): Promise<void>;
  77618. /**
  77619. * Read a unsigned 32-bit integer from the currently loaded data range.
  77620. * @returns The 32-bit integer read
  77621. */
  77622. readUint32(): number;
  77623. /**
  77624. * Read a byte array from the currently loaded data range.
  77625. * @param byteLength The byte length to read
  77626. * @returns The byte array read
  77627. */
  77628. readUint8Array(byteLength: number): Uint8Array;
  77629. /**
  77630. * Read a string from the currently loaded data range.
  77631. * @param byteLength The byte length to read
  77632. * @returns The string read
  77633. */
  77634. readString(byteLength: number): string;
  77635. /**
  77636. * Skips the given byte length the currently loaded data range.
  77637. * @param byteLength The byte length to skip
  77638. */
  77639. skipBytes(byteLength: number): void;
  77640. }
  77641. }
  77642. declare module "babylonjs/Misc/dataStorage" {
  77643. /**
  77644. * Class for storing data to local storage if available or in-memory storage otherwise
  77645. */
  77646. export class DataStorage {
  77647. private static _Storage;
  77648. private static _GetStorage;
  77649. /**
  77650. * Reads a string from the data storage
  77651. * @param key The key to read
  77652. * @param defaultValue The value if the key doesn't exist
  77653. * @returns The string value
  77654. */
  77655. static ReadString(key: string, defaultValue: string): string;
  77656. /**
  77657. * Writes a string to the data storage
  77658. * @param key The key to write
  77659. * @param value The value to write
  77660. */
  77661. static WriteString(key: string, value: string): void;
  77662. /**
  77663. * Reads a boolean from the data storage
  77664. * @param key The key to read
  77665. * @param defaultValue The value if the key doesn't exist
  77666. * @returns The boolean value
  77667. */
  77668. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77669. /**
  77670. * Writes a boolean to the data storage
  77671. * @param key The key to write
  77672. * @param value The value to write
  77673. */
  77674. static WriteBoolean(key: string, value: boolean): void;
  77675. /**
  77676. * Reads a number from the data storage
  77677. * @param key The key to read
  77678. * @param defaultValue The value if the key doesn't exist
  77679. * @returns The number value
  77680. */
  77681. static ReadNumber(key: string, defaultValue: number): number;
  77682. /**
  77683. * Writes a number to the data storage
  77684. * @param key The key to write
  77685. * @param value The value to write
  77686. */
  77687. static WriteNumber(key: string, value: number): void;
  77688. }
  77689. }
  77690. declare module "babylonjs/Misc/sceneRecorder" {
  77691. import { Scene } from "babylonjs/scene";
  77692. /**
  77693. * Class used to record delta files between 2 scene states
  77694. */
  77695. export class SceneRecorder {
  77696. private _trackedScene;
  77697. private _savedJSON;
  77698. /**
  77699. * Track a given scene. This means the current scene state will be considered the original state
  77700. * @param scene defines the scene to track
  77701. */
  77702. track(scene: Scene): void;
  77703. /**
  77704. * Get the delta between current state and original state
  77705. * @returns a string containing the delta
  77706. */
  77707. getDelta(): any;
  77708. private _compareArray;
  77709. private _compareObjects;
  77710. private _compareCollections;
  77711. private static GetShadowGeneratorById;
  77712. /**
  77713. * Apply a given delta to a given scene
  77714. * @param deltaJSON defines the JSON containing the delta
  77715. * @param scene defines the scene to apply the delta to
  77716. */
  77717. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77718. private static _ApplyPropertiesToEntity;
  77719. private static _ApplyDeltaForEntity;
  77720. }
  77721. }
  77722. declare module "babylonjs/Misc/index" {
  77723. export * from "babylonjs/Misc/andOrNotEvaluator";
  77724. export * from "babylonjs/Misc/assetsManager";
  77725. export * from "babylonjs/Misc/basis";
  77726. export * from "babylonjs/Misc/dds";
  77727. export * from "babylonjs/Misc/decorators";
  77728. export * from "babylonjs/Misc/deferred";
  77729. export * from "babylonjs/Misc/environmentTextureTools";
  77730. export * from "babylonjs/Misc/meshExploder";
  77731. export * from "babylonjs/Misc/filesInput";
  77732. export * from "babylonjs/Misc/HighDynamicRange/index";
  77733. export * from "babylonjs/Misc/khronosTextureContainer";
  77734. export * from "babylonjs/Misc/observable";
  77735. export * from "babylonjs/Misc/performanceMonitor";
  77736. export * from "babylonjs/Misc/promise";
  77737. export * from "babylonjs/Misc/sceneOptimizer";
  77738. export * from "babylonjs/Misc/sceneSerializer";
  77739. export * from "babylonjs/Misc/smartArray";
  77740. export * from "babylonjs/Misc/stringDictionary";
  77741. export * from "babylonjs/Misc/tags";
  77742. export * from "babylonjs/Misc/textureTools";
  77743. export * from "babylonjs/Misc/tga";
  77744. export * from "babylonjs/Misc/tools";
  77745. export * from "babylonjs/Misc/videoRecorder";
  77746. export * from "babylonjs/Misc/virtualJoystick";
  77747. export * from "babylonjs/Misc/workerPool";
  77748. export * from "babylonjs/Misc/logger";
  77749. export * from "babylonjs/Misc/typeStore";
  77750. export * from "babylonjs/Misc/filesInputStore";
  77751. export * from "babylonjs/Misc/deepCopier";
  77752. export * from "babylonjs/Misc/pivotTools";
  77753. export * from "babylonjs/Misc/precisionDate";
  77754. export * from "babylonjs/Misc/screenshotTools";
  77755. export * from "babylonjs/Misc/typeStore";
  77756. export * from "babylonjs/Misc/webRequest";
  77757. export * from "babylonjs/Misc/iInspectable";
  77758. export * from "babylonjs/Misc/brdfTextureTools";
  77759. export * from "babylonjs/Misc/rgbdTextureTools";
  77760. export * from "babylonjs/Misc/gradients";
  77761. export * from "babylonjs/Misc/perfCounter";
  77762. export * from "babylonjs/Misc/fileRequest";
  77763. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77764. export * from "babylonjs/Misc/retryStrategy";
  77765. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77766. export * from "babylonjs/Misc/canvasGenerator";
  77767. export * from "babylonjs/Misc/fileTools";
  77768. export * from "babylonjs/Misc/stringTools";
  77769. export * from "babylonjs/Misc/dataReader";
  77770. export * from "babylonjs/Misc/minMaxReducer";
  77771. export * from "babylonjs/Misc/depthReducer";
  77772. export * from "babylonjs/Misc/dataStorage";
  77773. export * from "babylonjs/Misc/sceneRecorder";
  77774. }
  77775. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77776. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77777. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77778. import { Observable } from "babylonjs/Misc/observable";
  77779. import { Matrix } from "babylonjs/Maths/math.vector";
  77780. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77781. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77782. /**
  77783. * An interface for all Hit test features
  77784. */
  77785. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77786. /**
  77787. * Triggered when new babylon (transformed) hit test results are available
  77788. */
  77789. onHitTestResultObservable: Observable<T[]>;
  77790. }
  77791. /**
  77792. * Options used for hit testing
  77793. */
  77794. export interface IWebXRLegacyHitTestOptions {
  77795. /**
  77796. * Only test when user interacted with the scene. Default - hit test every frame
  77797. */
  77798. testOnPointerDownOnly?: boolean;
  77799. /**
  77800. * The node to use to transform the local results to world coordinates
  77801. */
  77802. worldParentNode?: TransformNode;
  77803. }
  77804. /**
  77805. * Interface defining the babylon result of raycasting/hit-test
  77806. */
  77807. export interface IWebXRLegacyHitResult {
  77808. /**
  77809. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77810. */
  77811. transformationMatrix: Matrix;
  77812. /**
  77813. * The native hit test result
  77814. */
  77815. xrHitResult: XRHitResult | XRHitTestResult;
  77816. }
  77817. /**
  77818. * The currently-working hit-test module.
  77819. * Hit test (or Ray-casting) is used to interact with the real world.
  77820. * For further information read here - https://github.com/immersive-web/hit-test
  77821. */
  77822. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77823. /**
  77824. * options to use when constructing this feature
  77825. */
  77826. readonly options: IWebXRLegacyHitTestOptions;
  77827. private _direction;
  77828. private _mat;
  77829. private _onSelectEnabled;
  77830. private _origin;
  77831. /**
  77832. * The module's name
  77833. */
  77834. static readonly Name: string;
  77835. /**
  77836. * The (Babylon) version of this module.
  77837. * This is an integer representing the implementation version.
  77838. * This number does not correspond to the WebXR specs version
  77839. */
  77840. static readonly Version: number;
  77841. /**
  77842. * Populated with the last native XR Hit Results
  77843. */
  77844. lastNativeXRHitResults: XRHitResult[];
  77845. /**
  77846. * Triggered when new babylon (transformed) hit test results are available
  77847. */
  77848. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77849. /**
  77850. * Creates a new instance of the (legacy version) hit test feature
  77851. * @param _xrSessionManager an instance of WebXRSessionManager
  77852. * @param options options to use when constructing this feature
  77853. */
  77854. constructor(_xrSessionManager: WebXRSessionManager,
  77855. /**
  77856. * options to use when constructing this feature
  77857. */
  77858. options?: IWebXRLegacyHitTestOptions);
  77859. /**
  77860. * execute a hit test with an XR Ray
  77861. *
  77862. * @param xrSession a native xrSession that will execute this hit test
  77863. * @param xrRay the ray (position and direction) to use for ray-casting
  77864. * @param referenceSpace native XR reference space to use for the hit-test
  77865. * @param filter filter function that will filter the results
  77866. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77867. */
  77868. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77869. /**
  77870. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77871. * @param event the (select) event to use to select with
  77872. * @param referenceSpace the reference space to use for this hit test
  77873. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77874. */
  77875. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77876. /**
  77877. * attach this feature
  77878. * Will usually be called by the features manager
  77879. *
  77880. * @returns true if successful.
  77881. */
  77882. attach(): boolean;
  77883. /**
  77884. * detach this feature.
  77885. * Will usually be called by the features manager
  77886. *
  77887. * @returns true if successful.
  77888. */
  77889. detach(): boolean;
  77890. /**
  77891. * Dispose this feature and all of the resources attached
  77892. */
  77893. dispose(): void;
  77894. protected _onXRFrame(frame: XRFrame): void;
  77895. private _onHitTestResults;
  77896. private _onSelect;
  77897. }
  77898. }
  77899. declare module "babylonjs/XR/features/WebXRHitTest" {
  77900. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77901. import { Observable } from "babylonjs/Misc/observable";
  77902. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77903. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77904. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77905. /**
  77906. * Options used for hit testing (version 2)
  77907. */
  77908. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77909. /**
  77910. * Do not create a permanent hit test. Will usually be used when only
  77911. * transient inputs are needed.
  77912. */
  77913. disablePermanentHitTest?: boolean;
  77914. /**
  77915. * Enable transient (for example touch-based) hit test inspections
  77916. */
  77917. enableTransientHitTest?: boolean;
  77918. /**
  77919. * Offset ray for the permanent hit test
  77920. */
  77921. offsetRay?: Vector3;
  77922. /**
  77923. * Offset ray for the transient hit test
  77924. */
  77925. transientOffsetRay?: Vector3;
  77926. /**
  77927. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77928. */
  77929. useReferenceSpace?: boolean;
  77930. }
  77931. /**
  77932. * Interface defining the babylon result of hit-test
  77933. */
  77934. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77935. /**
  77936. * The input source that generated this hit test (if transient)
  77937. */
  77938. inputSource?: XRInputSource;
  77939. /**
  77940. * Is this a transient hit test
  77941. */
  77942. isTransient?: boolean;
  77943. /**
  77944. * Position of the hit test result
  77945. */
  77946. position: Vector3;
  77947. /**
  77948. * Rotation of the hit test result
  77949. */
  77950. rotationQuaternion: Quaternion;
  77951. /**
  77952. * The native hit test result
  77953. */
  77954. xrHitResult: XRHitTestResult;
  77955. }
  77956. /**
  77957. * The currently-working hit-test module.
  77958. * Hit test (or Ray-casting) is used to interact with the real world.
  77959. * For further information read here - https://github.com/immersive-web/hit-test
  77960. *
  77961. * Tested on chrome (mobile) 80.
  77962. */
  77963. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77964. /**
  77965. * options to use when constructing this feature
  77966. */
  77967. readonly options: IWebXRHitTestOptions;
  77968. private _tmpMat;
  77969. private _tmpPos;
  77970. private _tmpQuat;
  77971. private _transientXrHitTestSource;
  77972. private _xrHitTestSource;
  77973. private initHitTestSource;
  77974. /**
  77975. * The module's name
  77976. */
  77977. static readonly Name: string;
  77978. /**
  77979. * The (Babylon) version of this module.
  77980. * This is an integer representing the implementation version.
  77981. * This number does not correspond to the WebXR specs version
  77982. */
  77983. static readonly Version: number;
  77984. /**
  77985. * When set to true, each hit test will have its own position/rotation objects
  77986. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77987. * the developers will clone them or copy them as they see fit.
  77988. */
  77989. autoCloneTransformation: boolean;
  77990. /**
  77991. * Triggered when new babylon (transformed) hit test results are available
  77992. */
  77993. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77994. /**
  77995. * Use this to temporarily pause hit test checks.
  77996. */
  77997. paused: boolean;
  77998. /**
  77999. * Creates a new instance of the hit test feature
  78000. * @param _xrSessionManager an instance of WebXRSessionManager
  78001. * @param options options to use when constructing this feature
  78002. */
  78003. constructor(_xrSessionManager: WebXRSessionManager,
  78004. /**
  78005. * options to use when constructing this feature
  78006. */
  78007. options?: IWebXRHitTestOptions);
  78008. /**
  78009. * attach this feature
  78010. * Will usually be called by the features manager
  78011. *
  78012. * @returns true if successful.
  78013. */
  78014. attach(): boolean;
  78015. /**
  78016. * detach this feature.
  78017. * Will usually be called by the features manager
  78018. *
  78019. * @returns true if successful.
  78020. */
  78021. detach(): boolean;
  78022. /**
  78023. * Dispose this feature and all of the resources attached
  78024. */
  78025. dispose(): void;
  78026. protected _onXRFrame(frame: XRFrame): void;
  78027. private _processWebXRHitTestResult;
  78028. }
  78029. }
  78030. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78031. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78032. import { Observable } from "babylonjs/Misc/observable";
  78033. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78034. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78035. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78036. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78037. /**
  78038. * Configuration options of the anchor system
  78039. */
  78040. export interface IWebXRAnchorSystemOptions {
  78041. /**
  78042. * a node that will be used to convert local to world coordinates
  78043. */
  78044. worldParentNode?: TransformNode;
  78045. /**
  78046. * If set to true a reference of the created anchors will be kept until the next session starts
  78047. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78048. */
  78049. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78050. }
  78051. /**
  78052. * A babylon container for an XR Anchor
  78053. */
  78054. export interface IWebXRAnchor {
  78055. /**
  78056. * A babylon-assigned ID for this anchor
  78057. */
  78058. id: number;
  78059. /**
  78060. * Transformation matrix to apply to an object attached to this anchor
  78061. */
  78062. transformationMatrix: Matrix;
  78063. /**
  78064. * The native anchor object
  78065. */
  78066. xrAnchor: XRAnchor;
  78067. /**
  78068. * if defined, this object will be constantly updated by the anchor's position and rotation
  78069. */
  78070. attachedNode?: TransformNode;
  78071. }
  78072. /**
  78073. * An implementation of the anchor system for WebXR.
  78074. * For further information see https://github.com/immersive-web/anchors/
  78075. */
  78076. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78077. private _options;
  78078. private _lastFrameDetected;
  78079. private _trackedAnchors;
  78080. private _referenceSpaceForFrameAnchors;
  78081. private _futureAnchors;
  78082. /**
  78083. * The module's name
  78084. */
  78085. static readonly Name: string;
  78086. /**
  78087. * The (Babylon) version of this module.
  78088. * This is an integer representing the implementation version.
  78089. * This number does not correspond to the WebXR specs version
  78090. */
  78091. static readonly Version: number;
  78092. /**
  78093. * Observers registered here will be executed when a new anchor was added to the session
  78094. */
  78095. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78096. /**
  78097. * Observers registered here will be executed when an anchor was removed from the session
  78098. */
  78099. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78100. /**
  78101. * Observers registered here will be executed when an existing anchor updates
  78102. * This can execute N times every frame
  78103. */
  78104. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78105. /**
  78106. * Set the reference space to use for anchor creation, when not using a hit test.
  78107. * Will default to the session's reference space if not defined
  78108. */
  78109. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78110. /**
  78111. * constructs a new anchor system
  78112. * @param _xrSessionManager an instance of WebXRSessionManager
  78113. * @param _options configuration object for this feature
  78114. */
  78115. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78116. private _tmpVector;
  78117. private _tmpQuaternion;
  78118. private _populateTmpTransformation;
  78119. /**
  78120. * Create a new anchor point using a hit test result at a specific point in the scene
  78121. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78122. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78123. *
  78124. * @param hitTestResult The hit test result to use for this anchor creation
  78125. * @param position an optional position offset for this anchor
  78126. * @param rotationQuaternion an optional rotation offset for this anchor
  78127. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78128. */
  78129. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78130. /**
  78131. * Add a new anchor at a specific position and rotation
  78132. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78133. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78134. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78135. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78136. *
  78137. * @param position the position in which to add an anchor
  78138. * @param rotationQuaternion an optional rotation for the anchor transformation
  78139. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78140. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78141. */
  78142. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78143. /**
  78144. * detach this feature.
  78145. * Will usually be called by the features manager
  78146. *
  78147. * @returns true if successful.
  78148. */
  78149. detach(): boolean;
  78150. /**
  78151. * Dispose this feature and all of the resources attached
  78152. */
  78153. dispose(): void;
  78154. protected _onXRFrame(frame: XRFrame): void;
  78155. /**
  78156. * avoiding using Array.find for global support.
  78157. * @param xrAnchor the plane to find in the array
  78158. */
  78159. private _findIndexInAnchorArray;
  78160. private _updateAnchorWithXRFrame;
  78161. private _createAnchorAtTransformation;
  78162. }
  78163. }
  78164. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78165. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78166. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78167. import { Observable } from "babylonjs/Misc/observable";
  78168. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78169. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78170. /**
  78171. * Options used in the plane detector module
  78172. */
  78173. export interface IWebXRPlaneDetectorOptions {
  78174. /**
  78175. * The node to use to transform the local results to world coordinates
  78176. */
  78177. worldParentNode?: TransformNode;
  78178. /**
  78179. * If set to true a reference of the created planes will be kept until the next session starts
  78180. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78181. */
  78182. doNotRemovePlanesOnSessionEnded?: boolean;
  78183. }
  78184. /**
  78185. * A babylon interface for a WebXR plane.
  78186. * A Plane is actually a polygon, built from N points in space
  78187. *
  78188. * Supported in chrome 79, not supported in canary 81 ATM
  78189. */
  78190. export interface IWebXRPlane {
  78191. /**
  78192. * a babylon-assigned ID for this polygon
  78193. */
  78194. id: number;
  78195. /**
  78196. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78197. */
  78198. polygonDefinition: Array<Vector3>;
  78199. /**
  78200. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78201. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78202. */
  78203. transformationMatrix: Matrix;
  78204. /**
  78205. * the native xr-plane object
  78206. */
  78207. xrPlane: XRPlane;
  78208. }
  78209. /**
  78210. * The plane detector is used to detect planes in the real world when in AR
  78211. * For more information see https://github.com/immersive-web/real-world-geometry/
  78212. */
  78213. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78214. private _options;
  78215. private _detectedPlanes;
  78216. private _enabled;
  78217. private _lastFrameDetected;
  78218. /**
  78219. * The module's name
  78220. */
  78221. static readonly Name: string;
  78222. /**
  78223. * The (Babylon) version of this module.
  78224. * This is an integer representing the implementation version.
  78225. * This number does not correspond to the WebXR specs version
  78226. */
  78227. static readonly Version: number;
  78228. /**
  78229. * Observers registered here will be executed when a new plane was added to the session
  78230. */
  78231. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78232. /**
  78233. * Observers registered here will be executed when a plane is no longer detected in the session
  78234. */
  78235. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78236. /**
  78237. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78238. * This can execute N times every frame
  78239. */
  78240. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78241. /**
  78242. * construct a new Plane Detector
  78243. * @param _xrSessionManager an instance of xr Session manager
  78244. * @param _options configuration to use when constructing this feature
  78245. */
  78246. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78247. /**
  78248. * detach this feature.
  78249. * Will usually be called by the features manager
  78250. *
  78251. * @returns true if successful.
  78252. */
  78253. detach(): boolean;
  78254. /**
  78255. * Dispose this feature and all of the resources attached
  78256. */
  78257. dispose(): void;
  78258. protected _onXRFrame(frame: XRFrame): void;
  78259. private _init;
  78260. private _updatePlaneWithXRPlane;
  78261. /**
  78262. * avoiding using Array.find for global support.
  78263. * @param xrPlane the plane to find in the array
  78264. */
  78265. private findIndexInPlaneArray;
  78266. }
  78267. }
  78268. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78269. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78271. import { Observable } from "babylonjs/Misc/observable";
  78272. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78273. /**
  78274. * Options interface for the background remover plugin
  78275. */
  78276. export interface IWebXRBackgroundRemoverOptions {
  78277. /**
  78278. * Further background meshes to disable when entering AR
  78279. */
  78280. backgroundMeshes?: AbstractMesh[];
  78281. /**
  78282. * flags to configure the removal of the environment helper.
  78283. * If not set, the entire background will be removed. If set, flags should be set as well.
  78284. */
  78285. environmentHelperRemovalFlags?: {
  78286. /**
  78287. * Should the skybox be removed (default false)
  78288. */
  78289. skyBox?: boolean;
  78290. /**
  78291. * Should the ground be removed (default false)
  78292. */
  78293. ground?: boolean;
  78294. };
  78295. /**
  78296. * don't disable the environment helper
  78297. */
  78298. ignoreEnvironmentHelper?: boolean;
  78299. }
  78300. /**
  78301. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78302. */
  78303. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78304. /**
  78305. * read-only options to be used in this module
  78306. */
  78307. readonly options: IWebXRBackgroundRemoverOptions;
  78308. /**
  78309. * The module's name
  78310. */
  78311. static readonly Name: string;
  78312. /**
  78313. * The (Babylon) version of this module.
  78314. * This is an integer representing the implementation version.
  78315. * This number does not correspond to the WebXR specs version
  78316. */
  78317. static readonly Version: number;
  78318. /**
  78319. * registered observers will be triggered when the background state changes
  78320. */
  78321. onBackgroundStateChangedObservable: Observable<boolean>;
  78322. /**
  78323. * constructs a new background remover module
  78324. * @param _xrSessionManager the session manager for this module
  78325. * @param options read-only options to be used in this module
  78326. */
  78327. constructor(_xrSessionManager: WebXRSessionManager,
  78328. /**
  78329. * read-only options to be used in this module
  78330. */
  78331. options?: IWebXRBackgroundRemoverOptions);
  78332. /**
  78333. * attach this feature
  78334. * Will usually be called by the features manager
  78335. *
  78336. * @returns true if successful.
  78337. */
  78338. attach(): boolean;
  78339. /**
  78340. * detach this feature.
  78341. * Will usually be called by the features manager
  78342. *
  78343. * @returns true if successful.
  78344. */
  78345. detach(): boolean;
  78346. /**
  78347. * Dispose this feature and all of the resources attached
  78348. */
  78349. dispose(): void;
  78350. protected _onXRFrame(_xrFrame: XRFrame): void;
  78351. private _setBackgroundState;
  78352. }
  78353. }
  78354. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78355. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78356. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78357. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78358. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78359. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78360. import { Nullable } from "babylonjs/types";
  78361. /**
  78362. * Options for the controller physics feature
  78363. */
  78364. export class IWebXRControllerPhysicsOptions {
  78365. /**
  78366. * Should the headset get its own impostor
  78367. */
  78368. enableHeadsetImpostor?: boolean;
  78369. /**
  78370. * Optional parameters for the headset impostor
  78371. */
  78372. headsetImpostorParams?: {
  78373. /**
  78374. * The type of impostor to create. Default is sphere
  78375. */
  78376. impostorType: number;
  78377. /**
  78378. * the size of the impostor. Defaults to 10cm
  78379. */
  78380. impostorSize?: number | {
  78381. width: number;
  78382. height: number;
  78383. depth: number;
  78384. };
  78385. /**
  78386. * Friction definitions
  78387. */
  78388. friction?: number;
  78389. /**
  78390. * Restitution
  78391. */
  78392. restitution?: number;
  78393. };
  78394. /**
  78395. * The physics properties of the future impostors
  78396. */
  78397. physicsProperties?: {
  78398. /**
  78399. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78400. * Note that this requires a physics engine that supports mesh impostors!
  78401. */
  78402. useControllerMesh?: boolean;
  78403. /**
  78404. * The type of impostor to create. Default is sphere
  78405. */
  78406. impostorType?: number;
  78407. /**
  78408. * the size of the impostor. Defaults to 10cm
  78409. */
  78410. impostorSize?: number | {
  78411. width: number;
  78412. height: number;
  78413. depth: number;
  78414. };
  78415. /**
  78416. * Friction definitions
  78417. */
  78418. friction?: number;
  78419. /**
  78420. * Restitution
  78421. */
  78422. restitution?: number;
  78423. };
  78424. /**
  78425. * the xr input to use with this pointer selection
  78426. */
  78427. xrInput: WebXRInput;
  78428. }
  78429. /**
  78430. * Add physics impostor to your webxr controllers,
  78431. * including naive calculation of their linear and angular velocity
  78432. */
  78433. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78434. private readonly _options;
  78435. private _attachController;
  78436. private _controllers;
  78437. private _debugMode;
  78438. private _delta;
  78439. private _headsetImpostor?;
  78440. private _headsetMesh?;
  78441. private _lastTimestamp;
  78442. private _tmpQuaternion;
  78443. private _tmpVector;
  78444. /**
  78445. * The module's name
  78446. */
  78447. static readonly Name: string;
  78448. /**
  78449. * The (Babylon) version of this module.
  78450. * This is an integer representing the implementation version.
  78451. * This number does not correspond to the webxr specs version
  78452. */
  78453. static readonly Version: number;
  78454. /**
  78455. * Construct a new Controller Physics Feature
  78456. * @param _xrSessionManager the corresponding xr session manager
  78457. * @param _options options to create this feature with
  78458. */
  78459. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78460. /**
  78461. * @hidden
  78462. * enable debugging - will show console outputs and the impostor mesh
  78463. */
  78464. _enablePhysicsDebug(): void;
  78465. /**
  78466. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78467. * @param xrController the controller to add
  78468. */
  78469. addController(xrController: WebXRInputSource): void;
  78470. /**
  78471. * attach this feature
  78472. * Will usually be called by the features manager
  78473. *
  78474. * @returns true if successful.
  78475. */
  78476. attach(): boolean;
  78477. /**
  78478. * detach this feature.
  78479. * Will usually be called by the features manager
  78480. *
  78481. * @returns true if successful.
  78482. */
  78483. detach(): boolean;
  78484. /**
  78485. * Get the headset impostor, if enabled
  78486. * @returns the impostor
  78487. */
  78488. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78489. /**
  78490. * Get the physics impostor of a specific controller.
  78491. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78492. * @param controller the controller or the controller id of which to get the impostor
  78493. * @returns the impostor or null
  78494. */
  78495. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78496. /**
  78497. * Update the physics properties provided in the constructor
  78498. * @param newProperties the new properties object
  78499. */
  78500. setPhysicsProperties(newProperties: {
  78501. impostorType?: number;
  78502. impostorSize?: number | {
  78503. width: number;
  78504. height: number;
  78505. depth: number;
  78506. };
  78507. friction?: number;
  78508. restitution?: number;
  78509. }): void;
  78510. protected _onXRFrame(_xrFrame: any): void;
  78511. private _detachController;
  78512. }
  78513. }
  78514. declare module "babylonjs/XR/features/index" {
  78515. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78516. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78517. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78518. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78519. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78520. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78521. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78522. export * from "babylonjs/XR/features/WebXRHitTest";
  78523. }
  78524. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78525. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78527. import { Scene } from "babylonjs/scene";
  78528. /**
  78529. * The motion controller class for all microsoft mixed reality controllers
  78530. */
  78531. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78532. protected readonly _mapping: {
  78533. defaultButton: {
  78534. valueNodeName: string;
  78535. unpressedNodeName: string;
  78536. pressedNodeName: string;
  78537. };
  78538. defaultAxis: {
  78539. valueNodeName: string;
  78540. minNodeName: string;
  78541. maxNodeName: string;
  78542. };
  78543. buttons: {
  78544. "xr-standard-trigger": {
  78545. rootNodeName: string;
  78546. componentProperty: string;
  78547. states: string[];
  78548. };
  78549. "xr-standard-squeeze": {
  78550. rootNodeName: string;
  78551. componentProperty: string;
  78552. states: string[];
  78553. };
  78554. "xr-standard-touchpad": {
  78555. rootNodeName: string;
  78556. labelAnchorNodeName: string;
  78557. touchPointNodeName: string;
  78558. };
  78559. "xr-standard-thumbstick": {
  78560. rootNodeName: string;
  78561. componentProperty: string;
  78562. states: string[];
  78563. };
  78564. };
  78565. axes: {
  78566. "xr-standard-touchpad": {
  78567. "x-axis": {
  78568. rootNodeName: string;
  78569. };
  78570. "y-axis": {
  78571. rootNodeName: string;
  78572. };
  78573. };
  78574. "xr-standard-thumbstick": {
  78575. "x-axis": {
  78576. rootNodeName: string;
  78577. };
  78578. "y-axis": {
  78579. rootNodeName: string;
  78580. };
  78581. };
  78582. };
  78583. };
  78584. /**
  78585. * The base url used to load the left and right controller models
  78586. */
  78587. static MODEL_BASE_URL: string;
  78588. /**
  78589. * The name of the left controller model file
  78590. */
  78591. static MODEL_LEFT_FILENAME: string;
  78592. /**
  78593. * The name of the right controller model file
  78594. */
  78595. static MODEL_RIGHT_FILENAME: string;
  78596. profileId: string;
  78597. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78598. protected _getFilenameAndPath(): {
  78599. filename: string;
  78600. path: string;
  78601. };
  78602. protected _getModelLoadingConstraints(): boolean;
  78603. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78604. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78605. protected _updateModel(): void;
  78606. }
  78607. }
  78608. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78609. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78611. import { Scene } from "babylonjs/scene";
  78612. /**
  78613. * The motion controller class for oculus touch (quest, rift).
  78614. * This class supports legacy mapping as well the standard xr mapping
  78615. */
  78616. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78617. private _forceLegacyControllers;
  78618. private _modelRootNode;
  78619. /**
  78620. * The base url used to load the left and right controller models
  78621. */
  78622. static MODEL_BASE_URL: string;
  78623. /**
  78624. * The name of the left controller model file
  78625. */
  78626. static MODEL_LEFT_FILENAME: string;
  78627. /**
  78628. * The name of the right controller model file
  78629. */
  78630. static MODEL_RIGHT_FILENAME: string;
  78631. /**
  78632. * Base Url for the Quest controller model.
  78633. */
  78634. static QUEST_MODEL_BASE_URL: string;
  78635. profileId: string;
  78636. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78637. protected _getFilenameAndPath(): {
  78638. filename: string;
  78639. path: string;
  78640. };
  78641. protected _getModelLoadingConstraints(): boolean;
  78642. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78643. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78644. protected _updateModel(): void;
  78645. /**
  78646. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78647. * between the touch and touch 2.
  78648. */
  78649. private _isQuest;
  78650. }
  78651. }
  78652. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78653. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78654. import { Scene } from "babylonjs/scene";
  78655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78656. /**
  78657. * The motion controller class for the standard HTC-Vive controllers
  78658. */
  78659. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78660. private _modelRootNode;
  78661. /**
  78662. * The base url used to load the left and right controller models
  78663. */
  78664. static MODEL_BASE_URL: string;
  78665. /**
  78666. * File name for the controller model.
  78667. */
  78668. static MODEL_FILENAME: string;
  78669. profileId: string;
  78670. /**
  78671. * Create a new Vive motion controller object
  78672. * @param scene the scene to use to create this controller
  78673. * @param gamepadObject the corresponding gamepad object
  78674. * @param handedness the handedness of the controller
  78675. */
  78676. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78677. protected _getFilenameAndPath(): {
  78678. filename: string;
  78679. path: string;
  78680. };
  78681. protected _getModelLoadingConstraints(): boolean;
  78682. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78683. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78684. protected _updateModel(): void;
  78685. }
  78686. }
  78687. declare module "babylonjs/XR/motionController/index" {
  78688. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78689. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78690. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78691. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78692. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78693. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78694. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78695. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78696. }
  78697. declare module "babylonjs/XR/index" {
  78698. export * from "babylonjs/XR/webXRCamera";
  78699. export * from "babylonjs/XR/webXREnterExitUI";
  78700. export * from "babylonjs/XR/webXRExperienceHelper";
  78701. export * from "babylonjs/XR/webXRInput";
  78702. export * from "babylonjs/XR/webXRInputSource";
  78703. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78704. export * from "babylonjs/XR/webXRTypes";
  78705. export * from "babylonjs/XR/webXRSessionManager";
  78706. export * from "babylonjs/XR/webXRDefaultExperience";
  78707. export * from "babylonjs/XR/webXRFeaturesManager";
  78708. export * from "babylonjs/XR/features/index";
  78709. export * from "babylonjs/XR/motionController/index";
  78710. }
  78711. declare module "babylonjs/index" {
  78712. export * from "babylonjs/abstractScene";
  78713. export * from "babylonjs/Actions/index";
  78714. export * from "babylonjs/Animations/index";
  78715. export * from "babylonjs/assetContainer";
  78716. export * from "babylonjs/Audio/index";
  78717. export * from "babylonjs/Behaviors/index";
  78718. export * from "babylonjs/Bones/index";
  78719. export * from "babylonjs/Cameras/index";
  78720. export * from "babylonjs/Collisions/index";
  78721. export * from "babylonjs/Culling/index";
  78722. export * from "babylonjs/Debug/index";
  78723. export * from "babylonjs/DeviceInput/index";
  78724. export * from "babylonjs/Engines/index";
  78725. export * from "babylonjs/Events/index";
  78726. export * from "babylonjs/Gamepads/index";
  78727. export * from "babylonjs/Gizmos/index";
  78728. export * from "babylonjs/Helpers/index";
  78729. export * from "babylonjs/Instrumentation/index";
  78730. export * from "babylonjs/Layers/index";
  78731. export * from "babylonjs/LensFlares/index";
  78732. export * from "babylonjs/Lights/index";
  78733. export * from "babylonjs/Loading/index";
  78734. export * from "babylonjs/Materials/index";
  78735. export * from "babylonjs/Maths/index";
  78736. export * from "babylonjs/Meshes/index";
  78737. export * from "babylonjs/Morph/index";
  78738. export * from "babylonjs/Navigation/index";
  78739. export * from "babylonjs/node";
  78740. export * from "babylonjs/Offline/index";
  78741. export * from "babylonjs/Particles/index";
  78742. export * from "babylonjs/Physics/index";
  78743. export * from "babylonjs/PostProcesses/index";
  78744. export * from "babylonjs/Probes/index";
  78745. export * from "babylonjs/Rendering/index";
  78746. export * from "babylonjs/scene";
  78747. export * from "babylonjs/sceneComponent";
  78748. export * from "babylonjs/Sprites/index";
  78749. export * from "babylonjs/States/index";
  78750. export * from "babylonjs/Misc/index";
  78751. export * from "babylonjs/XR/index";
  78752. export * from "babylonjs/types";
  78753. }
  78754. declare module "babylonjs/Animations/pathCursor" {
  78755. import { Vector3 } from "babylonjs/Maths/math.vector";
  78756. import { Path2 } from "babylonjs/Maths/math.path";
  78757. /**
  78758. * A cursor which tracks a point on a path
  78759. */
  78760. export class PathCursor {
  78761. private path;
  78762. /**
  78763. * Stores path cursor callbacks for when an onchange event is triggered
  78764. */
  78765. private _onchange;
  78766. /**
  78767. * The value of the path cursor
  78768. */
  78769. value: number;
  78770. /**
  78771. * The animation array of the path cursor
  78772. */
  78773. animations: Animation[];
  78774. /**
  78775. * Initializes the path cursor
  78776. * @param path The path to track
  78777. */
  78778. constructor(path: Path2);
  78779. /**
  78780. * Gets the cursor point on the path
  78781. * @returns A point on the path cursor at the cursor location
  78782. */
  78783. getPoint(): Vector3;
  78784. /**
  78785. * Moves the cursor ahead by the step amount
  78786. * @param step The amount to move the cursor forward
  78787. * @returns This path cursor
  78788. */
  78789. moveAhead(step?: number): PathCursor;
  78790. /**
  78791. * Moves the cursor behind by the step amount
  78792. * @param step The amount to move the cursor back
  78793. * @returns This path cursor
  78794. */
  78795. moveBack(step?: number): PathCursor;
  78796. /**
  78797. * Moves the cursor by the step amount
  78798. * If the step amount is greater than one, an exception is thrown
  78799. * @param step The amount to move the cursor
  78800. * @returns This path cursor
  78801. */
  78802. move(step: number): PathCursor;
  78803. /**
  78804. * Ensures that the value is limited between zero and one
  78805. * @returns This path cursor
  78806. */
  78807. private ensureLimits;
  78808. /**
  78809. * Runs onchange callbacks on change (used by the animation engine)
  78810. * @returns This path cursor
  78811. */
  78812. private raiseOnChange;
  78813. /**
  78814. * Executes a function on change
  78815. * @param f A path cursor onchange callback
  78816. * @returns This path cursor
  78817. */
  78818. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78819. }
  78820. }
  78821. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78822. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78823. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78824. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78825. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78826. }
  78827. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78828. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78829. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78830. }
  78831. declare module "babylonjs/Engines/Processors/index" {
  78832. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78833. export * from "babylonjs/Engines/Processors/Expressions/index";
  78834. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78835. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78836. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78837. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78838. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78839. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78840. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78841. }
  78842. declare module "babylonjs/Legacy/legacy" {
  78843. import * as Babylon from "babylonjs/index";
  78844. export * from "babylonjs/index";
  78845. }
  78846. declare module "babylonjs/Shaders/blur.fragment" {
  78847. /** @hidden */
  78848. export var blurPixelShader: {
  78849. name: string;
  78850. shader: string;
  78851. };
  78852. }
  78853. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78854. /** @hidden */
  78855. export var pointCloudVertexDeclaration: {
  78856. name: string;
  78857. shader: string;
  78858. };
  78859. }
  78860. declare module "babylonjs" {
  78861. export * from "babylonjs/Legacy/legacy";
  78862. }
  78863. declare module BABYLON {
  78864. /** Alias type for value that can be null */
  78865. export type Nullable<T> = T | null;
  78866. /**
  78867. * Alias type for number that are floats
  78868. * @ignorenaming
  78869. */
  78870. export type float = number;
  78871. /**
  78872. * Alias type for number that are doubles.
  78873. * @ignorenaming
  78874. */
  78875. export type double = number;
  78876. /**
  78877. * Alias type for number that are integer
  78878. * @ignorenaming
  78879. */
  78880. export type int = number;
  78881. /** Alias type for number array or Float32Array */
  78882. export type FloatArray = number[] | Float32Array;
  78883. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78884. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78885. /**
  78886. * Alias for types that can be used by a Buffer or VertexBuffer.
  78887. */
  78888. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78889. /**
  78890. * Alias type for primitive types
  78891. * @ignorenaming
  78892. */
  78893. type Primitive = undefined | null | boolean | string | number | Function;
  78894. /**
  78895. * Type modifier to make all the properties of an object Readonly
  78896. */
  78897. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78898. /**
  78899. * Type modifier to make all the properties of an object Readonly recursively
  78900. */
  78901. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78902. /**
  78903. * Type modifier to make object properties readonly.
  78904. */
  78905. export type DeepImmutableObject<T> = {
  78906. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78907. };
  78908. /** @hidden */
  78909. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78910. }
  78911. }
  78912. declare module BABYLON {
  78913. /**
  78914. * A class serves as a medium between the observable and its observers
  78915. */
  78916. export class EventState {
  78917. /**
  78918. * Create a new EventState
  78919. * @param mask defines the mask associated with this state
  78920. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78921. * @param target defines the original target of the state
  78922. * @param currentTarget defines the current target of the state
  78923. */
  78924. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78925. /**
  78926. * Initialize the current event state
  78927. * @param mask defines the mask associated with this state
  78928. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78929. * @param target defines the original target of the state
  78930. * @param currentTarget defines the current target of the state
  78931. * @returns the current event state
  78932. */
  78933. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78934. /**
  78935. * An Observer can set this property to true to prevent subsequent observers of being notified
  78936. */
  78937. skipNextObservers: boolean;
  78938. /**
  78939. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78940. */
  78941. mask: number;
  78942. /**
  78943. * The object that originally notified the event
  78944. */
  78945. target?: any;
  78946. /**
  78947. * The current object in the bubbling phase
  78948. */
  78949. currentTarget?: any;
  78950. /**
  78951. * This will be populated with the return value of the last function that was executed.
  78952. * If it is the first function in the callback chain it will be the event data.
  78953. */
  78954. lastReturnValue?: any;
  78955. }
  78956. /**
  78957. * Represent an Observer registered to a given Observable object.
  78958. */
  78959. export class Observer<T> {
  78960. /**
  78961. * Defines the callback to call when the observer is notified
  78962. */
  78963. callback: (eventData: T, eventState: EventState) => void;
  78964. /**
  78965. * Defines the mask of the observer (used to filter notifications)
  78966. */
  78967. mask: number;
  78968. /**
  78969. * Defines the current scope used to restore the JS context
  78970. */
  78971. scope: any;
  78972. /** @hidden */
  78973. _willBeUnregistered: boolean;
  78974. /**
  78975. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78976. */
  78977. unregisterOnNextCall: boolean;
  78978. /**
  78979. * Creates a new observer
  78980. * @param callback defines the callback to call when the observer is notified
  78981. * @param mask defines the mask of the observer (used to filter notifications)
  78982. * @param scope defines the current scope used to restore the JS context
  78983. */
  78984. constructor(
  78985. /**
  78986. * Defines the callback to call when the observer is notified
  78987. */
  78988. callback: (eventData: T, eventState: EventState) => void,
  78989. /**
  78990. * Defines the mask of the observer (used to filter notifications)
  78991. */
  78992. mask: number,
  78993. /**
  78994. * Defines the current scope used to restore the JS context
  78995. */
  78996. scope?: any);
  78997. }
  78998. /**
  78999. * Represent a list of observers registered to multiple Observables object.
  79000. */
  79001. export class MultiObserver<T> {
  79002. private _observers;
  79003. private _observables;
  79004. /**
  79005. * Release associated resources
  79006. */
  79007. dispose(): void;
  79008. /**
  79009. * Raise a callback when one of the observable will notify
  79010. * @param observables defines a list of observables to watch
  79011. * @param callback defines the callback to call on notification
  79012. * @param mask defines the mask used to filter notifications
  79013. * @param scope defines the current scope used to restore the JS context
  79014. * @returns the new MultiObserver
  79015. */
  79016. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79017. }
  79018. /**
  79019. * The Observable class is a simple implementation of the Observable pattern.
  79020. *
  79021. * 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.
  79022. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79023. * 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).
  79024. * 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.
  79025. */
  79026. export class Observable<T> {
  79027. private _observers;
  79028. private _eventState;
  79029. private _onObserverAdded;
  79030. /**
  79031. * Gets the list of observers
  79032. */
  79033. get observers(): Array<Observer<T>>;
  79034. /**
  79035. * Creates a new observable
  79036. * @param onObserverAdded defines a callback to call when a new observer is added
  79037. */
  79038. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79039. /**
  79040. * Create a new Observer with the specified callback
  79041. * @param callback the callback that will be executed for that Observer
  79042. * @param mask the mask used to filter observers
  79043. * @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.
  79044. * @param scope optional scope for the callback to be called from
  79045. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79046. * @returns the new observer created for the callback
  79047. */
  79048. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79049. /**
  79050. * Create a new Observer with the specified callback and unregisters after the next notification
  79051. * @param callback the callback that will be executed for that Observer
  79052. * @returns the new observer created for the callback
  79053. */
  79054. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79055. /**
  79056. * Remove an Observer from the Observable object
  79057. * @param observer the instance of the Observer to remove
  79058. * @returns false if it doesn't belong to this Observable
  79059. */
  79060. remove(observer: Nullable<Observer<T>>): boolean;
  79061. /**
  79062. * Remove a callback from the Observable object
  79063. * @param callback the callback to remove
  79064. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79065. * @returns false if it doesn't belong to this Observable
  79066. */
  79067. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79068. private _deferUnregister;
  79069. private _remove;
  79070. /**
  79071. * Moves the observable to the top of the observer list making it get called first when notified
  79072. * @param observer the observer to move
  79073. */
  79074. makeObserverTopPriority(observer: Observer<T>): void;
  79075. /**
  79076. * Moves the observable to the bottom of the observer list making it get called last when notified
  79077. * @param observer the observer to move
  79078. */
  79079. makeObserverBottomPriority(observer: Observer<T>): void;
  79080. /**
  79081. * Notify all Observers by calling their respective callback with the given data
  79082. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79083. * @param eventData defines the data to send to all observers
  79084. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79085. * @param target defines the original target of the state
  79086. * @param currentTarget defines the current target of the state
  79087. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79088. */
  79089. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79090. /**
  79091. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79092. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79093. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79094. * and it is crucial that all callbacks will be executed.
  79095. * The order of the callbacks is kept, callbacks are not executed parallel.
  79096. *
  79097. * @param eventData The data to be sent to each callback
  79098. * @param mask is used to filter observers defaults to -1
  79099. * @param target defines the callback target (see EventState)
  79100. * @param currentTarget defines he current object in the bubbling phase
  79101. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79102. */
  79103. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79104. /**
  79105. * Notify a specific observer
  79106. * @param observer defines the observer to notify
  79107. * @param eventData defines the data to be sent to each callback
  79108. * @param mask is used to filter observers defaults to -1
  79109. */
  79110. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79111. /**
  79112. * Gets a boolean indicating if the observable has at least one observer
  79113. * @returns true is the Observable has at least one Observer registered
  79114. */
  79115. hasObservers(): boolean;
  79116. /**
  79117. * Clear the list of observers
  79118. */
  79119. clear(): void;
  79120. /**
  79121. * Clone the current observable
  79122. * @returns a new observable
  79123. */
  79124. clone(): Observable<T>;
  79125. /**
  79126. * Does this observable handles observer registered with a given mask
  79127. * @param mask defines the mask to be tested
  79128. * @return whether or not one observer registered with the given mask is handeled
  79129. **/
  79130. hasSpecificMask(mask?: number): boolean;
  79131. }
  79132. }
  79133. declare module BABYLON {
  79134. /**
  79135. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79136. * Babylon.js
  79137. */
  79138. export class DomManagement {
  79139. /**
  79140. * Checks if the window object exists
  79141. * @returns true if the window object exists
  79142. */
  79143. static IsWindowObjectExist(): boolean;
  79144. /**
  79145. * Checks if the navigator object exists
  79146. * @returns true if the navigator object exists
  79147. */
  79148. static IsNavigatorAvailable(): boolean;
  79149. /**
  79150. * Check if the document object exists
  79151. * @returns true if the document object exists
  79152. */
  79153. static IsDocumentAvailable(): boolean;
  79154. /**
  79155. * Extracts text content from a DOM element hierarchy
  79156. * @param element defines the root element
  79157. * @returns a string
  79158. */
  79159. static GetDOMTextContent(element: HTMLElement): string;
  79160. }
  79161. }
  79162. declare module BABYLON {
  79163. /**
  79164. * Logger used througouht the application to allow configuration of
  79165. * the log level required for the messages.
  79166. */
  79167. export class Logger {
  79168. /**
  79169. * No log
  79170. */
  79171. static readonly NoneLogLevel: number;
  79172. /**
  79173. * Only message logs
  79174. */
  79175. static readonly MessageLogLevel: number;
  79176. /**
  79177. * Only warning logs
  79178. */
  79179. static readonly WarningLogLevel: number;
  79180. /**
  79181. * Only error logs
  79182. */
  79183. static readonly ErrorLogLevel: number;
  79184. /**
  79185. * All logs
  79186. */
  79187. static readonly AllLogLevel: number;
  79188. private static _LogCache;
  79189. /**
  79190. * Gets a value indicating the number of loading errors
  79191. * @ignorenaming
  79192. */
  79193. static errorsCount: number;
  79194. /**
  79195. * Callback called when a new log is added
  79196. */
  79197. static OnNewCacheEntry: (entry: string) => void;
  79198. private static _AddLogEntry;
  79199. private static _FormatMessage;
  79200. private static _LogDisabled;
  79201. private static _LogEnabled;
  79202. private static _WarnDisabled;
  79203. private static _WarnEnabled;
  79204. private static _ErrorDisabled;
  79205. private static _ErrorEnabled;
  79206. /**
  79207. * Log a message to the console
  79208. */
  79209. static Log: (message: string) => void;
  79210. /**
  79211. * Write a warning message to the console
  79212. */
  79213. static Warn: (message: string) => void;
  79214. /**
  79215. * Write an error message to the console
  79216. */
  79217. static Error: (message: string) => void;
  79218. /**
  79219. * Gets current log cache (list of logs)
  79220. */
  79221. static get LogCache(): string;
  79222. /**
  79223. * Clears the log cache
  79224. */
  79225. static ClearLogCache(): void;
  79226. /**
  79227. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79228. */
  79229. static set LogLevels(level: number);
  79230. }
  79231. }
  79232. declare module BABYLON {
  79233. /** @hidden */
  79234. export class _TypeStore {
  79235. /** @hidden */
  79236. static RegisteredTypes: {
  79237. [key: string]: Object;
  79238. };
  79239. /** @hidden */
  79240. static GetClass(fqdn: string): any;
  79241. }
  79242. }
  79243. declare module BABYLON {
  79244. /**
  79245. * Helper to manipulate strings
  79246. */
  79247. export class StringTools {
  79248. /**
  79249. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79250. * @param str Source string
  79251. * @param suffix Suffix to search for in the source string
  79252. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79253. */
  79254. static EndsWith(str: string, suffix: string): boolean;
  79255. /**
  79256. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79257. * @param str Source string
  79258. * @param suffix Suffix to search for in the source string
  79259. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79260. */
  79261. static StartsWith(str: string, suffix: string): boolean;
  79262. /**
  79263. * Decodes a buffer into a string
  79264. * @param buffer The buffer to decode
  79265. * @returns The decoded string
  79266. */
  79267. static Decode(buffer: Uint8Array | Uint16Array): string;
  79268. /**
  79269. * Encode a buffer to a base64 string
  79270. * @param buffer defines the buffer to encode
  79271. * @returns the encoded string
  79272. */
  79273. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79274. /**
  79275. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79276. * @param num the number to convert and pad
  79277. * @param length the expected length of the string
  79278. * @returns the padded string
  79279. */
  79280. static PadNumber(num: number, length: number): string;
  79281. }
  79282. }
  79283. declare module BABYLON {
  79284. /**
  79285. * Class containing a set of static utilities functions for deep copy.
  79286. */
  79287. export class DeepCopier {
  79288. /**
  79289. * Tries to copy an object by duplicating every property
  79290. * @param source defines the source object
  79291. * @param destination defines the target object
  79292. * @param doNotCopyList defines a list of properties to avoid
  79293. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79294. */
  79295. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79296. }
  79297. }
  79298. declare module BABYLON {
  79299. /**
  79300. * Class containing a set of static utilities functions for precision date
  79301. */
  79302. export class PrecisionDate {
  79303. /**
  79304. * Gets either window.performance.now() if supported or Date.now() else
  79305. */
  79306. static get Now(): number;
  79307. }
  79308. }
  79309. declare module BABYLON {
  79310. /** @hidden */
  79311. export class _DevTools {
  79312. static WarnImport(name: string): string;
  79313. }
  79314. }
  79315. declare module BABYLON {
  79316. /**
  79317. * Interface used to define the mechanism to get data from the network
  79318. */
  79319. export interface IWebRequest {
  79320. /**
  79321. * Returns client's response url
  79322. */
  79323. responseURL: string;
  79324. /**
  79325. * Returns client's status
  79326. */
  79327. status: number;
  79328. /**
  79329. * Returns client's status as a text
  79330. */
  79331. statusText: string;
  79332. }
  79333. }
  79334. declare module BABYLON {
  79335. /**
  79336. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79337. */
  79338. export class WebRequest implements IWebRequest {
  79339. private _xhr;
  79340. /**
  79341. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79342. * i.e. when loading files, where the server/service expects an Authorization header
  79343. */
  79344. static CustomRequestHeaders: {
  79345. [key: string]: string;
  79346. };
  79347. /**
  79348. * Add callback functions in this array to update all the requests before they get sent to the network
  79349. */
  79350. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79351. private _injectCustomRequestHeaders;
  79352. /**
  79353. * Gets or sets a function to be called when loading progress changes
  79354. */
  79355. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79356. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79357. /**
  79358. * Returns client's state
  79359. */
  79360. get readyState(): number;
  79361. /**
  79362. * Returns client's status
  79363. */
  79364. get status(): number;
  79365. /**
  79366. * Returns client's status as a text
  79367. */
  79368. get statusText(): string;
  79369. /**
  79370. * Returns client's response
  79371. */
  79372. get response(): any;
  79373. /**
  79374. * Returns client's response url
  79375. */
  79376. get responseURL(): string;
  79377. /**
  79378. * Returns client's response as text
  79379. */
  79380. get responseText(): string;
  79381. /**
  79382. * Gets or sets the expected response type
  79383. */
  79384. get responseType(): XMLHttpRequestResponseType;
  79385. set responseType(value: XMLHttpRequestResponseType);
  79386. /** @hidden */
  79387. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79388. /** @hidden */
  79389. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79390. /**
  79391. * Cancels any network activity
  79392. */
  79393. abort(): void;
  79394. /**
  79395. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79396. * @param body defines an optional request body
  79397. */
  79398. send(body?: Document | BodyInit | null): void;
  79399. /**
  79400. * Sets the request method, request URL
  79401. * @param method defines the method to use (GET, POST, etc..)
  79402. * @param url defines the url to connect with
  79403. */
  79404. open(method: string, url: string): void;
  79405. /**
  79406. * Sets the value of a request header.
  79407. * @param name The name of the header whose value is to be set
  79408. * @param value The value to set as the body of the header
  79409. */
  79410. setRequestHeader(name: string, value: string): void;
  79411. /**
  79412. * Get the string containing the text of a particular header's value.
  79413. * @param name The name of the header
  79414. * @returns The string containing the text of the given header name
  79415. */
  79416. getResponseHeader(name: string): Nullable<string>;
  79417. }
  79418. }
  79419. declare module BABYLON {
  79420. /**
  79421. * File request interface
  79422. */
  79423. export interface IFileRequest {
  79424. /**
  79425. * Raised when the request is complete (success or error).
  79426. */
  79427. onCompleteObservable: Observable<IFileRequest>;
  79428. /**
  79429. * Aborts the request for a file.
  79430. */
  79431. abort: () => void;
  79432. }
  79433. }
  79434. declare module BABYLON {
  79435. /**
  79436. * Define options used to create a render target texture
  79437. */
  79438. export class RenderTargetCreationOptions {
  79439. /**
  79440. * Specifies is mipmaps must be generated
  79441. */
  79442. generateMipMaps?: boolean;
  79443. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79444. generateDepthBuffer?: boolean;
  79445. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79446. generateStencilBuffer?: boolean;
  79447. /** Defines texture type (int by default) */
  79448. type?: number;
  79449. /** Defines sampling mode (trilinear by default) */
  79450. samplingMode?: number;
  79451. /** Defines format (RGBA by default) */
  79452. format?: number;
  79453. }
  79454. }
  79455. declare module BABYLON {
  79456. /** Defines the cross module used constants to avoid circular dependncies */
  79457. export class Constants {
  79458. /** Defines that alpha blending is disabled */
  79459. static readonly ALPHA_DISABLE: number;
  79460. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79461. static readonly ALPHA_ADD: number;
  79462. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79463. static readonly ALPHA_COMBINE: number;
  79464. /** Defines that alpha blending is DEST - SRC * DEST */
  79465. static readonly ALPHA_SUBTRACT: number;
  79466. /** Defines that alpha blending is SRC * DEST */
  79467. static readonly ALPHA_MULTIPLY: number;
  79468. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79469. static readonly ALPHA_MAXIMIZED: number;
  79470. /** Defines that alpha blending is SRC + DEST */
  79471. static readonly ALPHA_ONEONE: number;
  79472. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79473. static readonly ALPHA_PREMULTIPLIED: number;
  79474. /**
  79475. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79476. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79477. */
  79478. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79479. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79480. static readonly ALPHA_INTERPOLATE: number;
  79481. /**
  79482. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79483. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79484. */
  79485. static readonly ALPHA_SCREENMODE: number;
  79486. /**
  79487. * Defines that alpha blending is SRC + DST
  79488. * Alpha will be set to SRC ALPHA + DST ALPHA
  79489. */
  79490. static readonly ALPHA_ONEONE_ONEONE: number;
  79491. /**
  79492. * Defines that alpha blending is SRC * DST ALPHA + DST
  79493. * Alpha will be set to 0
  79494. */
  79495. static readonly ALPHA_ALPHATOCOLOR: number;
  79496. /**
  79497. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79498. */
  79499. static readonly ALPHA_REVERSEONEMINUS: number;
  79500. /**
  79501. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79502. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79503. */
  79504. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79505. /**
  79506. * Defines that alpha blending is SRC + DST
  79507. * Alpha will be set to SRC ALPHA
  79508. */
  79509. static readonly ALPHA_ONEONE_ONEZERO: number;
  79510. /**
  79511. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79512. * Alpha will be set to DST ALPHA
  79513. */
  79514. static readonly ALPHA_EXCLUSION: number;
  79515. /** Defines that alpha blending equation a SUM */
  79516. static readonly ALPHA_EQUATION_ADD: number;
  79517. /** Defines that alpha blending equation a SUBSTRACTION */
  79518. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79519. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79520. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79521. /** Defines that alpha blending equation a MAX operation */
  79522. static readonly ALPHA_EQUATION_MAX: number;
  79523. /** Defines that alpha blending equation a MIN operation */
  79524. static readonly ALPHA_EQUATION_MIN: number;
  79525. /**
  79526. * Defines that alpha blending equation a DARKEN operation:
  79527. * It takes the min of the src and sums the alpha channels.
  79528. */
  79529. static readonly ALPHA_EQUATION_DARKEN: number;
  79530. /** Defines that the ressource is not delayed*/
  79531. static readonly DELAYLOADSTATE_NONE: number;
  79532. /** Defines that the ressource was successfully delay loaded */
  79533. static readonly DELAYLOADSTATE_LOADED: number;
  79534. /** Defines that the ressource is currently delay loading */
  79535. static readonly DELAYLOADSTATE_LOADING: number;
  79536. /** Defines that the ressource is delayed and has not started loading */
  79537. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79538. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79539. static readonly NEVER: number;
  79540. /** 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 */
  79541. static readonly ALWAYS: number;
  79542. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79543. static readonly LESS: number;
  79544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79545. static readonly EQUAL: number;
  79546. /** 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 */
  79547. static readonly LEQUAL: number;
  79548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79549. static readonly GREATER: number;
  79550. /** 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 */
  79551. static readonly GEQUAL: number;
  79552. /** 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 */
  79553. static readonly NOTEQUAL: number;
  79554. /** Passed to stencilOperation to specify that stencil value must be kept */
  79555. static readonly KEEP: number;
  79556. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79557. static readonly REPLACE: number;
  79558. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79559. static readonly INCR: number;
  79560. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79561. static readonly DECR: number;
  79562. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79563. static readonly INVERT: number;
  79564. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79565. static readonly INCR_WRAP: number;
  79566. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79567. static readonly DECR_WRAP: number;
  79568. /** Texture is not repeating outside of 0..1 UVs */
  79569. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79570. /** Texture is repeating outside of 0..1 UVs */
  79571. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79572. /** Texture is repeating and mirrored */
  79573. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79574. /** ALPHA */
  79575. static readonly TEXTUREFORMAT_ALPHA: number;
  79576. /** LUMINANCE */
  79577. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79578. /** LUMINANCE_ALPHA */
  79579. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79580. /** RGB */
  79581. static readonly TEXTUREFORMAT_RGB: number;
  79582. /** RGBA */
  79583. static readonly TEXTUREFORMAT_RGBA: number;
  79584. /** RED */
  79585. static readonly TEXTUREFORMAT_RED: number;
  79586. /** RED (2nd reference) */
  79587. static readonly TEXTUREFORMAT_R: number;
  79588. /** RG */
  79589. static readonly TEXTUREFORMAT_RG: number;
  79590. /** RED_INTEGER */
  79591. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79592. /** RED_INTEGER (2nd reference) */
  79593. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79594. /** RG_INTEGER */
  79595. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79596. /** RGB_INTEGER */
  79597. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79598. /** RGBA_INTEGER */
  79599. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79600. /** UNSIGNED_BYTE */
  79601. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79602. /** UNSIGNED_BYTE (2nd reference) */
  79603. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79604. /** FLOAT */
  79605. static readonly TEXTURETYPE_FLOAT: number;
  79606. /** HALF_FLOAT */
  79607. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79608. /** BYTE */
  79609. static readonly TEXTURETYPE_BYTE: number;
  79610. /** SHORT */
  79611. static readonly TEXTURETYPE_SHORT: number;
  79612. /** UNSIGNED_SHORT */
  79613. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79614. /** INT */
  79615. static readonly TEXTURETYPE_INT: number;
  79616. /** UNSIGNED_INT */
  79617. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79618. /** UNSIGNED_SHORT_4_4_4_4 */
  79619. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79620. /** UNSIGNED_SHORT_5_5_5_1 */
  79621. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79622. /** UNSIGNED_SHORT_5_6_5 */
  79623. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79624. /** UNSIGNED_INT_2_10_10_10_REV */
  79625. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79626. /** UNSIGNED_INT_24_8 */
  79627. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79628. /** UNSIGNED_INT_10F_11F_11F_REV */
  79629. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79630. /** UNSIGNED_INT_5_9_9_9_REV */
  79631. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79632. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79633. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79634. /** nearest is mag = nearest and min = nearest and no mip */
  79635. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79636. /** mag = nearest and min = nearest and mip = none */
  79637. static readonly TEXTURE_NEAREST_NEAREST: number;
  79638. /** Bilinear is mag = linear and min = linear and no mip */
  79639. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79640. /** mag = linear and min = linear and mip = none */
  79641. static readonly TEXTURE_LINEAR_LINEAR: number;
  79642. /** Trilinear is mag = linear and min = linear and mip = linear */
  79643. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79644. /** Trilinear is mag = linear and min = linear and mip = linear */
  79645. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79646. /** mag = nearest and min = nearest and mip = nearest */
  79647. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79648. /** mag = nearest and min = linear and mip = nearest */
  79649. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79650. /** mag = nearest and min = linear and mip = linear */
  79651. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79652. /** mag = nearest and min = linear and mip = none */
  79653. static readonly TEXTURE_NEAREST_LINEAR: number;
  79654. /** nearest is mag = nearest and min = nearest and mip = linear */
  79655. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79656. /** mag = linear and min = nearest and mip = nearest */
  79657. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79658. /** mag = linear and min = nearest and mip = linear */
  79659. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79660. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79661. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79662. /** mag = linear and min = nearest and mip = none */
  79663. static readonly TEXTURE_LINEAR_NEAREST: number;
  79664. /** Explicit coordinates mode */
  79665. static readonly TEXTURE_EXPLICIT_MODE: number;
  79666. /** Spherical coordinates mode */
  79667. static readonly TEXTURE_SPHERICAL_MODE: number;
  79668. /** Planar coordinates mode */
  79669. static readonly TEXTURE_PLANAR_MODE: number;
  79670. /** Cubic coordinates mode */
  79671. static readonly TEXTURE_CUBIC_MODE: number;
  79672. /** Projection coordinates mode */
  79673. static readonly TEXTURE_PROJECTION_MODE: number;
  79674. /** Skybox coordinates mode */
  79675. static readonly TEXTURE_SKYBOX_MODE: number;
  79676. /** Inverse Cubic coordinates mode */
  79677. static readonly TEXTURE_INVCUBIC_MODE: number;
  79678. /** Equirectangular coordinates mode */
  79679. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79680. /** Equirectangular Fixed coordinates mode */
  79681. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79682. /** Equirectangular Fixed Mirrored coordinates mode */
  79683. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79684. /** Offline (baking) quality for texture filtering */
  79685. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79686. /** High quality for texture filtering */
  79687. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79688. /** Medium quality for texture filtering */
  79689. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79690. /** Low quality for texture filtering */
  79691. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79692. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79693. static readonly SCALEMODE_FLOOR: number;
  79694. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79695. static readonly SCALEMODE_NEAREST: number;
  79696. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79697. static readonly SCALEMODE_CEILING: number;
  79698. /**
  79699. * The dirty texture flag value
  79700. */
  79701. static readonly MATERIAL_TextureDirtyFlag: number;
  79702. /**
  79703. * The dirty light flag value
  79704. */
  79705. static readonly MATERIAL_LightDirtyFlag: number;
  79706. /**
  79707. * The dirty fresnel flag value
  79708. */
  79709. static readonly MATERIAL_FresnelDirtyFlag: number;
  79710. /**
  79711. * The dirty attribute flag value
  79712. */
  79713. static readonly MATERIAL_AttributesDirtyFlag: number;
  79714. /**
  79715. * The dirty misc flag value
  79716. */
  79717. static readonly MATERIAL_MiscDirtyFlag: number;
  79718. /**
  79719. * The all dirty flag value
  79720. */
  79721. static readonly MATERIAL_AllDirtyFlag: number;
  79722. /**
  79723. * Returns the triangle fill mode
  79724. */
  79725. static readonly MATERIAL_TriangleFillMode: number;
  79726. /**
  79727. * Returns the wireframe mode
  79728. */
  79729. static readonly MATERIAL_WireFrameFillMode: number;
  79730. /**
  79731. * Returns the point fill mode
  79732. */
  79733. static readonly MATERIAL_PointFillMode: number;
  79734. /**
  79735. * Returns the point list draw mode
  79736. */
  79737. static readonly MATERIAL_PointListDrawMode: number;
  79738. /**
  79739. * Returns the line list draw mode
  79740. */
  79741. static readonly MATERIAL_LineListDrawMode: number;
  79742. /**
  79743. * Returns the line loop draw mode
  79744. */
  79745. static readonly MATERIAL_LineLoopDrawMode: number;
  79746. /**
  79747. * Returns the line strip draw mode
  79748. */
  79749. static readonly MATERIAL_LineStripDrawMode: number;
  79750. /**
  79751. * Returns the triangle strip draw mode
  79752. */
  79753. static readonly MATERIAL_TriangleStripDrawMode: number;
  79754. /**
  79755. * Returns the triangle fan draw mode
  79756. */
  79757. static readonly MATERIAL_TriangleFanDrawMode: number;
  79758. /**
  79759. * Stores the clock-wise side orientation
  79760. */
  79761. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79762. /**
  79763. * Stores the counter clock-wise side orientation
  79764. */
  79765. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79766. /**
  79767. * Nothing
  79768. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79769. */
  79770. static readonly ACTION_NothingTrigger: number;
  79771. /**
  79772. * On pick
  79773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79774. */
  79775. static readonly ACTION_OnPickTrigger: number;
  79776. /**
  79777. * On left pick
  79778. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79779. */
  79780. static readonly ACTION_OnLeftPickTrigger: number;
  79781. /**
  79782. * On right pick
  79783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79784. */
  79785. static readonly ACTION_OnRightPickTrigger: number;
  79786. /**
  79787. * On center pick
  79788. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79789. */
  79790. static readonly ACTION_OnCenterPickTrigger: number;
  79791. /**
  79792. * On pick down
  79793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79794. */
  79795. static readonly ACTION_OnPickDownTrigger: number;
  79796. /**
  79797. * On double pick
  79798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79799. */
  79800. static readonly ACTION_OnDoublePickTrigger: number;
  79801. /**
  79802. * On pick up
  79803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79804. */
  79805. static readonly ACTION_OnPickUpTrigger: number;
  79806. /**
  79807. * On pick out.
  79808. * This trigger will only be raised if you also declared a OnPickDown
  79809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79810. */
  79811. static readonly ACTION_OnPickOutTrigger: number;
  79812. /**
  79813. * On long press
  79814. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79815. */
  79816. static readonly ACTION_OnLongPressTrigger: number;
  79817. /**
  79818. * On pointer over
  79819. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79820. */
  79821. static readonly ACTION_OnPointerOverTrigger: number;
  79822. /**
  79823. * On pointer out
  79824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79825. */
  79826. static readonly ACTION_OnPointerOutTrigger: number;
  79827. /**
  79828. * On every frame
  79829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79830. */
  79831. static readonly ACTION_OnEveryFrameTrigger: number;
  79832. /**
  79833. * On intersection enter
  79834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79835. */
  79836. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79837. /**
  79838. * On intersection exit
  79839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79840. */
  79841. static readonly ACTION_OnIntersectionExitTrigger: number;
  79842. /**
  79843. * On key down
  79844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79845. */
  79846. static readonly ACTION_OnKeyDownTrigger: number;
  79847. /**
  79848. * On key up
  79849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79850. */
  79851. static readonly ACTION_OnKeyUpTrigger: number;
  79852. /**
  79853. * Billboard mode will only apply to Y axis
  79854. */
  79855. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79856. /**
  79857. * Billboard mode will apply to all axes
  79858. */
  79859. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79860. /**
  79861. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79862. */
  79863. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79864. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79865. * Test order :
  79866. * Is the bounding sphere outside the frustum ?
  79867. * If not, are the bounding box vertices outside the frustum ?
  79868. * It not, then the cullable object is in the frustum.
  79869. */
  79870. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79871. /** Culling strategy : Bounding Sphere Only.
  79872. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79873. * It's also less accurate than the standard because some not visible objects can still be selected.
  79874. * Test : is the bounding sphere outside the frustum ?
  79875. * If not, then the cullable object is in the frustum.
  79876. */
  79877. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79878. /** Culling strategy : Optimistic Inclusion.
  79879. * This in an inclusion test first, then the standard exclusion test.
  79880. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79881. * 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.
  79882. * Anyway, it's as accurate as the standard strategy.
  79883. * Test :
  79884. * Is the cullable object bounding sphere center in the frustum ?
  79885. * If not, apply the default culling strategy.
  79886. */
  79887. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79888. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79889. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79890. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79891. * 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.
  79892. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79893. * Test :
  79894. * Is the cullable object bounding sphere center in the frustum ?
  79895. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79896. */
  79897. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79898. /**
  79899. * No logging while loading
  79900. */
  79901. static readonly SCENELOADER_NO_LOGGING: number;
  79902. /**
  79903. * Minimal logging while loading
  79904. */
  79905. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79906. /**
  79907. * Summary logging while loading
  79908. */
  79909. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79910. /**
  79911. * Detailled logging while loading
  79912. */
  79913. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79914. /**
  79915. * Prepass texture index for color
  79916. */
  79917. static readonly PREPASS_COLOR_INDEX: number;
  79918. /**
  79919. * Prepass texture index for irradiance
  79920. */
  79921. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79922. /**
  79923. * Prepass texture index for depth + normal
  79924. */
  79925. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79926. /**
  79927. * Prepass texture index for albedo
  79928. */
  79929. static readonly PREPASS_ALBEDO_INDEX: number;
  79930. }
  79931. }
  79932. declare module BABYLON {
  79933. /**
  79934. * This represents the required contract to create a new type of texture loader.
  79935. */
  79936. export interface IInternalTextureLoader {
  79937. /**
  79938. * Defines wether the loader supports cascade loading the different faces.
  79939. */
  79940. supportCascades: boolean;
  79941. /**
  79942. * This returns if the loader support the current file information.
  79943. * @param extension defines the file extension of the file being loaded
  79944. * @param mimeType defines the optional mime type of the file being loaded
  79945. * @returns true if the loader can load the specified file
  79946. */
  79947. canLoad(extension: string, mimeType?: string): boolean;
  79948. /**
  79949. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79950. * @param data contains the texture data
  79951. * @param texture defines the BabylonJS internal texture
  79952. * @param createPolynomials will be true if polynomials have been requested
  79953. * @param onLoad defines the callback to trigger once the texture is ready
  79954. * @param onError defines the callback to trigger in case of error
  79955. */
  79956. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79957. /**
  79958. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79959. * @param data contains the texture data
  79960. * @param texture defines the BabylonJS internal texture
  79961. * @param callback defines the method to call once ready to upload
  79962. */
  79963. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79964. }
  79965. }
  79966. declare module BABYLON {
  79967. /**
  79968. * Class used to store and describe the pipeline context associated with an effect
  79969. */
  79970. export interface IPipelineContext {
  79971. /**
  79972. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79973. */
  79974. isAsync: boolean;
  79975. /**
  79976. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79977. */
  79978. isReady: boolean;
  79979. /** @hidden */
  79980. _getVertexShaderCode(): string | null;
  79981. /** @hidden */
  79982. _getFragmentShaderCode(): string | null;
  79983. /** @hidden */
  79984. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79985. }
  79986. }
  79987. declare module BABYLON {
  79988. /**
  79989. * Class used to store gfx data (like WebGLBuffer)
  79990. */
  79991. export class DataBuffer {
  79992. /**
  79993. * Gets or sets the number of objects referencing this buffer
  79994. */
  79995. references: number;
  79996. /** Gets or sets the size of the underlying buffer */
  79997. capacity: number;
  79998. /**
  79999. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80000. */
  80001. is32Bits: boolean;
  80002. /**
  80003. * Gets the underlying buffer
  80004. */
  80005. get underlyingResource(): any;
  80006. }
  80007. }
  80008. declare module BABYLON {
  80009. /** @hidden */
  80010. export interface IShaderProcessor {
  80011. attributeProcessor?: (attribute: string) => string;
  80012. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80013. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80014. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80015. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80016. lineProcessor?: (line: string, isFragment: boolean) => string;
  80017. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80018. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80019. }
  80020. }
  80021. declare module BABYLON {
  80022. /** @hidden */
  80023. export interface ProcessingOptions {
  80024. defines: string[];
  80025. indexParameters: any;
  80026. isFragment: boolean;
  80027. shouldUseHighPrecisionShader: boolean;
  80028. supportsUniformBuffers: boolean;
  80029. shadersRepository: string;
  80030. includesShadersStore: {
  80031. [key: string]: string;
  80032. };
  80033. processor?: IShaderProcessor;
  80034. version: string;
  80035. platformName: string;
  80036. lookForClosingBracketForUniformBuffer?: boolean;
  80037. }
  80038. }
  80039. declare module BABYLON {
  80040. /** @hidden */
  80041. export class ShaderCodeNode {
  80042. line: string;
  80043. children: ShaderCodeNode[];
  80044. additionalDefineKey?: string;
  80045. additionalDefineValue?: string;
  80046. isValid(preprocessors: {
  80047. [key: string]: string;
  80048. }): boolean;
  80049. process(preprocessors: {
  80050. [key: string]: string;
  80051. }, options: ProcessingOptions): string;
  80052. }
  80053. }
  80054. declare module BABYLON {
  80055. /** @hidden */
  80056. export class ShaderCodeCursor {
  80057. private _lines;
  80058. lineIndex: number;
  80059. get currentLine(): string;
  80060. get canRead(): boolean;
  80061. set lines(value: string[]);
  80062. }
  80063. }
  80064. declare module BABYLON {
  80065. /** @hidden */
  80066. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80067. process(preprocessors: {
  80068. [key: string]: string;
  80069. }, options: ProcessingOptions): string;
  80070. }
  80071. }
  80072. declare module BABYLON {
  80073. /** @hidden */
  80074. export class ShaderDefineExpression {
  80075. isTrue(preprocessors: {
  80076. [key: string]: string;
  80077. }): boolean;
  80078. private static _OperatorPriority;
  80079. private static _Stack;
  80080. static postfixToInfix(postfix: string[]): string;
  80081. static infixToPostfix(infix: string): string[];
  80082. }
  80083. }
  80084. declare module BABYLON {
  80085. /** @hidden */
  80086. export class ShaderCodeTestNode extends ShaderCodeNode {
  80087. testExpression: ShaderDefineExpression;
  80088. isValid(preprocessors: {
  80089. [key: string]: string;
  80090. }): boolean;
  80091. }
  80092. }
  80093. declare module BABYLON {
  80094. /** @hidden */
  80095. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80096. define: string;
  80097. not: boolean;
  80098. constructor(define: string, not?: boolean);
  80099. isTrue(preprocessors: {
  80100. [key: string]: string;
  80101. }): boolean;
  80102. }
  80103. }
  80104. declare module BABYLON {
  80105. /** @hidden */
  80106. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80107. leftOperand: ShaderDefineExpression;
  80108. rightOperand: ShaderDefineExpression;
  80109. isTrue(preprocessors: {
  80110. [key: string]: string;
  80111. }): boolean;
  80112. }
  80113. }
  80114. declare module BABYLON {
  80115. /** @hidden */
  80116. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80117. leftOperand: ShaderDefineExpression;
  80118. rightOperand: ShaderDefineExpression;
  80119. isTrue(preprocessors: {
  80120. [key: string]: string;
  80121. }): boolean;
  80122. }
  80123. }
  80124. declare module BABYLON {
  80125. /** @hidden */
  80126. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80127. define: string;
  80128. operand: string;
  80129. testValue: string;
  80130. constructor(define: string, operand: string, testValue: string);
  80131. isTrue(preprocessors: {
  80132. [key: string]: string;
  80133. }): boolean;
  80134. }
  80135. }
  80136. declare module BABYLON {
  80137. /**
  80138. * Class used to enable access to offline support
  80139. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80140. */
  80141. export interface IOfflineProvider {
  80142. /**
  80143. * Gets a boolean indicating if scene must be saved in the database
  80144. */
  80145. enableSceneOffline: boolean;
  80146. /**
  80147. * Gets a boolean indicating if textures must be saved in the database
  80148. */
  80149. enableTexturesOffline: boolean;
  80150. /**
  80151. * Open the offline support and make it available
  80152. * @param successCallback defines the callback to call on success
  80153. * @param errorCallback defines the callback to call on error
  80154. */
  80155. open(successCallback: () => void, errorCallback: () => void): void;
  80156. /**
  80157. * Loads an image from the offline support
  80158. * @param url defines the url to load from
  80159. * @param image defines the target DOM image
  80160. */
  80161. loadImage(url: string, image: HTMLImageElement): void;
  80162. /**
  80163. * Loads a file from offline support
  80164. * @param url defines the URL to load from
  80165. * @param sceneLoaded defines a callback to call on success
  80166. * @param progressCallBack defines a callback to call when progress changed
  80167. * @param errorCallback defines a callback to call on error
  80168. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80169. */
  80170. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80171. }
  80172. }
  80173. declare module BABYLON {
  80174. /**
  80175. * Class used to help managing file picking and drag'n'drop
  80176. * File Storage
  80177. */
  80178. export class FilesInputStore {
  80179. /**
  80180. * List of files ready to be loaded
  80181. */
  80182. static FilesToLoad: {
  80183. [key: string]: File;
  80184. };
  80185. }
  80186. }
  80187. declare module BABYLON {
  80188. /**
  80189. * Class used to define a retry strategy when error happens while loading assets
  80190. */
  80191. export class RetryStrategy {
  80192. /**
  80193. * Function used to defines an exponential back off strategy
  80194. * @param maxRetries defines the maximum number of retries (3 by default)
  80195. * @param baseInterval defines the interval between retries
  80196. * @returns the strategy function to use
  80197. */
  80198. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80199. }
  80200. }
  80201. declare module BABYLON {
  80202. /**
  80203. * @ignore
  80204. * Application error to support additional information when loading a file
  80205. */
  80206. export abstract class BaseError extends Error {
  80207. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80208. }
  80209. }
  80210. declare module BABYLON {
  80211. /** @ignore */
  80212. export class LoadFileError extends BaseError {
  80213. request?: WebRequest;
  80214. file?: File;
  80215. /**
  80216. * Creates a new LoadFileError
  80217. * @param message defines the message of the error
  80218. * @param request defines the optional web request
  80219. * @param file defines the optional file
  80220. */
  80221. constructor(message: string, object?: WebRequest | File);
  80222. }
  80223. /** @ignore */
  80224. export class RequestFileError extends BaseError {
  80225. request: WebRequest;
  80226. /**
  80227. * Creates a new LoadFileError
  80228. * @param message defines the message of the error
  80229. * @param request defines the optional web request
  80230. */
  80231. constructor(message: string, request: WebRequest);
  80232. }
  80233. /** @ignore */
  80234. export class ReadFileError extends BaseError {
  80235. file: File;
  80236. /**
  80237. * Creates a new ReadFileError
  80238. * @param message defines the message of the error
  80239. * @param file defines the optional file
  80240. */
  80241. constructor(message: string, file: File);
  80242. }
  80243. /**
  80244. * @hidden
  80245. */
  80246. export class FileTools {
  80247. /**
  80248. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80249. */
  80250. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80251. /**
  80252. * Gets or sets the base URL to use to load assets
  80253. */
  80254. static BaseUrl: string;
  80255. /**
  80256. * Default behaviour for cors in the application.
  80257. * It can be a string if the expected behavior is identical in the entire app.
  80258. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80259. */
  80260. static CorsBehavior: string | ((url: string | string[]) => string);
  80261. /**
  80262. * Gets or sets a function used to pre-process url before using them to load assets
  80263. */
  80264. static PreprocessUrl: (url: string) => string;
  80265. /**
  80266. * Removes unwanted characters from an url
  80267. * @param url defines the url to clean
  80268. * @returns the cleaned url
  80269. */
  80270. private static _CleanUrl;
  80271. /**
  80272. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80273. * @param url define the url we are trying
  80274. * @param element define the dom element where to configure the cors policy
  80275. */
  80276. static SetCorsBehavior(url: string | string[], element: {
  80277. crossOrigin: string | null;
  80278. }): void;
  80279. /**
  80280. * Loads an image as an HTMLImageElement.
  80281. * @param input url string, ArrayBuffer, or Blob to load
  80282. * @param onLoad callback called when the image successfully loads
  80283. * @param onError callback called when the image fails to load
  80284. * @param offlineProvider offline provider for caching
  80285. * @param mimeType optional mime type
  80286. * @returns the HTMLImageElement of the loaded image
  80287. */
  80288. 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>;
  80289. /**
  80290. * Reads a file from a File object
  80291. * @param file defines the file to load
  80292. * @param onSuccess defines the callback to call when data is loaded
  80293. * @param onProgress defines the callback to call during loading process
  80294. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80295. * @param onError defines the callback to call when an error occurs
  80296. * @returns a file request object
  80297. */
  80298. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80299. /**
  80300. * Loads a file from a url
  80301. * @param url url to load
  80302. * @param onSuccess callback called when the file successfully loads
  80303. * @param onProgress callback called while file is loading (if the server supports this mode)
  80304. * @param offlineProvider defines the offline provider for caching
  80305. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80306. * @param onError callback called when the file fails to load
  80307. * @returns a file request object
  80308. */
  80309. 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;
  80310. /**
  80311. * Loads a file
  80312. * @param url url to load
  80313. * @param onSuccess callback called when the file successfully loads
  80314. * @param onProgress callback called while file is loading (if the server supports this mode)
  80315. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80316. * @param onError callback called when the file fails to load
  80317. * @param onOpened callback called when the web request is opened
  80318. * @returns a file request object
  80319. */
  80320. 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;
  80321. /**
  80322. * Checks if the loaded document was accessed via `file:`-Protocol.
  80323. * @returns boolean
  80324. */
  80325. static IsFileURL(): boolean;
  80326. }
  80327. }
  80328. declare module BABYLON {
  80329. /** @hidden */
  80330. export class ShaderProcessor {
  80331. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80332. private static _ProcessPrecision;
  80333. private static _ExtractOperation;
  80334. private static _BuildSubExpression;
  80335. private static _BuildExpression;
  80336. private static _MoveCursorWithinIf;
  80337. private static _MoveCursor;
  80338. private static _EvaluatePreProcessors;
  80339. private static _PreparePreProcessors;
  80340. private static _ProcessShaderConversion;
  80341. private static _ProcessIncludes;
  80342. /**
  80343. * Loads a file from a url
  80344. * @param url url to load
  80345. * @param onSuccess callback called when the file successfully loads
  80346. * @param onProgress callback called while file is loading (if the server supports this mode)
  80347. * @param offlineProvider defines the offline provider for caching
  80348. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80349. * @param onError callback called when the file fails to load
  80350. * @returns a file request object
  80351. * @hidden
  80352. */
  80353. 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;
  80354. }
  80355. }
  80356. declare module BABYLON {
  80357. /**
  80358. * @hidden
  80359. */
  80360. export interface IColor4Like {
  80361. r: float;
  80362. g: float;
  80363. b: float;
  80364. a: float;
  80365. }
  80366. /**
  80367. * @hidden
  80368. */
  80369. export interface IColor3Like {
  80370. r: float;
  80371. g: float;
  80372. b: float;
  80373. }
  80374. /**
  80375. * @hidden
  80376. */
  80377. export interface IVector4Like {
  80378. x: float;
  80379. y: float;
  80380. z: float;
  80381. w: float;
  80382. }
  80383. /**
  80384. * @hidden
  80385. */
  80386. export interface IVector3Like {
  80387. x: float;
  80388. y: float;
  80389. z: float;
  80390. }
  80391. /**
  80392. * @hidden
  80393. */
  80394. export interface IVector2Like {
  80395. x: float;
  80396. y: float;
  80397. }
  80398. /**
  80399. * @hidden
  80400. */
  80401. export interface IMatrixLike {
  80402. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80403. updateFlag: int;
  80404. }
  80405. /**
  80406. * @hidden
  80407. */
  80408. export interface IViewportLike {
  80409. x: float;
  80410. y: float;
  80411. width: float;
  80412. height: float;
  80413. }
  80414. /**
  80415. * @hidden
  80416. */
  80417. export interface IPlaneLike {
  80418. normal: IVector3Like;
  80419. d: float;
  80420. normalize(): void;
  80421. }
  80422. }
  80423. declare module BABYLON {
  80424. /**
  80425. * Interface used to define common properties for effect fallbacks
  80426. */
  80427. export interface IEffectFallbacks {
  80428. /**
  80429. * Removes the defines that should be removed when falling back.
  80430. * @param currentDefines defines the current define statements for the shader.
  80431. * @param effect defines the current effect we try to compile
  80432. * @returns The resulting defines with defines of the current rank removed.
  80433. */
  80434. reduce(currentDefines: string, effect: Effect): string;
  80435. /**
  80436. * Removes the fallback from the bound mesh.
  80437. */
  80438. unBindMesh(): void;
  80439. /**
  80440. * Checks to see if more fallbacks are still availible.
  80441. */
  80442. hasMoreFallbacks: boolean;
  80443. }
  80444. }
  80445. declare module BABYLON {
  80446. /**
  80447. * Class used to evalaute queries containing `and` and `or` operators
  80448. */
  80449. export class AndOrNotEvaluator {
  80450. /**
  80451. * Evaluate a query
  80452. * @param query defines the query to evaluate
  80453. * @param evaluateCallback defines the callback used to filter result
  80454. * @returns true if the query matches
  80455. */
  80456. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80457. private static _HandleParenthesisContent;
  80458. private static _SimplifyNegation;
  80459. }
  80460. }
  80461. declare module BABYLON {
  80462. /**
  80463. * Class used to store custom tags
  80464. */
  80465. export class Tags {
  80466. /**
  80467. * Adds support for tags on the given object
  80468. * @param obj defines the object to use
  80469. */
  80470. static EnableFor(obj: any): void;
  80471. /**
  80472. * Removes tags support
  80473. * @param obj defines the object to use
  80474. */
  80475. static DisableFor(obj: any): void;
  80476. /**
  80477. * Gets a boolean indicating if the given object has tags
  80478. * @param obj defines the object to use
  80479. * @returns a boolean
  80480. */
  80481. static HasTags(obj: any): boolean;
  80482. /**
  80483. * Gets the tags available on a given object
  80484. * @param obj defines the object to use
  80485. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80486. * @returns the tags
  80487. */
  80488. static GetTags(obj: any, asString?: boolean): any;
  80489. /**
  80490. * Adds tags to an object
  80491. * @param obj defines the object to use
  80492. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80493. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80494. */
  80495. static AddTagsTo(obj: any, tagsString: string): void;
  80496. /**
  80497. * @hidden
  80498. */
  80499. static _AddTagTo(obj: any, tag: string): void;
  80500. /**
  80501. * Removes specific tags from a specific object
  80502. * @param obj defines the object to use
  80503. * @param tagsString defines the tags to remove
  80504. */
  80505. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80506. /**
  80507. * @hidden
  80508. */
  80509. static _RemoveTagFrom(obj: any, tag: string): void;
  80510. /**
  80511. * Defines if tags hosted on an object match a given query
  80512. * @param obj defines the object to use
  80513. * @param tagsQuery defines the tag query
  80514. * @returns a boolean
  80515. */
  80516. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80517. }
  80518. }
  80519. declare module BABYLON {
  80520. /**
  80521. * Scalar computation library
  80522. */
  80523. export class Scalar {
  80524. /**
  80525. * Two pi constants convenient for computation.
  80526. */
  80527. static TwoPi: number;
  80528. /**
  80529. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80530. * @param a number
  80531. * @param b number
  80532. * @param epsilon (default = 1.401298E-45)
  80533. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80534. */
  80535. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80536. /**
  80537. * Returns a string : the upper case translation of the number i to hexadecimal.
  80538. * @param i number
  80539. * @returns the upper case translation of the number i to hexadecimal.
  80540. */
  80541. static ToHex(i: number): string;
  80542. /**
  80543. * Returns -1 if value is negative and +1 is value is positive.
  80544. * @param value the value
  80545. * @returns the value itself if it's equal to zero.
  80546. */
  80547. static Sign(value: number): number;
  80548. /**
  80549. * Returns the value itself if it's between min and max.
  80550. * Returns min if the value is lower than min.
  80551. * Returns max if the value is greater than max.
  80552. * @param value the value to clmap
  80553. * @param min the min value to clamp to (default: 0)
  80554. * @param max the max value to clamp to (default: 1)
  80555. * @returns the clamped value
  80556. */
  80557. static Clamp(value: number, min?: number, max?: number): number;
  80558. /**
  80559. * the log2 of value.
  80560. * @param value the value to compute log2 of
  80561. * @returns the log2 of value.
  80562. */
  80563. static Log2(value: number): number;
  80564. /**
  80565. * Loops the value, so that it is never larger than length and never smaller than 0.
  80566. *
  80567. * This is similar to the modulo operator but it works with floating point numbers.
  80568. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80569. * With t = 5 and length = 2.5, the result would be 0.0.
  80570. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80571. * @param value the value
  80572. * @param length the length
  80573. * @returns the looped value
  80574. */
  80575. static Repeat(value: number, length: number): number;
  80576. /**
  80577. * Normalize the value between 0.0 and 1.0 using min and max values
  80578. * @param value value to normalize
  80579. * @param min max to normalize between
  80580. * @param max min to normalize between
  80581. * @returns the normalized value
  80582. */
  80583. static Normalize(value: number, min: number, max: number): number;
  80584. /**
  80585. * Denormalize the value from 0.0 and 1.0 using min and max values
  80586. * @param normalized value to denormalize
  80587. * @param min max to denormalize between
  80588. * @param max min to denormalize between
  80589. * @returns the denormalized value
  80590. */
  80591. static Denormalize(normalized: number, min: number, max: number): number;
  80592. /**
  80593. * Calculates the shortest difference between two given angles given in degrees.
  80594. * @param current current angle in degrees
  80595. * @param target target angle in degrees
  80596. * @returns the delta
  80597. */
  80598. static DeltaAngle(current: number, target: number): number;
  80599. /**
  80600. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80601. * @param tx value
  80602. * @param length length
  80603. * @returns The returned value will move back and forth between 0 and length
  80604. */
  80605. static PingPong(tx: number, length: number): number;
  80606. /**
  80607. * Interpolates between min and max with smoothing at the limits.
  80608. *
  80609. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80610. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80611. * @param from from
  80612. * @param to to
  80613. * @param tx value
  80614. * @returns the smooth stepped value
  80615. */
  80616. static SmoothStep(from: number, to: number, tx: number): number;
  80617. /**
  80618. * Moves a value current towards target.
  80619. *
  80620. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80621. * Negative values of maxDelta pushes the value away from target.
  80622. * @param current current value
  80623. * @param target target value
  80624. * @param maxDelta max distance to move
  80625. * @returns resulting value
  80626. */
  80627. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80628. /**
  80629. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80630. *
  80631. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80632. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80633. * @param current current value
  80634. * @param target target value
  80635. * @param maxDelta max distance to move
  80636. * @returns resulting angle
  80637. */
  80638. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80639. /**
  80640. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80641. * @param start start value
  80642. * @param end target value
  80643. * @param amount amount to lerp between
  80644. * @returns the lerped value
  80645. */
  80646. static Lerp(start: number, end: number, amount: number): number;
  80647. /**
  80648. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80649. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80650. * @param start start value
  80651. * @param end target value
  80652. * @param amount amount to lerp between
  80653. * @returns the lerped value
  80654. */
  80655. static LerpAngle(start: number, end: number, amount: number): number;
  80656. /**
  80657. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80658. * @param a start value
  80659. * @param b target value
  80660. * @param value value between a and b
  80661. * @returns the inverseLerp value
  80662. */
  80663. static InverseLerp(a: number, b: number, value: number): number;
  80664. /**
  80665. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80666. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80667. * @param value1 spline value
  80668. * @param tangent1 spline value
  80669. * @param value2 spline value
  80670. * @param tangent2 spline value
  80671. * @param amount input value
  80672. * @returns hermite result
  80673. */
  80674. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80675. /**
  80676. * Returns a random float number between and min and max values
  80677. * @param min min value of random
  80678. * @param max max value of random
  80679. * @returns random value
  80680. */
  80681. static RandomRange(min: number, max: number): number;
  80682. /**
  80683. * This function returns percentage of a number in a given range.
  80684. *
  80685. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80686. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80687. * @param number to convert to percentage
  80688. * @param min min range
  80689. * @param max max range
  80690. * @returns the percentage
  80691. */
  80692. static RangeToPercent(number: number, min: number, max: number): number;
  80693. /**
  80694. * This function returns number that corresponds to the percentage in a given range.
  80695. *
  80696. * PercentToRange(0.34,0,100) will return 34.
  80697. * @param percent to convert to number
  80698. * @param min min range
  80699. * @param max max range
  80700. * @returns the number
  80701. */
  80702. static PercentToRange(percent: number, min: number, max: number): number;
  80703. /**
  80704. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80705. * @param angle The angle to normalize in radian.
  80706. * @return The converted angle.
  80707. */
  80708. static NormalizeRadians(angle: number): number;
  80709. }
  80710. }
  80711. declare module BABYLON {
  80712. /**
  80713. * Constant used to convert a value to gamma space
  80714. * @ignorenaming
  80715. */
  80716. export const ToGammaSpace: number;
  80717. /**
  80718. * Constant used to convert a value to linear space
  80719. * @ignorenaming
  80720. */
  80721. export const ToLinearSpace = 2.2;
  80722. /**
  80723. * Constant used to define the minimal number value in Babylon.js
  80724. * @ignorenaming
  80725. */
  80726. let Epsilon: number;
  80727. }
  80728. declare module BABYLON {
  80729. /**
  80730. * Class used to represent a viewport on screen
  80731. */
  80732. export class Viewport {
  80733. /** viewport left coordinate */
  80734. x: number;
  80735. /** viewport top coordinate */
  80736. y: number;
  80737. /**viewport width */
  80738. width: number;
  80739. /** viewport height */
  80740. height: number;
  80741. /**
  80742. * Creates a Viewport object located at (x, y) and sized (width, height)
  80743. * @param x defines viewport left coordinate
  80744. * @param y defines viewport top coordinate
  80745. * @param width defines the viewport width
  80746. * @param height defines the viewport height
  80747. */
  80748. constructor(
  80749. /** viewport left coordinate */
  80750. x: number,
  80751. /** viewport top coordinate */
  80752. y: number,
  80753. /**viewport width */
  80754. width: number,
  80755. /** viewport height */
  80756. height: number);
  80757. /**
  80758. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80759. * @param renderWidth defines the rendering width
  80760. * @param renderHeight defines the rendering height
  80761. * @returns a new Viewport
  80762. */
  80763. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80764. /**
  80765. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80766. * @param renderWidth defines the rendering width
  80767. * @param renderHeight defines the rendering height
  80768. * @param ref defines the target viewport
  80769. * @returns the current viewport
  80770. */
  80771. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80772. /**
  80773. * Returns a new Viewport copied from the current one
  80774. * @returns a new Viewport
  80775. */
  80776. clone(): Viewport;
  80777. }
  80778. }
  80779. declare module BABYLON {
  80780. /**
  80781. * Class containing a set of static utilities functions for arrays.
  80782. */
  80783. export class ArrayTools {
  80784. /**
  80785. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80786. * @param size the number of element to construct and put in the array
  80787. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80788. * @returns a new array filled with new objects
  80789. */
  80790. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80791. }
  80792. }
  80793. declare module BABYLON {
  80794. /**
  80795. * Represents a plane by the equation ax + by + cz + d = 0
  80796. */
  80797. export class Plane {
  80798. private static _TmpMatrix;
  80799. /**
  80800. * Normal of the plane (a,b,c)
  80801. */
  80802. normal: Vector3;
  80803. /**
  80804. * d component of the plane
  80805. */
  80806. d: number;
  80807. /**
  80808. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80809. * @param a a component of the plane
  80810. * @param b b component of the plane
  80811. * @param c c component of the plane
  80812. * @param d d component of the plane
  80813. */
  80814. constructor(a: number, b: number, c: number, d: number);
  80815. /**
  80816. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80817. */
  80818. asArray(): number[];
  80819. /**
  80820. * @returns a new plane copied from the current Plane.
  80821. */
  80822. clone(): Plane;
  80823. /**
  80824. * @returns the string "Plane".
  80825. */
  80826. getClassName(): string;
  80827. /**
  80828. * @returns the Plane hash code.
  80829. */
  80830. getHashCode(): number;
  80831. /**
  80832. * Normalize the current Plane in place.
  80833. * @returns the updated Plane.
  80834. */
  80835. normalize(): Plane;
  80836. /**
  80837. * Applies a transformation the plane and returns the result
  80838. * @param transformation the transformation matrix to be applied to the plane
  80839. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80840. */
  80841. transform(transformation: DeepImmutable<Matrix>): Plane;
  80842. /**
  80843. * Compute the dot product between the point and the plane normal
  80844. * @param point point to calculate the dot product with
  80845. * @returns the dot product (float) of the point coordinates and the plane normal.
  80846. */
  80847. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80848. /**
  80849. * Updates the current Plane from the plane defined by the three given points.
  80850. * @param point1 one of the points used to contruct the plane
  80851. * @param point2 one of the points used to contruct the plane
  80852. * @param point3 one of the points used to contruct the plane
  80853. * @returns the updated Plane.
  80854. */
  80855. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80856. /**
  80857. * Checks if the plane is facing a given direction
  80858. * @param direction the direction to check if the plane is facing
  80859. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80860. * @returns True is the vector "direction" is the same side than the plane normal.
  80861. */
  80862. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80863. /**
  80864. * Calculates the distance to a point
  80865. * @param point point to calculate distance to
  80866. * @returns the signed distance (float) from the given point to the Plane.
  80867. */
  80868. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80869. /**
  80870. * Creates a plane from an array
  80871. * @param array the array to create a plane from
  80872. * @returns a new Plane from the given array.
  80873. */
  80874. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80875. /**
  80876. * Creates a plane from three points
  80877. * @param point1 point used to create the plane
  80878. * @param point2 point used to create the plane
  80879. * @param point3 point used to create the plane
  80880. * @returns a new Plane defined by the three given points.
  80881. */
  80882. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80883. /**
  80884. * Creates a plane from an origin point and a normal
  80885. * @param origin origin of the plane to be constructed
  80886. * @param normal normal of the plane to be constructed
  80887. * @returns a new Plane the normal vector to this plane at the given origin point.
  80888. * Note : the vector "normal" is updated because normalized.
  80889. */
  80890. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80891. /**
  80892. * Calculates the distance from a plane and a point
  80893. * @param origin origin of the plane to be constructed
  80894. * @param normal normal of the plane to be constructed
  80895. * @param point point to calculate distance to
  80896. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80897. */
  80898. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80899. }
  80900. }
  80901. declare module BABYLON {
  80902. /** @hidden */
  80903. export class PerformanceConfigurator {
  80904. /** @hidden */
  80905. static MatrixUse64Bits: boolean;
  80906. /** @hidden */
  80907. static MatrixTrackPrecisionChange: boolean;
  80908. /** @hidden */
  80909. static MatrixCurrentType: any;
  80910. /** @hidden */
  80911. static MatrixTrackedMatrices: Array<any> | null;
  80912. /** @hidden */
  80913. static SetMatrixPrecision(use64bits: boolean): void;
  80914. }
  80915. }
  80916. declare module BABYLON {
  80917. /**
  80918. * Class representing a vector containing 2 coordinates
  80919. */
  80920. export class Vector2 {
  80921. /** defines the first coordinate */
  80922. x: number;
  80923. /** defines the second coordinate */
  80924. y: number;
  80925. /**
  80926. * Creates a new Vector2 from the given x and y coordinates
  80927. * @param x defines the first coordinate
  80928. * @param y defines the second coordinate
  80929. */
  80930. constructor(
  80931. /** defines the first coordinate */
  80932. x?: number,
  80933. /** defines the second coordinate */
  80934. y?: number);
  80935. /**
  80936. * Gets a string with the Vector2 coordinates
  80937. * @returns a string with the Vector2 coordinates
  80938. */
  80939. toString(): string;
  80940. /**
  80941. * Gets class name
  80942. * @returns the string "Vector2"
  80943. */
  80944. getClassName(): string;
  80945. /**
  80946. * Gets current vector hash code
  80947. * @returns the Vector2 hash code as a number
  80948. */
  80949. getHashCode(): number;
  80950. /**
  80951. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80952. * @param array defines the source array
  80953. * @param index defines the offset in source array
  80954. * @returns the current Vector2
  80955. */
  80956. toArray(array: FloatArray, index?: number): Vector2;
  80957. /**
  80958. * Update the current vector from an array
  80959. * @param array defines the destination array
  80960. * @param index defines the offset in the destination array
  80961. * @returns the current Vector3
  80962. */
  80963. fromArray(array: FloatArray, index?: number): Vector2;
  80964. /**
  80965. * Copy the current vector to an array
  80966. * @returns a new array with 2 elements: the Vector2 coordinates.
  80967. */
  80968. asArray(): number[];
  80969. /**
  80970. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80971. * @param source defines the source Vector2
  80972. * @returns the current updated Vector2
  80973. */
  80974. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80975. /**
  80976. * Sets the Vector2 coordinates with the given floats
  80977. * @param x defines the first coordinate
  80978. * @param y defines the second coordinate
  80979. * @returns the current updated Vector2
  80980. */
  80981. copyFromFloats(x: number, y: number): Vector2;
  80982. /**
  80983. * Sets the Vector2 coordinates with the given floats
  80984. * @param x defines the first coordinate
  80985. * @param y defines the second coordinate
  80986. * @returns the current updated Vector2
  80987. */
  80988. set(x: number, y: number): Vector2;
  80989. /**
  80990. * Add another vector with the current one
  80991. * @param otherVector defines the other vector
  80992. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80993. */
  80994. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80995. /**
  80996. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80997. * @param otherVector defines the other vector
  80998. * @param result defines the target vector
  80999. * @returns the unmodified current Vector2
  81000. */
  81001. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81002. /**
  81003. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81004. * @param otherVector defines the other vector
  81005. * @returns the current updated Vector2
  81006. */
  81007. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81008. /**
  81009. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81010. * @param otherVector defines the other vector
  81011. * @returns a new Vector2
  81012. */
  81013. addVector3(otherVector: Vector3): Vector2;
  81014. /**
  81015. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81016. * @param otherVector defines the other vector
  81017. * @returns a new Vector2
  81018. */
  81019. subtract(otherVector: Vector2): Vector2;
  81020. /**
  81021. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81022. * @param otherVector defines the other vector
  81023. * @param result defines the target vector
  81024. * @returns the unmodified current Vector2
  81025. */
  81026. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81027. /**
  81028. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81029. * @param otherVector defines the other vector
  81030. * @returns the current updated Vector2
  81031. */
  81032. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81033. /**
  81034. * Multiplies in place the current Vector2 coordinates by the given ones
  81035. * @param otherVector defines the other vector
  81036. * @returns the current updated Vector2
  81037. */
  81038. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81039. /**
  81040. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81041. * @param otherVector defines the other vector
  81042. * @returns a new Vector2
  81043. */
  81044. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81045. /**
  81046. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81047. * @param otherVector defines the other vector
  81048. * @param result defines the target vector
  81049. * @returns the unmodified current Vector2
  81050. */
  81051. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81052. /**
  81053. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81054. * @param x defines the first coordinate
  81055. * @param y defines the second coordinate
  81056. * @returns a new Vector2
  81057. */
  81058. multiplyByFloats(x: number, y: number): Vector2;
  81059. /**
  81060. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81061. * @param otherVector defines the other vector
  81062. * @returns a new Vector2
  81063. */
  81064. divide(otherVector: Vector2): Vector2;
  81065. /**
  81066. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81067. * @param otherVector defines the other vector
  81068. * @param result defines the target vector
  81069. * @returns the unmodified current Vector2
  81070. */
  81071. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81072. /**
  81073. * Divides the current Vector2 coordinates by the given ones
  81074. * @param otherVector defines the other vector
  81075. * @returns the current updated Vector2
  81076. */
  81077. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81078. /**
  81079. * Gets a new Vector2 with current Vector2 negated coordinates
  81080. * @returns a new Vector2
  81081. */
  81082. negate(): Vector2;
  81083. /**
  81084. * Negate this vector in place
  81085. * @returns this
  81086. */
  81087. negateInPlace(): Vector2;
  81088. /**
  81089. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81090. * @param result defines the Vector3 object where to store the result
  81091. * @returns the current Vector2
  81092. */
  81093. negateToRef(result: Vector2): Vector2;
  81094. /**
  81095. * Multiply the Vector2 coordinates by scale
  81096. * @param scale defines the scaling factor
  81097. * @returns the current updated Vector2
  81098. */
  81099. scaleInPlace(scale: number): Vector2;
  81100. /**
  81101. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81102. * @param scale defines the scaling factor
  81103. * @returns a new Vector2
  81104. */
  81105. scale(scale: number): Vector2;
  81106. /**
  81107. * Scale the current Vector2 values by a factor to a given Vector2
  81108. * @param scale defines the scale factor
  81109. * @param result defines the Vector2 object where to store the result
  81110. * @returns the unmodified current Vector2
  81111. */
  81112. scaleToRef(scale: number, result: Vector2): Vector2;
  81113. /**
  81114. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81115. * @param scale defines the scale factor
  81116. * @param result defines the Vector2 object where to store the result
  81117. * @returns the unmodified current Vector2
  81118. */
  81119. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81120. /**
  81121. * Gets a boolean if two vectors are equals
  81122. * @param otherVector defines the other vector
  81123. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81124. */
  81125. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81126. /**
  81127. * Gets a boolean if two vectors are equals (using an epsilon value)
  81128. * @param otherVector defines the other vector
  81129. * @param epsilon defines the minimal distance to consider equality
  81130. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81131. */
  81132. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81133. /**
  81134. * Gets a new Vector2 from current Vector2 floored values
  81135. * @returns a new Vector2
  81136. */
  81137. floor(): Vector2;
  81138. /**
  81139. * Gets a new Vector2 from current Vector2 floored values
  81140. * @returns a new Vector2
  81141. */
  81142. fract(): Vector2;
  81143. /**
  81144. * Gets the length of the vector
  81145. * @returns the vector length (float)
  81146. */
  81147. length(): number;
  81148. /**
  81149. * Gets the vector squared length
  81150. * @returns the vector squared length (float)
  81151. */
  81152. lengthSquared(): number;
  81153. /**
  81154. * Normalize the vector
  81155. * @returns the current updated Vector2
  81156. */
  81157. normalize(): Vector2;
  81158. /**
  81159. * Gets a new Vector2 copied from the Vector2
  81160. * @returns a new Vector2
  81161. */
  81162. clone(): Vector2;
  81163. /**
  81164. * Gets a new Vector2(0, 0)
  81165. * @returns a new Vector2
  81166. */
  81167. static Zero(): Vector2;
  81168. /**
  81169. * Gets a new Vector2(1, 1)
  81170. * @returns a new Vector2
  81171. */
  81172. static One(): Vector2;
  81173. /**
  81174. * Gets a new Vector2 set from the given index element of the given array
  81175. * @param array defines the data source
  81176. * @param offset defines the offset in the data source
  81177. * @returns a new Vector2
  81178. */
  81179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81180. /**
  81181. * Sets "result" from the given index element of the given array
  81182. * @param array defines the data source
  81183. * @param offset defines the offset in the data source
  81184. * @param result defines the target vector
  81185. */
  81186. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81187. /**
  81188. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81189. * @param value1 defines 1st point of control
  81190. * @param value2 defines 2nd point of control
  81191. * @param value3 defines 3rd point of control
  81192. * @param value4 defines 4th point of control
  81193. * @param amount defines the interpolation factor
  81194. * @returns a new Vector2
  81195. */
  81196. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81197. /**
  81198. * 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".
  81199. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81200. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81201. * @param value defines the value to clamp
  81202. * @param min defines the lower limit
  81203. * @param max defines the upper limit
  81204. * @returns a new Vector2
  81205. */
  81206. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81207. /**
  81208. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81209. * @param value1 defines the 1st control point
  81210. * @param tangent1 defines the outgoing tangent
  81211. * @param value2 defines the 2nd control point
  81212. * @param tangent2 defines the incoming tangent
  81213. * @param amount defines the interpolation factor
  81214. * @returns a new Vector2
  81215. */
  81216. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81217. /**
  81218. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81219. * @param start defines the start vector
  81220. * @param end defines the end vector
  81221. * @param amount defines the interpolation factor
  81222. * @returns a new Vector2
  81223. */
  81224. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81225. /**
  81226. * Gets the dot product of the vector "left" and the vector "right"
  81227. * @param left defines first vector
  81228. * @param right defines second vector
  81229. * @returns the dot product (float)
  81230. */
  81231. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81232. /**
  81233. * Returns a new Vector2 equal to the normalized given vector
  81234. * @param vector defines the vector to normalize
  81235. * @returns a new Vector2
  81236. */
  81237. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81238. /**
  81239. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81240. * @param left defines 1st vector
  81241. * @param right defines 2nd vector
  81242. * @returns a new Vector2
  81243. */
  81244. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81245. /**
  81246. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81247. * @param left defines 1st vector
  81248. * @param right defines 2nd vector
  81249. * @returns a new Vector2
  81250. */
  81251. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81252. /**
  81253. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81254. * @param vector defines the vector to transform
  81255. * @param transformation defines the matrix to apply
  81256. * @returns a new Vector2
  81257. */
  81258. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81259. /**
  81260. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81261. * @param vector defines the vector to transform
  81262. * @param transformation defines the matrix to apply
  81263. * @param result defines the target vector
  81264. */
  81265. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81266. /**
  81267. * Determines if a given vector is included in a triangle
  81268. * @param p defines the vector to test
  81269. * @param p0 defines 1st triangle point
  81270. * @param p1 defines 2nd triangle point
  81271. * @param p2 defines 3rd triangle point
  81272. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81273. */
  81274. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81275. /**
  81276. * Gets the distance between the vectors "value1" and "value2"
  81277. * @param value1 defines first vector
  81278. * @param value2 defines second vector
  81279. * @returns the distance between vectors
  81280. */
  81281. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81282. /**
  81283. * Returns the squared distance between the vectors "value1" and "value2"
  81284. * @param value1 defines first vector
  81285. * @param value2 defines second vector
  81286. * @returns the squared distance between vectors
  81287. */
  81288. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81289. /**
  81290. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81291. * @param value1 defines first vector
  81292. * @param value2 defines second vector
  81293. * @returns a new Vector2
  81294. */
  81295. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81296. /**
  81297. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81298. * @param p defines the middle point
  81299. * @param segA defines one point of the segment
  81300. * @param segB defines the other point of the segment
  81301. * @returns the shortest distance
  81302. */
  81303. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81304. }
  81305. /**
  81306. * Class used to store (x,y,z) vector representation
  81307. * A Vector3 is the main object used in 3D geometry
  81308. * It can represent etiher the coordinates of a point the space, either a direction
  81309. * Reminder: js uses a left handed forward facing system
  81310. */
  81311. export class Vector3 {
  81312. private static _UpReadOnly;
  81313. private static _ZeroReadOnly;
  81314. /** @hidden */
  81315. _x: number;
  81316. /** @hidden */
  81317. _y: number;
  81318. /** @hidden */
  81319. _z: number;
  81320. /** @hidden */
  81321. _isDirty: boolean;
  81322. /** Gets or sets the x coordinate */
  81323. get x(): number;
  81324. set x(value: number);
  81325. /** Gets or sets the y coordinate */
  81326. get y(): number;
  81327. set y(value: number);
  81328. /** Gets or sets the z coordinate */
  81329. get z(): number;
  81330. set z(value: number);
  81331. /**
  81332. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81333. * @param x defines the first coordinates (on X axis)
  81334. * @param y defines the second coordinates (on Y axis)
  81335. * @param z defines the third coordinates (on Z axis)
  81336. */
  81337. constructor(x?: number, y?: number, z?: number);
  81338. /**
  81339. * Creates a string representation of the Vector3
  81340. * @returns a string with the Vector3 coordinates.
  81341. */
  81342. toString(): string;
  81343. /**
  81344. * Gets the class name
  81345. * @returns the string "Vector3"
  81346. */
  81347. getClassName(): string;
  81348. /**
  81349. * Creates the Vector3 hash code
  81350. * @returns a number which tends to be unique between Vector3 instances
  81351. */
  81352. getHashCode(): number;
  81353. /**
  81354. * Creates an array containing three elements : the coordinates of the Vector3
  81355. * @returns a new array of numbers
  81356. */
  81357. asArray(): number[];
  81358. /**
  81359. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81360. * @param array defines the destination array
  81361. * @param index defines the offset in the destination array
  81362. * @returns the current Vector3
  81363. */
  81364. toArray(array: FloatArray, index?: number): Vector3;
  81365. /**
  81366. * Update the current vector from an array
  81367. * @param array defines the destination array
  81368. * @param index defines the offset in the destination array
  81369. * @returns the current Vector3
  81370. */
  81371. fromArray(array: FloatArray, index?: number): Vector3;
  81372. /**
  81373. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81374. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81375. */
  81376. toQuaternion(): Quaternion;
  81377. /**
  81378. * Adds the given vector to the current Vector3
  81379. * @param otherVector defines the second operand
  81380. * @returns the current updated Vector3
  81381. */
  81382. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81383. /**
  81384. * Adds the given coordinates to the current Vector3
  81385. * @param x defines the x coordinate of the operand
  81386. * @param y defines the y coordinate of the operand
  81387. * @param z defines the z coordinate of the operand
  81388. * @returns the current updated Vector3
  81389. */
  81390. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81391. /**
  81392. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81393. * @param otherVector defines the second operand
  81394. * @returns the resulting Vector3
  81395. */
  81396. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81397. /**
  81398. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81399. * @param otherVector defines the second operand
  81400. * @param result defines the Vector3 object where to store the result
  81401. * @returns the current Vector3
  81402. */
  81403. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81404. /**
  81405. * Subtract the given vector from the current Vector3
  81406. * @param otherVector defines the second operand
  81407. * @returns the current updated Vector3
  81408. */
  81409. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81410. /**
  81411. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81412. * @param otherVector defines the second operand
  81413. * @returns the resulting Vector3
  81414. */
  81415. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81416. /**
  81417. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81418. * @param otherVector defines the second operand
  81419. * @param result defines the Vector3 object where to store the result
  81420. * @returns the current Vector3
  81421. */
  81422. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81423. /**
  81424. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81425. * @param x defines the x coordinate of the operand
  81426. * @param y defines the y coordinate of the operand
  81427. * @param z defines the z coordinate of the operand
  81428. * @returns the resulting Vector3
  81429. */
  81430. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81431. /**
  81432. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81433. * @param x defines the x coordinate of the operand
  81434. * @param y defines the y coordinate of the operand
  81435. * @param z defines the z coordinate of the operand
  81436. * @param result defines the Vector3 object where to store the result
  81437. * @returns the current Vector3
  81438. */
  81439. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81440. /**
  81441. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81442. * @returns a new Vector3
  81443. */
  81444. negate(): Vector3;
  81445. /**
  81446. * Negate this vector in place
  81447. * @returns this
  81448. */
  81449. negateInPlace(): Vector3;
  81450. /**
  81451. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81452. * @param result defines the Vector3 object where to store the result
  81453. * @returns the current Vector3
  81454. */
  81455. negateToRef(result: Vector3): Vector3;
  81456. /**
  81457. * Multiplies the Vector3 coordinates by the float "scale"
  81458. * @param scale defines the multiplier factor
  81459. * @returns the current updated Vector3
  81460. */
  81461. scaleInPlace(scale: number): Vector3;
  81462. /**
  81463. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81464. * @param scale defines the multiplier factor
  81465. * @returns a new Vector3
  81466. */
  81467. scale(scale: number): Vector3;
  81468. /**
  81469. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81470. * @param scale defines the multiplier factor
  81471. * @param result defines the Vector3 object where to store the result
  81472. * @returns the current Vector3
  81473. */
  81474. scaleToRef(scale: number, result: Vector3): Vector3;
  81475. /**
  81476. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81477. * @param scale defines the scale factor
  81478. * @param result defines the Vector3 object where to store the result
  81479. * @returns the unmodified current Vector3
  81480. */
  81481. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81482. /**
  81483. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81484. * @param origin defines the origin of the projection ray
  81485. * @param plane defines the plane to project to
  81486. * @returns the projected vector3
  81487. */
  81488. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81489. /**
  81490. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81491. * @param origin defines the origin of the projection ray
  81492. * @param plane defines the plane to project to
  81493. * @param result defines the Vector3 where to store the result
  81494. */
  81495. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81496. /**
  81497. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81498. * @param otherVector defines the second operand
  81499. * @returns true if both vectors are equals
  81500. */
  81501. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81502. /**
  81503. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81504. * @param otherVector defines the second operand
  81505. * @param epsilon defines the minimal distance to define values as equals
  81506. * @returns true if both vectors are distant less than epsilon
  81507. */
  81508. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81509. /**
  81510. * Returns true if the current Vector3 coordinates equals the given floats
  81511. * @param x defines the x coordinate of the operand
  81512. * @param y defines the y coordinate of the operand
  81513. * @param z defines the z coordinate of the operand
  81514. * @returns true if both vectors are equals
  81515. */
  81516. equalsToFloats(x: number, y: number, z: number): boolean;
  81517. /**
  81518. * Multiplies the current Vector3 coordinates by the given ones
  81519. * @param otherVector defines the second operand
  81520. * @returns the current updated Vector3
  81521. */
  81522. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81523. /**
  81524. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81525. * @param otherVector defines the second operand
  81526. * @returns the new Vector3
  81527. */
  81528. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81529. /**
  81530. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81531. * @param otherVector defines the second operand
  81532. * @param result defines the Vector3 object where to store the result
  81533. * @returns the current Vector3
  81534. */
  81535. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81536. /**
  81537. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81538. * @param x defines the x coordinate of the operand
  81539. * @param y defines the y coordinate of the operand
  81540. * @param z defines the z coordinate of the operand
  81541. * @returns the new Vector3
  81542. */
  81543. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81544. /**
  81545. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81546. * @param otherVector defines the second operand
  81547. * @returns the new Vector3
  81548. */
  81549. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81550. /**
  81551. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81552. * @param otherVector defines the second operand
  81553. * @param result defines the Vector3 object where to store the result
  81554. * @returns the current Vector3
  81555. */
  81556. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81557. /**
  81558. * Divides the current Vector3 coordinates by the given ones.
  81559. * @param otherVector defines the second operand
  81560. * @returns the current updated Vector3
  81561. */
  81562. divideInPlace(otherVector: Vector3): Vector3;
  81563. /**
  81564. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81565. * @param other defines the second operand
  81566. * @returns the current updated Vector3
  81567. */
  81568. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81569. /**
  81570. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81571. * @param other defines the second operand
  81572. * @returns the current updated Vector3
  81573. */
  81574. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81575. /**
  81576. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81577. * @param x defines the x coordinate of the operand
  81578. * @param y defines the y coordinate of the operand
  81579. * @param z defines the z coordinate of the operand
  81580. * @returns the current updated Vector3
  81581. */
  81582. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81583. /**
  81584. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81585. * @param x defines the x coordinate of the operand
  81586. * @param y defines the y coordinate of the operand
  81587. * @param z defines the z coordinate of the operand
  81588. * @returns the current updated Vector3
  81589. */
  81590. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81591. /**
  81592. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81593. * Check if is non uniform within a certain amount of decimal places to account for this
  81594. * @param epsilon the amount the values can differ
  81595. * @returns if the the vector is non uniform to a certain number of decimal places
  81596. */
  81597. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81598. /**
  81599. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81600. */
  81601. get isNonUniform(): boolean;
  81602. /**
  81603. * Gets a new Vector3 from current Vector3 floored values
  81604. * @returns a new Vector3
  81605. */
  81606. floor(): Vector3;
  81607. /**
  81608. * Gets a new Vector3 from current Vector3 floored values
  81609. * @returns a new Vector3
  81610. */
  81611. fract(): Vector3;
  81612. /**
  81613. * Gets the length of the Vector3
  81614. * @returns the length of the Vector3
  81615. */
  81616. length(): number;
  81617. /**
  81618. * Gets the squared length of the Vector3
  81619. * @returns squared length of the Vector3
  81620. */
  81621. lengthSquared(): number;
  81622. /**
  81623. * Normalize the current Vector3.
  81624. * Please note that this is an in place operation.
  81625. * @returns the current updated Vector3
  81626. */
  81627. normalize(): Vector3;
  81628. /**
  81629. * Reorders the x y z properties of the vector in place
  81630. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81631. * @returns the current updated vector
  81632. */
  81633. reorderInPlace(order: string): this;
  81634. /**
  81635. * Rotates the vector around 0,0,0 by a quaternion
  81636. * @param quaternion the rotation quaternion
  81637. * @param result vector to store the result
  81638. * @returns the resulting vector
  81639. */
  81640. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81641. /**
  81642. * Rotates a vector around a given point
  81643. * @param quaternion the rotation quaternion
  81644. * @param point the point to rotate around
  81645. * @param result vector to store the result
  81646. * @returns the resulting vector
  81647. */
  81648. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81649. /**
  81650. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81651. * The cross product is then orthogonal to both current and "other"
  81652. * @param other defines the right operand
  81653. * @returns the cross product
  81654. */
  81655. cross(other: Vector3): Vector3;
  81656. /**
  81657. * Normalize the current Vector3 with the given input length.
  81658. * Please note that this is an in place operation.
  81659. * @param len the length of the vector
  81660. * @returns the current updated Vector3
  81661. */
  81662. normalizeFromLength(len: number): Vector3;
  81663. /**
  81664. * Normalize the current Vector3 to a new vector
  81665. * @returns the new Vector3
  81666. */
  81667. normalizeToNew(): Vector3;
  81668. /**
  81669. * Normalize the current Vector3 to the reference
  81670. * @param reference define the Vector3 to update
  81671. * @returns the updated Vector3
  81672. */
  81673. normalizeToRef(reference: Vector3): Vector3;
  81674. /**
  81675. * Creates a new Vector3 copied from the current Vector3
  81676. * @returns the new Vector3
  81677. */
  81678. clone(): Vector3;
  81679. /**
  81680. * Copies the given vector coordinates to the current Vector3 ones
  81681. * @param source defines the source Vector3
  81682. * @returns the current updated Vector3
  81683. */
  81684. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81685. /**
  81686. * Copies the given floats to the current Vector3 coordinates
  81687. * @param x defines the x coordinate of the operand
  81688. * @param y defines the y coordinate of the operand
  81689. * @param z defines the z coordinate of the operand
  81690. * @returns the current updated Vector3
  81691. */
  81692. copyFromFloats(x: number, y: number, z: number): Vector3;
  81693. /**
  81694. * Copies the given floats to the current Vector3 coordinates
  81695. * @param x defines the x coordinate of the operand
  81696. * @param y defines the y coordinate of the operand
  81697. * @param z defines the z coordinate of the operand
  81698. * @returns the current updated Vector3
  81699. */
  81700. set(x: number, y: number, z: number): Vector3;
  81701. /**
  81702. * Copies the given float to the current Vector3 coordinates
  81703. * @param v defines the x, y and z coordinates of the operand
  81704. * @returns the current updated Vector3
  81705. */
  81706. setAll(v: number): Vector3;
  81707. /**
  81708. * Get the clip factor between two vectors
  81709. * @param vector0 defines the first operand
  81710. * @param vector1 defines the second operand
  81711. * @param axis defines the axis to use
  81712. * @param size defines the size along the axis
  81713. * @returns the clip factor
  81714. */
  81715. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81716. /**
  81717. * Get angle between two vectors
  81718. * @param vector0 angle between vector0 and vector1
  81719. * @param vector1 angle between vector0 and vector1
  81720. * @param normal direction of the normal
  81721. * @return the angle between vector0 and vector1
  81722. */
  81723. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81724. /**
  81725. * Returns a new Vector3 set from the index "offset" of the given array
  81726. * @param array defines the source array
  81727. * @param offset defines the offset in the source array
  81728. * @returns the new Vector3
  81729. */
  81730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81731. /**
  81732. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81733. * @param array defines the source array
  81734. * @param offset defines the offset in the source array
  81735. * @returns the new Vector3
  81736. * @deprecated Please use FromArray instead.
  81737. */
  81738. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81739. /**
  81740. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81741. * @param array defines the source array
  81742. * @param offset defines the offset in the source array
  81743. * @param result defines the Vector3 where to store the result
  81744. */
  81745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81746. /**
  81747. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81748. * @param array defines the source array
  81749. * @param offset defines the offset in the source array
  81750. * @param result defines the Vector3 where to store the result
  81751. * @deprecated Please use FromArrayToRef instead.
  81752. */
  81753. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81754. /**
  81755. * Sets the given vector "result" with the given floats.
  81756. * @param x defines the x coordinate of the source
  81757. * @param y defines the y coordinate of the source
  81758. * @param z defines the z coordinate of the source
  81759. * @param result defines the Vector3 where to store the result
  81760. */
  81761. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81762. /**
  81763. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81764. * @returns a new empty Vector3
  81765. */
  81766. static Zero(): Vector3;
  81767. /**
  81768. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81769. * @returns a new unit Vector3
  81770. */
  81771. static One(): Vector3;
  81772. /**
  81773. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81774. * @returns a new up Vector3
  81775. */
  81776. static Up(): Vector3;
  81777. /**
  81778. * Gets a up Vector3 that must not be updated
  81779. */
  81780. static get UpReadOnly(): DeepImmutable<Vector3>;
  81781. /**
  81782. * Gets a zero Vector3 that must not be updated
  81783. */
  81784. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81785. /**
  81786. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81787. * @returns a new down Vector3
  81788. */
  81789. static Down(): Vector3;
  81790. /**
  81791. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81792. * @param rightHandedSystem is the scene right-handed (negative z)
  81793. * @returns a new forward Vector3
  81794. */
  81795. static Forward(rightHandedSystem?: boolean): Vector3;
  81796. /**
  81797. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81798. * @param rightHandedSystem is the scene right-handed (negative-z)
  81799. * @returns a new forward Vector3
  81800. */
  81801. static Backward(rightHandedSystem?: boolean): Vector3;
  81802. /**
  81803. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81804. * @returns a new right Vector3
  81805. */
  81806. static Right(): Vector3;
  81807. /**
  81808. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81809. * @returns a new left Vector3
  81810. */
  81811. static Left(): Vector3;
  81812. /**
  81813. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81814. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81815. * @param vector defines the Vector3 to transform
  81816. * @param transformation defines the transformation matrix
  81817. * @returns the transformed Vector3
  81818. */
  81819. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81820. /**
  81821. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81822. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81823. * @param vector defines the Vector3 to transform
  81824. * @param transformation defines the transformation matrix
  81825. * @param result defines the Vector3 where to store the result
  81826. */
  81827. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81828. /**
  81829. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81830. * This method computes tranformed coordinates only, not transformed direction vectors
  81831. * @param x define the x coordinate of the source vector
  81832. * @param y define the y coordinate of the source vector
  81833. * @param z define the z coordinate of the source vector
  81834. * @param transformation defines the transformation matrix
  81835. * @param result defines the Vector3 where to store the result
  81836. */
  81837. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81838. /**
  81839. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81840. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81841. * @param vector defines the Vector3 to transform
  81842. * @param transformation defines the transformation matrix
  81843. * @returns the new Vector3
  81844. */
  81845. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81846. /**
  81847. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81848. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81849. * @param vector defines the Vector3 to transform
  81850. * @param transformation defines the transformation matrix
  81851. * @param result defines the Vector3 where to store the result
  81852. */
  81853. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81854. /**
  81855. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81856. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81857. * @param x define the x coordinate of the source vector
  81858. * @param y define the y coordinate of the source vector
  81859. * @param z define the z coordinate of the source vector
  81860. * @param transformation defines the transformation matrix
  81861. * @param result defines the Vector3 where to store the result
  81862. */
  81863. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81864. /**
  81865. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81866. * @param value1 defines the first control point
  81867. * @param value2 defines the second control point
  81868. * @param value3 defines the third control point
  81869. * @param value4 defines the fourth control point
  81870. * @param amount defines the amount on the spline to use
  81871. * @returns the new Vector3
  81872. */
  81873. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81874. /**
  81875. * 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"
  81876. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81877. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81878. * @param value defines the current value
  81879. * @param min defines the lower range value
  81880. * @param max defines the upper range value
  81881. * @returns the new Vector3
  81882. */
  81883. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81884. /**
  81885. * 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"
  81886. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81887. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81888. * @param value defines the current value
  81889. * @param min defines the lower range value
  81890. * @param max defines the upper range value
  81891. * @param result defines the Vector3 where to store the result
  81892. */
  81893. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81894. /**
  81895. * Checks if a given vector is inside a specific range
  81896. * @param v defines the vector to test
  81897. * @param min defines the minimum range
  81898. * @param max defines the maximum range
  81899. */
  81900. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81901. /**
  81902. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81903. * @param value1 defines the first control point
  81904. * @param tangent1 defines the first tangent vector
  81905. * @param value2 defines the second control point
  81906. * @param tangent2 defines the second tangent vector
  81907. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81908. * @returns the new Vector3
  81909. */
  81910. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81911. /**
  81912. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81913. * @param start defines the start value
  81914. * @param end defines the end value
  81915. * @param amount max defines amount between both (between 0 and 1)
  81916. * @returns the new Vector3
  81917. */
  81918. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81919. /**
  81920. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81921. * @param start defines the start value
  81922. * @param end defines the end value
  81923. * @param amount max defines amount between both (between 0 and 1)
  81924. * @param result defines the Vector3 where to store the result
  81925. */
  81926. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81927. /**
  81928. * Returns the dot product (float) between the vectors "left" and "right"
  81929. * @param left defines the left operand
  81930. * @param right defines the right operand
  81931. * @returns the dot product
  81932. */
  81933. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81934. /**
  81935. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81936. * The cross product is then orthogonal to both "left" and "right"
  81937. * @param left defines the left operand
  81938. * @param right defines the right operand
  81939. * @returns the cross product
  81940. */
  81941. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81942. /**
  81943. * Sets the given vector "result" with the cross product of "left" and "right"
  81944. * The cross product is then orthogonal to both "left" and "right"
  81945. * @param left defines the left operand
  81946. * @param right defines the right operand
  81947. * @param result defines the Vector3 where to store the result
  81948. */
  81949. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81950. /**
  81951. * Returns a new Vector3 as the normalization of the given vector
  81952. * @param vector defines the Vector3 to normalize
  81953. * @returns the new Vector3
  81954. */
  81955. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81956. /**
  81957. * Sets the given vector "result" with the normalization of the given first vector
  81958. * @param vector defines the Vector3 to normalize
  81959. * @param result defines the Vector3 where to store the result
  81960. */
  81961. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81962. /**
  81963. * Project a Vector3 onto screen space
  81964. * @param vector defines the Vector3 to project
  81965. * @param world defines the world matrix to use
  81966. * @param transform defines the transform (view x projection) matrix to use
  81967. * @param viewport defines the screen viewport to use
  81968. * @returns the new Vector3
  81969. */
  81970. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81971. /** @hidden */
  81972. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81973. /**
  81974. * Unproject from screen space to object space
  81975. * @param source defines the screen space Vector3 to use
  81976. * @param viewportWidth defines the current width of the viewport
  81977. * @param viewportHeight defines the current height of the viewport
  81978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81979. * @param transform defines the transform (view x projection) matrix to use
  81980. * @returns the new Vector3
  81981. */
  81982. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81983. /**
  81984. * Unproject from screen space to object space
  81985. * @param source defines the screen space Vector3 to use
  81986. * @param viewportWidth defines the current width of the viewport
  81987. * @param viewportHeight defines the current height of the viewport
  81988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81989. * @param view defines the view matrix to use
  81990. * @param projection defines the projection matrix to use
  81991. * @returns the new Vector3
  81992. */
  81993. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81994. /**
  81995. * Unproject from screen space to object space
  81996. * @param source defines the screen space Vector3 to use
  81997. * @param viewportWidth defines the current width of the viewport
  81998. * @param viewportHeight defines the current height of the viewport
  81999. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82000. * @param view defines the view matrix to use
  82001. * @param projection defines the projection matrix to use
  82002. * @param result defines the Vector3 where to store the result
  82003. */
  82004. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82005. /**
  82006. * Unproject from screen space to object space
  82007. * @param sourceX defines the screen space x coordinate to use
  82008. * @param sourceY defines the screen space y coordinate to use
  82009. * @param sourceZ defines the screen space z coordinate to use
  82010. * @param viewportWidth defines the current width of the viewport
  82011. * @param viewportHeight defines the current height of the viewport
  82012. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82013. * @param view defines the view matrix to use
  82014. * @param projection defines the projection matrix to use
  82015. * @param result defines the Vector3 where to store the result
  82016. */
  82017. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82018. /**
  82019. * Gets the minimal coordinate values between two Vector3
  82020. * @param left defines the first operand
  82021. * @param right defines the second operand
  82022. * @returns the new Vector3
  82023. */
  82024. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82025. /**
  82026. * Gets the maximal coordinate values between two Vector3
  82027. * @param left defines the first operand
  82028. * @param right defines the second operand
  82029. * @returns the new Vector3
  82030. */
  82031. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82032. /**
  82033. * Returns the distance between the vectors "value1" and "value2"
  82034. * @param value1 defines the first operand
  82035. * @param value2 defines the second operand
  82036. * @returns the distance
  82037. */
  82038. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82039. /**
  82040. * Returns the squared distance between the vectors "value1" and "value2"
  82041. * @param value1 defines the first operand
  82042. * @param value2 defines the second operand
  82043. * @returns the squared distance
  82044. */
  82045. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82046. /**
  82047. * Returns a new Vector3 located at the center between "value1" and "value2"
  82048. * @param value1 defines the first operand
  82049. * @param value2 defines the second operand
  82050. * @returns the new Vector3
  82051. */
  82052. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82053. /**
  82054. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82055. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82056. * to something in order to rotate it from its local system to the given target system
  82057. * Note: axis1, axis2 and axis3 are normalized during this operation
  82058. * @param axis1 defines the first axis
  82059. * @param axis2 defines the second axis
  82060. * @param axis3 defines the third axis
  82061. * @returns a new Vector3
  82062. */
  82063. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82064. /**
  82065. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82066. * @param axis1 defines the first axis
  82067. * @param axis2 defines the second axis
  82068. * @param axis3 defines the third axis
  82069. * @param ref defines the Vector3 where to store the result
  82070. */
  82071. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82072. }
  82073. /**
  82074. * Vector4 class created for EulerAngle class conversion to Quaternion
  82075. */
  82076. export class Vector4 {
  82077. /** x value of the vector */
  82078. x: number;
  82079. /** y value of the vector */
  82080. y: number;
  82081. /** z value of the vector */
  82082. z: number;
  82083. /** w value of the vector */
  82084. w: number;
  82085. /**
  82086. * Creates a Vector4 object from the given floats.
  82087. * @param x x value of the vector
  82088. * @param y y value of the vector
  82089. * @param z z value of the vector
  82090. * @param w w value of the vector
  82091. */
  82092. constructor(
  82093. /** x value of the vector */
  82094. x: number,
  82095. /** y value of the vector */
  82096. y: number,
  82097. /** z value of the vector */
  82098. z: number,
  82099. /** w value of the vector */
  82100. w: number);
  82101. /**
  82102. * Returns the string with the Vector4 coordinates.
  82103. * @returns a string containing all the vector values
  82104. */
  82105. toString(): string;
  82106. /**
  82107. * Returns the string "Vector4".
  82108. * @returns "Vector4"
  82109. */
  82110. getClassName(): string;
  82111. /**
  82112. * Returns the Vector4 hash code.
  82113. * @returns a unique hash code
  82114. */
  82115. getHashCode(): number;
  82116. /**
  82117. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82118. * @returns the resulting array
  82119. */
  82120. asArray(): number[];
  82121. /**
  82122. * Populates the given array from the given index with the Vector4 coordinates.
  82123. * @param array array to populate
  82124. * @param index index of the array to start at (default: 0)
  82125. * @returns the Vector4.
  82126. */
  82127. toArray(array: FloatArray, index?: number): Vector4;
  82128. /**
  82129. * Update the current vector from an array
  82130. * @param array defines the destination array
  82131. * @param index defines the offset in the destination array
  82132. * @returns the current Vector3
  82133. */
  82134. fromArray(array: FloatArray, index?: number): Vector4;
  82135. /**
  82136. * Adds the given vector to the current Vector4.
  82137. * @param otherVector the vector to add
  82138. * @returns the updated Vector4.
  82139. */
  82140. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82141. /**
  82142. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82143. * @param otherVector the vector to add
  82144. * @returns the resulting vector
  82145. */
  82146. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82147. /**
  82148. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82149. * @param otherVector the vector to add
  82150. * @param result the vector to store the result
  82151. * @returns the current Vector4.
  82152. */
  82153. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82154. /**
  82155. * Subtract in place the given vector from the current Vector4.
  82156. * @param otherVector the vector to subtract
  82157. * @returns the updated Vector4.
  82158. */
  82159. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82160. /**
  82161. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82162. * @param otherVector the vector to add
  82163. * @returns the new vector with the result
  82164. */
  82165. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82166. /**
  82167. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82168. * @param otherVector the vector to subtract
  82169. * @param result the vector to store the result
  82170. * @returns the current Vector4.
  82171. */
  82172. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82173. /**
  82174. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82175. */
  82176. /**
  82177. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82178. * @param x value to subtract
  82179. * @param y value to subtract
  82180. * @param z value to subtract
  82181. * @param w value to subtract
  82182. * @returns new vector containing the result
  82183. */
  82184. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82185. /**
  82186. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82187. * @param x value to subtract
  82188. * @param y value to subtract
  82189. * @param z value to subtract
  82190. * @param w value to subtract
  82191. * @param result the vector to store the result in
  82192. * @returns the current Vector4.
  82193. */
  82194. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82195. /**
  82196. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82197. * @returns a new vector with the negated values
  82198. */
  82199. negate(): Vector4;
  82200. /**
  82201. * Negate this vector in place
  82202. * @returns this
  82203. */
  82204. negateInPlace(): Vector4;
  82205. /**
  82206. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82207. * @param result defines the Vector3 object where to store the result
  82208. * @returns the current Vector4
  82209. */
  82210. negateToRef(result: Vector4): Vector4;
  82211. /**
  82212. * Multiplies the current Vector4 coordinates by scale (float).
  82213. * @param scale the number to scale with
  82214. * @returns the updated Vector4.
  82215. */
  82216. scaleInPlace(scale: number): Vector4;
  82217. /**
  82218. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82219. * @param scale the number to scale with
  82220. * @returns a new vector with the result
  82221. */
  82222. scale(scale: number): Vector4;
  82223. /**
  82224. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82225. * @param scale the number to scale with
  82226. * @param result a vector to store the result in
  82227. * @returns the current Vector4.
  82228. */
  82229. scaleToRef(scale: number, result: Vector4): Vector4;
  82230. /**
  82231. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82232. * @param scale defines the scale factor
  82233. * @param result defines the Vector4 object where to store the result
  82234. * @returns the unmodified current Vector4
  82235. */
  82236. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82237. /**
  82238. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82239. * @param otherVector the vector to compare against
  82240. * @returns true if they are equal
  82241. */
  82242. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82243. /**
  82244. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82245. * @param otherVector vector to compare against
  82246. * @param epsilon (Default: very small number)
  82247. * @returns true if they are equal
  82248. */
  82249. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82250. /**
  82251. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82252. * @param x x value to compare against
  82253. * @param y y value to compare against
  82254. * @param z z value to compare against
  82255. * @param w w value to compare against
  82256. * @returns true if equal
  82257. */
  82258. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82259. /**
  82260. * Multiplies in place the current Vector4 by the given one.
  82261. * @param otherVector vector to multiple with
  82262. * @returns the updated Vector4.
  82263. */
  82264. multiplyInPlace(otherVector: Vector4): Vector4;
  82265. /**
  82266. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82267. * @param otherVector vector to multiple with
  82268. * @returns resulting new vector
  82269. */
  82270. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82271. /**
  82272. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82273. * @param otherVector vector to multiple with
  82274. * @param result vector to store the result
  82275. * @returns the current Vector4.
  82276. */
  82277. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82278. /**
  82279. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82280. * @param x x value multiply with
  82281. * @param y y value multiply with
  82282. * @param z z value multiply with
  82283. * @param w w value multiply with
  82284. * @returns resulting new vector
  82285. */
  82286. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82287. /**
  82288. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82289. * @param otherVector vector to devide with
  82290. * @returns resulting new vector
  82291. */
  82292. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82293. /**
  82294. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82295. * @param otherVector vector to devide with
  82296. * @param result vector to store the result
  82297. * @returns the current Vector4.
  82298. */
  82299. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82300. /**
  82301. * Divides the current Vector3 coordinates by the given ones.
  82302. * @param otherVector vector to devide with
  82303. * @returns the updated Vector3.
  82304. */
  82305. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82306. /**
  82307. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82308. * @param other defines the second operand
  82309. * @returns the current updated Vector4
  82310. */
  82311. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82312. /**
  82313. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82314. * @param other defines the second operand
  82315. * @returns the current updated Vector4
  82316. */
  82317. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82318. /**
  82319. * Gets a new Vector4 from current Vector4 floored values
  82320. * @returns a new Vector4
  82321. */
  82322. floor(): Vector4;
  82323. /**
  82324. * Gets a new Vector4 from current Vector3 floored values
  82325. * @returns a new Vector4
  82326. */
  82327. fract(): Vector4;
  82328. /**
  82329. * Returns the Vector4 length (float).
  82330. * @returns the length
  82331. */
  82332. length(): number;
  82333. /**
  82334. * Returns the Vector4 squared length (float).
  82335. * @returns the length squared
  82336. */
  82337. lengthSquared(): number;
  82338. /**
  82339. * Normalizes in place the Vector4.
  82340. * @returns the updated Vector4.
  82341. */
  82342. normalize(): Vector4;
  82343. /**
  82344. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82345. * @returns this converted to a new vector3
  82346. */
  82347. toVector3(): Vector3;
  82348. /**
  82349. * Returns a new Vector4 copied from the current one.
  82350. * @returns the new cloned vector
  82351. */
  82352. clone(): Vector4;
  82353. /**
  82354. * Updates the current Vector4 with the given one coordinates.
  82355. * @param source the source vector to copy from
  82356. * @returns the updated Vector4.
  82357. */
  82358. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82359. /**
  82360. * Updates the current Vector4 coordinates with the given floats.
  82361. * @param x float to copy from
  82362. * @param y float to copy from
  82363. * @param z float to copy from
  82364. * @param w float to copy from
  82365. * @returns the updated Vector4.
  82366. */
  82367. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82368. /**
  82369. * Updates the current Vector4 coordinates with the given floats.
  82370. * @param x float to set from
  82371. * @param y float to set from
  82372. * @param z float to set from
  82373. * @param w float to set from
  82374. * @returns the updated Vector4.
  82375. */
  82376. set(x: number, y: number, z: number, w: number): Vector4;
  82377. /**
  82378. * Copies the given float to the current Vector3 coordinates
  82379. * @param v defines the x, y, z and w coordinates of the operand
  82380. * @returns the current updated Vector3
  82381. */
  82382. setAll(v: number): Vector4;
  82383. /**
  82384. * Returns a new Vector4 set from the starting index of the given array.
  82385. * @param array the array to pull values from
  82386. * @param offset the offset into the array to start at
  82387. * @returns the new vector
  82388. */
  82389. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82390. /**
  82391. * Updates the given vector "result" from the starting index of the given array.
  82392. * @param array the array to pull values from
  82393. * @param offset the offset into the array to start at
  82394. * @param result the vector to store the result in
  82395. */
  82396. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82397. /**
  82398. * Updates the given vector "result" from the starting index of the given Float32Array.
  82399. * @param array the array to pull values from
  82400. * @param offset the offset into the array to start at
  82401. * @param result the vector to store the result in
  82402. */
  82403. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82404. /**
  82405. * Updates the given vector "result" coordinates from the given floats.
  82406. * @param x float to set from
  82407. * @param y float to set from
  82408. * @param z float to set from
  82409. * @param w float to set from
  82410. * @param result the vector to the floats in
  82411. */
  82412. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82413. /**
  82414. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82415. * @returns the new vector
  82416. */
  82417. static Zero(): Vector4;
  82418. /**
  82419. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82420. * @returns the new vector
  82421. */
  82422. static One(): Vector4;
  82423. /**
  82424. * Returns a new normalized Vector4 from the given one.
  82425. * @param vector the vector to normalize
  82426. * @returns the vector
  82427. */
  82428. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82429. /**
  82430. * Updates the given vector "result" from the normalization of the given one.
  82431. * @param vector the vector to normalize
  82432. * @param result the vector to store the result in
  82433. */
  82434. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82435. /**
  82436. * Returns a vector with the minimum values from the left and right vectors
  82437. * @param left left vector to minimize
  82438. * @param right right vector to minimize
  82439. * @returns a new vector with the minimum of the left and right vector values
  82440. */
  82441. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82442. /**
  82443. * Returns a vector with the maximum values from the left and right vectors
  82444. * @param left left vector to maximize
  82445. * @param right right vector to maximize
  82446. * @returns a new vector with the maximum of the left and right vector values
  82447. */
  82448. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82449. /**
  82450. * Returns the distance (float) between the vectors "value1" and "value2".
  82451. * @param value1 value to calulate the distance between
  82452. * @param value2 value to calulate the distance between
  82453. * @return the distance between the two vectors
  82454. */
  82455. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82456. /**
  82457. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82458. * @param value1 value to calulate the distance between
  82459. * @param value2 value to calulate the distance between
  82460. * @return the distance between the two vectors squared
  82461. */
  82462. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82463. /**
  82464. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82465. * @param value1 value to calulate the center between
  82466. * @param value2 value to calulate the center between
  82467. * @return the center between the two vectors
  82468. */
  82469. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82470. /**
  82471. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82472. * This methods computes transformed normalized direction vectors only.
  82473. * @param vector the vector to transform
  82474. * @param transformation the transformation matrix to apply
  82475. * @returns the new vector
  82476. */
  82477. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82478. /**
  82479. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82480. * This methods computes transformed normalized direction vectors only.
  82481. * @param vector the vector to transform
  82482. * @param transformation the transformation matrix to apply
  82483. * @param result the vector to store the result in
  82484. */
  82485. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82486. /**
  82487. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82488. * This methods computes transformed normalized direction vectors only.
  82489. * @param x value to transform
  82490. * @param y value to transform
  82491. * @param z value to transform
  82492. * @param w value to transform
  82493. * @param transformation the transformation matrix to apply
  82494. * @param result the vector to store the results in
  82495. */
  82496. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82497. /**
  82498. * Creates a new Vector4 from a Vector3
  82499. * @param source defines the source data
  82500. * @param w defines the 4th component (default is 0)
  82501. * @returns a new Vector4
  82502. */
  82503. static FromVector3(source: Vector3, w?: number): Vector4;
  82504. }
  82505. /**
  82506. * Class used to store quaternion data
  82507. * @see https://en.wikipedia.org/wiki/Quaternion
  82508. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82509. */
  82510. export class Quaternion {
  82511. /** @hidden */
  82512. _x: number;
  82513. /** @hidden */
  82514. _y: number;
  82515. /** @hidden */
  82516. _z: number;
  82517. /** @hidden */
  82518. _w: number;
  82519. /** @hidden */
  82520. _isDirty: boolean;
  82521. /** Gets or sets the x coordinate */
  82522. get x(): number;
  82523. set x(value: number);
  82524. /** Gets or sets the y coordinate */
  82525. get y(): number;
  82526. set y(value: number);
  82527. /** Gets or sets the z coordinate */
  82528. get z(): number;
  82529. set z(value: number);
  82530. /** Gets or sets the w coordinate */
  82531. get w(): number;
  82532. set w(value: number);
  82533. /**
  82534. * Creates a new Quaternion from the given floats
  82535. * @param x defines the first component (0 by default)
  82536. * @param y defines the second component (0 by default)
  82537. * @param z defines the third component (0 by default)
  82538. * @param w defines the fourth component (1.0 by default)
  82539. */
  82540. constructor(x?: number, y?: number, z?: number, w?: number);
  82541. /**
  82542. * Gets a string representation for the current quaternion
  82543. * @returns a string with the Quaternion coordinates
  82544. */
  82545. toString(): string;
  82546. /**
  82547. * Gets the class name of the quaternion
  82548. * @returns the string "Quaternion"
  82549. */
  82550. getClassName(): string;
  82551. /**
  82552. * Gets a hash code for this quaternion
  82553. * @returns the quaternion hash code
  82554. */
  82555. getHashCode(): number;
  82556. /**
  82557. * Copy the quaternion to an array
  82558. * @returns a new array populated with 4 elements from the quaternion coordinates
  82559. */
  82560. asArray(): number[];
  82561. /**
  82562. * Check if two quaternions are equals
  82563. * @param otherQuaternion defines the second operand
  82564. * @return true if the current quaternion and the given one coordinates are strictly equals
  82565. */
  82566. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82567. /**
  82568. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82569. * @param otherQuaternion defines the other quaternion
  82570. * @param epsilon defines the minimal distance to consider equality
  82571. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82572. */
  82573. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82574. /**
  82575. * Clone the current quaternion
  82576. * @returns a new quaternion copied from the current one
  82577. */
  82578. clone(): Quaternion;
  82579. /**
  82580. * Copy a quaternion to the current one
  82581. * @param other defines the other quaternion
  82582. * @returns the updated current quaternion
  82583. */
  82584. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82585. /**
  82586. * Updates the current quaternion with the given float coordinates
  82587. * @param x defines the x coordinate
  82588. * @param y defines the y coordinate
  82589. * @param z defines the z coordinate
  82590. * @param w defines the w coordinate
  82591. * @returns the updated current quaternion
  82592. */
  82593. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82594. /**
  82595. * Updates the current quaternion from the given float coordinates
  82596. * @param x defines the x coordinate
  82597. * @param y defines the y coordinate
  82598. * @param z defines the z coordinate
  82599. * @param w defines the w coordinate
  82600. * @returns the updated current quaternion
  82601. */
  82602. set(x: number, y: number, z: number, w: number): Quaternion;
  82603. /**
  82604. * Adds two quaternions
  82605. * @param other defines the second operand
  82606. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82607. */
  82608. add(other: DeepImmutable<Quaternion>): Quaternion;
  82609. /**
  82610. * Add a quaternion to the current one
  82611. * @param other defines the quaternion to add
  82612. * @returns the current quaternion
  82613. */
  82614. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82615. /**
  82616. * Subtract two quaternions
  82617. * @param other defines the second operand
  82618. * @returns a new quaternion as the subtraction result of the given one from the current one
  82619. */
  82620. subtract(other: Quaternion): Quaternion;
  82621. /**
  82622. * Multiplies the current quaternion by a scale factor
  82623. * @param value defines the scale factor
  82624. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82625. */
  82626. scale(value: number): Quaternion;
  82627. /**
  82628. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82629. * @param scale defines the scale factor
  82630. * @param result defines the Quaternion object where to store the result
  82631. * @returns the unmodified current quaternion
  82632. */
  82633. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82634. /**
  82635. * Multiplies in place the current quaternion by a scale factor
  82636. * @param value defines the scale factor
  82637. * @returns the current modified quaternion
  82638. */
  82639. scaleInPlace(value: number): Quaternion;
  82640. /**
  82641. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82642. * @param scale defines the scale factor
  82643. * @param result defines the Quaternion object where to store the result
  82644. * @returns the unmodified current quaternion
  82645. */
  82646. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82647. /**
  82648. * Multiplies two quaternions
  82649. * @param q1 defines the second operand
  82650. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82651. */
  82652. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82653. /**
  82654. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82655. * @param q1 defines the second operand
  82656. * @param result defines the target quaternion
  82657. * @returns the current quaternion
  82658. */
  82659. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82660. /**
  82661. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82662. * @param q1 defines the second operand
  82663. * @returns the currentupdated quaternion
  82664. */
  82665. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82666. /**
  82667. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82668. * @param ref defines the target quaternion
  82669. * @returns the current quaternion
  82670. */
  82671. conjugateToRef(ref: Quaternion): Quaternion;
  82672. /**
  82673. * Conjugates in place (1-q) the current quaternion
  82674. * @returns the current updated quaternion
  82675. */
  82676. conjugateInPlace(): Quaternion;
  82677. /**
  82678. * Conjugates in place (1-q) the current quaternion
  82679. * @returns a new quaternion
  82680. */
  82681. conjugate(): Quaternion;
  82682. /**
  82683. * Gets length of current quaternion
  82684. * @returns the quaternion length (float)
  82685. */
  82686. length(): number;
  82687. /**
  82688. * Normalize in place the current quaternion
  82689. * @returns the current updated quaternion
  82690. */
  82691. normalize(): Quaternion;
  82692. /**
  82693. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82694. * @param order is a reserved parameter and is ignore for now
  82695. * @returns a new Vector3 containing the Euler angles
  82696. */
  82697. toEulerAngles(order?: string): Vector3;
  82698. /**
  82699. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82700. * @param result defines the vector which will be filled with the Euler angles
  82701. * @param order is a reserved parameter and is ignore for now
  82702. * @returns the current unchanged quaternion
  82703. */
  82704. toEulerAnglesToRef(result: Vector3): Quaternion;
  82705. /**
  82706. * Updates the given rotation matrix with the current quaternion values
  82707. * @param result defines the target matrix
  82708. * @returns the current unchanged quaternion
  82709. */
  82710. toRotationMatrix(result: Matrix): Quaternion;
  82711. /**
  82712. * Updates the current quaternion from the given rotation matrix values
  82713. * @param matrix defines the source matrix
  82714. * @returns the current updated quaternion
  82715. */
  82716. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82717. /**
  82718. * Creates a new quaternion from a rotation matrix
  82719. * @param matrix defines the source matrix
  82720. * @returns a new quaternion created from the given rotation matrix values
  82721. */
  82722. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82723. /**
  82724. * Updates the given quaternion with the given rotation matrix values
  82725. * @param matrix defines the source matrix
  82726. * @param result defines the target quaternion
  82727. */
  82728. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82729. /**
  82730. * Returns the dot product (float) between the quaternions "left" and "right"
  82731. * @param left defines the left operand
  82732. * @param right defines the right operand
  82733. * @returns the dot product
  82734. */
  82735. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82736. /**
  82737. * Checks if the two quaternions are close to each other
  82738. * @param quat0 defines the first quaternion to check
  82739. * @param quat1 defines the second quaternion to check
  82740. * @returns true if the two quaternions are close to each other
  82741. */
  82742. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82743. /**
  82744. * Creates an empty quaternion
  82745. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82746. */
  82747. static Zero(): Quaternion;
  82748. /**
  82749. * Inverse a given quaternion
  82750. * @param q defines the source quaternion
  82751. * @returns a new quaternion as the inverted current quaternion
  82752. */
  82753. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82754. /**
  82755. * Inverse a given quaternion
  82756. * @param q defines the source quaternion
  82757. * @param result the quaternion the result will be stored in
  82758. * @returns the result quaternion
  82759. */
  82760. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82761. /**
  82762. * Creates an identity quaternion
  82763. * @returns the identity quaternion
  82764. */
  82765. static Identity(): Quaternion;
  82766. /**
  82767. * Gets a boolean indicating if the given quaternion is identity
  82768. * @param quaternion defines the quaternion to check
  82769. * @returns true if the quaternion is identity
  82770. */
  82771. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82772. /**
  82773. * Creates a quaternion from a rotation around an axis
  82774. * @param axis defines the axis to use
  82775. * @param angle defines the angle to use
  82776. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82777. */
  82778. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82779. /**
  82780. * Creates a rotation around an axis and stores it into the given quaternion
  82781. * @param axis defines the axis to use
  82782. * @param angle defines the angle to use
  82783. * @param result defines the target quaternion
  82784. * @returns the target quaternion
  82785. */
  82786. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82787. /**
  82788. * Creates a new quaternion from data stored into an array
  82789. * @param array defines the data source
  82790. * @param offset defines the offset in the source array where the data starts
  82791. * @returns a new quaternion
  82792. */
  82793. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82794. /**
  82795. * Updates the given quaternion "result" from the starting index of the given array.
  82796. * @param array the array to pull values from
  82797. * @param offset the offset into the array to start at
  82798. * @param result the quaternion to store the result in
  82799. */
  82800. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82801. /**
  82802. * Create a quaternion from Euler rotation angles
  82803. * @param x Pitch
  82804. * @param y Yaw
  82805. * @param z Roll
  82806. * @returns the new Quaternion
  82807. */
  82808. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82809. /**
  82810. * Updates a quaternion from Euler rotation angles
  82811. * @param x Pitch
  82812. * @param y Yaw
  82813. * @param z Roll
  82814. * @param result the quaternion to store the result
  82815. * @returns the updated quaternion
  82816. */
  82817. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82818. /**
  82819. * Create a quaternion from Euler rotation vector
  82820. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82821. * @returns the new Quaternion
  82822. */
  82823. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82824. /**
  82825. * Updates a quaternion from Euler rotation vector
  82826. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82827. * @param result the quaternion to store the result
  82828. * @returns the updated quaternion
  82829. */
  82830. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82831. /**
  82832. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82833. * @param yaw defines the rotation around Y axis
  82834. * @param pitch defines the rotation around X axis
  82835. * @param roll defines the rotation around Z axis
  82836. * @returns the new quaternion
  82837. */
  82838. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82839. /**
  82840. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82841. * @param yaw defines the rotation around Y axis
  82842. * @param pitch defines the rotation around X axis
  82843. * @param roll defines the rotation around Z axis
  82844. * @param result defines the target quaternion
  82845. */
  82846. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82847. /**
  82848. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82849. * @param alpha defines the rotation around first axis
  82850. * @param beta defines the rotation around second axis
  82851. * @param gamma defines the rotation around third axis
  82852. * @returns the new quaternion
  82853. */
  82854. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82855. /**
  82856. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82857. * @param alpha defines the rotation around first axis
  82858. * @param beta defines the rotation around second axis
  82859. * @param gamma defines the rotation around third axis
  82860. * @param result defines the target quaternion
  82861. */
  82862. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82863. /**
  82864. * 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)
  82865. * @param axis1 defines the first axis
  82866. * @param axis2 defines the second axis
  82867. * @param axis3 defines the third axis
  82868. * @returns the new quaternion
  82869. */
  82870. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82871. /**
  82872. * 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
  82873. * @param axis1 defines the first axis
  82874. * @param axis2 defines the second axis
  82875. * @param axis3 defines the third axis
  82876. * @param ref defines the target quaternion
  82877. */
  82878. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82879. /**
  82880. * Interpolates between two quaternions
  82881. * @param left defines first quaternion
  82882. * @param right defines second quaternion
  82883. * @param amount defines the gradient to use
  82884. * @returns the new interpolated quaternion
  82885. */
  82886. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82887. /**
  82888. * Interpolates between two quaternions and stores it into a target quaternion
  82889. * @param left defines first quaternion
  82890. * @param right defines second quaternion
  82891. * @param amount defines the gradient to use
  82892. * @param result defines the target quaternion
  82893. */
  82894. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82895. /**
  82896. * Interpolate between two quaternions using Hermite interpolation
  82897. * @param value1 defines first quaternion
  82898. * @param tangent1 defines the incoming tangent
  82899. * @param value2 defines second quaternion
  82900. * @param tangent2 defines the outgoing tangent
  82901. * @param amount defines the target quaternion
  82902. * @returns the new interpolated quaternion
  82903. */
  82904. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82905. }
  82906. /**
  82907. * Class used to store matrix data (4x4)
  82908. */
  82909. export class Matrix {
  82910. /**
  82911. * Gets the precision of matrix computations
  82912. */
  82913. static get Use64Bits(): boolean;
  82914. private static _updateFlagSeed;
  82915. private static _identityReadOnly;
  82916. private _isIdentity;
  82917. private _isIdentityDirty;
  82918. private _isIdentity3x2;
  82919. private _isIdentity3x2Dirty;
  82920. /**
  82921. * Gets the update flag of the matrix which is an unique number for the matrix.
  82922. * It will be incremented every time the matrix data change.
  82923. * You can use it to speed the comparison between two versions of the same matrix.
  82924. */
  82925. updateFlag: number;
  82926. private readonly _m;
  82927. /**
  82928. * Gets the internal data of the matrix
  82929. */
  82930. get m(): DeepImmutable<Float32Array | Array<number>>;
  82931. /** @hidden */
  82932. _markAsUpdated(): void;
  82933. /** @hidden */
  82934. private _updateIdentityStatus;
  82935. /**
  82936. * Creates an empty matrix (filled with zeros)
  82937. */
  82938. constructor();
  82939. /**
  82940. * Check if the current matrix is identity
  82941. * @returns true is the matrix is the identity matrix
  82942. */
  82943. isIdentity(): boolean;
  82944. /**
  82945. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82946. * @returns true is the matrix is the identity matrix
  82947. */
  82948. isIdentityAs3x2(): boolean;
  82949. /**
  82950. * Gets the determinant of the matrix
  82951. * @returns the matrix determinant
  82952. */
  82953. determinant(): number;
  82954. /**
  82955. * Returns the matrix as a Float32Array or Array<number>
  82956. * @returns the matrix underlying array
  82957. */
  82958. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82959. /**
  82960. * Returns the matrix as a Float32Array or Array<number>
  82961. * @returns the matrix underlying array.
  82962. */
  82963. asArray(): DeepImmutable<Float32Array | Array<number>>;
  82964. /**
  82965. * Inverts the current matrix in place
  82966. * @returns the current inverted matrix
  82967. */
  82968. invert(): Matrix;
  82969. /**
  82970. * Sets all the matrix elements to zero
  82971. * @returns the current matrix
  82972. */
  82973. reset(): Matrix;
  82974. /**
  82975. * Adds the current matrix with a second one
  82976. * @param other defines the matrix to add
  82977. * @returns a new matrix as the addition of the current matrix and the given one
  82978. */
  82979. add(other: DeepImmutable<Matrix>): Matrix;
  82980. /**
  82981. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82982. * @param other defines the matrix to add
  82983. * @param result defines the target matrix
  82984. * @returns the current matrix
  82985. */
  82986. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82987. /**
  82988. * Adds in place the given matrix to the current matrix
  82989. * @param other defines the second operand
  82990. * @returns the current updated matrix
  82991. */
  82992. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82993. /**
  82994. * Sets the given matrix to the current inverted Matrix
  82995. * @param other defines the target matrix
  82996. * @returns the unmodified current matrix
  82997. */
  82998. invertToRef(other: Matrix): Matrix;
  82999. /**
  83000. * add a value at the specified position in the current Matrix
  83001. * @param index the index of the value within the matrix. between 0 and 15.
  83002. * @param value the value to be added
  83003. * @returns the current updated matrix
  83004. */
  83005. addAtIndex(index: number, value: number): Matrix;
  83006. /**
  83007. * mutiply the specified position in the current Matrix by a value
  83008. * @param index the index of the value within the matrix. between 0 and 15.
  83009. * @param value the value to be added
  83010. * @returns the current updated matrix
  83011. */
  83012. multiplyAtIndex(index: number, value: number): Matrix;
  83013. /**
  83014. * Inserts the translation vector (using 3 floats) in the current matrix
  83015. * @param x defines the 1st component of the translation
  83016. * @param y defines the 2nd component of the translation
  83017. * @param z defines the 3rd component of the translation
  83018. * @returns the current updated matrix
  83019. */
  83020. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83021. /**
  83022. * Adds the translation vector (using 3 floats) in the current matrix
  83023. * @param x defines the 1st component of the translation
  83024. * @param y defines the 2nd component of the translation
  83025. * @param z defines the 3rd component of the translation
  83026. * @returns the current updated matrix
  83027. */
  83028. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83029. /**
  83030. * Inserts the translation vector in the current matrix
  83031. * @param vector3 defines the translation to insert
  83032. * @returns the current updated matrix
  83033. */
  83034. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83035. /**
  83036. * Gets the translation value of the current matrix
  83037. * @returns a new Vector3 as the extracted translation from the matrix
  83038. */
  83039. getTranslation(): Vector3;
  83040. /**
  83041. * Fill a Vector3 with the extracted translation from the matrix
  83042. * @param result defines the Vector3 where to store the translation
  83043. * @returns the current matrix
  83044. */
  83045. getTranslationToRef(result: Vector3): Matrix;
  83046. /**
  83047. * Remove rotation and scaling part from the matrix
  83048. * @returns the updated matrix
  83049. */
  83050. removeRotationAndScaling(): Matrix;
  83051. /**
  83052. * Multiply two matrices
  83053. * @param other defines the second operand
  83054. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83055. */
  83056. multiply(other: DeepImmutable<Matrix>): Matrix;
  83057. /**
  83058. * Copy the current matrix from the given one
  83059. * @param other defines the source matrix
  83060. * @returns the current updated matrix
  83061. */
  83062. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83063. /**
  83064. * Populates the given array from the starting index with the current matrix values
  83065. * @param array defines the target array
  83066. * @param offset defines the offset in the target array where to start storing values
  83067. * @returns the current matrix
  83068. */
  83069. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83070. /**
  83071. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83072. * @param other defines the second operand
  83073. * @param result defines the matrix where to store the multiplication
  83074. * @returns the current matrix
  83075. */
  83076. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83077. /**
  83078. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83079. * @param other defines the second operand
  83080. * @param result defines the array where to store the multiplication
  83081. * @param offset defines the offset in the target array where to start storing values
  83082. * @returns the current matrix
  83083. */
  83084. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83085. /**
  83086. * Check equality between this matrix and a second one
  83087. * @param value defines the second matrix to compare
  83088. * @returns true is the current matrix and the given one values are strictly equal
  83089. */
  83090. equals(value: DeepImmutable<Matrix>): boolean;
  83091. /**
  83092. * Clone the current matrix
  83093. * @returns a new matrix from the current matrix
  83094. */
  83095. clone(): Matrix;
  83096. /**
  83097. * Returns the name of the current matrix class
  83098. * @returns the string "Matrix"
  83099. */
  83100. getClassName(): string;
  83101. /**
  83102. * Gets the hash code of the current matrix
  83103. * @returns the hash code
  83104. */
  83105. getHashCode(): number;
  83106. /**
  83107. * Decomposes the current Matrix into a translation, rotation and scaling components
  83108. * @param scale defines the scale vector3 given as a reference to update
  83109. * @param rotation defines the rotation quaternion given as a reference to update
  83110. * @param translation defines the translation vector3 given as a reference to update
  83111. * @returns true if operation was successful
  83112. */
  83113. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83114. /**
  83115. * Gets specific row of the matrix
  83116. * @param index defines the number of the row to get
  83117. * @returns the index-th row of the current matrix as a new Vector4
  83118. */
  83119. getRow(index: number): Nullable<Vector4>;
  83120. /**
  83121. * Sets the index-th row of the current matrix to the vector4 values
  83122. * @param index defines the number of the row to set
  83123. * @param row defines the target vector4
  83124. * @returns the updated current matrix
  83125. */
  83126. setRow(index: number, row: Vector4): Matrix;
  83127. /**
  83128. * Compute the transpose of the matrix
  83129. * @returns the new transposed matrix
  83130. */
  83131. transpose(): Matrix;
  83132. /**
  83133. * Compute the transpose of the matrix and store it in a given matrix
  83134. * @param result defines the target matrix
  83135. * @returns the current matrix
  83136. */
  83137. transposeToRef(result: Matrix): Matrix;
  83138. /**
  83139. * Sets the index-th row of the current matrix with the given 4 x float values
  83140. * @param index defines the row index
  83141. * @param x defines the x component to set
  83142. * @param y defines the y component to set
  83143. * @param z defines the z component to set
  83144. * @param w defines the w component to set
  83145. * @returns the updated current matrix
  83146. */
  83147. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83148. /**
  83149. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83150. * @param scale defines the scale factor
  83151. * @returns a new matrix
  83152. */
  83153. scale(scale: number): Matrix;
  83154. /**
  83155. * Scale the current matrix values by a factor to a given result matrix
  83156. * @param scale defines the scale factor
  83157. * @param result defines the matrix to store the result
  83158. * @returns the current matrix
  83159. */
  83160. scaleToRef(scale: number, result: Matrix): Matrix;
  83161. /**
  83162. * Scale the current matrix values by a factor and add the result to a given matrix
  83163. * @param scale defines the scale factor
  83164. * @param result defines the Matrix to store the result
  83165. * @returns the current matrix
  83166. */
  83167. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83168. /**
  83169. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83170. * @param ref matrix to store the result
  83171. */
  83172. toNormalMatrix(ref: Matrix): void;
  83173. /**
  83174. * Gets only rotation part of the current matrix
  83175. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83176. */
  83177. getRotationMatrix(): Matrix;
  83178. /**
  83179. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83180. * @param result defines the target matrix to store data to
  83181. * @returns the current matrix
  83182. */
  83183. getRotationMatrixToRef(result: Matrix): Matrix;
  83184. /**
  83185. * Toggles model matrix from being right handed to left handed in place and vice versa
  83186. */
  83187. toggleModelMatrixHandInPlace(): void;
  83188. /**
  83189. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83190. */
  83191. toggleProjectionMatrixHandInPlace(): void;
  83192. /**
  83193. * Creates a matrix from an array
  83194. * @param array defines the source array
  83195. * @param offset defines an offset in the source array
  83196. * @returns a new Matrix set from the starting index of the given array
  83197. */
  83198. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83199. /**
  83200. * Copy the content of an array into a given matrix
  83201. * @param array defines the source array
  83202. * @param offset defines an offset in the source array
  83203. * @param result defines the target matrix
  83204. */
  83205. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83206. /**
  83207. * Stores an array into a matrix after having multiplied each component by a given factor
  83208. * @param array defines the source array
  83209. * @param offset defines the offset in the source array
  83210. * @param scale defines the scaling factor
  83211. * @param result defines the target matrix
  83212. */
  83213. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83214. /**
  83215. * Gets an identity matrix that must not be updated
  83216. */
  83217. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83218. /**
  83219. * Stores a list of values (16) inside a given matrix
  83220. * @param initialM11 defines 1st value of 1st row
  83221. * @param initialM12 defines 2nd value of 1st row
  83222. * @param initialM13 defines 3rd value of 1st row
  83223. * @param initialM14 defines 4th value of 1st row
  83224. * @param initialM21 defines 1st value of 2nd row
  83225. * @param initialM22 defines 2nd value of 2nd row
  83226. * @param initialM23 defines 3rd value of 2nd row
  83227. * @param initialM24 defines 4th value of 2nd row
  83228. * @param initialM31 defines 1st value of 3rd row
  83229. * @param initialM32 defines 2nd value of 3rd row
  83230. * @param initialM33 defines 3rd value of 3rd row
  83231. * @param initialM34 defines 4th value of 3rd row
  83232. * @param initialM41 defines 1st value of 4th row
  83233. * @param initialM42 defines 2nd value of 4th row
  83234. * @param initialM43 defines 3rd value of 4th row
  83235. * @param initialM44 defines 4th value of 4th row
  83236. * @param result defines the target matrix
  83237. */
  83238. 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;
  83239. /**
  83240. * Creates new matrix from a list of values (16)
  83241. * @param initialM11 defines 1st value of 1st row
  83242. * @param initialM12 defines 2nd value of 1st row
  83243. * @param initialM13 defines 3rd value of 1st row
  83244. * @param initialM14 defines 4th value of 1st row
  83245. * @param initialM21 defines 1st value of 2nd row
  83246. * @param initialM22 defines 2nd value of 2nd row
  83247. * @param initialM23 defines 3rd value of 2nd row
  83248. * @param initialM24 defines 4th value of 2nd row
  83249. * @param initialM31 defines 1st value of 3rd row
  83250. * @param initialM32 defines 2nd value of 3rd row
  83251. * @param initialM33 defines 3rd value of 3rd row
  83252. * @param initialM34 defines 4th value of 3rd row
  83253. * @param initialM41 defines 1st value of 4th row
  83254. * @param initialM42 defines 2nd value of 4th row
  83255. * @param initialM43 defines 3rd value of 4th row
  83256. * @param initialM44 defines 4th value of 4th row
  83257. * @returns the new matrix
  83258. */
  83259. 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;
  83260. /**
  83261. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83262. * @param scale defines the scale vector3
  83263. * @param rotation defines the rotation quaternion
  83264. * @param translation defines the translation vector3
  83265. * @returns a new matrix
  83266. */
  83267. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83268. /**
  83269. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83270. * @param scale defines the scale vector3
  83271. * @param rotation defines the rotation quaternion
  83272. * @param translation defines the translation vector3
  83273. * @param result defines the target matrix
  83274. */
  83275. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83276. /**
  83277. * Creates a new identity matrix
  83278. * @returns a new identity matrix
  83279. */
  83280. static Identity(): Matrix;
  83281. /**
  83282. * Creates a new identity matrix and stores the result in a given matrix
  83283. * @param result defines the target matrix
  83284. */
  83285. static IdentityToRef(result: Matrix): void;
  83286. /**
  83287. * Creates a new zero matrix
  83288. * @returns a new zero matrix
  83289. */
  83290. static Zero(): Matrix;
  83291. /**
  83292. * Creates a new rotation matrix for "angle" radians around the X axis
  83293. * @param angle defines the angle (in radians) to use
  83294. * @return the new matrix
  83295. */
  83296. static RotationX(angle: number): Matrix;
  83297. /**
  83298. * Creates a new matrix as the invert of a given matrix
  83299. * @param source defines the source matrix
  83300. * @returns the new matrix
  83301. */
  83302. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83303. /**
  83304. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83305. * @param angle defines the angle (in radians) to use
  83306. * @param result defines the target matrix
  83307. */
  83308. static RotationXToRef(angle: number, result: Matrix): void;
  83309. /**
  83310. * Creates a new rotation matrix for "angle" radians around the Y axis
  83311. * @param angle defines the angle (in radians) to use
  83312. * @return the new matrix
  83313. */
  83314. static RotationY(angle: number): Matrix;
  83315. /**
  83316. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83317. * @param angle defines the angle (in radians) to use
  83318. * @param result defines the target matrix
  83319. */
  83320. static RotationYToRef(angle: number, result: Matrix): void;
  83321. /**
  83322. * Creates a new rotation matrix for "angle" radians around the Z axis
  83323. * @param angle defines the angle (in radians) to use
  83324. * @return the new matrix
  83325. */
  83326. static RotationZ(angle: number): Matrix;
  83327. /**
  83328. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83329. * @param angle defines the angle (in radians) to use
  83330. * @param result defines the target matrix
  83331. */
  83332. static RotationZToRef(angle: number, result: Matrix): void;
  83333. /**
  83334. * Creates a new rotation matrix for "angle" radians around the given axis
  83335. * @param axis defines the axis to use
  83336. * @param angle defines the angle (in radians) to use
  83337. * @return the new matrix
  83338. */
  83339. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83340. /**
  83341. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83342. * @param axis defines the axis to use
  83343. * @param angle defines the angle (in radians) to use
  83344. * @param result defines the target matrix
  83345. */
  83346. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83347. /**
  83348. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83349. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83350. * @param from defines the vector to align
  83351. * @param to defines the vector to align to
  83352. * @param result defines the target matrix
  83353. */
  83354. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83355. /**
  83356. * Creates a rotation matrix
  83357. * @param yaw defines the yaw angle in radians (Y axis)
  83358. * @param pitch defines the pitch angle in radians (X axis)
  83359. * @param roll defines the roll angle in radians (Z axis)
  83360. * @returns the new rotation matrix
  83361. */
  83362. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83363. /**
  83364. * Creates a rotation matrix and stores it in a given matrix
  83365. * @param yaw defines the yaw angle in radians (Y axis)
  83366. * @param pitch defines the pitch angle in radians (X axis)
  83367. * @param roll defines the roll angle in radians (Z axis)
  83368. * @param result defines the target matrix
  83369. */
  83370. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83371. /**
  83372. * Creates a scaling matrix
  83373. * @param x defines the scale factor on X axis
  83374. * @param y defines the scale factor on Y axis
  83375. * @param z defines the scale factor on Z axis
  83376. * @returns the new matrix
  83377. */
  83378. static Scaling(x: number, y: number, z: number): Matrix;
  83379. /**
  83380. * Creates a scaling matrix and stores it in a given matrix
  83381. * @param x defines the scale factor on X axis
  83382. * @param y defines the scale factor on Y axis
  83383. * @param z defines the scale factor on Z axis
  83384. * @param result defines the target matrix
  83385. */
  83386. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83387. /**
  83388. * Creates a translation matrix
  83389. * @param x defines the translation on X axis
  83390. * @param y defines the translation on Y axis
  83391. * @param z defines the translationon Z axis
  83392. * @returns the new matrix
  83393. */
  83394. static Translation(x: number, y: number, z: number): Matrix;
  83395. /**
  83396. * Creates a translation matrix and stores it in a given matrix
  83397. * @param x defines the translation on X axis
  83398. * @param y defines the translation on Y axis
  83399. * @param z defines the translationon Z axis
  83400. * @param result defines the target matrix
  83401. */
  83402. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83403. /**
  83404. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83405. * @param startValue defines the start value
  83406. * @param endValue defines the end value
  83407. * @param gradient defines the gradient factor
  83408. * @returns the new matrix
  83409. */
  83410. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83411. /**
  83412. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83413. * @param startValue defines the start value
  83414. * @param endValue defines the end value
  83415. * @param gradient defines the gradient factor
  83416. * @param result defines the Matrix object where to store data
  83417. */
  83418. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83419. /**
  83420. * Builds a new matrix whose values are computed by:
  83421. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83422. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83423. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83424. * @param startValue defines the first matrix
  83425. * @param endValue defines the second matrix
  83426. * @param gradient defines the gradient between the two matrices
  83427. * @returns the new matrix
  83428. */
  83429. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83430. /**
  83431. * Update a matrix to values which are computed by:
  83432. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83433. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83434. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83435. * @param startValue defines the first matrix
  83436. * @param endValue defines the second matrix
  83437. * @param gradient defines the gradient between the two matrices
  83438. * @param result defines the target matrix
  83439. */
  83440. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83441. /**
  83442. * 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"
  83443. * This function works in left handed mode
  83444. * @param eye defines the final position of the entity
  83445. * @param target defines where the entity should look at
  83446. * @param up defines the up vector for the entity
  83447. * @returns the new matrix
  83448. */
  83449. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83450. /**
  83451. * 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".
  83452. * This function works in left handed mode
  83453. * @param eye defines the final position of the entity
  83454. * @param target defines where the entity should look at
  83455. * @param up defines the up vector for the entity
  83456. * @param result defines the target matrix
  83457. */
  83458. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83459. /**
  83460. * 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"
  83461. * This function works in right handed mode
  83462. * @param eye defines the final position of the entity
  83463. * @param target defines where the entity should look at
  83464. * @param up defines the up vector for the entity
  83465. * @returns the new matrix
  83466. */
  83467. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83468. /**
  83469. * 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".
  83470. * This function works in right handed mode
  83471. * @param eye defines the final position of the entity
  83472. * @param target defines where the entity should look at
  83473. * @param up defines the up vector for the entity
  83474. * @param result defines the target matrix
  83475. */
  83476. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83477. /**
  83478. * Create a left-handed orthographic projection matrix
  83479. * @param width defines the viewport width
  83480. * @param height defines the viewport height
  83481. * @param znear defines the near clip plane
  83482. * @param zfar defines the far clip plane
  83483. * @returns a new matrix as a left-handed orthographic projection matrix
  83484. */
  83485. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83486. /**
  83487. * Store a left-handed orthographic projection to a given matrix
  83488. * @param width defines the viewport width
  83489. * @param height defines the viewport height
  83490. * @param znear defines the near clip plane
  83491. * @param zfar defines the far clip plane
  83492. * @param result defines the target matrix
  83493. */
  83494. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83495. /**
  83496. * Create a left-handed orthographic projection matrix
  83497. * @param left defines the viewport left coordinate
  83498. * @param right defines the viewport right coordinate
  83499. * @param bottom defines the viewport bottom coordinate
  83500. * @param top defines the viewport top coordinate
  83501. * @param znear defines the near clip plane
  83502. * @param zfar defines the far clip plane
  83503. * @returns a new matrix as a left-handed orthographic projection matrix
  83504. */
  83505. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83506. /**
  83507. * Stores a left-handed orthographic projection into a given matrix
  83508. * @param left defines the viewport left coordinate
  83509. * @param right defines the viewport right coordinate
  83510. * @param bottom defines the viewport bottom coordinate
  83511. * @param top defines the viewport top coordinate
  83512. * @param znear defines the near clip plane
  83513. * @param zfar defines the far clip plane
  83514. * @param result defines the target matrix
  83515. */
  83516. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83517. /**
  83518. * Creates a right-handed orthographic projection matrix
  83519. * @param left defines the viewport left coordinate
  83520. * @param right defines the viewport right coordinate
  83521. * @param bottom defines the viewport bottom coordinate
  83522. * @param top defines the viewport top coordinate
  83523. * @param znear defines the near clip plane
  83524. * @param zfar defines the far clip plane
  83525. * @returns a new matrix as a right-handed orthographic projection matrix
  83526. */
  83527. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83528. /**
  83529. * Stores a right-handed orthographic projection into a given matrix
  83530. * @param left defines the viewport left coordinate
  83531. * @param right defines the viewport right coordinate
  83532. * @param bottom defines the viewport bottom coordinate
  83533. * @param top defines the viewport top coordinate
  83534. * @param znear defines the near clip plane
  83535. * @param zfar defines the far clip plane
  83536. * @param result defines the target matrix
  83537. */
  83538. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83539. /**
  83540. * Creates a left-handed perspective projection matrix
  83541. * @param width defines the viewport width
  83542. * @param height defines the viewport height
  83543. * @param znear defines the near clip plane
  83544. * @param zfar defines the far clip plane
  83545. * @returns a new matrix as a left-handed perspective projection matrix
  83546. */
  83547. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83548. /**
  83549. * Creates a left-handed perspective projection matrix
  83550. * @param fov defines the horizontal field of view
  83551. * @param aspect defines the aspect ratio
  83552. * @param znear defines the near clip plane
  83553. * @param zfar defines the far clip plane
  83554. * @returns a new matrix as a left-handed perspective projection matrix
  83555. */
  83556. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83557. /**
  83558. * Stores a left-handed perspective projection into a given matrix
  83559. * @param fov defines the horizontal field of view
  83560. * @param aspect defines the aspect ratio
  83561. * @param znear defines the near clip plane
  83562. * @param zfar defines the far clip plane
  83563. * @param result defines the target matrix
  83564. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83565. */
  83566. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83567. /**
  83568. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83569. * @param fov defines the horizontal field of view
  83570. * @param aspect defines the aspect ratio
  83571. * @param znear defines the near clip plane
  83572. * @param zfar not used as infinity is used as far clip
  83573. * @param result defines the target matrix
  83574. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83575. */
  83576. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83577. /**
  83578. * Creates a right-handed perspective projection matrix
  83579. * @param fov defines the horizontal field of view
  83580. * @param aspect defines the aspect ratio
  83581. * @param znear defines the near clip plane
  83582. * @param zfar defines the far clip plane
  83583. * @returns a new matrix as a right-handed perspective projection matrix
  83584. */
  83585. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83586. /**
  83587. * Stores a right-handed perspective projection into a given matrix
  83588. * @param fov defines the horizontal field of view
  83589. * @param aspect defines the aspect ratio
  83590. * @param znear defines the near clip plane
  83591. * @param zfar defines the far clip plane
  83592. * @param result defines the target matrix
  83593. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83594. */
  83595. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83596. /**
  83597. * Stores a right-handed perspective projection into a given matrix
  83598. * @param fov defines the horizontal field of view
  83599. * @param aspect defines the aspect ratio
  83600. * @param znear defines the near clip plane
  83601. * @param zfar not used as infinity is used as far clip
  83602. * @param result defines the target matrix
  83603. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83604. */
  83605. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83606. /**
  83607. * Stores a perspective projection for WebVR info a given matrix
  83608. * @param fov defines the field of view
  83609. * @param znear defines the near clip plane
  83610. * @param zfar defines the far clip plane
  83611. * @param result defines the target matrix
  83612. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83613. */
  83614. static PerspectiveFovWebVRToRef(fov: {
  83615. upDegrees: number;
  83616. downDegrees: number;
  83617. leftDegrees: number;
  83618. rightDegrees: number;
  83619. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83620. /**
  83621. * Computes a complete transformation matrix
  83622. * @param viewport defines the viewport to use
  83623. * @param world defines the world matrix
  83624. * @param view defines the view matrix
  83625. * @param projection defines the projection matrix
  83626. * @param zmin defines the near clip plane
  83627. * @param zmax defines the far clip plane
  83628. * @returns the transformation matrix
  83629. */
  83630. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83631. /**
  83632. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83633. * @param matrix defines the matrix to use
  83634. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83635. */
  83636. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83637. /**
  83638. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83639. * @param matrix defines the matrix to use
  83640. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83641. */
  83642. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83643. /**
  83644. * Compute the transpose of a given matrix
  83645. * @param matrix defines the matrix to transpose
  83646. * @returns the new matrix
  83647. */
  83648. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83649. /**
  83650. * Compute the transpose of a matrix and store it in a target matrix
  83651. * @param matrix defines the matrix to transpose
  83652. * @param result defines the target matrix
  83653. */
  83654. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83655. /**
  83656. * Computes a reflection matrix from a plane
  83657. * @param plane defines the reflection plane
  83658. * @returns a new matrix
  83659. */
  83660. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83661. /**
  83662. * Computes a reflection matrix from a plane
  83663. * @param plane defines the reflection plane
  83664. * @param result defines the target matrix
  83665. */
  83666. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83667. /**
  83668. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83669. * @param xaxis defines the value of the 1st axis
  83670. * @param yaxis defines the value of the 2nd axis
  83671. * @param zaxis defines the value of the 3rd axis
  83672. * @param result defines the target matrix
  83673. */
  83674. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83675. /**
  83676. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83677. * @param quat defines the quaternion to use
  83678. * @param result defines the target matrix
  83679. */
  83680. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83681. }
  83682. /**
  83683. * @hidden
  83684. */
  83685. export class TmpVectors {
  83686. static Vector2: Vector2[];
  83687. static Vector3: Vector3[];
  83688. static Vector4: Vector4[];
  83689. static Quaternion: Quaternion[];
  83690. static Matrix: Matrix[];
  83691. }
  83692. }
  83693. declare module BABYLON {
  83694. /**
  83695. * Defines potential orientation for back face culling
  83696. */
  83697. export enum Orientation {
  83698. /**
  83699. * Clockwise
  83700. */
  83701. CW = 0,
  83702. /** Counter clockwise */
  83703. CCW = 1
  83704. }
  83705. /** Class used to represent a Bezier curve */
  83706. export class BezierCurve {
  83707. /**
  83708. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83709. * @param t defines the time
  83710. * @param x1 defines the left coordinate on X axis
  83711. * @param y1 defines the left coordinate on Y axis
  83712. * @param x2 defines the right coordinate on X axis
  83713. * @param y2 defines the right coordinate on Y axis
  83714. * @returns the interpolated value
  83715. */
  83716. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83717. }
  83718. /**
  83719. * Defines angle representation
  83720. */
  83721. export class Angle {
  83722. private _radians;
  83723. /**
  83724. * Creates an Angle object of "radians" radians (float).
  83725. * @param radians the angle in radians
  83726. */
  83727. constructor(radians: number);
  83728. /**
  83729. * Get value in degrees
  83730. * @returns the Angle value in degrees (float)
  83731. */
  83732. degrees(): number;
  83733. /**
  83734. * Get value in radians
  83735. * @returns the Angle value in radians (float)
  83736. */
  83737. radians(): number;
  83738. /**
  83739. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83740. * @param a defines first point as the origin
  83741. * @param b defines point
  83742. * @returns a new Angle
  83743. */
  83744. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83745. /**
  83746. * Gets a new Angle object from the given float in radians
  83747. * @param radians defines the angle value in radians
  83748. * @returns a new Angle
  83749. */
  83750. static FromRadians(radians: number): Angle;
  83751. /**
  83752. * Gets a new Angle object from the given float in degrees
  83753. * @param degrees defines the angle value in degrees
  83754. * @returns a new Angle
  83755. */
  83756. static FromDegrees(degrees: number): Angle;
  83757. }
  83758. /**
  83759. * This represents an arc in a 2d space.
  83760. */
  83761. export class Arc2 {
  83762. /** Defines the start point of the arc */
  83763. startPoint: Vector2;
  83764. /** Defines the mid point of the arc */
  83765. midPoint: Vector2;
  83766. /** Defines the end point of the arc */
  83767. endPoint: Vector2;
  83768. /**
  83769. * Defines the center point of the arc.
  83770. */
  83771. centerPoint: Vector2;
  83772. /**
  83773. * Defines the radius of the arc.
  83774. */
  83775. radius: number;
  83776. /**
  83777. * Defines the angle of the arc (from mid point to end point).
  83778. */
  83779. angle: Angle;
  83780. /**
  83781. * Defines the start angle of the arc (from start point to middle point).
  83782. */
  83783. startAngle: Angle;
  83784. /**
  83785. * Defines the orientation of the arc (clock wise/counter clock wise).
  83786. */
  83787. orientation: Orientation;
  83788. /**
  83789. * Creates an Arc object from the three given points : start, middle and end.
  83790. * @param startPoint Defines the start point of the arc
  83791. * @param midPoint Defines the midlle point of the arc
  83792. * @param endPoint Defines the end point of the arc
  83793. */
  83794. constructor(
  83795. /** Defines the start point of the arc */
  83796. startPoint: Vector2,
  83797. /** Defines the mid point of the arc */
  83798. midPoint: Vector2,
  83799. /** Defines the end point of the arc */
  83800. endPoint: Vector2);
  83801. }
  83802. /**
  83803. * Represents a 2D path made up of multiple 2D points
  83804. */
  83805. export class Path2 {
  83806. private _points;
  83807. private _length;
  83808. /**
  83809. * If the path start and end point are the same
  83810. */
  83811. closed: boolean;
  83812. /**
  83813. * Creates a Path2 object from the starting 2D coordinates x and y.
  83814. * @param x the starting points x value
  83815. * @param y the starting points y value
  83816. */
  83817. constructor(x: number, y: number);
  83818. /**
  83819. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83820. * @param x the added points x value
  83821. * @param y the added points y value
  83822. * @returns the updated Path2.
  83823. */
  83824. addLineTo(x: number, y: number): Path2;
  83825. /**
  83826. * 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.
  83827. * @param midX middle point x value
  83828. * @param midY middle point y value
  83829. * @param endX end point x value
  83830. * @param endY end point y value
  83831. * @param numberOfSegments (default: 36)
  83832. * @returns the updated Path2.
  83833. */
  83834. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83835. /**
  83836. * Closes the Path2.
  83837. * @returns the Path2.
  83838. */
  83839. close(): Path2;
  83840. /**
  83841. * Gets the sum of the distance between each sequential point in the path
  83842. * @returns the Path2 total length (float).
  83843. */
  83844. length(): number;
  83845. /**
  83846. * Gets the points which construct the path
  83847. * @returns the Path2 internal array of points.
  83848. */
  83849. getPoints(): Vector2[];
  83850. /**
  83851. * Retreives the point at the distance aways from the starting point
  83852. * @param normalizedLengthPosition the length along the path to retreive the point from
  83853. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83854. */
  83855. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83856. /**
  83857. * Creates a new path starting from an x and y position
  83858. * @param x starting x value
  83859. * @param y starting y value
  83860. * @returns a new Path2 starting at the coordinates (x, y).
  83861. */
  83862. static StartingAt(x: number, y: number): Path2;
  83863. }
  83864. /**
  83865. * Represents a 3D path made up of multiple 3D points
  83866. */
  83867. export class Path3D {
  83868. /**
  83869. * an array of Vector3, the curve axis of the Path3D
  83870. */
  83871. path: Vector3[];
  83872. private _curve;
  83873. private _distances;
  83874. private _tangents;
  83875. private _normals;
  83876. private _binormals;
  83877. private _raw;
  83878. private _alignTangentsWithPath;
  83879. private readonly _pointAtData;
  83880. /**
  83881. * new Path3D(path, normal, raw)
  83882. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83883. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83884. * @param path an array of Vector3, the curve axis of the Path3D
  83885. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83886. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83887. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83888. */
  83889. constructor(
  83890. /**
  83891. * an array of Vector3, the curve axis of the Path3D
  83892. */
  83893. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83894. /**
  83895. * Returns the Path3D array of successive Vector3 designing its curve.
  83896. * @returns the Path3D array of successive Vector3 designing its curve.
  83897. */
  83898. getCurve(): Vector3[];
  83899. /**
  83900. * Returns the Path3D array of successive Vector3 designing its curve.
  83901. * @returns the Path3D array of successive Vector3 designing its curve.
  83902. */
  83903. getPoints(): Vector3[];
  83904. /**
  83905. * @returns the computed length (float) of the path.
  83906. */
  83907. length(): number;
  83908. /**
  83909. * Returns an array populated with tangent vectors on each Path3D curve point.
  83910. * @returns an array populated with tangent vectors on each Path3D curve point.
  83911. */
  83912. getTangents(): Vector3[];
  83913. /**
  83914. * Returns an array populated with normal vectors on each Path3D curve point.
  83915. * @returns an array populated with normal vectors on each Path3D curve point.
  83916. */
  83917. getNormals(): Vector3[];
  83918. /**
  83919. * Returns an array populated with binormal vectors on each Path3D curve point.
  83920. * @returns an array populated with binormal vectors on each Path3D curve point.
  83921. */
  83922. getBinormals(): Vector3[];
  83923. /**
  83924. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83925. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83926. */
  83927. getDistances(): number[];
  83928. /**
  83929. * Returns an interpolated point along this path
  83930. * @param position the position of the point along this path, from 0.0 to 1.0
  83931. * @returns a new Vector3 as the point
  83932. */
  83933. getPointAt(position: number): Vector3;
  83934. /**
  83935. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83936. * @param position the position of the point along this path, from 0.0 to 1.0
  83937. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83938. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83939. */
  83940. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83941. /**
  83942. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83943. * @param position the position of the point along this path, from 0.0 to 1.0
  83944. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83945. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83946. */
  83947. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83948. /**
  83949. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83950. * @param position the position of the point along this path, from 0.0 to 1.0
  83951. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83952. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83953. */
  83954. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83955. /**
  83956. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83957. * @param position the position of the point along this path, from 0.0 to 1.0
  83958. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83959. */
  83960. getDistanceAt(position: number): number;
  83961. /**
  83962. * Returns the array index of the previous point of an interpolated point along this path
  83963. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83964. * @returns the array index
  83965. */
  83966. getPreviousPointIndexAt(position: number): number;
  83967. /**
  83968. * 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)
  83969. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83970. * @returns the sub position
  83971. */
  83972. getSubPositionAt(position: number): number;
  83973. /**
  83974. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83975. * @param target the vector of which to get the closest position to
  83976. * @returns the position of the closest virtual point on this path to the target vector
  83977. */
  83978. getClosestPositionTo(target: Vector3): number;
  83979. /**
  83980. * Returns a sub path (slice) of this path
  83981. * @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
  83982. * @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
  83983. * @returns a sub path (slice) of this path
  83984. */
  83985. slice(start?: number, end?: number): Path3D;
  83986. /**
  83987. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83988. * @param path path which all values are copied into the curves points
  83989. * @param firstNormal which should be projected onto the curve
  83990. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83991. * @returns the same object updated.
  83992. */
  83993. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83994. private _compute;
  83995. private _getFirstNonNullVector;
  83996. private _getLastNonNullVector;
  83997. private _normalVector;
  83998. /**
  83999. * Updates the point at data for an interpolated point along this curve
  84000. * @param position the position of the point along this curve, from 0.0 to 1.0
  84001. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84002. * @returns the (updated) point at data
  84003. */
  84004. private _updatePointAtData;
  84005. /**
  84006. * Updates the point at data from the specified parameters
  84007. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84008. * @param point the interpolated point
  84009. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84010. */
  84011. private _setPointAtData;
  84012. /**
  84013. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84014. */
  84015. private _updateInterpolationMatrix;
  84016. }
  84017. /**
  84018. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84019. * A Curve3 is designed from a series of successive Vector3.
  84020. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84021. */
  84022. export class Curve3 {
  84023. private _points;
  84024. private _length;
  84025. /**
  84026. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84027. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84028. * @param v1 (Vector3) the control point
  84029. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84030. * @param nbPoints (integer) the wanted number of points in the curve
  84031. * @returns the created Curve3
  84032. */
  84033. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84034. /**
  84035. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84036. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84037. * @param v1 (Vector3) the first control point
  84038. * @param v2 (Vector3) the second control point
  84039. * @param v3 (Vector3) the end point of the Cubic Bezier
  84040. * @param nbPoints (integer) the wanted number of points in the curve
  84041. * @returns the created Curve3
  84042. */
  84043. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84044. /**
  84045. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84046. * @param p1 (Vector3) the origin point of the Hermite Spline
  84047. * @param t1 (Vector3) the tangent vector at the origin point
  84048. * @param p2 (Vector3) the end point of the Hermite Spline
  84049. * @param t2 (Vector3) the tangent vector at the end point
  84050. * @param nbPoints (integer) the wanted number of points in the curve
  84051. * @returns the created Curve3
  84052. */
  84053. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84054. /**
  84055. * Returns a Curve3 object along a CatmullRom Spline curve :
  84056. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84057. * @param nbPoints (integer) the wanted number of points between each curve control points
  84058. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84059. * @returns the created Curve3
  84060. */
  84061. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84062. /**
  84063. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84064. * A Curve3 is designed from a series of successive Vector3.
  84065. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84066. * @param points points which make up the curve
  84067. */
  84068. constructor(points: Vector3[]);
  84069. /**
  84070. * @returns the Curve3 stored array of successive Vector3
  84071. */
  84072. getPoints(): Vector3[];
  84073. /**
  84074. * @returns the computed length (float) of the curve.
  84075. */
  84076. length(): number;
  84077. /**
  84078. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84079. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84080. * curveA and curveB keep unchanged.
  84081. * @param curve the curve to continue from this curve
  84082. * @returns the newly constructed curve
  84083. */
  84084. continue(curve: DeepImmutable<Curve3>): Curve3;
  84085. private _computeLength;
  84086. }
  84087. }
  84088. declare module BABYLON {
  84089. /**
  84090. * This represents the main contract an easing function should follow.
  84091. * Easing functions are used throughout the animation system.
  84092. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84093. */
  84094. export interface IEasingFunction {
  84095. /**
  84096. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84097. * of the easing function.
  84098. * The link below provides some of the most common examples of easing functions.
  84099. * @see https://easings.net/
  84100. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84101. * @returns the corresponding value on the curve defined by the easing function
  84102. */
  84103. ease(gradient: number): number;
  84104. }
  84105. /**
  84106. * Base class used for every default easing function.
  84107. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84108. */
  84109. export class EasingFunction implements IEasingFunction {
  84110. /**
  84111. * Interpolation follows the mathematical formula associated with the easing function.
  84112. */
  84113. static readonly EASINGMODE_EASEIN: number;
  84114. /**
  84115. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84116. */
  84117. static readonly EASINGMODE_EASEOUT: number;
  84118. /**
  84119. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84120. */
  84121. static readonly EASINGMODE_EASEINOUT: number;
  84122. private _easingMode;
  84123. /**
  84124. * Sets the easing mode of the current function.
  84125. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84126. */
  84127. setEasingMode(easingMode: number): void;
  84128. /**
  84129. * Gets the current easing mode.
  84130. * @returns the easing mode
  84131. */
  84132. getEasingMode(): number;
  84133. /**
  84134. * @hidden
  84135. */
  84136. easeInCore(gradient: number): number;
  84137. /**
  84138. * Given an input gradient between 0 and 1, this returns the corresponding value
  84139. * of the easing function.
  84140. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84141. * @returns the corresponding value on the curve defined by the easing function
  84142. */
  84143. ease(gradient: number): number;
  84144. }
  84145. /**
  84146. * Easing function with a circle shape (see link below).
  84147. * @see https://easings.net/#easeInCirc
  84148. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84149. */
  84150. export class CircleEase extends EasingFunction implements IEasingFunction {
  84151. /** @hidden */
  84152. easeInCore(gradient: number): number;
  84153. }
  84154. /**
  84155. * Easing function with a ease back shape (see link below).
  84156. * @see https://easings.net/#easeInBack
  84157. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84158. */
  84159. export class BackEase extends EasingFunction implements IEasingFunction {
  84160. /** Defines the amplitude of the function */
  84161. amplitude: number;
  84162. /**
  84163. * Instantiates a back ease easing
  84164. * @see https://easings.net/#easeInBack
  84165. * @param amplitude Defines the amplitude of the function
  84166. */
  84167. constructor(
  84168. /** Defines the amplitude of the function */
  84169. amplitude?: number);
  84170. /** @hidden */
  84171. easeInCore(gradient: number): number;
  84172. }
  84173. /**
  84174. * Easing function with a bouncing shape (see link below).
  84175. * @see https://easings.net/#easeInBounce
  84176. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84177. */
  84178. export class BounceEase extends EasingFunction implements IEasingFunction {
  84179. /** Defines the number of bounces */
  84180. bounces: number;
  84181. /** Defines the amplitude of the bounce */
  84182. bounciness: number;
  84183. /**
  84184. * Instantiates a bounce easing
  84185. * @see https://easings.net/#easeInBounce
  84186. * @param bounces Defines the number of bounces
  84187. * @param bounciness Defines the amplitude of the bounce
  84188. */
  84189. constructor(
  84190. /** Defines the number of bounces */
  84191. bounces?: number,
  84192. /** Defines the amplitude of the bounce */
  84193. bounciness?: number);
  84194. /** @hidden */
  84195. easeInCore(gradient: number): number;
  84196. }
  84197. /**
  84198. * Easing function with a power of 3 shape (see link below).
  84199. * @see https://easings.net/#easeInCubic
  84200. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84201. */
  84202. export class CubicEase extends EasingFunction implements IEasingFunction {
  84203. /** @hidden */
  84204. easeInCore(gradient: number): number;
  84205. }
  84206. /**
  84207. * Easing function with an elastic shape (see link below).
  84208. * @see https://easings.net/#easeInElastic
  84209. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84210. */
  84211. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84212. /** Defines the number of oscillations*/
  84213. oscillations: number;
  84214. /** Defines the amplitude of the oscillations*/
  84215. springiness: number;
  84216. /**
  84217. * Instantiates an elastic easing function
  84218. * @see https://easings.net/#easeInElastic
  84219. * @param oscillations Defines the number of oscillations
  84220. * @param springiness Defines the amplitude of the oscillations
  84221. */
  84222. constructor(
  84223. /** Defines the number of oscillations*/
  84224. oscillations?: number,
  84225. /** Defines the amplitude of the oscillations*/
  84226. springiness?: number);
  84227. /** @hidden */
  84228. easeInCore(gradient: number): number;
  84229. }
  84230. /**
  84231. * Easing function with an exponential shape (see link below).
  84232. * @see https://easings.net/#easeInExpo
  84233. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84234. */
  84235. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84236. /** Defines the exponent of the function */
  84237. exponent: number;
  84238. /**
  84239. * Instantiates an exponential easing function
  84240. * @see https://easings.net/#easeInExpo
  84241. * @param exponent Defines the exponent of the function
  84242. */
  84243. constructor(
  84244. /** Defines the exponent of the function */
  84245. exponent?: number);
  84246. /** @hidden */
  84247. easeInCore(gradient: number): number;
  84248. }
  84249. /**
  84250. * Easing function with a power shape (see link below).
  84251. * @see https://easings.net/#easeInQuad
  84252. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84253. */
  84254. export class PowerEase extends EasingFunction implements IEasingFunction {
  84255. /** Defines the power of the function */
  84256. power: number;
  84257. /**
  84258. * Instantiates an power base easing function
  84259. * @see https://easings.net/#easeInQuad
  84260. * @param power Defines the power of the function
  84261. */
  84262. constructor(
  84263. /** Defines the power of the function */
  84264. power?: number);
  84265. /** @hidden */
  84266. easeInCore(gradient: number): number;
  84267. }
  84268. /**
  84269. * Easing function with a power of 2 shape (see link below).
  84270. * @see https://easings.net/#easeInQuad
  84271. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84272. */
  84273. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84274. /** @hidden */
  84275. easeInCore(gradient: number): number;
  84276. }
  84277. /**
  84278. * Easing function with a power of 4 shape (see link below).
  84279. * @see https://easings.net/#easeInQuart
  84280. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84281. */
  84282. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84283. /** @hidden */
  84284. easeInCore(gradient: number): number;
  84285. }
  84286. /**
  84287. * Easing function with a power of 5 shape (see link below).
  84288. * @see https://easings.net/#easeInQuint
  84289. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84290. */
  84291. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84292. /** @hidden */
  84293. easeInCore(gradient: number): number;
  84294. }
  84295. /**
  84296. * Easing function with a sin shape (see link below).
  84297. * @see https://easings.net/#easeInSine
  84298. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84299. */
  84300. export class SineEase extends EasingFunction implements IEasingFunction {
  84301. /** @hidden */
  84302. easeInCore(gradient: number): number;
  84303. }
  84304. /**
  84305. * Easing function with a bezier shape (see link below).
  84306. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84307. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84308. */
  84309. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84310. /** Defines the x component of the start tangent in the bezier curve */
  84311. x1: number;
  84312. /** Defines the y component of the start tangent in the bezier curve */
  84313. y1: number;
  84314. /** Defines the x component of the end tangent in the bezier curve */
  84315. x2: number;
  84316. /** Defines the y component of the end tangent in the bezier curve */
  84317. y2: number;
  84318. /**
  84319. * Instantiates a bezier function
  84320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84321. * @param x1 Defines the x component of the start tangent in the bezier curve
  84322. * @param y1 Defines the y component of the start tangent in the bezier curve
  84323. * @param x2 Defines the x component of the end tangent in the bezier curve
  84324. * @param y2 Defines the y component of the end tangent in the bezier curve
  84325. */
  84326. constructor(
  84327. /** Defines the x component of the start tangent in the bezier curve */
  84328. x1?: number,
  84329. /** Defines the y component of the start tangent in the bezier curve */
  84330. y1?: number,
  84331. /** Defines the x component of the end tangent in the bezier curve */
  84332. x2?: number,
  84333. /** Defines the y component of the end tangent in the bezier curve */
  84334. y2?: number);
  84335. /** @hidden */
  84336. easeInCore(gradient: number): number;
  84337. }
  84338. }
  84339. declare module BABYLON {
  84340. /**
  84341. * Class used to hold a RBG color
  84342. */
  84343. export class Color3 {
  84344. /**
  84345. * Defines the red component (between 0 and 1, default is 0)
  84346. */
  84347. r: number;
  84348. /**
  84349. * Defines the green component (between 0 and 1, default is 0)
  84350. */
  84351. g: number;
  84352. /**
  84353. * Defines the blue component (between 0 and 1, default is 0)
  84354. */
  84355. b: number;
  84356. /**
  84357. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84358. * @param r defines the red component (between 0 and 1, default is 0)
  84359. * @param g defines the green component (between 0 and 1, default is 0)
  84360. * @param b defines the blue component (between 0 and 1, default is 0)
  84361. */
  84362. constructor(
  84363. /**
  84364. * Defines the red component (between 0 and 1, default is 0)
  84365. */
  84366. r?: number,
  84367. /**
  84368. * Defines the green component (between 0 and 1, default is 0)
  84369. */
  84370. g?: number,
  84371. /**
  84372. * Defines the blue component (between 0 and 1, default is 0)
  84373. */
  84374. b?: number);
  84375. /**
  84376. * Creates a string with the Color3 current values
  84377. * @returns the string representation of the Color3 object
  84378. */
  84379. toString(): string;
  84380. /**
  84381. * Returns the string "Color3"
  84382. * @returns "Color3"
  84383. */
  84384. getClassName(): string;
  84385. /**
  84386. * Compute the Color3 hash code
  84387. * @returns an unique number that can be used to hash Color3 objects
  84388. */
  84389. getHashCode(): number;
  84390. /**
  84391. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84392. * @param array defines the array where to store the r,g,b components
  84393. * @param index defines an optional index in the target array to define where to start storing values
  84394. * @returns the current Color3 object
  84395. */
  84396. toArray(array: FloatArray, index?: number): Color3;
  84397. /**
  84398. * Update the current color with values stored in an array from the starting index of the given array
  84399. * @param array defines the source array
  84400. * @param offset defines an offset in the source array
  84401. * @returns the current Color3 object
  84402. */
  84403. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84404. /**
  84405. * Returns a new Color4 object from the current Color3 and the given alpha
  84406. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84407. * @returns a new Color4 object
  84408. */
  84409. toColor4(alpha?: number): Color4;
  84410. /**
  84411. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84412. * @returns the new array
  84413. */
  84414. asArray(): number[];
  84415. /**
  84416. * Returns the luminance value
  84417. * @returns a float value
  84418. */
  84419. toLuminance(): number;
  84420. /**
  84421. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84422. * @param otherColor defines the second operand
  84423. * @returns the new Color3 object
  84424. */
  84425. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84426. /**
  84427. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84428. * @param otherColor defines the second operand
  84429. * @param result defines the Color3 object where to store the result
  84430. * @returns the current Color3
  84431. */
  84432. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84433. /**
  84434. * Determines equality between Color3 objects
  84435. * @param otherColor defines the second operand
  84436. * @returns true if the rgb values are equal to the given ones
  84437. */
  84438. equals(otherColor: DeepImmutable<Color3>): boolean;
  84439. /**
  84440. * Determines equality between the current Color3 object and a set of r,b,g values
  84441. * @param r defines the red component to check
  84442. * @param g defines the green component to check
  84443. * @param b defines the blue component to check
  84444. * @returns true if the rgb values are equal to the given ones
  84445. */
  84446. equalsFloats(r: number, g: number, b: number): boolean;
  84447. /**
  84448. * Multiplies in place each rgb value by scale
  84449. * @param scale defines the scaling factor
  84450. * @returns the updated Color3
  84451. */
  84452. scale(scale: number): Color3;
  84453. /**
  84454. * Multiplies the rgb values by scale and stores the result into "result"
  84455. * @param scale defines the scaling factor
  84456. * @param result defines the Color3 object where to store the result
  84457. * @returns the unmodified current Color3
  84458. */
  84459. scaleToRef(scale: number, result: Color3): Color3;
  84460. /**
  84461. * Scale the current Color3 values by a factor and add the result to a given Color3
  84462. * @param scale defines the scale factor
  84463. * @param result defines color to store the result into
  84464. * @returns the unmodified current Color3
  84465. */
  84466. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84467. /**
  84468. * Clamps the rgb values by the min and max values and stores the result into "result"
  84469. * @param min defines minimum clamping value (default is 0)
  84470. * @param max defines maximum clamping value (default is 1)
  84471. * @param result defines color to store the result into
  84472. * @returns the original Color3
  84473. */
  84474. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84475. /**
  84476. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84477. * @param otherColor defines the second operand
  84478. * @returns the new Color3
  84479. */
  84480. add(otherColor: DeepImmutable<Color3>): Color3;
  84481. /**
  84482. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84483. * @param otherColor defines the second operand
  84484. * @param result defines Color3 object to store the result into
  84485. * @returns the unmodified current Color3
  84486. */
  84487. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84488. /**
  84489. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84490. * @param otherColor defines the second operand
  84491. * @returns the new Color3
  84492. */
  84493. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84494. /**
  84495. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84496. * @param otherColor defines the second operand
  84497. * @param result defines Color3 object to store the result into
  84498. * @returns the unmodified current Color3
  84499. */
  84500. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84501. /**
  84502. * Copy the current object
  84503. * @returns a new Color3 copied the current one
  84504. */
  84505. clone(): Color3;
  84506. /**
  84507. * Copies the rgb values from the source in the current Color3
  84508. * @param source defines the source Color3 object
  84509. * @returns the updated Color3 object
  84510. */
  84511. copyFrom(source: DeepImmutable<Color3>): Color3;
  84512. /**
  84513. * Updates the Color3 rgb values from the given floats
  84514. * @param r defines the red component to read from
  84515. * @param g defines the green component to read from
  84516. * @param b defines the blue component to read from
  84517. * @returns the current Color3 object
  84518. */
  84519. copyFromFloats(r: number, g: number, b: number): Color3;
  84520. /**
  84521. * Updates the Color3 rgb values from the given floats
  84522. * @param r defines the red component to read from
  84523. * @param g defines the green component to read from
  84524. * @param b defines the blue component to read from
  84525. * @returns the current Color3 object
  84526. */
  84527. set(r: number, g: number, b: number): Color3;
  84528. /**
  84529. * Compute the Color3 hexadecimal code as a string
  84530. * @returns a string containing the hexadecimal representation of the Color3 object
  84531. */
  84532. toHexString(): string;
  84533. /**
  84534. * Computes a new Color3 converted from the current one to linear space
  84535. * @returns a new Color3 object
  84536. */
  84537. toLinearSpace(): Color3;
  84538. /**
  84539. * Converts current color in rgb space to HSV values
  84540. * @returns a new color3 representing the HSV values
  84541. */
  84542. toHSV(): Color3;
  84543. /**
  84544. * Converts current color in rgb space to HSV values
  84545. * @param result defines the Color3 where to store the HSV values
  84546. */
  84547. toHSVToRef(result: Color3): void;
  84548. /**
  84549. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84550. * @param convertedColor defines the Color3 object where to store the linear space version
  84551. * @returns the unmodified Color3
  84552. */
  84553. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84554. /**
  84555. * Computes a new Color3 converted from the current one to gamma space
  84556. * @returns a new Color3 object
  84557. */
  84558. toGammaSpace(): Color3;
  84559. /**
  84560. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84561. * @param convertedColor defines the Color3 object where to store the gamma space version
  84562. * @returns the unmodified Color3
  84563. */
  84564. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84565. private static _BlackReadOnly;
  84566. /**
  84567. * Convert Hue, saturation and value to a Color3 (RGB)
  84568. * @param hue defines the hue
  84569. * @param saturation defines the saturation
  84570. * @param value defines the value
  84571. * @param result defines the Color3 where to store the RGB values
  84572. */
  84573. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84574. /**
  84575. * Creates a new Color3 from the string containing valid hexadecimal values
  84576. * @param hex defines a string containing valid hexadecimal values
  84577. * @returns a new Color3 object
  84578. */
  84579. static FromHexString(hex: string): Color3;
  84580. /**
  84581. * Creates a new Color3 from the starting index of the given array
  84582. * @param array defines the source array
  84583. * @param offset defines an offset in the source array
  84584. * @returns a new Color3 object
  84585. */
  84586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84587. /**
  84588. * Creates a new Color3 from the starting index element of the given array
  84589. * @param array defines the source array to read from
  84590. * @param offset defines the offset in the source array
  84591. * @param result defines the target Color3 object
  84592. */
  84593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84594. /**
  84595. * Creates a new Color3 from integer values (< 256)
  84596. * @param r defines the red component to read from (value between 0 and 255)
  84597. * @param g defines the green component to read from (value between 0 and 255)
  84598. * @param b defines the blue component to read from (value between 0 and 255)
  84599. * @returns a new Color3 object
  84600. */
  84601. static FromInts(r: number, g: number, b: number): Color3;
  84602. /**
  84603. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84604. * @param start defines the start Color3 value
  84605. * @param end defines the end Color3 value
  84606. * @param amount defines the gradient value between start and end
  84607. * @returns a new Color3 object
  84608. */
  84609. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84610. /**
  84611. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84612. * @param left defines the start value
  84613. * @param right defines the end value
  84614. * @param amount defines the gradient factor
  84615. * @param result defines the Color3 object where to store the result
  84616. */
  84617. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84618. /**
  84619. * Returns a Color3 value containing a red color
  84620. * @returns a new Color3 object
  84621. */
  84622. static Red(): Color3;
  84623. /**
  84624. * Returns a Color3 value containing a green color
  84625. * @returns a new Color3 object
  84626. */
  84627. static Green(): Color3;
  84628. /**
  84629. * Returns a Color3 value containing a blue color
  84630. * @returns a new Color3 object
  84631. */
  84632. static Blue(): Color3;
  84633. /**
  84634. * Returns a Color3 value containing a black color
  84635. * @returns a new Color3 object
  84636. */
  84637. static Black(): Color3;
  84638. /**
  84639. * Gets a Color3 value containing a black color that must not be updated
  84640. */
  84641. static get BlackReadOnly(): DeepImmutable<Color3>;
  84642. /**
  84643. * Returns a Color3 value containing a white color
  84644. * @returns a new Color3 object
  84645. */
  84646. static White(): Color3;
  84647. /**
  84648. * Returns a Color3 value containing a purple color
  84649. * @returns a new Color3 object
  84650. */
  84651. static Purple(): Color3;
  84652. /**
  84653. * Returns a Color3 value containing a magenta color
  84654. * @returns a new Color3 object
  84655. */
  84656. static Magenta(): Color3;
  84657. /**
  84658. * Returns a Color3 value containing a yellow color
  84659. * @returns a new Color3 object
  84660. */
  84661. static Yellow(): Color3;
  84662. /**
  84663. * Returns a Color3 value containing a gray color
  84664. * @returns a new Color3 object
  84665. */
  84666. static Gray(): Color3;
  84667. /**
  84668. * Returns a Color3 value containing a teal color
  84669. * @returns a new Color3 object
  84670. */
  84671. static Teal(): Color3;
  84672. /**
  84673. * Returns a Color3 value containing a random color
  84674. * @returns a new Color3 object
  84675. */
  84676. static Random(): Color3;
  84677. }
  84678. /**
  84679. * Class used to hold a RBGA color
  84680. */
  84681. export class Color4 {
  84682. /**
  84683. * Defines the red component (between 0 and 1, default is 0)
  84684. */
  84685. r: number;
  84686. /**
  84687. * Defines the green component (between 0 and 1, default is 0)
  84688. */
  84689. g: number;
  84690. /**
  84691. * Defines the blue component (between 0 and 1, default is 0)
  84692. */
  84693. b: number;
  84694. /**
  84695. * Defines the alpha component (between 0 and 1, default is 1)
  84696. */
  84697. a: number;
  84698. /**
  84699. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84700. * @param r defines the red component (between 0 and 1, default is 0)
  84701. * @param g defines the green component (between 0 and 1, default is 0)
  84702. * @param b defines the blue component (between 0 and 1, default is 0)
  84703. * @param a defines the alpha component (between 0 and 1, default is 1)
  84704. */
  84705. constructor(
  84706. /**
  84707. * Defines the red component (between 0 and 1, default is 0)
  84708. */
  84709. r?: number,
  84710. /**
  84711. * Defines the green component (between 0 and 1, default is 0)
  84712. */
  84713. g?: number,
  84714. /**
  84715. * Defines the blue component (between 0 and 1, default is 0)
  84716. */
  84717. b?: number,
  84718. /**
  84719. * Defines the alpha component (between 0 and 1, default is 1)
  84720. */
  84721. a?: number);
  84722. /**
  84723. * Adds in place the given Color4 values to the current Color4 object
  84724. * @param right defines the second operand
  84725. * @returns the current updated Color4 object
  84726. */
  84727. addInPlace(right: DeepImmutable<Color4>): Color4;
  84728. /**
  84729. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84730. * @returns the new array
  84731. */
  84732. asArray(): number[];
  84733. /**
  84734. * Stores from the starting index in the given array the Color4 successive values
  84735. * @param array defines the array where to store the r,g,b components
  84736. * @param index defines an optional index in the target array to define where to start storing values
  84737. * @returns the current Color4 object
  84738. */
  84739. toArray(array: number[], index?: number): Color4;
  84740. /**
  84741. * Update the current color with values stored in an array from the starting index of the given array
  84742. * @param array defines the source array
  84743. * @param offset defines an offset in the source array
  84744. * @returns the current Color4 object
  84745. */
  84746. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84747. /**
  84748. * Determines equality between Color4 objects
  84749. * @param otherColor defines the second operand
  84750. * @returns true if the rgba values are equal to the given ones
  84751. */
  84752. equals(otherColor: DeepImmutable<Color4>): boolean;
  84753. /**
  84754. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84755. * @param right defines the second operand
  84756. * @returns a new Color4 object
  84757. */
  84758. add(right: DeepImmutable<Color4>): Color4;
  84759. /**
  84760. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84761. * @param right defines the second operand
  84762. * @returns a new Color4 object
  84763. */
  84764. subtract(right: DeepImmutable<Color4>): Color4;
  84765. /**
  84766. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84767. * @param right defines the second operand
  84768. * @param result defines the Color4 object where to store the result
  84769. * @returns the current Color4 object
  84770. */
  84771. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84772. /**
  84773. * Creates a new Color4 with the current Color4 values multiplied by scale
  84774. * @param scale defines the scaling factor to apply
  84775. * @returns a new Color4 object
  84776. */
  84777. scale(scale: number): Color4;
  84778. /**
  84779. * Multiplies the current Color4 values by scale and stores the result in "result"
  84780. * @param scale defines the scaling factor to apply
  84781. * @param result defines the Color4 object where to store the result
  84782. * @returns the current unmodified Color4
  84783. */
  84784. scaleToRef(scale: number, result: Color4): Color4;
  84785. /**
  84786. * Scale the current Color4 values by a factor and add the result to a given Color4
  84787. * @param scale defines the scale factor
  84788. * @param result defines the Color4 object where to store the result
  84789. * @returns the unmodified current Color4
  84790. */
  84791. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84792. /**
  84793. * Clamps the rgb values by the min and max values and stores the result into "result"
  84794. * @param min defines minimum clamping value (default is 0)
  84795. * @param max defines maximum clamping value (default is 1)
  84796. * @param result defines color to store the result into.
  84797. * @returns the cuurent Color4
  84798. */
  84799. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84800. /**
  84801. * Multipy an Color4 value by another and return a new Color4 object
  84802. * @param color defines the Color4 value to multiply by
  84803. * @returns a new Color4 object
  84804. */
  84805. multiply(color: Color4): Color4;
  84806. /**
  84807. * Multipy a Color4 value by another and push the result in a reference value
  84808. * @param color defines the Color4 value to multiply by
  84809. * @param result defines the Color4 to fill the result in
  84810. * @returns the result Color4
  84811. */
  84812. multiplyToRef(color: Color4, result: Color4): Color4;
  84813. /**
  84814. * Creates a string with the Color4 current values
  84815. * @returns the string representation of the Color4 object
  84816. */
  84817. toString(): string;
  84818. /**
  84819. * Returns the string "Color4"
  84820. * @returns "Color4"
  84821. */
  84822. getClassName(): string;
  84823. /**
  84824. * Compute the Color4 hash code
  84825. * @returns an unique number that can be used to hash Color4 objects
  84826. */
  84827. getHashCode(): number;
  84828. /**
  84829. * Creates a new Color4 copied from the current one
  84830. * @returns a new Color4 object
  84831. */
  84832. clone(): Color4;
  84833. /**
  84834. * Copies the given Color4 values into the current one
  84835. * @param source defines the source Color4 object
  84836. * @returns the current updated Color4 object
  84837. */
  84838. copyFrom(source: Color4): Color4;
  84839. /**
  84840. * Copies the given float values into the current one
  84841. * @param r defines the red component to read from
  84842. * @param g defines the green component to read from
  84843. * @param b defines the blue component to read from
  84844. * @param a defines the alpha component to read from
  84845. * @returns the current updated Color4 object
  84846. */
  84847. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84848. /**
  84849. * Copies the given float values into the current one
  84850. * @param r defines the red component to read from
  84851. * @param g defines the green component to read from
  84852. * @param b defines the blue component to read from
  84853. * @param a defines the alpha component to read from
  84854. * @returns the current updated Color4 object
  84855. */
  84856. set(r: number, g: number, b: number, a: number): Color4;
  84857. /**
  84858. * Compute the Color4 hexadecimal code as a string
  84859. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84860. * @returns a string containing the hexadecimal representation of the Color4 object
  84861. */
  84862. toHexString(returnAsColor3?: boolean): string;
  84863. /**
  84864. * Computes a new Color4 converted from the current one to linear space
  84865. * @returns a new Color4 object
  84866. */
  84867. toLinearSpace(): Color4;
  84868. /**
  84869. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84870. * @param convertedColor defines the Color4 object where to store the linear space version
  84871. * @returns the unmodified Color4
  84872. */
  84873. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84874. /**
  84875. * Computes a new Color4 converted from the current one to gamma space
  84876. * @returns a new Color4 object
  84877. */
  84878. toGammaSpace(): Color4;
  84879. /**
  84880. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84881. * @param convertedColor defines the Color4 object where to store the gamma space version
  84882. * @returns the unmodified Color4
  84883. */
  84884. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84885. /**
  84886. * Creates a new Color4 from the string containing valid hexadecimal values
  84887. * @param hex defines a string containing valid hexadecimal values
  84888. * @returns a new Color4 object
  84889. */
  84890. static FromHexString(hex: string): Color4;
  84891. /**
  84892. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84893. * @param left defines the start value
  84894. * @param right defines the end value
  84895. * @param amount defines the gradient factor
  84896. * @returns a new Color4 object
  84897. */
  84898. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84899. /**
  84900. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84901. * @param left defines the start value
  84902. * @param right defines the end value
  84903. * @param amount defines the gradient factor
  84904. * @param result defines the Color4 object where to store data
  84905. */
  84906. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84907. /**
  84908. * Creates a new Color4 from a Color3 and an alpha value
  84909. * @param color3 defines the source Color3 to read from
  84910. * @param alpha defines the alpha component (1.0 by default)
  84911. * @returns a new Color4 object
  84912. */
  84913. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84914. /**
  84915. * Creates a new Color4 from the starting index element of the given array
  84916. * @param array defines the source array to read from
  84917. * @param offset defines the offset in the source array
  84918. * @returns a new Color4 object
  84919. */
  84920. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84921. /**
  84922. * Creates a new Color4 from the starting index element of the given array
  84923. * @param array defines the source array to read from
  84924. * @param offset defines the offset in the source array
  84925. * @param result defines the target Color4 object
  84926. */
  84927. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  84928. /**
  84929. * Creates a new Color3 from integer values (< 256)
  84930. * @param r defines the red component to read from (value between 0 and 255)
  84931. * @param g defines the green component to read from (value between 0 and 255)
  84932. * @param b defines the blue component to read from (value between 0 and 255)
  84933. * @param a defines the alpha component to read from (value between 0 and 255)
  84934. * @returns a new Color3 object
  84935. */
  84936. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84937. /**
  84938. * Check the content of a given array and convert it to an array containing RGBA data
  84939. * If the original array was already containing count * 4 values then it is returned directly
  84940. * @param colors defines the array to check
  84941. * @param count defines the number of RGBA data to expect
  84942. * @returns an array containing count * 4 values (RGBA)
  84943. */
  84944. static CheckColors4(colors: number[], count: number): number[];
  84945. }
  84946. /**
  84947. * @hidden
  84948. */
  84949. export class TmpColors {
  84950. static Color3: Color3[];
  84951. static Color4: Color4[];
  84952. }
  84953. }
  84954. declare module BABYLON {
  84955. /**
  84956. * Defines an interface which represents an animation key frame
  84957. */
  84958. export interface IAnimationKey {
  84959. /**
  84960. * Frame of the key frame
  84961. */
  84962. frame: number;
  84963. /**
  84964. * Value at the specifies key frame
  84965. */
  84966. value: any;
  84967. /**
  84968. * The input tangent for the cubic hermite spline
  84969. */
  84970. inTangent?: any;
  84971. /**
  84972. * The output tangent for the cubic hermite spline
  84973. */
  84974. outTangent?: any;
  84975. /**
  84976. * The animation interpolation type
  84977. */
  84978. interpolation?: AnimationKeyInterpolation;
  84979. }
  84980. /**
  84981. * Enum for the animation key frame interpolation type
  84982. */
  84983. export enum AnimationKeyInterpolation {
  84984. /**
  84985. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84986. */
  84987. STEP = 1
  84988. }
  84989. }
  84990. declare module BABYLON {
  84991. /**
  84992. * Represents the range of an animation
  84993. */
  84994. export class AnimationRange {
  84995. /**The name of the animation range**/
  84996. name: string;
  84997. /**The starting frame of the animation */
  84998. from: number;
  84999. /**The ending frame of the animation*/
  85000. to: number;
  85001. /**
  85002. * Initializes the range of an animation
  85003. * @param name The name of the animation range
  85004. * @param from The starting frame of the animation
  85005. * @param to The ending frame of the animation
  85006. */
  85007. constructor(
  85008. /**The name of the animation range**/
  85009. name: string,
  85010. /**The starting frame of the animation */
  85011. from: number,
  85012. /**The ending frame of the animation*/
  85013. to: number);
  85014. /**
  85015. * Makes a copy of the animation range
  85016. * @returns A copy of the animation range
  85017. */
  85018. clone(): AnimationRange;
  85019. }
  85020. }
  85021. declare module BABYLON {
  85022. /**
  85023. * Composed of a frame, and an action function
  85024. */
  85025. export class AnimationEvent {
  85026. /** The frame for which the event is triggered **/
  85027. frame: number;
  85028. /** The event to perform when triggered **/
  85029. action: (currentFrame: number) => void;
  85030. /** Specifies if the event should be triggered only once**/
  85031. onlyOnce?: boolean | undefined;
  85032. /**
  85033. * Specifies if the animation event is done
  85034. */
  85035. isDone: boolean;
  85036. /**
  85037. * Initializes the animation event
  85038. * @param frame The frame for which the event is triggered
  85039. * @param action The event to perform when triggered
  85040. * @param onlyOnce Specifies if the event should be triggered only once
  85041. */
  85042. constructor(
  85043. /** The frame for which the event is triggered **/
  85044. frame: number,
  85045. /** The event to perform when triggered **/
  85046. action: (currentFrame: number) => void,
  85047. /** Specifies if the event should be triggered only once**/
  85048. onlyOnce?: boolean | undefined);
  85049. /** @hidden */
  85050. _clone(): AnimationEvent;
  85051. }
  85052. }
  85053. declare module BABYLON {
  85054. /**
  85055. * Interface used to define a behavior
  85056. */
  85057. export interface Behavior<T> {
  85058. /** gets or sets behavior's name */
  85059. name: string;
  85060. /**
  85061. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85062. */
  85063. init(): void;
  85064. /**
  85065. * Called when the behavior is attached to a target
  85066. * @param target defines the target where the behavior is attached to
  85067. */
  85068. attach(target: T): void;
  85069. /**
  85070. * Called when the behavior is detached from its target
  85071. */
  85072. detach(): void;
  85073. }
  85074. /**
  85075. * Interface implemented by classes supporting behaviors
  85076. */
  85077. export interface IBehaviorAware<T> {
  85078. /**
  85079. * Attach a behavior
  85080. * @param behavior defines the behavior to attach
  85081. * @returns the current host
  85082. */
  85083. addBehavior(behavior: Behavior<T>): T;
  85084. /**
  85085. * Remove a behavior from the current object
  85086. * @param behavior defines the behavior to detach
  85087. * @returns the current host
  85088. */
  85089. removeBehavior(behavior: Behavior<T>): T;
  85090. /**
  85091. * Gets a behavior using its name to search
  85092. * @param name defines the name to search
  85093. * @returns the behavior or null if not found
  85094. */
  85095. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85096. }
  85097. }
  85098. declare module BABYLON {
  85099. /**
  85100. * Defines an array and its length.
  85101. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85102. */
  85103. export interface ISmartArrayLike<T> {
  85104. /**
  85105. * The data of the array.
  85106. */
  85107. data: Array<T>;
  85108. /**
  85109. * The active length of the array.
  85110. */
  85111. length: number;
  85112. }
  85113. /**
  85114. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85115. */
  85116. export class SmartArray<T> implements ISmartArrayLike<T> {
  85117. /**
  85118. * The full set of data from the array.
  85119. */
  85120. data: Array<T>;
  85121. /**
  85122. * The active length of the array.
  85123. */
  85124. length: number;
  85125. protected _id: number;
  85126. /**
  85127. * Instantiates a Smart Array.
  85128. * @param capacity defines the default capacity of the array.
  85129. */
  85130. constructor(capacity: number);
  85131. /**
  85132. * Pushes a value at the end of the active data.
  85133. * @param value defines the object to push in the array.
  85134. */
  85135. push(value: T): void;
  85136. /**
  85137. * Iterates over the active data and apply the lambda to them.
  85138. * @param func defines the action to apply on each value.
  85139. */
  85140. forEach(func: (content: T) => void): void;
  85141. /**
  85142. * Sorts the full sets of data.
  85143. * @param compareFn defines the comparison function to apply.
  85144. */
  85145. sort(compareFn: (a: T, b: T) => number): void;
  85146. /**
  85147. * Resets the active data to an empty array.
  85148. */
  85149. reset(): void;
  85150. /**
  85151. * Releases all the data from the array as well as the array.
  85152. */
  85153. dispose(): void;
  85154. /**
  85155. * Concats the active data with a given array.
  85156. * @param array defines the data to concatenate with.
  85157. */
  85158. concat(array: any): void;
  85159. /**
  85160. * Returns the position of a value in the active data.
  85161. * @param value defines the value to find the index for
  85162. * @returns the index if found in the active data otherwise -1
  85163. */
  85164. indexOf(value: T): number;
  85165. /**
  85166. * Returns whether an element is part of the active data.
  85167. * @param value defines the value to look for
  85168. * @returns true if found in the active data otherwise false
  85169. */
  85170. contains(value: T): boolean;
  85171. private static _GlobalId;
  85172. }
  85173. /**
  85174. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85175. * The data in this array can only be present once
  85176. */
  85177. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85178. private _duplicateId;
  85179. /**
  85180. * Pushes a value at the end of the active data.
  85181. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85182. * @param value defines the object to push in the array.
  85183. */
  85184. push(value: T): void;
  85185. /**
  85186. * Pushes a value at the end of the active data.
  85187. * If the data is already present, it won t be added again
  85188. * @param value defines the object to push in the array.
  85189. * @returns true if added false if it was already present
  85190. */
  85191. pushNoDuplicate(value: T): boolean;
  85192. /**
  85193. * Resets the active data to an empty array.
  85194. */
  85195. reset(): void;
  85196. /**
  85197. * Concats the active data with a given array.
  85198. * This ensures no dupplicate will be present in the result.
  85199. * @param array defines the data to concatenate with.
  85200. */
  85201. concatWithNoDuplicate(array: any): void;
  85202. }
  85203. }
  85204. declare module BABYLON {
  85205. /**
  85206. * @ignore
  85207. * This is a list of all the different input types that are available in the application.
  85208. * Fo instance: ArcRotateCameraGamepadInput...
  85209. */
  85210. export var CameraInputTypes: {};
  85211. /**
  85212. * This is the contract to implement in order to create a new input class.
  85213. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85214. */
  85215. export interface ICameraInput<TCamera extends Camera> {
  85216. /**
  85217. * Defines the camera the input is attached to.
  85218. */
  85219. camera: Nullable<TCamera>;
  85220. /**
  85221. * Gets the class name of the current intput.
  85222. * @returns the class name
  85223. */
  85224. getClassName(): string;
  85225. /**
  85226. * Get the friendly name associated with the input class.
  85227. * @returns the input friendly name
  85228. */
  85229. getSimpleName(): string;
  85230. /**
  85231. * Attach the input controls to a specific dom element to get the input from.
  85232. * @param element Defines the element the controls should be listened from
  85233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85234. */
  85235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85236. /**
  85237. * Detach the current controls from the specified dom element.
  85238. * @param element Defines the element to stop listening the inputs from
  85239. */
  85240. detachControl(element: Nullable<HTMLElement>): void;
  85241. /**
  85242. * Update the current camera state depending on the inputs that have been used this frame.
  85243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85244. */
  85245. checkInputs?: () => void;
  85246. }
  85247. /**
  85248. * Represents a map of input types to input instance or input index to input instance.
  85249. */
  85250. export interface CameraInputsMap<TCamera extends Camera> {
  85251. /**
  85252. * Accessor to the input by input type.
  85253. */
  85254. [name: string]: ICameraInput<TCamera>;
  85255. /**
  85256. * Accessor to the input by input index.
  85257. */
  85258. [idx: number]: ICameraInput<TCamera>;
  85259. }
  85260. /**
  85261. * This represents the input manager used within a camera.
  85262. * It helps dealing with all the different kind of input attached to a camera.
  85263. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85264. */
  85265. export class CameraInputsManager<TCamera extends Camera> {
  85266. /**
  85267. * Defines the list of inputs attahed to the camera.
  85268. */
  85269. attached: CameraInputsMap<TCamera>;
  85270. /**
  85271. * Defines the dom element the camera is collecting inputs from.
  85272. * This is null if the controls have not been attached.
  85273. */
  85274. attachedElement: Nullable<HTMLElement>;
  85275. /**
  85276. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85277. */
  85278. noPreventDefault: boolean;
  85279. /**
  85280. * Defined the camera the input manager belongs to.
  85281. */
  85282. camera: TCamera;
  85283. /**
  85284. * Update the current camera state depending on the inputs that have been used this frame.
  85285. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85286. */
  85287. checkInputs: () => void;
  85288. /**
  85289. * Instantiate a new Camera Input Manager.
  85290. * @param camera Defines the camera the input manager blongs to
  85291. */
  85292. constructor(camera: TCamera);
  85293. /**
  85294. * Add an input method to a camera
  85295. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85296. * @param input camera input method
  85297. */
  85298. add(input: ICameraInput<TCamera>): void;
  85299. /**
  85300. * Remove a specific input method from a camera
  85301. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85302. * @param inputToRemove camera input method
  85303. */
  85304. remove(inputToRemove: ICameraInput<TCamera>): void;
  85305. /**
  85306. * Remove a specific input type from a camera
  85307. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85308. * @param inputType the type of the input to remove
  85309. */
  85310. removeByType(inputType: string): void;
  85311. private _addCheckInputs;
  85312. /**
  85313. * Attach the input controls to the currently attached dom element to listen the events from.
  85314. * @param input Defines the input to attach
  85315. */
  85316. attachInput(input: ICameraInput<TCamera>): void;
  85317. /**
  85318. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85319. * @param element Defines the dom element to collect the events from
  85320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85321. */
  85322. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85323. /**
  85324. * Detach the current manager inputs controls from a specific dom element.
  85325. * @param element Defines the dom element to collect the events from
  85326. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85327. */
  85328. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85329. /**
  85330. * Rebuild the dynamic inputCheck function from the current list of
  85331. * defined inputs in the manager.
  85332. */
  85333. rebuildInputCheck(): void;
  85334. /**
  85335. * Remove all attached input methods from a camera
  85336. */
  85337. clear(): void;
  85338. /**
  85339. * Serialize the current input manager attached to a camera.
  85340. * This ensures than once parsed,
  85341. * the input associated to the camera will be identical to the current ones
  85342. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85343. */
  85344. serialize(serializedCamera: any): void;
  85345. /**
  85346. * Parses an input manager serialized JSON to restore the previous list of inputs
  85347. * and states associated to a camera.
  85348. * @param parsedCamera Defines the JSON to parse
  85349. */
  85350. parse(parsedCamera: any): void;
  85351. }
  85352. }
  85353. declare module BABYLON {
  85354. /**
  85355. * Class used to store data that will be store in GPU memory
  85356. */
  85357. export class Buffer {
  85358. private _engine;
  85359. private _buffer;
  85360. /** @hidden */
  85361. _data: Nullable<DataArray>;
  85362. private _updatable;
  85363. private _instanced;
  85364. private _divisor;
  85365. /**
  85366. * Gets the byte stride.
  85367. */
  85368. readonly byteStride: number;
  85369. /**
  85370. * Constructor
  85371. * @param engine the engine
  85372. * @param data the data to use for this buffer
  85373. * @param updatable whether the data is updatable
  85374. * @param stride the stride (optional)
  85375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85376. * @param instanced whether the buffer is instanced (optional)
  85377. * @param useBytes set to true if the stride in in bytes (optional)
  85378. * @param divisor sets an optional divisor for instances (1 by default)
  85379. */
  85380. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85381. /**
  85382. * Create a new VertexBuffer based on the current buffer
  85383. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85384. * @param offset defines offset in the buffer (0 by default)
  85385. * @param size defines the size in floats of attributes (position is 3 for instance)
  85386. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85387. * @param instanced defines if the vertex buffer contains indexed data
  85388. * @param useBytes defines if the offset and stride are in bytes *
  85389. * @param divisor sets an optional divisor for instances (1 by default)
  85390. * @returns the new vertex buffer
  85391. */
  85392. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85393. /**
  85394. * Gets a boolean indicating if the Buffer is updatable?
  85395. * @returns true if the buffer is updatable
  85396. */
  85397. isUpdatable(): boolean;
  85398. /**
  85399. * Gets current buffer's data
  85400. * @returns a DataArray or null
  85401. */
  85402. getData(): Nullable<DataArray>;
  85403. /**
  85404. * Gets underlying native buffer
  85405. * @returns underlying native buffer
  85406. */
  85407. getBuffer(): Nullable<DataBuffer>;
  85408. /**
  85409. * Gets the stride in float32 units (i.e. byte stride / 4).
  85410. * May not be an integer if the byte stride is not divisible by 4.
  85411. * @returns the stride in float32 units
  85412. * @deprecated Please use byteStride instead.
  85413. */
  85414. getStrideSize(): number;
  85415. /**
  85416. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85417. * @param data defines the data to store
  85418. */
  85419. create(data?: Nullable<DataArray>): void;
  85420. /** @hidden */
  85421. _rebuild(): void;
  85422. /**
  85423. * Update current buffer data
  85424. * @param data defines the data to store
  85425. */
  85426. update(data: DataArray): void;
  85427. /**
  85428. * Updates the data directly.
  85429. * @param data the new data
  85430. * @param offset the new offset
  85431. * @param vertexCount the vertex count (optional)
  85432. * @param useBytes set to true if the offset is in bytes
  85433. */
  85434. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85435. /**
  85436. * Release all resources
  85437. */
  85438. dispose(): void;
  85439. }
  85440. /**
  85441. * Specialized buffer used to store vertex data
  85442. */
  85443. export class VertexBuffer {
  85444. /** @hidden */
  85445. _buffer: Buffer;
  85446. private _kind;
  85447. private _size;
  85448. private _ownsBuffer;
  85449. private _instanced;
  85450. private _instanceDivisor;
  85451. /**
  85452. * The byte type.
  85453. */
  85454. static readonly BYTE: number;
  85455. /**
  85456. * The unsigned byte type.
  85457. */
  85458. static readonly UNSIGNED_BYTE: number;
  85459. /**
  85460. * The short type.
  85461. */
  85462. static readonly SHORT: number;
  85463. /**
  85464. * The unsigned short type.
  85465. */
  85466. static readonly UNSIGNED_SHORT: number;
  85467. /**
  85468. * The integer type.
  85469. */
  85470. static readonly INT: number;
  85471. /**
  85472. * The unsigned integer type.
  85473. */
  85474. static readonly UNSIGNED_INT: number;
  85475. /**
  85476. * The float type.
  85477. */
  85478. static readonly FLOAT: number;
  85479. /**
  85480. * Gets or sets the instance divisor when in instanced mode
  85481. */
  85482. get instanceDivisor(): number;
  85483. set instanceDivisor(value: number);
  85484. /**
  85485. * Gets the byte stride.
  85486. */
  85487. readonly byteStride: number;
  85488. /**
  85489. * Gets the byte offset.
  85490. */
  85491. readonly byteOffset: number;
  85492. /**
  85493. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85494. */
  85495. readonly normalized: boolean;
  85496. /**
  85497. * Gets the data type of each component in the array.
  85498. */
  85499. readonly type: number;
  85500. /**
  85501. * Constructor
  85502. * @param engine the engine
  85503. * @param data the data to use for this vertex buffer
  85504. * @param kind the vertex buffer kind
  85505. * @param updatable whether the data is updatable
  85506. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85507. * @param stride the stride (optional)
  85508. * @param instanced whether the buffer is instanced (optional)
  85509. * @param offset the offset of the data (optional)
  85510. * @param size the number of components (optional)
  85511. * @param type the type of the component (optional)
  85512. * @param normalized whether the data contains normalized data (optional)
  85513. * @param useBytes set to true if stride and offset are in bytes (optional)
  85514. * @param divisor defines the instance divisor to use (1 by default)
  85515. */
  85516. 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);
  85517. /** @hidden */
  85518. _rebuild(): void;
  85519. /**
  85520. * Returns the kind of the VertexBuffer (string)
  85521. * @returns a string
  85522. */
  85523. getKind(): string;
  85524. /**
  85525. * Gets a boolean indicating if the VertexBuffer is updatable?
  85526. * @returns true if the buffer is updatable
  85527. */
  85528. isUpdatable(): boolean;
  85529. /**
  85530. * Gets current buffer's data
  85531. * @returns a DataArray or null
  85532. */
  85533. getData(): Nullable<DataArray>;
  85534. /**
  85535. * Gets underlying native buffer
  85536. * @returns underlying native buffer
  85537. */
  85538. getBuffer(): Nullable<DataBuffer>;
  85539. /**
  85540. * Gets the stride in float32 units (i.e. byte stride / 4).
  85541. * May not be an integer if the byte stride is not divisible by 4.
  85542. * @returns the stride in float32 units
  85543. * @deprecated Please use byteStride instead.
  85544. */
  85545. getStrideSize(): number;
  85546. /**
  85547. * Returns the offset as a multiple of the type byte length.
  85548. * @returns the offset in bytes
  85549. * @deprecated Please use byteOffset instead.
  85550. */
  85551. getOffset(): number;
  85552. /**
  85553. * Returns the number of components per vertex attribute (integer)
  85554. * @returns the size in float
  85555. */
  85556. getSize(): number;
  85557. /**
  85558. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85559. * @returns true if this buffer is instanced
  85560. */
  85561. getIsInstanced(): boolean;
  85562. /**
  85563. * Returns the instancing divisor, zero for non-instanced (integer).
  85564. * @returns a number
  85565. */
  85566. getInstanceDivisor(): number;
  85567. /**
  85568. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85569. * @param data defines the data to store
  85570. */
  85571. create(data?: DataArray): void;
  85572. /**
  85573. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85574. * This function will create a new buffer if the current one is not updatable
  85575. * @param data defines the data to store
  85576. */
  85577. update(data: DataArray): void;
  85578. /**
  85579. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85580. * Returns the directly updated WebGLBuffer.
  85581. * @param data the new data
  85582. * @param offset the new offset
  85583. * @param useBytes set to true if the offset is in bytes
  85584. */
  85585. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85586. /**
  85587. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85588. */
  85589. dispose(): void;
  85590. /**
  85591. * Enumerates each value of this vertex buffer as numbers.
  85592. * @param count the number of values to enumerate
  85593. * @param callback the callback function called for each value
  85594. */
  85595. forEach(count: number, callback: (value: number, index: number) => void): void;
  85596. /**
  85597. * Positions
  85598. */
  85599. static readonly PositionKind: string;
  85600. /**
  85601. * Normals
  85602. */
  85603. static readonly NormalKind: string;
  85604. /**
  85605. * Tangents
  85606. */
  85607. static readonly TangentKind: string;
  85608. /**
  85609. * Texture coordinates
  85610. */
  85611. static readonly UVKind: string;
  85612. /**
  85613. * Texture coordinates 2
  85614. */
  85615. static readonly UV2Kind: string;
  85616. /**
  85617. * Texture coordinates 3
  85618. */
  85619. static readonly UV3Kind: string;
  85620. /**
  85621. * Texture coordinates 4
  85622. */
  85623. static readonly UV4Kind: string;
  85624. /**
  85625. * Texture coordinates 5
  85626. */
  85627. static readonly UV5Kind: string;
  85628. /**
  85629. * Texture coordinates 6
  85630. */
  85631. static readonly UV6Kind: string;
  85632. /**
  85633. * Colors
  85634. */
  85635. static readonly ColorKind: string;
  85636. /**
  85637. * Matrix indices (for bones)
  85638. */
  85639. static readonly MatricesIndicesKind: string;
  85640. /**
  85641. * Matrix weights (for bones)
  85642. */
  85643. static readonly MatricesWeightsKind: string;
  85644. /**
  85645. * Additional matrix indices (for bones)
  85646. */
  85647. static readonly MatricesIndicesExtraKind: string;
  85648. /**
  85649. * Additional matrix weights (for bones)
  85650. */
  85651. static readonly MatricesWeightsExtraKind: string;
  85652. /**
  85653. * Deduces the stride given a kind.
  85654. * @param kind The kind string to deduce
  85655. * @returns The deduced stride
  85656. */
  85657. static DeduceStride(kind: string): number;
  85658. /**
  85659. * Gets the byte length of the given type.
  85660. * @param type the type
  85661. * @returns the number of bytes
  85662. */
  85663. static GetTypeByteLength(type: number): number;
  85664. /**
  85665. * Enumerates each value of the given parameters as numbers.
  85666. * @param data the data to enumerate
  85667. * @param byteOffset the byte offset of the data
  85668. * @param byteStride the byte stride of the data
  85669. * @param componentCount the number of components per element
  85670. * @param componentType the type of the component
  85671. * @param count the number of values to enumerate
  85672. * @param normalized whether the data is normalized
  85673. * @param callback the callback function called for each value
  85674. */
  85675. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85676. private static _GetFloatValue;
  85677. }
  85678. }
  85679. declare module BABYLON {
  85680. /**
  85681. * @hidden
  85682. */
  85683. export class IntersectionInfo {
  85684. bu: Nullable<number>;
  85685. bv: Nullable<number>;
  85686. distance: number;
  85687. faceId: number;
  85688. subMeshId: number;
  85689. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85690. }
  85691. }
  85692. declare module BABYLON {
  85693. /**
  85694. * Class used to store bounding sphere information
  85695. */
  85696. export class BoundingSphere {
  85697. /**
  85698. * Gets the center of the bounding sphere in local space
  85699. */
  85700. readonly center: Vector3;
  85701. /**
  85702. * Radius of the bounding sphere in local space
  85703. */
  85704. radius: number;
  85705. /**
  85706. * Gets the center of the bounding sphere in world space
  85707. */
  85708. readonly centerWorld: Vector3;
  85709. /**
  85710. * Radius of the bounding sphere in world space
  85711. */
  85712. radiusWorld: number;
  85713. /**
  85714. * Gets the minimum vector in local space
  85715. */
  85716. readonly minimum: Vector3;
  85717. /**
  85718. * Gets the maximum vector in local space
  85719. */
  85720. readonly maximum: Vector3;
  85721. private _worldMatrix;
  85722. private static readonly TmpVector3;
  85723. /**
  85724. * Creates a new bounding sphere
  85725. * @param min defines the minimum vector (in local space)
  85726. * @param max defines the maximum vector (in local space)
  85727. * @param worldMatrix defines the new world matrix
  85728. */
  85729. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85730. /**
  85731. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85732. * @param min defines the new minimum vector (in local space)
  85733. * @param max defines the new maximum vector (in local space)
  85734. * @param worldMatrix defines the new world matrix
  85735. */
  85736. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85737. /**
  85738. * Scale the current bounding sphere by applying a scale factor
  85739. * @param factor defines the scale factor to apply
  85740. * @returns the current bounding box
  85741. */
  85742. scale(factor: number): BoundingSphere;
  85743. /**
  85744. * Gets the world matrix of the bounding box
  85745. * @returns a matrix
  85746. */
  85747. getWorldMatrix(): DeepImmutable<Matrix>;
  85748. /** @hidden */
  85749. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85750. /**
  85751. * Tests if the bounding sphere is intersecting the frustum planes
  85752. * @param frustumPlanes defines the frustum planes to test
  85753. * @returns true if there is an intersection
  85754. */
  85755. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85756. /**
  85757. * Tests if the bounding sphere center is in between the frustum planes.
  85758. * Used for optimistic fast inclusion.
  85759. * @param frustumPlanes defines the frustum planes to test
  85760. * @returns true if the sphere center is in between the frustum planes
  85761. */
  85762. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85763. /**
  85764. * Tests if a point is inside the bounding sphere
  85765. * @param point defines the point to test
  85766. * @returns true if the point is inside the bounding sphere
  85767. */
  85768. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85769. /**
  85770. * Checks if two sphere intersct
  85771. * @param sphere0 sphere 0
  85772. * @param sphere1 sphere 1
  85773. * @returns true if the speres intersect
  85774. */
  85775. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85776. }
  85777. }
  85778. declare module BABYLON {
  85779. /**
  85780. * Class used to store bounding box information
  85781. */
  85782. export class BoundingBox implements ICullable {
  85783. /**
  85784. * Gets the 8 vectors representing the bounding box in local space
  85785. */
  85786. readonly vectors: Vector3[];
  85787. /**
  85788. * Gets the center of the bounding box in local space
  85789. */
  85790. readonly center: Vector3;
  85791. /**
  85792. * Gets the center of the bounding box in world space
  85793. */
  85794. readonly centerWorld: Vector3;
  85795. /**
  85796. * Gets the extend size in local space
  85797. */
  85798. readonly extendSize: Vector3;
  85799. /**
  85800. * Gets the extend size in world space
  85801. */
  85802. readonly extendSizeWorld: Vector3;
  85803. /**
  85804. * Gets the OBB (object bounding box) directions
  85805. */
  85806. readonly directions: Vector3[];
  85807. /**
  85808. * Gets the 8 vectors representing the bounding box in world space
  85809. */
  85810. readonly vectorsWorld: Vector3[];
  85811. /**
  85812. * Gets the minimum vector in world space
  85813. */
  85814. readonly minimumWorld: Vector3;
  85815. /**
  85816. * Gets the maximum vector in world space
  85817. */
  85818. readonly maximumWorld: Vector3;
  85819. /**
  85820. * Gets the minimum vector in local space
  85821. */
  85822. readonly minimum: Vector3;
  85823. /**
  85824. * Gets the maximum vector in local space
  85825. */
  85826. readonly maximum: Vector3;
  85827. private _worldMatrix;
  85828. private static readonly TmpVector3;
  85829. /**
  85830. * @hidden
  85831. */
  85832. _tag: number;
  85833. /**
  85834. * Creates a new bounding box
  85835. * @param min defines the minimum vector (in local space)
  85836. * @param max defines the maximum vector (in local space)
  85837. * @param worldMatrix defines the new world matrix
  85838. */
  85839. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85840. /**
  85841. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85842. * @param min defines the new minimum vector (in local space)
  85843. * @param max defines the new maximum vector (in local space)
  85844. * @param worldMatrix defines the new world matrix
  85845. */
  85846. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85847. /**
  85848. * Scale the current bounding box by applying a scale factor
  85849. * @param factor defines the scale factor to apply
  85850. * @returns the current bounding box
  85851. */
  85852. scale(factor: number): BoundingBox;
  85853. /**
  85854. * Gets the world matrix of the bounding box
  85855. * @returns a matrix
  85856. */
  85857. getWorldMatrix(): DeepImmutable<Matrix>;
  85858. /** @hidden */
  85859. _update(world: DeepImmutable<Matrix>): void;
  85860. /**
  85861. * Tests if the bounding box is intersecting the frustum planes
  85862. * @param frustumPlanes defines the frustum planes to test
  85863. * @returns true if there is an intersection
  85864. */
  85865. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85866. /**
  85867. * Tests if the bounding box is entirely inside the frustum planes
  85868. * @param frustumPlanes defines the frustum planes to test
  85869. * @returns true if there is an inclusion
  85870. */
  85871. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85872. /**
  85873. * Tests if a point is inside the bounding box
  85874. * @param point defines the point to test
  85875. * @returns true if the point is inside the bounding box
  85876. */
  85877. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85878. /**
  85879. * Tests if the bounding box intersects with a bounding sphere
  85880. * @param sphere defines the sphere to test
  85881. * @returns true if there is an intersection
  85882. */
  85883. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85884. /**
  85885. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85886. * @param min defines the min vector to use
  85887. * @param max defines the max vector to use
  85888. * @returns true if there is an intersection
  85889. */
  85890. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85891. /**
  85892. * Tests if two bounding boxes are intersections
  85893. * @param box0 defines the first box to test
  85894. * @param box1 defines the second box to test
  85895. * @returns true if there is an intersection
  85896. */
  85897. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85898. /**
  85899. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85900. * @param minPoint defines the minimum vector of the bounding box
  85901. * @param maxPoint defines the maximum vector of the bounding box
  85902. * @param sphereCenter defines the sphere center
  85903. * @param sphereRadius defines the sphere radius
  85904. * @returns true if there is an intersection
  85905. */
  85906. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85907. /**
  85908. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85909. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85910. * @param frustumPlanes defines the frustum planes to test
  85911. * @return true if there is an inclusion
  85912. */
  85913. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85914. /**
  85915. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85916. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85917. * @param frustumPlanes defines the frustum planes to test
  85918. * @return true if there is an intersection
  85919. */
  85920. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85921. }
  85922. }
  85923. declare module BABYLON {
  85924. /** @hidden */
  85925. export class Collider {
  85926. /** Define if a collision was found */
  85927. collisionFound: boolean;
  85928. /**
  85929. * Define last intersection point in local space
  85930. */
  85931. intersectionPoint: Vector3;
  85932. /**
  85933. * Define last collided mesh
  85934. */
  85935. collidedMesh: Nullable<AbstractMesh>;
  85936. private _collisionPoint;
  85937. private _planeIntersectionPoint;
  85938. private _tempVector;
  85939. private _tempVector2;
  85940. private _tempVector3;
  85941. private _tempVector4;
  85942. private _edge;
  85943. private _baseToVertex;
  85944. private _destinationPoint;
  85945. private _slidePlaneNormal;
  85946. private _displacementVector;
  85947. /** @hidden */
  85948. _radius: Vector3;
  85949. /** @hidden */
  85950. _retry: number;
  85951. private _velocity;
  85952. private _basePoint;
  85953. private _epsilon;
  85954. /** @hidden */
  85955. _velocityWorldLength: number;
  85956. /** @hidden */
  85957. _basePointWorld: Vector3;
  85958. private _velocityWorld;
  85959. private _normalizedVelocity;
  85960. /** @hidden */
  85961. _initialVelocity: Vector3;
  85962. /** @hidden */
  85963. _initialPosition: Vector3;
  85964. private _nearestDistance;
  85965. private _collisionMask;
  85966. get collisionMask(): number;
  85967. set collisionMask(mask: number);
  85968. /**
  85969. * Gets the plane normal used to compute the sliding response (in local space)
  85970. */
  85971. get slidePlaneNormal(): Vector3;
  85972. /** @hidden */
  85973. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85974. /** @hidden */
  85975. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85976. /** @hidden */
  85977. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85978. /** @hidden */
  85979. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85980. /** @hidden */
  85981. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85982. /** @hidden */
  85983. _getResponse(pos: Vector3, vel: Vector3): void;
  85984. }
  85985. }
  85986. declare module BABYLON {
  85987. /**
  85988. * Interface for cullable objects
  85989. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85990. */
  85991. export interface ICullable {
  85992. /**
  85993. * Checks if the object or part of the object is in the frustum
  85994. * @param frustumPlanes Camera near/planes
  85995. * @returns true if the object is in frustum otherwise false
  85996. */
  85997. isInFrustum(frustumPlanes: Plane[]): boolean;
  85998. /**
  85999. * Checks if a cullable object (mesh...) is in the camera frustum
  86000. * Unlike isInFrustum this cheks the full bounding box
  86001. * @param frustumPlanes Camera near/planes
  86002. * @returns true if the object is in frustum otherwise false
  86003. */
  86004. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86005. }
  86006. /**
  86007. * Info for a bounding data of a mesh
  86008. */
  86009. export class BoundingInfo implements ICullable {
  86010. /**
  86011. * Bounding box for the mesh
  86012. */
  86013. readonly boundingBox: BoundingBox;
  86014. /**
  86015. * Bounding sphere for the mesh
  86016. */
  86017. readonly boundingSphere: BoundingSphere;
  86018. private _isLocked;
  86019. private static readonly TmpVector3;
  86020. /**
  86021. * Constructs bounding info
  86022. * @param minimum min vector of the bounding box/sphere
  86023. * @param maximum max vector of the bounding box/sphere
  86024. * @param worldMatrix defines the new world matrix
  86025. */
  86026. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86027. /**
  86028. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86029. * @param min defines the new minimum vector (in local space)
  86030. * @param max defines the new maximum vector (in local space)
  86031. * @param worldMatrix defines the new world matrix
  86032. */
  86033. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86034. /**
  86035. * min vector of the bounding box/sphere
  86036. */
  86037. get minimum(): Vector3;
  86038. /**
  86039. * max vector of the bounding box/sphere
  86040. */
  86041. get maximum(): Vector3;
  86042. /**
  86043. * If the info is locked and won't be updated to avoid perf overhead
  86044. */
  86045. get isLocked(): boolean;
  86046. set isLocked(value: boolean);
  86047. /**
  86048. * Updates the bounding sphere and box
  86049. * @param world world matrix to be used to update
  86050. */
  86051. update(world: DeepImmutable<Matrix>): void;
  86052. /**
  86053. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86054. * @param center New center of the bounding info
  86055. * @param extend New extend of the bounding info
  86056. * @returns the current bounding info
  86057. */
  86058. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86059. /**
  86060. * Scale the current bounding info by applying a scale factor
  86061. * @param factor defines the scale factor to apply
  86062. * @returns the current bounding info
  86063. */
  86064. scale(factor: number): BoundingInfo;
  86065. /**
  86066. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86067. * @param frustumPlanes defines the frustum to test
  86068. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86069. * @returns true if the bounding info is in the frustum planes
  86070. */
  86071. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86072. /**
  86073. * Gets the world distance between the min and max points of the bounding box
  86074. */
  86075. get diagonalLength(): number;
  86076. /**
  86077. * Checks if a cullable object (mesh...) is in the camera frustum
  86078. * Unlike isInFrustum this cheks the full bounding box
  86079. * @param frustumPlanes Camera near/planes
  86080. * @returns true if the object is in frustum otherwise false
  86081. */
  86082. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86083. /** @hidden */
  86084. _checkCollision(collider: Collider): boolean;
  86085. /**
  86086. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86087. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86088. * @param point the point to check intersection with
  86089. * @returns if the point intersects
  86090. */
  86091. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86092. /**
  86093. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86094. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86095. * @param boundingInfo the bounding info to check intersection with
  86096. * @param precise if the intersection should be done using OBB
  86097. * @returns if the bounding info intersects
  86098. */
  86099. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86100. }
  86101. }
  86102. declare module BABYLON {
  86103. /**
  86104. * Extracts minimum and maximum values from a list of indexed positions
  86105. * @param positions defines the positions to use
  86106. * @param indices defines the indices to the positions
  86107. * @param indexStart defines the start index
  86108. * @param indexCount defines the end index
  86109. * @param bias defines bias value to add to the result
  86110. * @return minimum and maximum values
  86111. */
  86112. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86113. minimum: Vector3;
  86114. maximum: Vector3;
  86115. };
  86116. /**
  86117. * Extracts minimum and maximum values from a list of positions
  86118. * @param positions defines the positions to use
  86119. * @param start defines the start index in the positions array
  86120. * @param count defines the number of positions to handle
  86121. * @param bias defines bias value to add to the result
  86122. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86123. * @return minimum and maximum values
  86124. */
  86125. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86126. minimum: Vector3;
  86127. maximum: Vector3;
  86128. };
  86129. }
  86130. declare module BABYLON {
  86131. /** @hidden */
  86132. export class WebGLDataBuffer extends DataBuffer {
  86133. private _buffer;
  86134. constructor(resource: WebGLBuffer);
  86135. get underlyingResource(): any;
  86136. }
  86137. }
  86138. declare module BABYLON {
  86139. /** @hidden */
  86140. export class WebGLPipelineContext implements IPipelineContext {
  86141. engine: ThinEngine;
  86142. program: Nullable<WebGLProgram>;
  86143. context?: WebGLRenderingContext;
  86144. vertexShader?: WebGLShader;
  86145. fragmentShader?: WebGLShader;
  86146. isParallelCompiled: boolean;
  86147. onCompiled?: () => void;
  86148. transformFeedback?: WebGLTransformFeedback | null;
  86149. vertexCompilationError: Nullable<string>;
  86150. fragmentCompilationError: Nullable<string>;
  86151. programLinkError: Nullable<string>;
  86152. programValidationError: Nullable<string>;
  86153. get isAsync(): boolean;
  86154. get isReady(): boolean;
  86155. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86156. _getVertexShaderCode(): string | null;
  86157. _getFragmentShaderCode(): string | null;
  86158. }
  86159. }
  86160. declare module BABYLON {
  86161. interface ThinEngine {
  86162. /**
  86163. * Create an uniform buffer
  86164. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86165. * @param elements defines the content of the uniform buffer
  86166. * @returns the webGL uniform buffer
  86167. */
  86168. createUniformBuffer(elements: FloatArray): DataBuffer;
  86169. /**
  86170. * Create a dynamic uniform buffer
  86171. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86172. * @param elements defines the content of the uniform buffer
  86173. * @returns the webGL uniform buffer
  86174. */
  86175. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86176. /**
  86177. * Update an existing uniform buffer
  86178. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86179. * @param uniformBuffer defines the target uniform buffer
  86180. * @param elements defines the content to update
  86181. * @param offset defines the offset in the uniform buffer where update should start
  86182. * @param count defines the size of the data to update
  86183. */
  86184. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86185. /**
  86186. * Bind an uniform buffer to the current webGL context
  86187. * @param buffer defines the buffer to bind
  86188. */
  86189. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86190. /**
  86191. * Bind a buffer to the current webGL context at a given location
  86192. * @param buffer defines the buffer to bind
  86193. * @param location defines the index where to bind the buffer
  86194. */
  86195. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86196. /**
  86197. * Bind a specific block at a given index in a specific shader program
  86198. * @param pipelineContext defines the pipeline context to use
  86199. * @param blockName defines the block name
  86200. * @param index defines the index where to bind the block
  86201. */
  86202. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86203. }
  86204. }
  86205. declare module BABYLON {
  86206. /**
  86207. * Uniform buffer objects.
  86208. *
  86209. * Handles blocks of uniform on the GPU.
  86210. *
  86211. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86212. *
  86213. * For more information, please refer to :
  86214. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86215. */
  86216. export class UniformBuffer {
  86217. private _engine;
  86218. private _buffer;
  86219. private _data;
  86220. private _bufferData;
  86221. private _dynamic?;
  86222. private _uniformLocations;
  86223. private _uniformSizes;
  86224. private _uniformLocationPointer;
  86225. private _needSync;
  86226. private _noUBO;
  86227. private _currentEffect;
  86228. /** @hidden */
  86229. _alreadyBound: boolean;
  86230. private static _MAX_UNIFORM_SIZE;
  86231. private static _tempBuffer;
  86232. /**
  86233. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86234. * This is dynamic to allow compat with webgl 1 and 2.
  86235. * You will need to pass the name of the uniform as well as the value.
  86236. */
  86237. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86238. /**
  86239. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86240. * This is dynamic to allow compat with webgl 1 and 2.
  86241. * You will need to pass the name of the uniform as well as the value.
  86242. */
  86243. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86244. /**
  86245. * Lambda to Update a single float in a uniform buffer.
  86246. * This is dynamic to allow compat with webgl 1 and 2.
  86247. * You will need to pass the name of the uniform as well as the value.
  86248. */
  86249. updateFloat: (name: string, x: number) => void;
  86250. /**
  86251. * Lambda to Update a vec2 of float in a uniform buffer.
  86252. * This is dynamic to allow compat with webgl 1 and 2.
  86253. * You will need to pass the name of the uniform as well as the value.
  86254. */
  86255. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86256. /**
  86257. * Lambda to Update a vec3 of float in a uniform buffer.
  86258. * This is dynamic to allow compat with webgl 1 and 2.
  86259. * You will need to pass the name of the uniform as well as the value.
  86260. */
  86261. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86262. /**
  86263. * Lambda to Update a vec4 of float in a uniform buffer.
  86264. * This is dynamic to allow compat with webgl 1 and 2.
  86265. * You will need to pass the name of the uniform as well as the value.
  86266. */
  86267. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86268. /**
  86269. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86270. * This is dynamic to allow compat with webgl 1 and 2.
  86271. * You will need to pass the name of the uniform as well as the value.
  86272. */
  86273. updateMatrix: (name: string, mat: Matrix) => void;
  86274. /**
  86275. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86276. * This is dynamic to allow compat with webgl 1 and 2.
  86277. * You will need to pass the name of the uniform as well as the value.
  86278. */
  86279. updateVector3: (name: string, vector: Vector3) => void;
  86280. /**
  86281. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86282. * This is dynamic to allow compat with webgl 1 and 2.
  86283. * You will need to pass the name of the uniform as well as the value.
  86284. */
  86285. updateVector4: (name: string, vector: Vector4) => void;
  86286. /**
  86287. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86288. * This is dynamic to allow compat with webgl 1 and 2.
  86289. * You will need to pass the name of the uniform as well as the value.
  86290. */
  86291. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86292. /**
  86293. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86294. * This is dynamic to allow compat with webgl 1 and 2.
  86295. * You will need to pass the name of the uniform as well as the value.
  86296. */
  86297. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86298. /**
  86299. * Instantiates a new Uniform buffer objects.
  86300. *
  86301. * Handles blocks of uniform on the GPU.
  86302. *
  86303. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86304. *
  86305. * For more information, please refer to :
  86306. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86307. * @param engine Define the engine the buffer is associated with
  86308. * @param data Define the data contained in the buffer
  86309. * @param dynamic Define if the buffer is updatable
  86310. */
  86311. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86312. /**
  86313. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86314. * or just falling back on setUniformXXX calls.
  86315. */
  86316. get useUbo(): boolean;
  86317. /**
  86318. * Indicates if the WebGL underlying uniform buffer is in sync
  86319. * with the javascript cache data.
  86320. */
  86321. get isSync(): boolean;
  86322. /**
  86323. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86324. * Also, a dynamic UniformBuffer will disable cache verification and always
  86325. * update the underlying WebGL uniform buffer to the GPU.
  86326. * @returns if Dynamic, otherwise false
  86327. */
  86328. isDynamic(): boolean;
  86329. /**
  86330. * The data cache on JS side.
  86331. * @returns the underlying data as a float array
  86332. */
  86333. getData(): Float32Array;
  86334. /**
  86335. * The underlying WebGL Uniform buffer.
  86336. * @returns the webgl buffer
  86337. */
  86338. getBuffer(): Nullable<DataBuffer>;
  86339. /**
  86340. * std140 layout specifies how to align data within an UBO structure.
  86341. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86342. * for specs.
  86343. */
  86344. private _fillAlignment;
  86345. /**
  86346. * Adds an uniform in the buffer.
  86347. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86348. * for the layout to be correct !
  86349. * @param name Name of the uniform, as used in the uniform block in the shader.
  86350. * @param size Data size, or data directly.
  86351. */
  86352. addUniform(name: string, size: number | number[]): void;
  86353. /**
  86354. * Adds a Matrix 4x4 to the uniform buffer.
  86355. * @param name Name of the uniform, as used in the uniform block in the shader.
  86356. * @param mat A 4x4 matrix.
  86357. */
  86358. addMatrix(name: string, mat: Matrix): void;
  86359. /**
  86360. * Adds a vec2 to the uniform buffer.
  86361. * @param name Name of the uniform, as used in the uniform block in the shader.
  86362. * @param x Define the x component value of the vec2
  86363. * @param y Define the y component value of the vec2
  86364. */
  86365. addFloat2(name: string, x: number, y: number): void;
  86366. /**
  86367. * Adds a vec3 to the uniform buffer.
  86368. * @param name Name of the uniform, as used in the uniform block in the shader.
  86369. * @param x Define the x component value of the vec3
  86370. * @param y Define the y component value of the vec3
  86371. * @param z Define the z component value of the vec3
  86372. */
  86373. addFloat3(name: string, x: number, y: number, z: number): void;
  86374. /**
  86375. * Adds a vec3 to the uniform buffer.
  86376. * @param name Name of the uniform, as used in the uniform block in the shader.
  86377. * @param color Define the vec3 from a Color
  86378. */
  86379. addColor3(name: string, color: Color3): void;
  86380. /**
  86381. * Adds a vec4 to the uniform buffer.
  86382. * @param name Name of the uniform, as used in the uniform block in the shader.
  86383. * @param color Define the rgb components from a Color
  86384. * @param alpha Define the a component of the vec4
  86385. */
  86386. addColor4(name: string, color: Color3, alpha: number): void;
  86387. /**
  86388. * Adds a vec3 to the uniform buffer.
  86389. * @param name Name of the uniform, as used in the uniform block in the shader.
  86390. * @param vector Define the vec3 components from a Vector
  86391. */
  86392. addVector3(name: string, vector: Vector3): void;
  86393. /**
  86394. * Adds a Matrix 3x3 to the uniform buffer.
  86395. * @param name Name of the uniform, as used in the uniform block in the shader.
  86396. */
  86397. addMatrix3x3(name: string): void;
  86398. /**
  86399. * Adds a Matrix 2x2 to the uniform buffer.
  86400. * @param name Name of the uniform, as used in the uniform block in the shader.
  86401. */
  86402. addMatrix2x2(name: string): void;
  86403. /**
  86404. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86405. */
  86406. create(): void;
  86407. /** @hidden */
  86408. _rebuild(): void;
  86409. /**
  86410. * Updates the WebGL Uniform Buffer on the GPU.
  86411. * If the `dynamic` flag is set to true, no cache comparison is done.
  86412. * Otherwise, the buffer will be updated only if the cache differs.
  86413. */
  86414. update(): void;
  86415. /**
  86416. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86417. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86418. * @param data Define the flattened data
  86419. * @param size Define the size of the data.
  86420. */
  86421. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86422. private _valueCache;
  86423. private _cacheMatrix;
  86424. private _updateMatrix3x3ForUniform;
  86425. private _updateMatrix3x3ForEffect;
  86426. private _updateMatrix2x2ForEffect;
  86427. private _updateMatrix2x2ForUniform;
  86428. private _updateFloatForEffect;
  86429. private _updateFloatForUniform;
  86430. private _updateFloat2ForEffect;
  86431. private _updateFloat2ForUniform;
  86432. private _updateFloat3ForEffect;
  86433. private _updateFloat3ForUniform;
  86434. private _updateFloat4ForEffect;
  86435. private _updateFloat4ForUniform;
  86436. private _updateMatrixForEffect;
  86437. private _updateMatrixForUniform;
  86438. private _updateVector3ForEffect;
  86439. private _updateVector3ForUniform;
  86440. private _updateVector4ForEffect;
  86441. private _updateVector4ForUniform;
  86442. private _updateColor3ForEffect;
  86443. private _updateColor3ForUniform;
  86444. private _updateColor4ForEffect;
  86445. private _updateColor4ForUniform;
  86446. /**
  86447. * Sets a sampler uniform on the effect.
  86448. * @param name Define the name of the sampler.
  86449. * @param texture Define the texture to set in the sampler
  86450. */
  86451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86452. /**
  86453. * Directly updates the value of the uniform in the cache AND on the GPU.
  86454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86455. * @param data Define the flattened data
  86456. */
  86457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86458. /**
  86459. * Binds this uniform buffer to an effect.
  86460. * @param effect Define the effect to bind the buffer to
  86461. * @param name Name of the uniform block in the shader.
  86462. */
  86463. bindToEffect(effect: Effect, name: string): void;
  86464. /**
  86465. * Disposes the uniform buffer.
  86466. */
  86467. dispose(): void;
  86468. }
  86469. }
  86470. declare module BABYLON {
  86471. /**
  86472. * Enum that determines the text-wrapping mode to use.
  86473. */
  86474. export enum InspectableType {
  86475. /**
  86476. * Checkbox for booleans
  86477. */
  86478. Checkbox = 0,
  86479. /**
  86480. * Sliders for numbers
  86481. */
  86482. Slider = 1,
  86483. /**
  86484. * Vector3
  86485. */
  86486. Vector3 = 2,
  86487. /**
  86488. * Quaternions
  86489. */
  86490. Quaternion = 3,
  86491. /**
  86492. * Color3
  86493. */
  86494. Color3 = 4,
  86495. /**
  86496. * String
  86497. */
  86498. String = 5
  86499. }
  86500. /**
  86501. * Interface used to define custom inspectable properties.
  86502. * This interface is used by the inspector to display custom property grids
  86503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86504. */
  86505. export interface IInspectable {
  86506. /**
  86507. * Gets the label to display
  86508. */
  86509. label: string;
  86510. /**
  86511. * Gets the name of the property to edit
  86512. */
  86513. propertyName: string;
  86514. /**
  86515. * Gets the type of the editor to use
  86516. */
  86517. type: InspectableType;
  86518. /**
  86519. * Gets the minimum value of the property when using in "slider" mode
  86520. */
  86521. min?: number;
  86522. /**
  86523. * Gets the maximum value of the property when using in "slider" mode
  86524. */
  86525. max?: number;
  86526. /**
  86527. * Gets the setp to use when using in "slider" mode
  86528. */
  86529. step?: number;
  86530. }
  86531. }
  86532. declare module BABYLON {
  86533. /**
  86534. * Class used to provide helper for timing
  86535. */
  86536. export class TimingTools {
  86537. /**
  86538. * Polyfill for setImmediate
  86539. * @param action defines the action to execute after the current execution block
  86540. */
  86541. static SetImmediate(action: () => void): void;
  86542. }
  86543. }
  86544. declare module BABYLON {
  86545. /**
  86546. * Class used to enable instatition of objects by class name
  86547. */
  86548. export class InstantiationTools {
  86549. /**
  86550. * Use this object to register external classes like custom textures or material
  86551. * to allow the laoders to instantiate them
  86552. */
  86553. static RegisteredExternalClasses: {
  86554. [key: string]: Object;
  86555. };
  86556. /**
  86557. * Tries to instantiate a new object from a given class name
  86558. * @param className defines the class name to instantiate
  86559. * @returns the new object or null if the system was not able to do the instantiation
  86560. */
  86561. static Instantiate(className: string): any;
  86562. }
  86563. }
  86564. declare module BABYLON {
  86565. /**
  86566. * Define options used to create a depth texture
  86567. */
  86568. export class DepthTextureCreationOptions {
  86569. /** Specifies whether or not a stencil should be allocated in the texture */
  86570. generateStencil?: boolean;
  86571. /** Specifies whether or not bilinear filtering is enable on the texture */
  86572. bilinearFiltering?: boolean;
  86573. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86574. comparisonFunction?: number;
  86575. /** Specifies if the created texture is a cube texture */
  86576. isCube?: boolean;
  86577. }
  86578. }
  86579. declare module BABYLON {
  86580. interface ThinEngine {
  86581. /**
  86582. * Creates a depth stencil cube texture.
  86583. * This is only available in WebGL 2.
  86584. * @param size The size of face edge in the cube texture.
  86585. * @param options The options defining the cube texture.
  86586. * @returns The cube texture
  86587. */
  86588. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86589. /**
  86590. * Creates a cube texture
  86591. * @param rootUrl defines the url where the files to load is located
  86592. * @param scene defines the current scene
  86593. * @param files defines the list of files to load (1 per face)
  86594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86595. * @param onLoad defines an optional callback raised when the texture is loaded
  86596. * @param onError defines an optional callback raised if there is an issue to load the texture
  86597. * @param format defines the format of the data
  86598. * @param forcedExtension defines the extension to use to pick the right loader
  86599. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86602. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86603. * @returns the cube texture as an InternalTexture
  86604. */
  86605. 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;
  86606. /**
  86607. * Creates a cube texture
  86608. * @param rootUrl defines the url where the files to load is located
  86609. * @param scene defines the current scene
  86610. * @param files defines the list of files to load (1 per face)
  86611. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86612. * @param onLoad defines an optional callback raised when the texture is loaded
  86613. * @param onError defines an optional callback raised if there is an issue to load the texture
  86614. * @param format defines the format of the data
  86615. * @param forcedExtension defines the extension to use to pick the right loader
  86616. * @returns the cube texture as an InternalTexture
  86617. */
  86618. 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;
  86619. /**
  86620. * Creates a cube texture
  86621. * @param rootUrl defines the url where the files to load is located
  86622. * @param scene defines the current scene
  86623. * @param files defines the list of files to load (1 per face)
  86624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86625. * @param onLoad defines an optional callback raised when the texture is loaded
  86626. * @param onError defines an optional callback raised if there is an issue to load the texture
  86627. * @param format defines the format of the data
  86628. * @param forcedExtension defines the extension to use to pick the right loader
  86629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86632. * @returns the cube texture as an InternalTexture
  86633. */
  86634. 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;
  86635. /** @hidden */
  86636. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86637. /** @hidden */
  86638. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86639. /** @hidden */
  86640. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86641. /** @hidden */
  86642. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86643. /**
  86644. * @hidden
  86645. */
  86646. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86647. }
  86648. }
  86649. declare module BABYLON {
  86650. /**
  86651. * Class for creating a cube texture
  86652. */
  86653. export class CubeTexture extends BaseTexture {
  86654. private _delayedOnLoad;
  86655. /**
  86656. * Observable triggered once the texture has been loaded.
  86657. */
  86658. onLoadObservable: Observable<CubeTexture>;
  86659. /**
  86660. * The url of the texture
  86661. */
  86662. url: string;
  86663. /**
  86664. * Gets or sets the center of the bounding box associated with the cube texture.
  86665. * It must define where the camera used to render the texture was set
  86666. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86667. */
  86668. boundingBoxPosition: Vector3;
  86669. private _boundingBoxSize;
  86670. /**
  86671. * Gets or sets the size of the bounding box associated with the cube texture
  86672. * When defined, the cubemap will switch to local mode
  86673. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86674. * @example https://www.babylonjs-playground.com/#RNASML
  86675. */
  86676. set boundingBoxSize(value: Vector3);
  86677. /**
  86678. * Returns the bounding box size
  86679. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86680. */
  86681. get boundingBoxSize(): Vector3;
  86682. protected _rotationY: number;
  86683. /**
  86684. * Sets texture matrix rotation angle around Y axis in radians.
  86685. */
  86686. set rotationY(value: number);
  86687. /**
  86688. * Gets texture matrix rotation angle around Y axis radians.
  86689. */
  86690. get rotationY(): number;
  86691. /**
  86692. * Are mip maps generated for this texture or not.
  86693. */
  86694. get noMipmap(): boolean;
  86695. private _noMipmap;
  86696. private _files;
  86697. protected _forcedExtension: Nullable<string>;
  86698. private _extensions;
  86699. private _textureMatrix;
  86700. private _format;
  86701. private _createPolynomials;
  86702. /**
  86703. * Creates a cube texture from an array of image urls
  86704. * @param files defines an array of image urls
  86705. * @param scene defines the hosting scene
  86706. * @param noMipmap specifies if mip maps are not used
  86707. * @returns a cube texture
  86708. */
  86709. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86710. /**
  86711. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86712. * @param url defines the url of the prefiltered texture
  86713. * @param scene defines the scene the texture is attached to
  86714. * @param forcedExtension defines the extension of the file if different from the url
  86715. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86716. * @return the prefiltered texture
  86717. */
  86718. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86719. /**
  86720. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86721. * as prefiltered data.
  86722. * @param rootUrl defines the url of the texture or the root name of the six images
  86723. * @param null defines the scene or engine the texture is attached to
  86724. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86725. * @param noMipmap defines if mipmaps should be created or not
  86726. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86727. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86728. * @param onError defines a callback triggered in case of error during load
  86729. * @param format defines the internal format to use for the texture once loaded
  86730. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86731. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86732. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86735. * @return the cube texture
  86736. */
  86737. 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);
  86738. /**
  86739. * Get the current class name of the texture useful for serialization or dynamic coding.
  86740. * @returns "CubeTexture"
  86741. */
  86742. getClassName(): string;
  86743. /**
  86744. * Update the url (and optional buffer) of this texture if url was null during construction.
  86745. * @param url the url of the texture
  86746. * @param forcedExtension defines the extension to use
  86747. * @param onLoad callback called when the texture is loaded (defaults to null)
  86748. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86749. */
  86750. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86751. /**
  86752. * Delays loading of the cube texture
  86753. * @param forcedExtension defines the extension to use
  86754. */
  86755. delayLoad(forcedExtension?: string): void;
  86756. /**
  86757. * Returns the reflection texture matrix
  86758. * @returns the reflection texture matrix
  86759. */
  86760. getReflectionTextureMatrix(): Matrix;
  86761. /**
  86762. * Sets the reflection texture matrix
  86763. * @param value Reflection texture matrix
  86764. */
  86765. setReflectionTextureMatrix(value: Matrix): void;
  86766. /**
  86767. * Parses text to create a cube texture
  86768. * @param parsedTexture define the serialized text to read from
  86769. * @param scene defines the hosting scene
  86770. * @param rootUrl defines the root url of the cube texture
  86771. * @returns a cube texture
  86772. */
  86773. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86774. /**
  86775. * Makes a clone, or deep copy, of the cube texture
  86776. * @returns a new cube texture
  86777. */
  86778. clone(): CubeTexture;
  86779. }
  86780. }
  86781. declare module BABYLON {
  86782. /**
  86783. * Manages the defines for the Material
  86784. */
  86785. export class MaterialDefines {
  86786. /** @hidden */
  86787. protected _keys: string[];
  86788. private _isDirty;
  86789. /** @hidden */
  86790. _renderId: number;
  86791. /** @hidden */
  86792. _areLightsDirty: boolean;
  86793. /** @hidden */
  86794. _areLightsDisposed: boolean;
  86795. /** @hidden */
  86796. _areAttributesDirty: boolean;
  86797. /** @hidden */
  86798. _areTexturesDirty: boolean;
  86799. /** @hidden */
  86800. _areFresnelDirty: boolean;
  86801. /** @hidden */
  86802. _areMiscDirty: boolean;
  86803. /** @hidden */
  86804. _areImageProcessingDirty: boolean;
  86805. /** @hidden */
  86806. _normals: boolean;
  86807. /** @hidden */
  86808. _uvs: boolean;
  86809. /** @hidden */
  86810. _needNormals: boolean;
  86811. /** @hidden */
  86812. _needUVs: boolean;
  86813. [id: string]: any;
  86814. /**
  86815. * Specifies if the material needs to be re-calculated
  86816. */
  86817. get isDirty(): boolean;
  86818. /**
  86819. * Marks the material to indicate that it has been re-calculated
  86820. */
  86821. markAsProcessed(): void;
  86822. /**
  86823. * Marks the material to indicate that it needs to be re-calculated
  86824. */
  86825. markAsUnprocessed(): void;
  86826. /**
  86827. * Marks the material to indicate all of its defines need to be re-calculated
  86828. */
  86829. markAllAsDirty(): void;
  86830. /**
  86831. * Marks the material to indicate that image processing needs to be re-calculated
  86832. */
  86833. markAsImageProcessingDirty(): void;
  86834. /**
  86835. * Marks the material to indicate the lights need to be re-calculated
  86836. * @param disposed Defines whether the light is dirty due to dispose or not
  86837. */
  86838. markAsLightDirty(disposed?: boolean): void;
  86839. /**
  86840. * Marks the attribute state as changed
  86841. */
  86842. markAsAttributesDirty(): void;
  86843. /**
  86844. * Marks the texture state as changed
  86845. */
  86846. markAsTexturesDirty(): void;
  86847. /**
  86848. * Marks the fresnel state as changed
  86849. */
  86850. markAsFresnelDirty(): void;
  86851. /**
  86852. * Marks the misc state as changed
  86853. */
  86854. markAsMiscDirty(): void;
  86855. /**
  86856. * Rebuilds the material defines
  86857. */
  86858. rebuild(): void;
  86859. /**
  86860. * Specifies if two material defines are equal
  86861. * @param other - A material define instance to compare to
  86862. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86863. */
  86864. isEqual(other: MaterialDefines): boolean;
  86865. /**
  86866. * Clones this instance's defines to another instance
  86867. * @param other - material defines to clone values to
  86868. */
  86869. cloneTo(other: MaterialDefines): void;
  86870. /**
  86871. * Resets the material define values
  86872. */
  86873. reset(): void;
  86874. /**
  86875. * Converts the material define values to a string
  86876. * @returns - String of material define information
  86877. */
  86878. toString(): string;
  86879. }
  86880. }
  86881. declare module BABYLON {
  86882. /**
  86883. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86884. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86885. * 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;
  86886. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86887. */
  86888. export class ColorCurves {
  86889. private _dirty;
  86890. private _tempColor;
  86891. private _globalCurve;
  86892. private _highlightsCurve;
  86893. private _midtonesCurve;
  86894. private _shadowsCurve;
  86895. private _positiveCurve;
  86896. private _negativeCurve;
  86897. private _globalHue;
  86898. private _globalDensity;
  86899. private _globalSaturation;
  86900. private _globalExposure;
  86901. /**
  86902. * Gets the global Hue value.
  86903. * 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).
  86904. */
  86905. get globalHue(): number;
  86906. /**
  86907. * Sets the global Hue value.
  86908. * 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).
  86909. */
  86910. set globalHue(value: number);
  86911. /**
  86912. * Gets the global Density value.
  86913. * 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.
  86914. * Values less than zero provide a filter of opposite hue.
  86915. */
  86916. get globalDensity(): number;
  86917. /**
  86918. * Sets the global Density value.
  86919. * 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.
  86920. * Values less than zero provide a filter of opposite hue.
  86921. */
  86922. set globalDensity(value: number);
  86923. /**
  86924. * Gets the global Saturation value.
  86925. * 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.
  86926. */
  86927. get globalSaturation(): number;
  86928. /**
  86929. * Sets the global Saturation value.
  86930. * 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.
  86931. */
  86932. set globalSaturation(value: number);
  86933. /**
  86934. * Gets the global Exposure value.
  86935. * 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.
  86936. */
  86937. get globalExposure(): number;
  86938. /**
  86939. * Sets the global Exposure value.
  86940. * 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.
  86941. */
  86942. set globalExposure(value: number);
  86943. private _highlightsHue;
  86944. private _highlightsDensity;
  86945. private _highlightsSaturation;
  86946. private _highlightsExposure;
  86947. /**
  86948. * Gets the highlights Hue value.
  86949. * 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).
  86950. */
  86951. get highlightsHue(): number;
  86952. /**
  86953. * Sets the highlights Hue value.
  86954. * 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).
  86955. */
  86956. set highlightsHue(value: number);
  86957. /**
  86958. * Gets the highlights Density value.
  86959. * 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.
  86960. * Values less than zero provide a filter of opposite hue.
  86961. */
  86962. get highlightsDensity(): number;
  86963. /**
  86964. * Sets the highlights Density value.
  86965. * 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.
  86966. * Values less than zero provide a filter of opposite hue.
  86967. */
  86968. set highlightsDensity(value: number);
  86969. /**
  86970. * Gets the highlights Saturation value.
  86971. * 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.
  86972. */
  86973. get highlightsSaturation(): number;
  86974. /**
  86975. * Sets the highlights Saturation value.
  86976. * 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.
  86977. */
  86978. set highlightsSaturation(value: number);
  86979. /**
  86980. * Gets the highlights Exposure value.
  86981. * 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.
  86982. */
  86983. get highlightsExposure(): number;
  86984. /**
  86985. * Sets the highlights Exposure value.
  86986. * 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.
  86987. */
  86988. set highlightsExposure(value: number);
  86989. private _midtonesHue;
  86990. private _midtonesDensity;
  86991. private _midtonesSaturation;
  86992. private _midtonesExposure;
  86993. /**
  86994. * Gets the midtones Hue value.
  86995. * 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).
  86996. */
  86997. get midtonesHue(): number;
  86998. /**
  86999. * Sets the midtones Hue value.
  87000. * 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).
  87001. */
  87002. set midtonesHue(value: number);
  87003. /**
  87004. * Gets the midtones Density value.
  87005. * 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.
  87006. * Values less than zero provide a filter of opposite hue.
  87007. */
  87008. get midtonesDensity(): number;
  87009. /**
  87010. * Sets the midtones Density value.
  87011. * 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.
  87012. * Values less than zero provide a filter of opposite hue.
  87013. */
  87014. set midtonesDensity(value: number);
  87015. /**
  87016. * Gets the midtones Saturation value.
  87017. * 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.
  87018. */
  87019. get midtonesSaturation(): number;
  87020. /**
  87021. * Sets the midtones Saturation value.
  87022. * 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.
  87023. */
  87024. set midtonesSaturation(value: number);
  87025. /**
  87026. * Gets the midtones Exposure value.
  87027. * 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.
  87028. */
  87029. get midtonesExposure(): number;
  87030. /**
  87031. * Sets the midtones Exposure value.
  87032. * 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.
  87033. */
  87034. set midtonesExposure(value: number);
  87035. private _shadowsHue;
  87036. private _shadowsDensity;
  87037. private _shadowsSaturation;
  87038. private _shadowsExposure;
  87039. /**
  87040. * Gets the shadows Hue value.
  87041. * 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).
  87042. */
  87043. get shadowsHue(): number;
  87044. /**
  87045. * Sets the shadows Hue value.
  87046. * 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).
  87047. */
  87048. set shadowsHue(value: number);
  87049. /**
  87050. * Gets the shadows Density value.
  87051. * 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.
  87052. * Values less than zero provide a filter of opposite hue.
  87053. */
  87054. get shadowsDensity(): number;
  87055. /**
  87056. * Sets the shadows Density value.
  87057. * 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.
  87058. * Values less than zero provide a filter of opposite hue.
  87059. */
  87060. set shadowsDensity(value: number);
  87061. /**
  87062. * Gets the shadows Saturation value.
  87063. * 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.
  87064. */
  87065. get shadowsSaturation(): number;
  87066. /**
  87067. * Sets the shadows Saturation value.
  87068. * 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.
  87069. */
  87070. set shadowsSaturation(value: number);
  87071. /**
  87072. * Gets the shadows Exposure value.
  87073. * 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.
  87074. */
  87075. get shadowsExposure(): number;
  87076. /**
  87077. * Sets the shadows Exposure value.
  87078. * 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.
  87079. */
  87080. set shadowsExposure(value: number);
  87081. /**
  87082. * Returns the class name
  87083. * @returns The class name
  87084. */
  87085. getClassName(): string;
  87086. /**
  87087. * Binds the color curves to the shader.
  87088. * @param colorCurves The color curve to bind
  87089. * @param effect The effect to bind to
  87090. * @param positiveUniform The positive uniform shader parameter
  87091. * @param neutralUniform The neutral uniform shader parameter
  87092. * @param negativeUniform The negative uniform shader parameter
  87093. */
  87094. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87095. /**
  87096. * Prepare the list of uniforms associated with the ColorCurves effects.
  87097. * @param uniformsList The list of uniforms used in the effect
  87098. */
  87099. static PrepareUniforms(uniformsList: string[]): void;
  87100. /**
  87101. * Returns color grading data based on a hue, density, saturation and exposure value.
  87102. * @param filterHue The hue of the color filter.
  87103. * @param filterDensity The density of the color filter.
  87104. * @param saturation The saturation.
  87105. * @param exposure The exposure.
  87106. * @param result The result data container.
  87107. */
  87108. private getColorGradingDataToRef;
  87109. /**
  87110. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87111. * @param value The input slider value in range [-100,100].
  87112. * @returns Adjusted value.
  87113. */
  87114. private static applyColorGradingSliderNonlinear;
  87115. /**
  87116. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87117. * @param hue The hue (H) input.
  87118. * @param saturation The saturation (S) input.
  87119. * @param brightness The brightness (B) input.
  87120. * @result An RGBA color represented as Vector4.
  87121. */
  87122. private static fromHSBToRef;
  87123. /**
  87124. * Returns a value clamped between min and max
  87125. * @param value The value to clamp
  87126. * @param min The minimum of value
  87127. * @param max The maximum of value
  87128. * @returns The clamped value.
  87129. */
  87130. private static clamp;
  87131. /**
  87132. * Clones the current color curve instance.
  87133. * @return The cloned curves
  87134. */
  87135. clone(): ColorCurves;
  87136. /**
  87137. * Serializes the current color curve instance to a json representation.
  87138. * @return a JSON representation
  87139. */
  87140. serialize(): any;
  87141. /**
  87142. * Parses the color curve from a json representation.
  87143. * @param source the JSON source to parse
  87144. * @return The parsed curves
  87145. */
  87146. static Parse(source: any): ColorCurves;
  87147. }
  87148. }
  87149. declare module BABYLON {
  87150. /**
  87151. * Interface to follow in your material defines to integrate easily the
  87152. * Image proccessing functions.
  87153. * @hidden
  87154. */
  87155. export interface IImageProcessingConfigurationDefines {
  87156. IMAGEPROCESSING: boolean;
  87157. VIGNETTE: boolean;
  87158. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87159. VIGNETTEBLENDMODEOPAQUE: boolean;
  87160. TONEMAPPING: boolean;
  87161. TONEMAPPING_ACES: boolean;
  87162. CONTRAST: boolean;
  87163. EXPOSURE: boolean;
  87164. COLORCURVES: boolean;
  87165. COLORGRADING: boolean;
  87166. COLORGRADING3D: boolean;
  87167. SAMPLER3DGREENDEPTH: boolean;
  87168. SAMPLER3DBGRMAP: boolean;
  87169. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87170. }
  87171. /**
  87172. * @hidden
  87173. */
  87174. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87175. IMAGEPROCESSING: boolean;
  87176. VIGNETTE: boolean;
  87177. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87178. VIGNETTEBLENDMODEOPAQUE: boolean;
  87179. TONEMAPPING: boolean;
  87180. TONEMAPPING_ACES: boolean;
  87181. CONTRAST: boolean;
  87182. COLORCURVES: boolean;
  87183. COLORGRADING: boolean;
  87184. COLORGRADING3D: boolean;
  87185. SAMPLER3DGREENDEPTH: boolean;
  87186. SAMPLER3DBGRMAP: boolean;
  87187. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87188. EXPOSURE: boolean;
  87189. constructor();
  87190. }
  87191. /**
  87192. * This groups together the common properties used for image processing either in direct forward pass
  87193. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87194. * or not.
  87195. */
  87196. export class ImageProcessingConfiguration {
  87197. /**
  87198. * Default tone mapping applied in BabylonJS.
  87199. */
  87200. static readonly TONEMAPPING_STANDARD: number;
  87201. /**
  87202. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87203. * to other engines rendering to increase portability.
  87204. */
  87205. static readonly TONEMAPPING_ACES: number;
  87206. /**
  87207. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87208. */
  87209. colorCurves: Nullable<ColorCurves>;
  87210. private _colorCurvesEnabled;
  87211. /**
  87212. * Gets wether the color curves effect is enabled.
  87213. */
  87214. get colorCurvesEnabled(): boolean;
  87215. /**
  87216. * Sets wether the color curves effect is enabled.
  87217. */
  87218. set colorCurvesEnabled(value: boolean);
  87219. private _colorGradingTexture;
  87220. /**
  87221. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87222. */
  87223. get colorGradingTexture(): Nullable<BaseTexture>;
  87224. /**
  87225. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87226. */
  87227. set colorGradingTexture(value: Nullable<BaseTexture>);
  87228. private _colorGradingEnabled;
  87229. /**
  87230. * Gets wether the color grading effect is enabled.
  87231. */
  87232. get colorGradingEnabled(): boolean;
  87233. /**
  87234. * Sets wether the color grading effect is enabled.
  87235. */
  87236. set colorGradingEnabled(value: boolean);
  87237. private _colorGradingWithGreenDepth;
  87238. /**
  87239. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87240. */
  87241. get colorGradingWithGreenDepth(): boolean;
  87242. /**
  87243. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87244. */
  87245. set colorGradingWithGreenDepth(value: boolean);
  87246. private _colorGradingBGR;
  87247. /**
  87248. * Gets wether the color grading texture contains BGR values.
  87249. */
  87250. get colorGradingBGR(): boolean;
  87251. /**
  87252. * Sets wether the color grading texture contains BGR values.
  87253. */
  87254. set colorGradingBGR(value: boolean);
  87255. /** @hidden */
  87256. _exposure: number;
  87257. /**
  87258. * Gets the Exposure used in the effect.
  87259. */
  87260. get exposure(): number;
  87261. /**
  87262. * Sets the Exposure used in the effect.
  87263. */
  87264. set exposure(value: number);
  87265. private _toneMappingEnabled;
  87266. /**
  87267. * Gets wether the tone mapping effect is enabled.
  87268. */
  87269. get toneMappingEnabled(): boolean;
  87270. /**
  87271. * Sets wether the tone mapping effect is enabled.
  87272. */
  87273. set toneMappingEnabled(value: boolean);
  87274. private _toneMappingType;
  87275. /**
  87276. * Gets the type of tone mapping effect.
  87277. */
  87278. get toneMappingType(): number;
  87279. /**
  87280. * Sets the type of tone mapping effect used in BabylonJS.
  87281. */
  87282. set toneMappingType(value: number);
  87283. protected _contrast: number;
  87284. /**
  87285. * Gets the contrast used in the effect.
  87286. */
  87287. get contrast(): number;
  87288. /**
  87289. * Sets the contrast used in the effect.
  87290. */
  87291. set contrast(value: number);
  87292. /**
  87293. * Vignette stretch size.
  87294. */
  87295. vignetteStretch: number;
  87296. /**
  87297. * Vignette centre X Offset.
  87298. */
  87299. vignetteCentreX: number;
  87300. /**
  87301. * Vignette centre Y Offset.
  87302. */
  87303. vignetteCentreY: number;
  87304. /**
  87305. * Vignette weight or intensity of the vignette effect.
  87306. */
  87307. vignetteWeight: number;
  87308. /**
  87309. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87310. * if vignetteEnabled is set to true.
  87311. */
  87312. vignetteColor: Color4;
  87313. /**
  87314. * Camera field of view used by the Vignette effect.
  87315. */
  87316. vignetteCameraFov: number;
  87317. private _vignetteBlendMode;
  87318. /**
  87319. * Gets the vignette blend mode allowing different kind of effect.
  87320. */
  87321. get vignetteBlendMode(): number;
  87322. /**
  87323. * Sets the vignette blend mode allowing different kind of effect.
  87324. */
  87325. set vignetteBlendMode(value: number);
  87326. private _vignetteEnabled;
  87327. /**
  87328. * Gets wether the vignette effect is enabled.
  87329. */
  87330. get vignetteEnabled(): boolean;
  87331. /**
  87332. * Sets wether the vignette effect is enabled.
  87333. */
  87334. set vignetteEnabled(value: boolean);
  87335. private _applyByPostProcess;
  87336. /**
  87337. * Gets wether the image processing is applied through a post process or not.
  87338. */
  87339. get applyByPostProcess(): boolean;
  87340. /**
  87341. * Sets wether the image processing is applied through a post process or not.
  87342. */
  87343. set applyByPostProcess(value: boolean);
  87344. private _isEnabled;
  87345. /**
  87346. * Gets wether the image processing is enabled or not.
  87347. */
  87348. get isEnabled(): boolean;
  87349. /**
  87350. * Sets wether the image processing is enabled or not.
  87351. */
  87352. set isEnabled(value: boolean);
  87353. /**
  87354. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87355. */
  87356. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87357. /**
  87358. * Method called each time the image processing information changes requires to recompile the effect.
  87359. */
  87360. protected _updateParameters(): void;
  87361. /**
  87362. * Gets the current class name.
  87363. * @return "ImageProcessingConfiguration"
  87364. */
  87365. getClassName(): string;
  87366. /**
  87367. * Prepare the list of uniforms associated with the Image Processing effects.
  87368. * @param uniforms The list of uniforms used in the effect
  87369. * @param defines the list of defines currently in use
  87370. */
  87371. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87372. /**
  87373. * Prepare the list of samplers associated with the Image Processing effects.
  87374. * @param samplersList The list of uniforms used in the effect
  87375. * @param defines the list of defines currently in use
  87376. */
  87377. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87378. /**
  87379. * Prepare the list of defines associated to the shader.
  87380. * @param defines the list of defines to complete
  87381. * @param forPostProcess Define if we are currently in post process mode or not
  87382. */
  87383. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87384. /**
  87385. * Returns true if all the image processing information are ready.
  87386. * @returns True if ready, otherwise, false
  87387. */
  87388. isReady(): boolean;
  87389. /**
  87390. * Binds the image processing to the shader.
  87391. * @param effect The effect to bind to
  87392. * @param overrideAspectRatio Override the aspect ratio of the effect
  87393. */
  87394. bind(effect: Effect, overrideAspectRatio?: number): void;
  87395. /**
  87396. * Clones the current image processing instance.
  87397. * @return The cloned image processing
  87398. */
  87399. clone(): ImageProcessingConfiguration;
  87400. /**
  87401. * Serializes the current image processing instance to a json representation.
  87402. * @return a JSON representation
  87403. */
  87404. serialize(): any;
  87405. /**
  87406. * Parses the image processing from a json representation.
  87407. * @param source the JSON source to parse
  87408. * @return The parsed image processing
  87409. */
  87410. static Parse(source: any): ImageProcessingConfiguration;
  87411. private static _VIGNETTEMODE_MULTIPLY;
  87412. private static _VIGNETTEMODE_OPAQUE;
  87413. /**
  87414. * Used to apply the vignette as a mix with the pixel color.
  87415. */
  87416. static get VIGNETTEMODE_MULTIPLY(): number;
  87417. /**
  87418. * Used to apply the vignette as a replacement of the pixel color.
  87419. */
  87420. static get VIGNETTEMODE_OPAQUE(): number;
  87421. }
  87422. }
  87423. declare module BABYLON {
  87424. /** @hidden */
  87425. export var postprocessVertexShader: {
  87426. name: string;
  87427. shader: string;
  87428. };
  87429. }
  87430. declare module BABYLON {
  87431. interface ThinEngine {
  87432. /**
  87433. * Creates a new render target texture
  87434. * @param size defines the size of the texture
  87435. * @param options defines the options used to create the texture
  87436. * @returns a new render target texture stored in an InternalTexture
  87437. */
  87438. createRenderTargetTexture(size: number | {
  87439. width: number;
  87440. height: number;
  87441. layers?: number;
  87442. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87443. /**
  87444. * Creates a depth stencil texture.
  87445. * This is only available in WebGL 2 or with the depth texture extension available.
  87446. * @param size The size of face edge in the texture.
  87447. * @param options The options defining the texture.
  87448. * @returns The texture
  87449. */
  87450. createDepthStencilTexture(size: number | {
  87451. width: number;
  87452. height: number;
  87453. layers?: number;
  87454. }, options: DepthTextureCreationOptions): InternalTexture;
  87455. /** @hidden */
  87456. _createDepthStencilTexture(size: number | {
  87457. width: number;
  87458. height: number;
  87459. layers?: number;
  87460. }, options: DepthTextureCreationOptions): InternalTexture;
  87461. }
  87462. }
  87463. declare module BABYLON {
  87464. /**
  87465. * Defines the kind of connection point for node based material
  87466. */
  87467. export enum NodeMaterialBlockConnectionPointTypes {
  87468. /** Float */
  87469. Float = 1,
  87470. /** Int */
  87471. Int = 2,
  87472. /** Vector2 */
  87473. Vector2 = 4,
  87474. /** Vector3 */
  87475. Vector3 = 8,
  87476. /** Vector4 */
  87477. Vector4 = 16,
  87478. /** Color3 */
  87479. Color3 = 32,
  87480. /** Color4 */
  87481. Color4 = 64,
  87482. /** Matrix */
  87483. Matrix = 128,
  87484. /** Custom object */
  87485. Object = 256,
  87486. /** Detect type based on connection */
  87487. AutoDetect = 1024,
  87488. /** Output type that will be defined by input type */
  87489. BasedOnInput = 2048
  87490. }
  87491. }
  87492. declare module BABYLON {
  87493. /**
  87494. * Enum used to define the target of a block
  87495. */
  87496. export enum NodeMaterialBlockTargets {
  87497. /** Vertex shader */
  87498. Vertex = 1,
  87499. /** Fragment shader */
  87500. Fragment = 2,
  87501. /** Neutral */
  87502. Neutral = 4,
  87503. /** Vertex and Fragment */
  87504. VertexAndFragment = 3
  87505. }
  87506. }
  87507. declare module BABYLON {
  87508. /**
  87509. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87510. */
  87511. export enum NodeMaterialBlockConnectionPointMode {
  87512. /** Value is an uniform */
  87513. Uniform = 0,
  87514. /** Value is a mesh attribute */
  87515. Attribute = 1,
  87516. /** Value is a varying between vertex and fragment shaders */
  87517. Varying = 2,
  87518. /** Mode is undefined */
  87519. Undefined = 3
  87520. }
  87521. }
  87522. declare module BABYLON {
  87523. /**
  87524. * Enum used to define system values e.g. values automatically provided by the system
  87525. */
  87526. export enum NodeMaterialSystemValues {
  87527. /** World */
  87528. World = 1,
  87529. /** View */
  87530. View = 2,
  87531. /** Projection */
  87532. Projection = 3,
  87533. /** ViewProjection */
  87534. ViewProjection = 4,
  87535. /** WorldView */
  87536. WorldView = 5,
  87537. /** WorldViewProjection */
  87538. WorldViewProjection = 6,
  87539. /** CameraPosition */
  87540. CameraPosition = 7,
  87541. /** Fog Color */
  87542. FogColor = 8,
  87543. /** Delta time */
  87544. DeltaTime = 9
  87545. }
  87546. }
  87547. declare module BABYLON {
  87548. /** Defines supported spaces */
  87549. export enum Space {
  87550. /** Local (object) space */
  87551. LOCAL = 0,
  87552. /** World space */
  87553. WORLD = 1,
  87554. /** Bone space */
  87555. BONE = 2
  87556. }
  87557. /** Defines the 3 main axes */
  87558. export class Axis {
  87559. /** X axis */
  87560. static X: Vector3;
  87561. /** Y axis */
  87562. static Y: Vector3;
  87563. /** Z axis */
  87564. static Z: Vector3;
  87565. }
  87566. }
  87567. declare module BABYLON {
  87568. /**
  87569. * Represents a camera frustum
  87570. */
  87571. export class Frustum {
  87572. /**
  87573. * Gets the planes representing the frustum
  87574. * @param transform matrix to be applied to the returned planes
  87575. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87576. */
  87577. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87578. /**
  87579. * Gets the near frustum plane transformed by the transform matrix
  87580. * @param transform transformation matrix to be applied to the resulting frustum plane
  87581. * @param frustumPlane the resuling frustum plane
  87582. */
  87583. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87584. /**
  87585. * Gets the far frustum plane transformed by the transform matrix
  87586. * @param transform transformation matrix to be applied to the resulting frustum plane
  87587. * @param frustumPlane the resuling frustum plane
  87588. */
  87589. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87590. /**
  87591. * Gets the left frustum plane transformed by the transform matrix
  87592. * @param transform transformation matrix to be applied to the resulting frustum plane
  87593. * @param frustumPlane the resuling frustum plane
  87594. */
  87595. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87596. /**
  87597. * Gets the right frustum plane transformed by the transform matrix
  87598. * @param transform transformation matrix to be applied to the resulting frustum plane
  87599. * @param frustumPlane the resuling frustum plane
  87600. */
  87601. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87602. /**
  87603. * Gets the top frustum plane transformed by the transform matrix
  87604. * @param transform transformation matrix to be applied to the resulting frustum plane
  87605. * @param frustumPlane the resuling frustum plane
  87606. */
  87607. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87608. /**
  87609. * Gets the bottom frustum plane transformed by the transform matrix
  87610. * @param transform transformation matrix to be applied to the resulting frustum plane
  87611. * @param frustumPlane the resuling frustum plane
  87612. */
  87613. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87614. /**
  87615. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87616. * @param transform transformation matrix to be applied to the resulting frustum planes
  87617. * @param frustumPlanes the resuling frustum planes
  87618. */
  87619. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87620. }
  87621. }
  87622. declare module BABYLON {
  87623. /**
  87624. * Interface for the size containing width and height
  87625. */
  87626. export interface ISize {
  87627. /**
  87628. * Width
  87629. */
  87630. width: number;
  87631. /**
  87632. * Heighht
  87633. */
  87634. height: number;
  87635. }
  87636. /**
  87637. * Size containing widht and height
  87638. */
  87639. export class Size implements ISize {
  87640. /**
  87641. * Width
  87642. */
  87643. width: number;
  87644. /**
  87645. * Height
  87646. */
  87647. height: number;
  87648. /**
  87649. * Creates a Size object from the given width and height (floats).
  87650. * @param width width of the new size
  87651. * @param height height of the new size
  87652. */
  87653. constructor(width: number, height: number);
  87654. /**
  87655. * Returns a string with the Size width and height
  87656. * @returns a string with the Size width and height
  87657. */
  87658. toString(): string;
  87659. /**
  87660. * "Size"
  87661. * @returns the string "Size"
  87662. */
  87663. getClassName(): string;
  87664. /**
  87665. * Returns the Size hash code.
  87666. * @returns a hash code for a unique width and height
  87667. */
  87668. getHashCode(): number;
  87669. /**
  87670. * Updates the current size from the given one.
  87671. * @param src the given size
  87672. */
  87673. copyFrom(src: Size): void;
  87674. /**
  87675. * Updates in place the current Size from the given floats.
  87676. * @param width width of the new size
  87677. * @param height height of the new size
  87678. * @returns the updated Size.
  87679. */
  87680. copyFromFloats(width: number, height: number): Size;
  87681. /**
  87682. * Updates in place the current Size from the given floats.
  87683. * @param width width to set
  87684. * @param height height to set
  87685. * @returns the updated Size.
  87686. */
  87687. set(width: number, height: number): Size;
  87688. /**
  87689. * Multiplies the width and height by numbers
  87690. * @param w factor to multiple the width by
  87691. * @param h factor to multiple the height by
  87692. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87693. */
  87694. multiplyByFloats(w: number, h: number): Size;
  87695. /**
  87696. * Clones the size
  87697. * @returns a new Size copied from the given one.
  87698. */
  87699. clone(): Size;
  87700. /**
  87701. * True if the current Size and the given one width and height are strictly equal.
  87702. * @param other the other size to compare against
  87703. * @returns True if the current Size and the given one width and height are strictly equal.
  87704. */
  87705. equals(other: Size): boolean;
  87706. /**
  87707. * The surface of the Size : width * height (float).
  87708. */
  87709. get surface(): number;
  87710. /**
  87711. * Create a new size of zero
  87712. * @returns a new Size set to (0.0, 0.0)
  87713. */
  87714. static Zero(): Size;
  87715. /**
  87716. * Sums the width and height of two sizes
  87717. * @param otherSize size to add to this size
  87718. * @returns a new Size set as the addition result of the current Size and the given one.
  87719. */
  87720. add(otherSize: Size): Size;
  87721. /**
  87722. * Subtracts the width and height of two
  87723. * @param otherSize size to subtract to this size
  87724. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87725. */
  87726. subtract(otherSize: Size): Size;
  87727. /**
  87728. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87729. * @param start starting size to lerp between
  87730. * @param end end size to lerp between
  87731. * @param amount amount to lerp between the start and end values
  87732. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87733. */
  87734. static Lerp(start: Size, end: Size, amount: number): Size;
  87735. }
  87736. }
  87737. declare module BABYLON {
  87738. /**
  87739. * Contains position and normal vectors for a vertex
  87740. */
  87741. export class PositionNormalVertex {
  87742. /** the position of the vertex (defaut: 0,0,0) */
  87743. position: Vector3;
  87744. /** the normal of the vertex (defaut: 0,1,0) */
  87745. normal: Vector3;
  87746. /**
  87747. * Creates a PositionNormalVertex
  87748. * @param position the position of the vertex (defaut: 0,0,0)
  87749. * @param normal the normal of the vertex (defaut: 0,1,0)
  87750. */
  87751. constructor(
  87752. /** the position of the vertex (defaut: 0,0,0) */
  87753. position?: Vector3,
  87754. /** the normal of the vertex (defaut: 0,1,0) */
  87755. normal?: Vector3);
  87756. /**
  87757. * Clones the PositionNormalVertex
  87758. * @returns the cloned PositionNormalVertex
  87759. */
  87760. clone(): PositionNormalVertex;
  87761. }
  87762. /**
  87763. * Contains position, normal and uv vectors for a vertex
  87764. */
  87765. export class PositionNormalTextureVertex {
  87766. /** the position of the vertex (defaut: 0,0,0) */
  87767. position: Vector3;
  87768. /** the normal of the vertex (defaut: 0,1,0) */
  87769. normal: Vector3;
  87770. /** the uv of the vertex (default: 0,0) */
  87771. uv: Vector2;
  87772. /**
  87773. * Creates a PositionNormalTextureVertex
  87774. * @param position the position of the vertex (defaut: 0,0,0)
  87775. * @param normal the normal of the vertex (defaut: 0,1,0)
  87776. * @param uv the uv of the vertex (default: 0,0)
  87777. */
  87778. constructor(
  87779. /** the position of the vertex (defaut: 0,0,0) */
  87780. position?: Vector3,
  87781. /** the normal of the vertex (defaut: 0,1,0) */
  87782. normal?: Vector3,
  87783. /** the uv of the vertex (default: 0,0) */
  87784. uv?: Vector2);
  87785. /**
  87786. * Clones the PositionNormalTextureVertex
  87787. * @returns the cloned PositionNormalTextureVertex
  87788. */
  87789. clone(): PositionNormalTextureVertex;
  87790. }
  87791. }
  87792. declare module BABYLON {
  87793. /**
  87794. * Enum defining the type of animations supported by InputBlock
  87795. */
  87796. export enum AnimatedInputBlockTypes {
  87797. /** No animation */
  87798. None = 0,
  87799. /** Time based animation. Will only work for floats */
  87800. Time = 1
  87801. }
  87802. }
  87803. declare module BABYLON {
  87804. /**
  87805. * Interface describing all the common properties and methods a shadow light needs to implement.
  87806. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87807. * as well as binding the different shadow properties to the effects.
  87808. */
  87809. export interface IShadowLight extends Light {
  87810. /**
  87811. * The light id in the scene (used in scene.findLighById for instance)
  87812. */
  87813. id: string;
  87814. /**
  87815. * The position the shdow will be casted from.
  87816. */
  87817. position: Vector3;
  87818. /**
  87819. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87820. */
  87821. direction: Vector3;
  87822. /**
  87823. * The transformed position. Position of the light in world space taking parenting in account.
  87824. */
  87825. transformedPosition: Vector3;
  87826. /**
  87827. * The transformed direction. Direction of the light in world space taking parenting in account.
  87828. */
  87829. transformedDirection: Vector3;
  87830. /**
  87831. * The friendly name of the light in the scene.
  87832. */
  87833. name: string;
  87834. /**
  87835. * Defines the shadow projection clipping minimum z value.
  87836. */
  87837. shadowMinZ: number;
  87838. /**
  87839. * Defines the shadow projection clipping maximum z value.
  87840. */
  87841. shadowMaxZ: number;
  87842. /**
  87843. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87844. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87845. */
  87846. computeTransformedInformation(): boolean;
  87847. /**
  87848. * Gets the scene the light belongs to.
  87849. * @returns The scene
  87850. */
  87851. getScene(): Scene;
  87852. /**
  87853. * Callback defining a custom Projection Matrix Builder.
  87854. * This can be used to override the default projection matrix computation.
  87855. */
  87856. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87857. /**
  87858. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87859. * @param matrix The materix to updated with the projection information
  87860. * @param viewMatrix The transform matrix of the light
  87861. * @param renderList The list of mesh to render in the map
  87862. * @returns The current light
  87863. */
  87864. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87865. /**
  87866. * Gets the current depth scale used in ESM.
  87867. * @returns The scale
  87868. */
  87869. getDepthScale(): number;
  87870. /**
  87871. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87872. * @returns true if a cube texture needs to be use
  87873. */
  87874. needCube(): boolean;
  87875. /**
  87876. * Detects if the projection matrix requires to be recomputed this frame.
  87877. * @returns true if it requires to be recomputed otherwise, false.
  87878. */
  87879. needProjectionMatrixCompute(): boolean;
  87880. /**
  87881. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87882. */
  87883. forceProjectionMatrixCompute(): void;
  87884. /**
  87885. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87886. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87887. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87888. */
  87889. getShadowDirection(faceIndex?: number): Vector3;
  87890. /**
  87891. * Gets the minZ used for shadow according to both the scene and the light.
  87892. * @param activeCamera The camera we are returning the min for
  87893. * @returns the depth min z
  87894. */
  87895. getDepthMinZ(activeCamera: Camera): number;
  87896. /**
  87897. * Gets the maxZ used for shadow according to both the scene and the light.
  87898. * @param activeCamera The camera we are returning the max for
  87899. * @returns the depth max z
  87900. */
  87901. getDepthMaxZ(activeCamera: Camera): number;
  87902. }
  87903. /**
  87904. * Base implementation IShadowLight
  87905. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87906. */
  87907. export abstract class ShadowLight extends Light implements IShadowLight {
  87908. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87909. protected _position: Vector3;
  87910. protected _setPosition(value: Vector3): void;
  87911. /**
  87912. * Sets the position the shadow will be casted from. Also use as the light position for both
  87913. * point and spot lights.
  87914. */
  87915. get position(): Vector3;
  87916. /**
  87917. * Sets the position the shadow will be casted from. Also use as the light position for both
  87918. * point and spot lights.
  87919. */
  87920. set position(value: Vector3);
  87921. protected _direction: Vector3;
  87922. protected _setDirection(value: Vector3): void;
  87923. /**
  87924. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87925. * Also use as the light direction on spot and directional lights.
  87926. */
  87927. get direction(): Vector3;
  87928. /**
  87929. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87930. * Also use as the light direction on spot and directional lights.
  87931. */
  87932. set direction(value: Vector3);
  87933. protected _shadowMinZ: number;
  87934. /**
  87935. * Gets the shadow projection clipping minimum z value.
  87936. */
  87937. get shadowMinZ(): number;
  87938. /**
  87939. * Sets the shadow projection clipping minimum z value.
  87940. */
  87941. set shadowMinZ(value: number);
  87942. protected _shadowMaxZ: number;
  87943. /**
  87944. * Sets the shadow projection clipping maximum z value.
  87945. */
  87946. get shadowMaxZ(): number;
  87947. /**
  87948. * Gets the shadow projection clipping maximum z value.
  87949. */
  87950. set shadowMaxZ(value: number);
  87951. /**
  87952. * Callback defining a custom Projection Matrix Builder.
  87953. * This can be used to override the default projection matrix computation.
  87954. */
  87955. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87956. /**
  87957. * The transformed position. Position of the light in world space taking parenting in account.
  87958. */
  87959. transformedPosition: Vector3;
  87960. /**
  87961. * The transformed direction. Direction of the light in world space taking parenting in account.
  87962. */
  87963. transformedDirection: Vector3;
  87964. private _needProjectionMatrixCompute;
  87965. /**
  87966. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87967. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87968. */
  87969. computeTransformedInformation(): boolean;
  87970. /**
  87971. * Return the depth scale used for the shadow map.
  87972. * @returns the depth scale.
  87973. */
  87974. getDepthScale(): number;
  87975. /**
  87976. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87977. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87978. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87979. */
  87980. getShadowDirection(faceIndex?: number): Vector3;
  87981. /**
  87982. * Returns the ShadowLight absolute position in the World.
  87983. * @returns the position vector in world space
  87984. */
  87985. getAbsolutePosition(): Vector3;
  87986. /**
  87987. * Sets the ShadowLight direction toward the passed target.
  87988. * @param target The point to target in local space
  87989. * @returns the updated ShadowLight direction
  87990. */
  87991. setDirectionToTarget(target: Vector3): Vector3;
  87992. /**
  87993. * Returns the light rotation in euler definition.
  87994. * @returns the x y z rotation in local space.
  87995. */
  87996. getRotation(): Vector3;
  87997. /**
  87998. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87999. * @returns true if a cube texture needs to be use
  88000. */
  88001. needCube(): boolean;
  88002. /**
  88003. * Detects if the projection matrix requires to be recomputed this frame.
  88004. * @returns true if it requires to be recomputed otherwise, false.
  88005. */
  88006. needProjectionMatrixCompute(): boolean;
  88007. /**
  88008. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88009. */
  88010. forceProjectionMatrixCompute(): void;
  88011. /** @hidden */
  88012. _initCache(): void;
  88013. /** @hidden */
  88014. _isSynchronized(): boolean;
  88015. /**
  88016. * Computes the world matrix of the node
  88017. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88018. * @returns the world matrix
  88019. */
  88020. computeWorldMatrix(force?: boolean): Matrix;
  88021. /**
  88022. * Gets the minZ used for shadow according to both the scene and the light.
  88023. * @param activeCamera The camera we are returning the min for
  88024. * @returns the depth min z
  88025. */
  88026. getDepthMinZ(activeCamera: Camera): number;
  88027. /**
  88028. * Gets the maxZ used for shadow according to both the scene and the light.
  88029. * @param activeCamera The camera we are returning the max for
  88030. * @returns the depth max z
  88031. */
  88032. getDepthMaxZ(activeCamera: Camera): number;
  88033. /**
  88034. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88035. * @param matrix The materix to updated with the projection information
  88036. * @param viewMatrix The transform matrix of the light
  88037. * @param renderList The list of mesh to render in the map
  88038. * @returns The current light
  88039. */
  88040. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88041. }
  88042. }
  88043. declare module BABYLON {
  88044. /** @hidden */
  88045. export var packingFunctions: {
  88046. name: string;
  88047. shader: string;
  88048. };
  88049. }
  88050. declare module BABYLON {
  88051. /** @hidden */
  88052. export var bayerDitherFunctions: {
  88053. name: string;
  88054. shader: string;
  88055. };
  88056. }
  88057. declare module BABYLON {
  88058. /** @hidden */
  88059. export var shadowMapFragmentDeclaration: {
  88060. name: string;
  88061. shader: string;
  88062. };
  88063. }
  88064. declare module BABYLON {
  88065. /** @hidden */
  88066. export var clipPlaneFragmentDeclaration: {
  88067. name: string;
  88068. shader: string;
  88069. };
  88070. }
  88071. declare module BABYLON {
  88072. /** @hidden */
  88073. export var clipPlaneFragment: {
  88074. name: string;
  88075. shader: string;
  88076. };
  88077. }
  88078. declare module BABYLON {
  88079. /** @hidden */
  88080. export var shadowMapFragment: {
  88081. name: string;
  88082. shader: string;
  88083. };
  88084. }
  88085. declare module BABYLON {
  88086. /** @hidden */
  88087. export var shadowMapPixelShader: {
  88088. name: string;
  88089. shader: string;
  88090. };
  88091. }
  88092. declare module BABYLON {
  88093. /** @hidden */
  88094. export var bonesDeclaration: {
  88095. name: string;
  88096. shader: string;
  88097. };
  88098. }
  88099. declare module BABYLON {
  88100. /** @hidden */
  88101. export var morphTargetsVertexGlobalDeclaration: {
  88102. name: string;
  88103. shader: string;
  88104. };
  88105. }
  88106. declare module BABYLON {
  88107. /** @hidden */
  88108. export var morphTargetsVertexDeclaration: {
  88109. name: string;
  88110. shader: string;
  88111. };
  88112. }
  88113. declare module BABYLON {
  88114. /** @hidden */
  88115. export var instancesDeclaration: {
  88116. name: string;
  88117. shader: string;
  88118. };
  88119. }
  88120. declare module BABYLON {
  88121. /** @hidden */
  88122. export var helperFunctions: {
  88123. name: string;
  88124. shader: string;
  88125. };
  88126. }
  88127. declare module BABYLON {
  88128. /** @hidden */
  88129. export var shadowMapVertexDeclaration: {
  88130. name: string;
  88131. shader: string;
  88132. };
  88133. }
  88134. declare module BABYLON {
  88135. /** @hidden */
  88136. export var clipPlaneVertexDeclaration: {
  88137. name: string;
  88138. shader: string;
  88139. };
  88140. }
  88141. declare module BABYLON {
  88142. /** @hidden */
  88143. export var morphTargetsVertex: {
  88144. name: string;
  88145. shader: string;
  88146. };
  88147. }
  88148. declare module BABYLON {
  88149. /** @hidden */
  88150. export var instancesVertex: {
  88151. name: string;
  88152. shader: string;
  88153. };
  88154. }
  88155. declare module BABYLON {
  88156. /** @hidden */
  88157. export var bonesVertex: {
  88158. name: string;
  88159. shader: string;
  88160. };
  88161. }
  88162. declare module BABYLON {
  88163. /** @hidden */
  88164. export var shadowMapVertexNormalBias: {
  88165. name: string;
  88166. shader: string;
  88167. };
  88168. }
  88169. declare module BABYLON {
  88170. /** @hidden */
  88171. export var shadowMapVertexMetric: {
  88172. name: string;
  88173. shader: string;
  88174. };
  88175. }
  88176. declare module BABYLON {
  88177. /** @hidden */
  88178. export var clipPlaneVertex: {
  88179. name: string;
  88180. shader: string;
  88181. };
  88182. }
  88183. declare module BABYLON {
  88184. /** @hidden */
  88185. export var shadowMapVertexShader: {
  88186. name: string;
  88187. shader: string;
  88188. };
  88189. }
  88190. declare module BABYLON {
  88191. /** @hidden */
  88192. export var depthBoxBlurPixelShader: {
  88193. name: string;
  88194. shader: string;
  88195. };
  88196. }
  88197. declare module BABYLON {
  88198. /** @hidden */
  88199. export var shadowMapFragmentSoftTransparentShadow: {
  88200. name: string;
  88201. shader: string;
  88202. };
  88203. }
  88204. declare module BABYLON {
  88205. /**
  88206. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88207. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88208. */
  88209. export class EffectFallbacks implements IEffectFallbacks {
  88210. private _defines;
  88211. private _currentRank;
  88212. private _maxRank;
  88213. private _mesh;
  88214. /**
  88215. * Removes the fallback from the bound mesh.
  88216. */
  88217. unBindMesh(): void;
  88218. /**
  88219. * Adds a fallback on the specified property.
  88220. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88221. * @param define The name of the define in the shader
  88222. */
  88223. addFallback(rank: number, define: string): void;
  88224. /**
  88225. * Sets the mesh to use CPU skinning when needing to fallback.
  88226. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88227. * @param mesh The mesh to use the fallbacks.
  88228. */
  88229. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88230. /**
  88231. * Checks to see if more fallbacks are still availible.
  88232. */
  88233. get hasMoreFallbacks(): boolean;
  88234. /**
  88235. * Removes the defines that should be removed when falling back.
  88236. * @param currentDefines defines the current define statements for the shader.
  88237. * @param effect defines the current effect we try to compile
  88238. * @returns The resulting defines with defines of the current rank removed.
  88239. */
  88240. reduce(currentDefines: string, effect: Effect): string;
  88241. }
  88242. }
  88243. declare module BABYLON {
  88244. /**
  88245. * Interface used to define Action
  88246. */
  88247. export interface IAction {
  88248. /**
  88249. * Trigger for the action
  88250. */
  88251. trigger: number;
  88252. /** Options of the trigger */
  88253. triggerOptions: any;
  88254. /**
  88255. * Gets the trigger parameters
  88256. * @returns the trigger parameters
  88257. */
  88258. getTriggerParameter(): any;
  88259. /**
  88260. * Internal only - executes current action event
  88261. * @hidden
  88262. */
  88263. _executeCurrent(evt?: ActionEvent): void;
  88264. /**
  88265. * Serialize placeholder for child classes
  88266. * @param parent of child
  88267. * @returns the serialized object
  88268. */
  88269. serialize(parent: any): any;
  88270. /**
  88271. * Internal only
  88272. * @hidden
  88273. */
  88274. _prepare(): void;
  88275. /**
  88276. * Internal only - manager for action
  88277. * @hidden
  88278. */
  88279. _actionManager: AbstractActionManager;
  88280. /**
  88281. * Adds action to chain of actions, may be a DoNothingAction
  88282. * @param action defines the next action to execute
  88283. * @returns The action passed in
  88284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88285. */
  88286. then(action: IAction): IAction;
  88287. }
  88288. /**
  88289. * The action to be carried out following a trigger
  88290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88291. */
  88292. export class Action implements IAction {
  88293. /** the trigger, with or without parameters, for the action */
  88294. triggerOptions: any;
  88295. /**
  88296. * Trigger for the action
  88297. */
  88298. trigger: number;
  88299. /**
  88300. * Internal only - manager for action
  88301. * @hidden
  88302. */
  88303. _actionManager: ActionManager;
  88304. private _nextActiveAction;
  88305. private _child;
  88306. private _condition?;
  88307. private _triggerParameter;
  88308. /**
  88309. * An event triggered prior to action being executed.
  88310. */
  88311. onBeforeExecuteObservable: Observable<Action>;
  88312. /**
  88313. * Creates a new Action
  88314. * @param triggerOptions the trigger, with or without parameters, for the action
  88315. * @param condition an optional determinant of action
  88316. */
  88317. constructor(
  88318. /** the trigger, with or without parameters, for the action */
  88319. triggerOptions: any, condition?: Condition);
  88320. /**
  88321. * Internal only
  88322. * @hidden
  88323. */
  88324. _prepare(): void;
  88325. /**
  88326. * Gets the trigger parameters
  88327. * @returns the trigger parameters
  88328. */
  88329. getTriggerParameter(): any;
  88330. /**
  88331. * Internal only - executes current action event
  88332. * @hidden
  88333. */
  88334. _executeCurrent(evt?: ActionEvent): void;
  88335. /**
  88336. * Execute placeholder for child classes
  88337. * @param evt optional action event
  88338. */
  88339. execute(evt?: ActionEvent): void;
  88340. /**
  88341. * Skips to next active action
  88342. */
  88343. skipToNextActiveAction(): void;
  88344. /**
  88345. * Adds action to chain of actions, may be a DoNothingAction
  88346. * @param action defines the next action to execute
  88347. * @returns The action passed in
  88348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88349. */
  88350. then(action: Action): Action;
  88351. /**
  88352. * Internal only
  88353. * @hidden
  88354. */
  88355. _getProperty(propertyPath: string): string;
  88356. /**
  88357. * Internal only
  88358. * @hidden
  88359. */
  88360. _getEffectiveTarget(target: any, propertyPath: string): any;
  88361. /**
  88362. * Serialize placeholder for child classes
  88363. * @param parent of child
  88364. * @returns the serialized object
  88365. */
  88366. serialize(parent: any): any;
  88367. /**
  88368. * Internal only called by serialize
  88369. * @hidden
  88370. */
  88371. protected _serialize(serializedAction: any, parent?: any): any;
  88372. /**
  88373. * Internal only
  88374. * @hidden
  88375. */
  88376. static _SerializeValueAsString: (value: any) => string;
  88377. /**
  88378. * Internal only
  88379. * @hidden
  88380. */
  88381. static _GetTargetProperty: (target: Scene | Node) => {
  88382. name: string;
  88383. targetType: string;
  88384. value: string;
  88385. };
  88386. }
  88387. }
  88388. declare module BABYLON {
  88389. /**
  88390. * A Condition applied to an Action
  88391. */
  88392. export class Condition {
  88393. /**
  88394. * Internal only - manager for action
  88395. * @hidden
  88396. */
  88397. _actionManager: ActionManager;
  88398. /**
  88399. * Internal only
  88400. * @hidden
  88401. */
  88402. _evaluationId: number;
  88403. /**
  88404. * Internal only
  88405. * @hidden
  88406. */
  88407. _currentResult: boolean;
  88408. /**
  88409. * Creates a new Condition
  88410. * @param actionManager the manager of the action the condition is applied to
  88411. */
  88412. constructor(actionManager: ActionManager);
  88413. /**
  88414. * Check if the current condition is valid
  88415. * @returns a boolean
  88416. */
  88417. isValid(): boolean;
  88418. /**
  88419. * Internal only
  88420. * @hidden
  88421. */
  88422. _getProperty(propertyPath: string): string;
  88423. /**
  88424. * Internal only
  88425. * @hidden
  88426. */
  88427. _getEffectiveTarget(target: any, propertyPath: string): any;
  88428. /**
  88429. * Serialize placeholder for child classes
  88430. * @returns the serialized object
  88431. */
  88432. serialize(): any;
  88433. /**
  88434. * Internal only
  88435. * @hidden
  88436. */
  88437. protected _serialize(serializedCondition: any): any;
  88438. }
  88439. /**
  88440. * Defines specific conditional operators as extensions of Condition
  88441. */
  88442. export class ValueCondition extends Condition {
  88443. /** path to specify the property of the target the conditional operator uses */
  88444. propertyPath: string;
  88445. /** the value compared by the conditional operator against the current value of the property */
  88446. value: any;
  88447. /** the conditional operator, default ValueCondition.IsEqual */
  88448. operator: number;
  88449. /**
  88450. * Internal only
  88451. * @hidden
  88452. */
  88453. private static _IsEqual;
  88454. /**
  88455. * Internal only
  88456. * @hidden
  88457. */
  88458. private static _IsDifferent;
  88459. /**
  88460. * Internal only
  88461. * @hidden
  88462. */
  88463. private static _IsGreater;
  88464. /**
  88465. * Internal only
  88466. * @hidden
  88467. */
  88468. private static _IsLesser;
  88469. /**
  88470. * returns the number for IsEqual
  88471. */
  88472. static get IsEqual(): number;
  88473. /**
  88474. * Returns the number for IsDifferent
  88475. */
  88476. static get IsDifferent(): number;
  88477. /**
  88478. * Returns the number for IsGreater
  88479. */
  88480. static get IsGreater(): number;
  88481. /**
  88482. * Returns the number for IsLesser
  88483. */
  88484. static get IsLesser(): number;
  88485. /**
  88486. * Internal only The action manager for the condition
  88487. * @hidden
  88488. */
  88489. _actionManager: ActionManager;
  88490. /**
  88491. * Internal only
  88492. * @hidden
  88493. */
  88494. private _target;
  88495. /**
  88496. * Internal only
  88497. * @hidden
  88498. */
  88499. private _effectiveTarget;
  88500. /**
  88501. * Internal only
  88502. * @hidden
  88503. */
  88504. private _property;
  88505. /**
  88506. * Creates a new ValueCondition
  88507. * @param actionManager manager for the action the condition applies to
  88508. * @param target for the action
  88509. * @param propertyPath path to specify the property of the target the conditional operator uses
  88510. * @param value the value compared by the conditional operator against the current value of the property
  88511. * @param operator the conditional operator, default ValueCondition.IsEqual
  88512. */
  88513. constructor(actionManager: ActionManager, target: any,
  88514. /** path to specify the property of the target the conditional operator uses */
  88515. propertyPath: string,
  88516. /** the value compared by the conditional operator against the current value of the property */
  88517. value: any,
  88518. /** the conditional operator, default ValueCondition.IsEqual */
  88519. operator?: number);
  88520. /**
  88521. * Compares the given value with the property value for the specified conditional operator
  88522. * @returns the result of the comparison
  88523. */
  88524. isValid(): boolean;
  88525. /**
  88526. * Serialize the ValueCondition into a JSON compatible object
  88527. * @returns serialization object
  88528. */
  88529. serialize(): any;
  88530. /**
  88531. * Gets the name of the conditional operator for the ValueCondition
  88532. * @param operator the conditional operator
  88533. * @returns the name
  88534. */
  88535. static GetOperatorName(operator: number): string;
  88536. }
  88537. /**
  88538. * Defines a predicate condition as an extension of Condition
  88539. */
  88540. export class PredicateCondition extends Condition {
  88541. /** defines the predicate function used to validate the condition */
  88542. predicate: () => boolean;
  88543. /**
  88544. * Internal only - manager for action
  88545. * @hidden
  88546. */
  88547. _actionManager: ActionManager;
  88548. /**
  88549. * Creates a new PredicateCondition
  88550. * @param actionManager manager for the action the condition applies to
  88551. * @param predicate defines the predicate function used to validate the condition
  88552. */
  88553. constructor(actionManager: ActionManager,
  88554. /** defines the predicate function used to validate the condition */
  88555. predicate: () => boolean);
  88556. /**
  88557. * @returns the validity of the predicate condition
  88558. */
  88559. isValid(): boolean;
  88560. }
  88561. /**
  88562. * Defines a state condition as an extension of Condition
  88563. */
  88564. export class StateCondition extends Condition {
  88565. /** Value to compare with target state */
  88566. value: string;
  88567. /**
  88568. * Internal only - manager for action
  88569. * @hidden
  88570. */
  88571. _actionManager: ActionManager;
  88572. /**
  88573. * Internal only
  88574. * @hidden
  88575. */
  88576. private _target;
  88577. /**
  88578. * Creates a new StateCondition
  88579. * @param actionManager manager for the action the condition applies to
  88580. * @param target of the condition
  88581. * @param value to compare with target state
  88582. */
  88583. constructor(actionManager: ActionManager, target: any,
  88584. /** Value to compare with target state */
  88585. value: string);
  88586. /**
  88587. * Gets a boolean indicating if the current condition is met
  88588. * @returns the validity of the state
  88589. */
  88590. isValid(): boolean;
  88591. /**
  88592. * Serialize the StateCondition into a JSON compatible object
  88593. * @returns serialization object
  88594. */
  88595. serialize(): any;
  88596. }
  88597. }
  88598. declare module BABYLON {
  88599. /**
  88600. * This defines an action responsible to toggle a boolean once triggered.
  88601. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88602. */
  88603. export class SwitchBooleanAction extends Action {
  88604. /**
  88605. * The path to the boolean property in the target object
  88606. */
  88607. propertyPath: string;
  88608. private _target;
  88609. private _effectiveTarget;
  88610. private _property;
  88611. /**
  88612. * Instantiate the action
  88613. * @param triggerOptions defines the trigger options
  88614. * @param target defines the object containing the boolean
  88615. * @param propertyPath defines the path to the boolean property in the target object
  88616. * @param condition defines the trigger related conditions
  88617. */
  88618. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88619. /** @hidden */
  88620. _prepare(): void;
  88621. /**
  88622. * Execute the action toggle the boolean value.
  88623. */
  88624. execute(): void;
  88625. /**
  88626. * Serializes the actions and its related information.
  88627. * @param parent defines the object to serialize in
  88628. * @returns the serialized object
  88629. */
  88630. serialize(parent: any): any;
  88631. }
  88632. /**
  88633. * This defines an action responsible to set a the state field of the target
  88634. * to a desired value once triggered.
  88635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88636. */
  88637. export class SetStateAction extends Action {
  88638. /**
  88639. * The value to store in the state field.
  88640. */
  88641. value: string;
  88642. private _target;
  88643. /**
  88644. * Instantiate the action
  88645. * @param triggerOptions defines the trigger options
  88646. * @param target defines the object containing the state property
  88647. * @param value defines the value to store in the state field
  88648. * @param condition defines the trigger related conditions
  88649. */
  88650. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88651. /**
  88652. * Execute the action and store the value on the target state property.
  88653. */
  88654. execute(): void;
  88655. /**
  88656. * Serializes the actions and its related information.
  88657. * @param parent defines the object to serialize in
  88658. * @returns the serialized object
  88659. */
  88660. serialize(parent: any): any;
  88661. }
  88662. /**
  88663. * This defines an action responsible to set a property of the target
  88664. * to a desired value once triggered.
  88665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88666. */
  88667. export class SetValueAction extends Action {
  88668. /**
  88669. * The path of the property to set in the target.
  88670. */
  88671. propertyPath: string;
  88672. /**
  88673. * The value to set in the property
  88674. */
  88675. value: any;
  88676. private _target;
  88677. private _effectiveTarget;
  88678. private _property;
  88679. /**
  88680. * Instantiate the action
  88681. * @param triggerOptions defines the trigger options
  88682. * @param target defines the object containing the property
  88683. * @param propertyPath defines the path of the property to set in the target
  88684. * @param value defines the value to set in the property
  88685. * @param condition defines the trigger related conditions
  88686. */
  88687. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88688. /** @hidden */
  88689. _prepare(): void;
  88690. /**
  88691. * Execute the action and set the targetted property to the desired value.
  88692. */
  88693. execute(): void;
  88694. /**
  88695. * Serializes the actions and its related information.
  88696. * @param parent defines the object to serialize in
  88697. * @returns the serialized object
  88698. */
  88699. serialize(parent: any): any;
  88700. }
  88701. /**
  88702. * This defines an action responsible to increment the target value
  88703. * to a desired value once triggered.
  88704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88705. */
  88706. export class IncrementValueAction extends Action {
  88707. /**
  88708. * The path of the property to increment in the target.
  88709. */
  88710. propertyPath: string;
  88711. /**
  88712. * The value we should increment the property by.
  88713. */
  88714. value: any;
  88715. private _target;
  88716. private _effectiveTarget;
  88717. private _property;
  88718. /**
  88719. * Instantiate the action
  88720. * @param triggerOptions defines the trigger options
  88721. * @param target defines the object containing the property
  88722. * @param propertyPath defines the path of the property to increment in the target
  88723. * @param value defines the value value we should increment the property by
  88724. * @param condition defines the trigger related conditions
  88725. */
  88726. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88727. /** @hidden */
  88728. _prepare(): void;
  88729. /**
  88730. * Execute the action and increment the target of the value amount.
  88731. */
  88732. execute(): void;
  88733. /**
  88734. * Serializes the actions and its related information.
  88735. * @param parent defines the object to serialize in
  88736. * @returns the serialized object
  88737. */
  88738. serialize(parent: any): any;
  88739. }
  88740. /**
  88741. * This defines an action responsible to start an animation once triggered.
  88742. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88743. */
  88744. export class PlayAnimationAction extends Action {
  88745. /**
  88746. * Where the animation should start (animation frame)
  88747. */
  88748. from: number;
  88749. /**
  88750. * Where the animation should stop (animation frame)
  88751. */
  88752. to: number;
  88753. /**
  88754. * Define if the animation should loop or stop after the first play.
  88755. */
  88756. loop?: boolean;
  88757. private _target;
  88758. /**
  88759. * Instantiate the action
  88760. * @param triggerOptions defines the trigger options
  88761. * @param target defines the target animation or animation name
  88762. * @param from defines from where the animation should start (animation frame)
  88763. * @param end defines where the animation should stop (animation frame)
  88764. * @param loop defines if the animation should loop or stop after the first play
  88765. * @param condition defines the trigger related conditions
  88766. */
  88767. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88768. /** @hidden */
  88769. _prepare(): void;
  88770. /**
  88771. * Execute the action and play the animation.
  88772. */
  88773. execute(): void;
  88774. /**
  88775. * Serializes the actions and its related information.
  88776. * @param parent defines the object to serialize in
  88777. * @returns the serialized object
  88778. */
  88779. serialize(parent: any): any;
  88780. }
  88781. /**
  88782. * This defines an action responsible to stop an animation once triggered.
  88783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88784. */
  88785. export class StopAnimationAction extends Action {
  88786. private _target;
  88787. /**
  88788. * Instantiate the action
  88789. * @param triggerOptions defines the trigger options
  88790. * @param target defines the target animation or animation name
  88791. * @param condition defines the trigger related conditions
  88792. */
  88793. constructor(triggerOptions: any, target: any, condition?: Condition);
  88794. /** @hidden */
  88795. _prepare(): void;
  88796. /**
  88797. * Execute the action and stop the animation.
  88798. */
  88799. execute(): void;
  88800. /**
  88801. * Serializes the actions and its related information.
  88802. * @param parent defines the object to serialize in
  88803. * @returns the serialized object
  88804. */
  88805. serialize(parent: any): any;
  88806. }
  88807. /**
  88808. * This defines an action responsible that does nothing once triggered.
  88809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88810. */
  88811. export class DoNothingAction extends Action {
  88812. /**
  88813. * Instantiate the action
  88814. * @param triggerOptions defines the trigger options
  88815. * @param condition defines the trigger related conditions
  88816. */
  88817. constructor(triggerOptions?: any, condition?: Condition);
  88818. /**
  88819. * Execute the action and do nothing.
  88820. */
  88821. execute(): void;
  88822. /**
  88823. * Serializes the actions and its related information.
  88824. * @param parent defines the object to serialize in
  88825. * @returns the serialized object
  88826. */
  88827. serialize(parent: any): any;
  88828. }
  88829. /**
  88830. * This defines an action responsible to trigger several actions once triggered.
  88831. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88832. */
  88833. export class CombineAction extends Action {
  88834. /**
  88835. * The list of aggregated animations to run.
  88836. */
  88837. children: Action[];
  88838. /**
  88839. * Instantiate the action
  88840. * @param triggerOptions defines the trigger options
  88841. * @param children defines the list of aggregated animations to run
  88842. * @param condition defines the trigger related conditions
  88843. */
  88844. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88845. /** @hidden */
  88846. _prepare(): void;
  88847. /**
  88848. * Execute the action and executes all the aggregated actions.
  88849. */
  88850. execute(evt: ActionEvent): void;
  88851. /**
  88852. * Serializes the actions and its related information.
  88853. * @param parent defines the object to serialize in
  88854. * @returns the serialized object
  88855. */
  88856. serialize(parent: any): any;
  88857. }
  88858. /**
  88859. * This defines an action responsible to run code (external event) once triggered.
  88860. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88861. */
  88862. export class ExecuteCodeAction extends Action {
  88863. /**
  88864. * The callback function to run.
  88865. */
  88866. func: (evt: ActionEvent) => void;
  88867. /**
  88868. * Instantiate the action
  88869. * @param triggerOptions defines the trigger options
  88870. * @param func defines the callback function to run
  88871. * @param condition defines the trigger related conditions
  88872. */
  88873. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88874. /**
  88875. * Execute the action and run the attached code.
  88876. */
  88877. execute(evt: ActionEvent): void;
  88878. }
  88879. /**
  88880. * This defines an action responsible to set the parent property of the target once triggered.
  88881. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88882. */
  88883. export class SetParentAction extends Action {
  88884. private _parent;
  88885. private _target;
  88886. /**
  88887. * Instantiate the action
  88888. * @param triggerOptions defines the trigger options
  88889. * @param target defines the target containing the parent property
  88890. * @param parent defines from where the animation should start (animation frame)
  88891. * @param condition defines the trigger related conditions
  88892. */
  88893. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88894. /** @hidden */
  88895. _prepare(): void;
  88896. /**
  88897. * Execute the action and set the parent property.
  88898. */
  88899. execute(): void;
  88900. /**
  88901. * Serializes the actions and its related information.
  88902. * @param parent defines the object to serialize in
  88903. * @returns the serialized object
  88904. */
  88905. serialize(parent: any): any;
  88906. }
  88907. }
  88908. declare module BABYLON {
  88909. /**
  88910. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88911. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88913. */
  88914. export class ActionManager extends AbstractActionManager {
  88915. /**
  88916. * Nothing
  88917. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88918. */
  88919. static readonly NothingTrigger: number;
  88920. /**
  88921. * On pick
  88922. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88923. */
  88924. static readonly OnPickTrigger: number;
  88925. /**
  88926. * On left pick
  88927. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88928. */
  88929. static readonly OnLeftPickTrigger: number;
  88930. /**
  88931. * On right pick
  88932. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88933. */
  88934. static readonly OnRightPickTrigger: number;
  88935. /**
  88936. * On center pick
  88937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88938. */
  88939. static readonly OnCenterPickTrigger: number;
  88940. /**
  88941. * On pick down
  88942. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88943. */
  88944. static readonly OnPickDownTrigger: number;
  88945. /**
  88946. * On double pick
  88947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88948. */
  88949. static readonly OnDoublePickTrigger: number;
  88950. /**
  88951. * On pick up
  88952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88953. */
  88954. static readonly OnPickUpTrigger: number;
  88955. /**
  88956. * On pick out.
  88957. * This trigger will only be raised if you also declared a OnPickDown
  88958. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88959. */
  88960. static readonly OnPickOutTrigger: number;
  88961. /**
  88962. * On long press
  88963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88964. */
  88965. static readonly OnLongPressTrigger: number;
  88966. /**
  88967. * On pointer over
  88968. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88969. */
  88970. static readonly OnPointerOverTrigger: number;
  88971. /**
  88972. * On pointer out
  88973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88974. */
  88975. static readonly OnPointerOutTrigger: number;
  88976. /**
  88977. * On every frame
  88978. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88979. */
  88980. static readonly OnEveryFrameTrigger: number;
  88981. /**
  88982. * On intersection enter
  88983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88984. */
  88985. static readonly OnIntersectionEnterTrigger: number;
  88986. /**
  88987. * On intersection exit
  88988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88989. */
  88990. static readonly OnIntersectionExitTrigger: number;
  88991. /**
  88992. * On key down
  88993. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88994. */
  88995. static readonly OnKeyDownTrigger: number;
  88996. /**
  88997. * On key up
  88998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88999. */
  89000. static readonly OnKeyUpTrigger: number;
  89001. private _scene;
  89002. /**
  89003. * Creates a new action manager
  89004. * @param scene defines the hosting scene
  89005. */
  89006. constructor(scene: Scene);
  89007. /**
  89008. * Releases all associated resources
  89009. */
  89010. dispose(): void;
  89011. /**
  89012. * Gets hosting scene
  89013. * @returns the hosting scene
  89014. */
  89015. getScene(): Scene;
  89016. /**
  89017. * Does this action manager handles actions of any of the given triggers
  89018. * @param triggers defines the triggers to be tested
  89019. * @return a boolean indicating whether one (or more) of the triggers is handled
  89020. */
  89021. hasSpecificTriggers(triggers: number[]): boolean;
  89022. /**
  89023. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89024. * speed.
  89025. * @param triggerA defines the trigger to be tested
  89026. * @param triggerB defines the trigger to be tested
  89027. * @return a boolean indicating whether one (or more) of the triggers is handled
  89028. */
  89029. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89030. /**
  89031. * Does this action manager handles actions of a given trigger
  89032. * @param trigger defines the trigger to be tested
  89033. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89034. * @return whether the trigger is handled
  89035. */
  89036. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89037. /**
  89038. * Does this action manager has pointer triggers
  89039. */
  89040. get hasPointerTriggers(): boolean;
  89041. /**
  89042. * Does this action manager has pick triggers
  89043. */
  89044. get hasPickTriggers(): boolean;
  89045. /**
  89046. * Registers an action to this action manager
  89047. * @param action defines the action to be registered
  89048. * @return the action amended (prepared) after registration
  89049. */
  89050. registerAction(action: IAction): Nullable<IAction>;
  89051. /**
  89052. * Unregisters an action to this action manager
  89053. * @param action defines the action to be unregistered
  89054. * @return a boolean indicating whether the action has been unregistered
  89055. */
  89056. unregisterAction(action: IAction): Boolean;
  89057. /**
  89058. * Process a specific trigger
  89059. * @param trigger defines the trigger to process
  89060. * @param evt defines the event details to be processed
  89061. */
  89062. processTrigger(trigger: number, evt?: IActionEvent): void;
  89063. /** @hidden */
  89064. _getEffectiveTarget(target: any, propertyPath: string): any;
  89065. /** @hidden */
  89066. _getProperty(propertyPath: string): string;
  89067. /**
  89068. * Serialize this manager to a JSON object
  89069. * @param name defines the property name to store this manager
  89070. * @returns a JSON representation of this manager
  89071. */
  89072. serialize(name: string): any;
  89073. /**
  89074. * Creates a new ActionManager from a JSON data
  89075. * @param parsedActions defines the JSON data to read from
  89076. * @param object defines the hosting mesh
  89077. * @param scene defines the hosting scene
  89078. */
  89079. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89080. /**
  89081. * Get a trigger name by index
  89082. * @param trigger defines the trigger index
  89083. * @returns a trigger name
  89084. */
  89085. static GetTriggerName(trigger: number): string;
  89086. }
  89087. }
  89088. declare module BABYLON {
  89089. /**
  89090. * Class used to represent a sprite
  89091. * @see https://doc.babylonjs.com/babylon101/sprites
  89092. */
  89093. export class Sprite implements IAnimatable {
  89094. /** defines the name */
  89095. name: string;
  89096. /** Gets or sets the current world position */
  89097. position: Vector3;
  89098. /** Gets or sets the main color */
  89099. color: Color4;
  89100. /** Gets or sets the width */
  89101. width: number;
  89102. /** Gets or sets the height */
  89103. height: number;
  89104. /** Gets or sets rotation angle */
  89105. angle: number;
  89106. /** Gets or sets the cell index in the sprite sheet */
  89107. cellIndex: number;
  89108. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89109. cellRef: string;
  89110. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89111. invertU: boolean;
  89112. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89113. invertV: boolean;
  89114. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89115. disposeWhenFinishedAnimating: boolean;
  89116. /** Gets the list of attached animations */
  89117. animations: Nullable<Array<Animation>>;
  89118. /** Gets or sets a boolean indicating if the sprite can be picked */
  89119. isPickable: boolean;
  89120. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89121. useAlphaForPicking: boolean;
  89122. /** @hidden */
  89123. _xOffset: number;
  89124. /** @hidden */
  89125. _yOffset: number;
  89126. /** @hidden */
  89127. _xSize: number;
  89128. /** @hidden */
  89129. _ySize: number;
  89130. /**
  89131. * Gets or sets the associated action manager
  89132. */
  89133. actionManager: Nullable<ActionManager>;
  89134. /**
  89135. * An event triggered when the control has been disposed
  89136. */
  89137. onDisposeObservable: Observable<Sprite>;
  89138. private _animationStarted;
  89139. private _loopAnimation;
  89140. private _fromIndex;
  89141. private _toIndex;
  89142. private _delay;
  89143. private _direction;
  89144. private _manager;
  89145. private _time;
  89146. private _onAnimationEnd;
  89147. /**
  89148. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89149. */
  89150. isVisible: boolean;
  89151. /**
  89152. * Gets or sets the sprite size
  89153. */
  89154. get size(): number;
  89155. set size(value: number);
  89156. /**
  89157. * Returns a boolean indicating if the animation is started
  89158. */
  89159. get animationStarted(): boolean;
  89160. /**
  89161. * Gets or sets the unique id of the sprite
  89162. */
  89163. uniqueId: number;
  89164. /**
  89165. * Gets the manager of this sprite
  89166. */
  89167. get manager(): ISpriteManager;
  89168. /**
  89169. * Creates a new Sprite
  89170. * @param name defines the name
  89171. * @param manager defines the manager
  89172. */
  89173. constructor(
  89174. /** defines the name */
  89175. name: string, manager: ISpriteManager);
  89176. /**
  89177. * Returns the string "Sprite"
  89178. * @returns "Sprite"
  89179. */
  89180. getClassName(): string;
  89181. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89182. get fromIndex(): number;
  89183. set fromIndex(value: number);
  89184. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89185. get toIndex(): number;
  89186. set toIndex(value: number);
  89187. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89188. get loopAnimation(): boolean;
  89189. set loopAnimation(value: boolean);
  89190. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89191. get delay(): number;
  89192. set delay(value: number);
  89193. /**
  89194. * Starts an animation
  89195. * @param from defines the initial key
  89196. * @param to defines the end key
  89197. * @param loop defines if the animation must loop
  89198. * @param delay defines the start delay (in ms)
  89199. * @param onAnimationEnd defines a callback to call when animation ends
  89200. */
  89201. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89202. /** Stops current animation (if any) */
  89203. stopAnimation(): void;
  89204. /** @hidden */
  89205. _animate(deltaTime: number): void;
  89206. /** Release associated resources */
  89207. dispose(): void;
  89208. /**
  89209. * Serializes the sprite to a JSON object
  89210. * @returns the JSON object
  89211. */
  89212. serialize(): any;
  89213. /**
  89214. * Parses a JSON object to create a new sprite
  89215. * @param parsedSprite The JSON object to parse
  89216. * @param manager defines the hosting manager
  89217. * @returns the new sprite
  89218. */
  89219. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89220. }
  89221. }
  89222. declare module BABYLON {
  89223. /**
  89224. * Information about the result of picking within a scene
  89225. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89226. */
  89227. export class PickingInfo {
  89228. /** @hidden */
  89229. _pickingUnavailable: boolean;
  89230. /**
  89231. * If the pick collided with an object
  89232. */
  89233. hit: boolean;
  89234. /**
  89235. * Distance away where the pick collided
  89236. */
  89237. distance: number;
  89238. /**
  89239. * The location of pick collision
  89240. */
  89241. pickedPoint: Nullable<Vector3>;
  89242. /**
  89243. * The mesh corresponding the the pick collision
  89244. */
  89245. pickedMesh: Nullable<AbstractMesh>;
  89246. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89247. bu: number;
  89248. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89249. bv: number;
  89250. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89251. faceId: number;
  89252. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89253. subMeshFaceId: number;
  89254. /** Id of the the submesh that was picked */
  89255. subMeshId: number;
  89256. /** If a sprite was picked, this will be the sprite the pick collided with */
  89257. pickedSprite: Nullable<Sprite>;
  89258. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89259. thinInstanceIndex: number;
  89260. /**
  89261. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89262. */
  89263. originMesh: Nullable<AbstractMesh>;
  89264. /**
  89265. * The ray that was used to perform the picking.
  89266. */
  89267. ray: Nullable<Ray>;
  89268. /**
  89269. * Gets the normal correspodning to the face the pick collided with
  89270. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89271. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89272. * @returns The normal correspodning to the face the pick collided with
  89273. */
  89274. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89275. /**
  89276. * Gets the texture coordinates of where the pick occured
  89277. * @returns the vector containing the coordnates of the texture
  89278. */
  89279. getTextureCoordinates(): Nullable<Vector2>;
  89280. }
  89281. }
  89282. declare module BABYLON {
  89283. /**
  89284. * Class representing a ray with position and direction
  89285. */
  89286. export class Ray {
  89287. /** origin point */
  89288. origin: Vector3;
  89289. /** direction */
  89290. direction: Vector3;
  89291. /** length of the ray */
  89292. length: number;
  89293. private static readonly _TmpVector3;
  89294. private _tmpRay;
  89295. /**
  89296. * Creates a new ray
  89297. * @param origin origin point
  89298. * @param direction direction
  89299. * @param length length of the ray
  89300. */
  89301. constructor(
  89302. /** origin point */
  89303. origin: Vector3,
  89304. /** direction */
  89305. direction: Vector3,
  89306. /** length of the ray */
  89307. length?: number);
  89308. /**
  89309. * Checks if the ray intersects a box
  89310. * This does not account for the ray lenght by design to improve perfs.
  89311. * @param minimum bound of the box
  89312. * @param maximum bound of the box
  89313. * @param intersectionTreshold extra extend to be added to the box in all direction
  89314. * @returns if the box was hit
  89315. */
  89316. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89317. /**
  89318. * Checks if the ray intersects a box
  89319. * This does not account for the ray lenght by design to improve perfs.
  89320. * @param box the bounding box to check
  89321. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89322. * @returns if the box was hit
  89323. */
  89324. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89325. /**
  89326. * If the ray hits a sphere
  89327. * @param sphere the bounding sphere to check
  89328. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89329. * @returns true if it hits the sphere
  89330. */
  89331. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89332. /**
  89333. * If the ray hits a triange
  89334. * @param vertex0 triangle vertex
  89335. * @param vertex1 triangle vertex
  89336. * @param vertex2 triangle vertex
  89337. * @returns intersection information if hit
  89338. */
  89339. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89340. /**
  89341. * Checks if ray intersects a plane
  89342. * @param plane the plane to check
  89343. * @returns the distance away it was hit
  89344. */
  89345. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89346. /**
  89347. * Calculate the intercept of a ray on a given axis
  89348. * @param axis to check 'x' | 'y' | 'z'
  89349. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89350. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89351. */
  89352. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89353. /**
  89354. * Checks if ray intersects a mesh
  89355. * @param mesh the mesh to check
  89356. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89357. * @returns picking info of the intersecton
  89358. */
  89359. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89360. /**
  89361. * Checks if ray intersects a mesh
  89362. * @param meshes the meshes to check
  89363. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89364. * @param results array to store result in
  89365. * @returns Array of picking infos
  89366. */
  89367. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89368. private _comparePickingInfo;
  89369. private static smallnum;
  89370. private static rayl;
  89371. /**
  89372. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89373. * @param sega the first point of the segment to test the intersection against
  89374. * @param segb the second point of the segment to test the intersection against
  89375. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89376. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89377. */
  89378. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89379. /**
  89380. * Update the ray from viewport position
  89381. * @param x position
  89382. * @param y y position
  89383. * @param viewportWidth viewport width
  89384. * @param viewportHeight viewport height
  89385. * @param world world matrix
  89386. * @param view view matrix
  89387. * @param projection projection matrix
  89388. * @returns this ray updated
  89389. */
  89390. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89391. /**
  89392. * Creates a ray with origin and direction of 0,0,0
  89393. * @returns the new ray
  89394. */
  89395. static Zero(): Ray;
  89396. /**
  89397. * Creates a new ray from screen space and viewport
  89398. * @param x position
  89399. * @param y y position
  89400. * @param viewportWidth viewport width
  89401. * @param viewportHeight viewport height
  89402. * @param world world matrix
  89403. * @param view view matrix
  89404. * @param projection projection matrix
  89405. * @returns new ray
  89406. */
  89407. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89408. /**
  89409. * 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
  89410. * transformed to the given world matrix.
  89411. * @param origin The origin point
  89412. * @param end The end point
  89413. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89414. * @returns the new ray
  89415. */
  89416. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89417. /**
  89418. * Transforms a ray by a matrix
  89419. * @param ray ray to transform
  89420. * @param matrix matrix to apply
  89421. * @returns the resulting new ray
  89422. */
  89423. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89424. /**
  89425. * Transforms a ray by a matrix
  89426. * @param ray ray to transform
  89427. * @param matrix matrix to apply
  89428. * @param result ray to store result in
  89429. */
  89430. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89431. /**
  89432. * Unproject a ray from screen space to object space
  89433. * @param sourceX defines the screen space x coordinate to use
  89434. * @param sourceY defines the screen space y coordinate to use
  89435. * @param viewportWidth defines the current width of the viewport
  89436. * @param viewportHeight defines the current height of the viewport
  89437. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89438. * @param view defines the view matrix to use
  89439. * @param projection defines the projection matrix to use
  89440. */
  89441. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89442. }
  89443. /**
  89444. * Type used to define predicate used to select faces when a mesh intersection is detected
  89445. */
  89446. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89447. interface Scene {
  89448. /** @hidden */
  89449. _tempPickingRay: Nullable<Ray>;
  89450. /** @hidden */
  89451. _cachedRayForTransform: Ray;
  89452. /** @hidden */
  89453. _pickWithRayInverseMatrix: Matrix;
  89454. /** @hidden */
  89455. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89456. /** @hidden */
  89457. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89458. /** @hidden */
  89459. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89460. }
  89461. }
  89462. declare module BABYLON {
  89463. /**
  89464. * Groups all the scene component constants in one place to ease maintenance.
  89465. * @hidden
  89466. */
  89467. export class SceneComponentConstants {
  89468. static readonly NAME_EFFECTLAYER: string;
  89469. static readonly NAME_LAYER: string;
  89470. static readonly NAME_LENSFLARESYSTEM: string;
  89471. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89472. static readonly NAME_PARTICLESYSTEM: string;
  89473. static readonly NAME_GAMEPAD: string;
  89474. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89475. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89476. static readonly NAME_PREPASSRENDERER: string;
  89477. static readonly NAME_DEPTHRENDERER: string;
  89478. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89479. static readonly NAME_SPRITE: string;
  89480. static readonly NAME_OUTLINERENDERER: string;
  89481. static readonly NAME_PROCEDURALTEXTURE: string;
  89482. static readonly NAME_SHADOWGENERATOR: string;
  89483. static readonly NAME_OCTREE: string;
  89484. static readonly NAME_PHYSICSENGINE: string;
  89485. static readonly NAME_AUDIO: string;
  89486. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89487. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89488. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89489. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89490. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89491. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89492. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89493. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89494. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89495. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89496. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89497. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89498. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89499. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89500. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89501. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89502. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89504. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89505. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89506. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89507. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89508. static readonly STEP_AFTERRENDER_AUDIO: number;
  89509. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89510. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89511. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89512. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89513. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89514. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89515. static readonly STEP_POINTERMOVE_SPRITE: number;
  89516. static readonly STEP_POINTERDOWN_SPRITE: number;
  89517. static readonly STEP_POINTERUP_SPRITE: number;
  89518. }
  89519. /**
  89520. * This represents a scene component.
  89521. *
  89522. * This is used to decouple the dependency the scene is having on the different workloads like
  89523. * layers, post processes...
  89524. */
  89525. export interface ISceneComponent {
  89526. /**
  89527. * The name of the component. Each component must have a unique name.
  89528. */
  89529. name: string;
  89530. /**
  89531. * The scene the component belongs to.
  89532. */
  89533. scene: Scene;
  89534. /**
  89535. * Register the component to one instance of a scene.
  89536. */
  89537. register(): void;
  89538. /**
  89539. * Rebuilds the elements related to this component in case of
  89540. * context lost for instance.
  89541. */
  89542. rebuild(): void;
  89543. /**
  89544. * Disposes the component and the associated ressources.
  89545. */
  89546. dispose(): void;
  89547. }
  89548. /**
  89549. * This represents a SERIALIZABLE scene component.
  89550. *
  89551. * This extends Scene Component to add Serialization methods on top.
  89552. */
  89553. export interface ISceneSerializableComponent extends ISceneComponent {
  89554. /**
  89555. * Adds all the elements from the container to the scene
  89556. * @param container the container holding the elements
  89557. */
  89558. addFromContainer(container: AbstractScene): void;
  89559. /**
  89560. * Removes all the elements in the container from the scene
  89561. * @param container contains the elements to remove
  89562. * @param dispose if the removed element should be disposed (default: false)
  89563. */
  89564. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89565. /**
  89566. * Serializes the component data to the specified json object
  89567. * @param serializationObject The object to serialize to
  89568. */
  89569. serialize(serializationObject: any): void;
  89570. }
  89571. /**
  89572. * Strong typing of a Mesh related stage step action
  89573. */
  89574. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89575. /**
  89576. * Strong typing of a Evaluate Sub Mesh related stage step action
  89577. */
  89578. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89579. /**
  89580. * Strong typing of a Active Mesh related stage step action
  89581. */
  89582. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89583. /**
  89584. * Strong typing of a Camera related stage step action
  89585. */
  89586. export type CameraStageAction = (camera: Camera) => void;
  89587. /**
  89588. * Strong typing of a Camera Frame buffer related stage step action
  89589. */
  89590. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89591. /**
  89592. * Strong typing of a Render Target related stage step action
  89593. */
  89594. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89595. /**
  89596. * Strong typing of a RenderingGroup related stage step action
  89597. */
  89598. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89599. /**
  89600. * Strong typing of a Mesh Render related stage step action
  89601. */
  89602. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89603. /**
  89604. * Strong typing of a simple stage step action
  89605. */
  89606. export type SimpleStageAction = () => void;
  89607. /**
  89608. * Strong typing of a render target action.
  89609. */
  89610. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89611. /**
  89612. * Strong typing of a pointer move action.
  89613. */
  89614. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89615. /**
  89616. * Strong typing of a pointer up/down action.
  89617. */
  89618. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89619. /**
  89620. * Representation of a stage in the scene (Basically a list of ordered steps)
  89621. * @hidden
  89622. */
  89623. export class Stage<T extends Function> extends Array<{
  89624. index: number;
  89625. component: ISceneComponent;
  89626. action: T;
  89627. }> {
  89628. /**
  89629. * Hide ctor from the rest of the world.
  89630. * @param items The items to add.
  89631. */
  89632. private constructor();
  89633. /**
  89634. * Creates a new Stage.
  89635. * @returns A new instance of a Stage
  89636. */
  89637. static Create<T extends Function>(): Stage<T>;
  89638. /**
  89639. * Registers a step in an ordered way in the targeted stage.
  89640. * @param index Defines the position to register the step in
  89641. * @param component Defines the component attached to the step
  89642. * @param action Defines the action to launch during the step
  89643. */
  89644. registerStep(index: number, component: ISceneComponent, action: T): void;
  89645. /**
  89646. * Clears all the steps from the stage.
  89647. */
  89648. clear(): void;
  89649. }
  89650. }
  89651. declare module BABYLON {
  89652. interface Scene {
  89653. /** @hidden */
  89654. _pointerOverSprite: Nullable<Sprite>;
  89655. /** @hidden */
  89656. _pickedDownSprite: Nullable<Sprite>;
  89657. /** @hidden */
  89658. _tempSpritePickingRay: Nullable<Ray>;
  89659. /**
  89660. * All of the sprite managers added to this scene
  89661. * @see https://doc.babylonjs.com/babylon101/sprites
  89662. */
  89663. spriteManagers: Array<ISpriteManager>;
  89664. /**
  89665. * An event triggered when sprites rendering is about to start
  89666. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89667. */
  89668. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89669. /**
  89670. * An event triggered when sprites rendering is done
  89671. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89672. */
  89673. onAfterSpritesRenderingObservable: Observable<Scene>;
  89674. /** @hidden */
  89675. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89676. /** Launch a ray to try to pick a sprite in the scene
  89677. * @param x position on screen
  89678. * @param y position on screen
  89679. * @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
  89680. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89681. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89682. * @returns a PickingInfo
  89683. */
  89684. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89685. /** Use the given ray to pick a sprite in the scene
  89686. * @param ray The ray (in world space) to use to pick meshes
  89687. * @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
  89688. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89689. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89690. * @returns a PickingInfo
  89691. */
  89692. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89693. /** @hidden */
  89694. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89695. /** Launch a ray to try to pick sprites in the scene
  89696. * @param x position on screen
  89697. * @param y position on screen
  89698. * @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
  89699. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89700. * @returns a PickingInfo array
  89701. */
  89702. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89703. /** Use the given ray to pick sprites in the scene
  89704. * @param ray The ray (in world space) to use to pick meshes
  89705. * @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
  89706. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89707. * @returns a PickingInfo array
  89708. */
  89709. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89710. /**
  89711. * Force the sprite under the pointer
  89712. * @param sprite defines the sprite to use
  89713. */
  89714. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89715. /**
  89716. * Gets the sprite under the pointer
  89717. * @returns a Sprite or null if no sprite is under the pointer
  89718. */
  89719. getPointerOverSprite(): Nullable<Sprite>;
  89720. }
  89721. /**
  89722. * Defines the sprite scene component responsible to manage sprites
  89723. * in a given scene.
  89724. */
  89725. export class SpriteSceneComponent implements ISceneComponent {
  89726. /**
  89727. * The component name helpfull to identify the component in the list of scene components.
  89728. */
  89729. readonly name: string;
  89730. /**
  89731. * The scene the component belongs to.
  89732. */
  89733. scene: Scene;
  89734. /** @hidden */
  89735. private _spritePredicate;
  89736. /**
  89737. * Creates a new instance of the component for the given scene
  89738. * @param scene Defines the scene to register the component in
  89739. */
  89740. constructor(scene: Scene);
  89741. /**
  89742. * Registers the component in a given scene
  89743. */
  89744. register(): void;
  89745. /**
  89746. * Rebuilds the elements related to this component in case of
  89747. * context lost for instance.
  89748. */
  89749. rebuild(): void;
  89750. /**
  89751. * Disposes the component and the associated ressources.
  89752. */
  89753. dispose(): void;
  89754. private _pickSpriteButKeepRay;
  89755. private _pointerMove;
  89756. private _pointerDown;
  89757. private _pointerUp;
  89758. }
  89759. }
  89760. declare module BABYLON {
  89761. /** @hidden */
  89762. export var fogFragmentDeclaration: {
  89763. name: string;
  89764. shader: string;
  89765. };
  89766. }
  89767. declare module BABYLON {
  89768. /** @hidden */
  89769. export var fogFragment: {
  89770. name: string;
  89771. shader: string;
  89772. };
  89773. }
  89774. declare module BABYLON {
  89775. /** @hidden */
  89776. export var spritesPixelShader: {
  89777. name: string;
  89778. shader: string;
  89779. };
  89780. }
  89781. declare module BABYLON {
  89782. /** @hidden */
  89783. export var fogVertexDeclaration: {
  89784. name: string;
  89785. shader: string;
  89786. };
  89787. }
  89788. declare module BABYLON {
  89789. /** @hidden */
  89790. export var spritesVertexShader: {
  89791. name: string;
  89792. shader: string;
  89793. };
  89794. }
  89795. declare module BABYLON {
  89796. /**
  89797. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89798. */
  89799. export interface ISpriteManager extends IDisposable {
  89800. /**
  89801. * Gets manager's name
  89802. */
  89803. name: string;
  89804. /**
  89805. * Restricts the camera to viewing objects with the same layerMask.
  89806. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89807. */
  89808. layerMask: number;
  89809. /**
  89810. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89811. */
  89812. isPickable: boolean;
  89813. /**
  89814. * Gets the hosting scene
  89815. */
  89816. scene: Scene;
  89817. /**
  89818. * Specifies the rendering group id for this mesh (0 by default)
  89819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89820. */
  89821. renderingGroupId: number;
  89822. /**
  89823. * Defines the list of sprites managed by the manager.
  89824. */
  89825. sprites: Array<Sprite>;
  89826. /**
  89827. * Gets or sets the spritesheet texture
  89828. */
  89829. texture: Texture;
  89830. /** Defines the default width of a cell in the spritesheet */
  89831. cellWidth: number;
  89832. /** Defines the default height of a cell in the spritesheet */
  89833. cellHeight: number;
  89834. /**
  89835. * Tests the intersection of a sprite with a specific ray.
  89836. * @param ray The ray we are sending to test the collision
  89837. * @param camera The camera space we are sending rays in
  89838. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89839. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89840. * @returns picking info or null.
  89841. */
  89842. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89843. /**
  89844. * Intersects the sprites with a ray
  89845. * @param ray defines the ray to intersect with
  89846. * @param camera defines the current active camera
  89847. * @param predicate defines a predicate used to select candidate sprites
  89848. * @returns null if no hit or a PickingInfo array
  89849. */
  89850. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89851. /**
  89852. * Renders the list of sprites on screen.
  89853. */
  89854. render(): void;
  89855. }
  89856. /**
  89857. * Class used to manage multiple sprites on the same spritesheet
  89858. * @see https://doc.babylonjs.com/babylon101/sprites
  89859. */
  89860. export class SpriteManager implements ISpriteManager {
  89861. /** defines the manager's name */
  89862. name: string;
  89863. /** Define the Url to load snippets */
  89864. static SnippetUrl: string;
  89865. /** Snippet ID if the manager was created from the snippet server */
  89866. snippetId: string;
  89867. /** Gets the list of sprites */
  89868. sprites: Sprite[];
  89869. /** Gets or sets the rendering group id (0 by default) */
  89870. renderingGroupId: number;
  89871. /** Gets or sets camera layer mask */
  89872. layerMask: number;
  89873. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89874. fogEnabled: boolean;
  89875. /** Gets or sets a boolean indicating if the sprites are pickable */
  89876. isPickable: boolean;
  89877. /** Defines the default width of a cell in the spritesheet */
  89878. cellWidth: number;
  89879. /** Defines the default height of a cell in the spritesheet */
  89880. cellHeight: number;
  89881. /** Associative array from JSON sprite data file */
  89882. private _cellData;
  89883. /** Array of sprite names from JSON sprite data file */
  89884. private _spriteMap;
  89885. /** True when packed cell data from JSON file is ready*/
  89886. private _packedAndReady;
  89887. private _textureContent;
  89888. /**
  89889. * An event triggered when the manager is disposed.
  89890. */
  89891. onDisposeObservable: Observable<SpriteManager>;
  89892. private _onDisposeObserver;
  89893. /**
  89894. * Callback called when the manager is disposed
  89895. */
  89896. set onDispose(callback: () => void);
  89897. private _capacity;
  89898. private _fromPacked;
  89899. private _spriteTexture;
  89900. private _epsilon;
  89901. private _scene;
  89902. private _vertexData;
  89903. private _buffer;
  89904. private _vertexBuffers;
  89905. private _indexBuffer;
  89906. private _effectBase;
  89907. private _effectFog;
  89908. /**
  89909. * Gets or sets the unique id of the sprite
  89910. */
  89911. uniqueId: number;
  89912. /**
  89913. * Gets the array of sprites
  89914. */
  89915. get children(): Sprite[];
  89916. /**
  89917. * Gets the hosting scene
  89918. */
  89919. get scene(): Scene;
  89920. /**
  89921. * Gets the capacity of the manager
  89922. */
  89923. get capacity(): number;
  89924. /**
  89925. * Gets or sets the spritesheet texture
  89926. */
  89927. get texture(): Texture;
  89928. set texture(value: Texture);
  89929. private _blendMode;
  89930. /**
  89931. * Blend mode use to render the particle, it can be any of
  89932. * the static Constants.ALPHA_x properties provided in this class.
  89933. * Default value is Constants.ALPHA_COMBINE
  89934. */
  89935. get blendMode(): number;
  89936. set blendMode(blendMode: number);
  89937. /** Disables writing to the depth buffer when rendering the sprites.
  89938. * It can be handy to disable depth writing when using textures without alpha channel
  89939. * and setting some specific blend modes.
  89940. */
  89941. disableDepthWrite: boolean;
  89942. /**
  89943. * Creates a new sprite manager
  89944. * @param name defines the manager's name
  89945. * @param imgUrl defines the sprite sheet url
  89946. * @param capacity defines the maximum allowed number of sprites
  89947. * @param cellSize defines the size of a sprite cell
  89948. * @param scene defines the hosting scene
  89949. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89950. * @param samplingMode defines the smapling mode to use with spritesheet
  89951. * @param fromPacked set to false; do not alter
  89952. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89953. */
  89954. constructor(
  89955. /** defines the manager's name */
  89956. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89957. /**
  89958. * Returns the string "SpriteManager"
  89959. * @returns "SpriteManager"
  89960. */
  89961. getClassName(): string;
  89962. private _makePacked;
  89963. private _appendSpriteVertex;
  89964. private _checkTextureAlpha;
  89965. /**
  89966. * Intersects the sprites with a ray
  89967. * @param ray defines the ray to intersect with
  89968. * @param camera defines the current active camera
  89969. * @param predicate defines a predicate used to select candidate sprites
  89970. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89971. * @returns null if no hit or a PickingInfo
  89972. */
  89973. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89974. /**
  89975. * Intersects the sprites with a ray
  89976. * @param ray defines the ray to intersect with
  89977. * @param camera defines the current active camera
  89978. * @param predicate defines a predicate used to select candidate sprites
  89979. * @returns null if no hit or a PickingInfo array
  89980. */
  89981. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89982. /**
  89983. * Render all child sprites
  89984. */
  89985. render(): void;
  89986. /**
  89987. * Release associated resources
  89988. */
  89989. dispose(): void;
  89990. /**
  89991. * Serializes the sprite manager to a JSON object
  89992. * @param serializeTexture defines if the texture must be serialized as well
  89993. * @returns the JSON object
  89994. */
  89995. serialize(serializeTexture?: boolean): any;
  89996. /**
  89997. * Parses a JSON object to create a new sprite manager.
  89998. * @param parsedManager The JSON object to parse
  89999. * @param scene The scene to create the sprite managerin
  90000. * @param rootUrl The root url to use to load external dependencies like texture
  90001. * @returns the new sprite manager
  90002. */
  90003. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90004. /**
  90005. * Creates a sprite manager from a snippet saved in a remote file
  90006. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90007. * @param url defines the url to load from
  90008. * @param scene defines the hosting scene
  90009. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90010. * @returns a promise that will resolve to the new sprite manager
  90011. */
  90012. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90013. /**
  90014. * Creates a sprite manager from a snippet saved by the sprite editor
  90015. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90016. * @param scene defines the hosting scene
  90017. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90018. * @returns a promise that will resolve to the new sprite manager
  90019. */
  90020. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90021. }
  90022. }
  90023. declare module BABYLON {
  90024. /** Interface used by value gradients (color, factor, ...) */
  90025. export interface IValueGradient {
  90026. /**
  90027. * Gets or sets the gradient value (between 0 and 1)
  90028. */
  90029. gradient: number;
  90030. }
  90031. /** Class used to store color4 gradient */
  90032. export class ColorGradient implements IValueGradient {
  90033. /**
  90034. * Gets or sets the gradient value (between 0 and 1)
  90035. */
  90036. gradient: number;
  90037. /**
  90038. * Gets or sets first associated color
  90039. */
  90040. color1: Color4;
  90041. /**
  90042. * Gets or sets second associated color
  90043. */
  90044. color2?: Color4 | undefined;
  90045. /**
  90046. * Creates a new color4 gradient
  90047. * @param gradient gets or sets the gradient value (between 0 and 1)
  90048. * @param color1 gets or sets first associated color
  90049. * @param color2 gets or sets first second color
  90050. */
  90051. constructor(
  90052. /**
  90053. * Gets or sets the gradient value (between 0 and 1)
  90054. */
  90055. gradient: number,
  90056. /**
  90057. * Gets or sets first associated color
  90058. */
  90059. color1: Color4,
  90060. /**
  90061. * Gets or sets second associated color
  90062. */
  90063. color2?: Color4 | undefined);
  90064. /**
  90065. * Will get a color picked randomly between color1 and color2.
  90066. * If color2 is undefined then color1 will be used
  90067. * @param result defines the target Color4 to store the result in
  90068. */
  90069. getColorToRef(result: Color4): void;
  90070. }
  90071. /** Class used to store color 3 gradient */
  90072. export class Color3Gradient implements IValueGradient {
  90073. /**
  90074. * Gets or sets the gradient value (between 0 and 1)
  90075. */
  90076. gradient: number;
  90077. /**
  90078. * Gets or sets the associated color
  90079. */
  90080. color: Color3;
  90081. /**
  90082. * Creates a new color3 gradient
  90083. * @param gradient gets or sets the gradient value (between 0 and 1)
  90084. * @param color gets or sets associated color
  90085. */
  90086. constructor(
  90087. /**
  90088. * Gets or sets the gradient value (between 0 and 1)
  90089. */
  90090. gradient: number,
  90091. /**
  90092. * Gets or sets the associated color
  90093. */
  90094. color: Color3);
  90095. }
  90096. /** Class used to store factor gradient */
  90097. export class FactorGradient implements IValueGradient {
  90098. /**
  90099. * Gets or sets the gradient value (between 0 and 1)
  90100. */
  90101. gradient: number;
  90102. /**
  90103. * Gets or sets first associated factor
  90104. */
  90105. factor1: number;
  90106. /**
  90107. * Gets or sets second associated factor
  90108. */
  90109. factor2?: number | undefined;
  90110. /**
  90111. * Creates a new factor gradient
  90112. * @param gradient gets or sets the gradient value (between 0 and 1)
  90113. * @param factor1 gets or sets first associated factor
  90114. * @param factor2 gets or sets second associated factor
  90115. */
  90116. constructor(
  90117. /**
  90118. * Gets or sets the gradient value (between 0 and 1)
  90119. */
  90120. gradient: number,
  90121. /**
  90122. * Gets or sets first associated factor
  90123. */
  90124. factor1: number,
  90125. /**
  90126. * Gets or sets second associated factor
  90127. */
  90128. factor2?: number | undefined);
  90129. /**
  90130. * Will get a number picked randomly between factor1 and factor2.
  90131. * If factor2 is undefined then factor1 will be used
  90132. * @returns the picked number
  90133. */
  90134. getFactor(): number;
  90135. }
  90136. /**
  90137. * Helper used to simplify some generic gradient tasks
  90138. */
  90139. export class GradientHelper {
  90140. /**
  90141. * Gets the current gradient from an array of IValueGradient
  90142. * @param ratio defines the current ratio to get
  90143. * @param gradients defines the array of IValueGradient
  90144. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90145. */
  90146. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90147. }
  90148. }
  90149. declare module BABYLON {
  90150. interface ThinEngine {
  90151. /**
  90152. * Creates a raw texture
  90153. * @param data defines the data to store in the texture
  90154. * @param width defines the width of the texture
  90155. * @param height defines the height of the texture
  90156. * @param format defines the format of the data
  90157. * @param generateMipMaps defines if the engine should generate the mip levels
  90158. * @param invertY defines if data must be stored with Y axis inverted
  90159. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90160. * @param compression defines the compression used (null by default)
  90161. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90162. * @returns the raw texture inside an InternalTexture
  90163. */
  90164. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90165. /**
  90166. * Update a raw texture
  90167. * @param texture defines the texture to update
  90168. * @param data defines the data to store in the texture
  90169. * @param format defines the format of the data
  90170. * @param invertY defines if data must be stored with Y axis inverted
  90171. */
  90172. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90173. /**
  90174. * Update a raw texture
  90175. * @param texture defines the texture to update
  90176. * @param data defines the data to store in the texture
  90177. * @param format defines the format of the data
  90178. * @param invertY defines if data must be stored with Y axis inverted
  90179. * @param compression defines the compression used (null by default)
  90180. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90181. */
  90182. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90183. /**
  90184. * Creates a new raw cube texture
  90185. * @param data defines the array of data to use to create each face
  90186. * @param size defines the size of the textures
  90187. * @param format defines the format of the data
  90188. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90189. * @param generateMipMaps defines if the engine should generate the mip levels
  90190. * @param invertY defines if data must be stored with Y axis inverted
  90191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90192. * @param compression defines the compression used (null by default)
  90193. * @returns the cube texture as an InternalTexture
  90194. */
  90195. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90196. /**
  90197. * Update a raw cube texture
  90198. * @param texture defines the texture to udpdate
  90199. * @param data defines the data to store
  90200. * @param format defines the data format
  90201. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90202. * @param invertY defines if data must be stored with Y axis inverted
  90203. */
  90204. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90205. /**
  90206. * Update a raw cube texture
  90207. * @param texture defines the texture to udpdate
  90208. * @param data defines the data to store
  90209. * @param format defines the data format
  90210. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90211. * @param invertY defines if data must be stored with Y axis inverted
  90212. * @param compression defines the compression used (null by default)
  90213. */
  90214. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90215. /**
  90216. * Update a raw cube texture
  90217. * @param texture defines the texture to udpdate
  90218. * @param data defines the data to store
  90219. * @param format defines the data format
  90220. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90221. * @param invertY defines if data must be stored with Y axis inverted
  90222. * @param compression defines the compression used (null by default)
  90223. * @param level defines which level of the texture to update
  90224. */
  90225. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90226. /**
  90227. * Creates a new raw cube texture from a specified url
  90228. * @param url defines the url where the data is located
  90229. * @param scene defines the current scene
  90230. * @param size defines the size of the textures
  90231. * @param format defines the format of the data
  90232. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90233. * @param noMipmap defines if the engine should avoid generating the mip levels
  90234. * @param callback defines a callback used to extract texture data from loaded data
  90235. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90236. * @param onLoad defines a callback called when texture is loaded
  90237. * @param onError defines a callback called if there is an error
  90238. * @returns the cube texture as an InternalTexture
  90239. */
  90240. 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;
  90241. /**
  90242. * Creates a new raw cube texture from a specified url
  90243. * @param url defines the url where the data is located
  90244. * @param scene defines the current scene
  90245. * @param size defines the size of the textures
  90246. * @param format defines the format of the data
  90247. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90248. * @param noMipmap defines if the engine should avoid generating the mip levels
  90249. * @param callback defines a callback used to extract texture data from loaded data
  90250. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90251. * @param onLoad defines a callback called when texture is loaded
  90252. * @param onError defines a callback called if there is an error
  90253. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90254. * @param invertY defines if data must be stored with Y axis inverted
  90255. * @returns the cube texture as an InternalTexture
  90256. */
  90257. 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;
  90258. /**
  90259. * Creates a new raw 3D texture
  90260. * @param data defines the data used to create the texture
  90261. * @param width defines the width of the texture
  90262. * @param height defines the height of the texture
  90263. * @param depth defines the depth of the texture
  90264. * @param format defines the format of the texture
  90265. * @param generateMipMaps defines if the engine must generate mip levels
  90266. * @param invertY defines if data must be stored with Y axis inverted
  90267. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90268. * @param compression defines the compressed used (can be null)
  90269. * @param textureType defines the compressed used (can be null)
  90270. * @returns a new raw 3D texture (stored in an InternalTexture)
  90271. */
  90272. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90273. /**
  90274. * Update a raw 3D texture
  90275. * @param texture defines the texture to update
  90276. * @param data defines the data to store
  90277. * @param format defines the data format
  90278. * @param invertY defines if data must be stored with Y axis inverted
  90279. */
  90280. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90281. /**
  90282. * Update a raw 3D texture
  90283. * @param texture defines the texture to update
  90284. * @param data defines the data to store
  90285. * @param format defines the data format
  90286. * @param invertY defines if data must be stored with Y axis inverted
  90287. * @param compression defines the used compression (can be null)
  90288. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90289. */
  90290. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90291. /**
  90292. * Creates a new raw 2D array texture
  90293. * @param data defines the data used to create the texture
  90294. * @param width defines the width of the texture
  90295. * @param height defines the height of the texture
  90296. * @param depth defines the number of layers of the texture
  90297. * @param format defines the format of the texture
  90298. * @param generateMipMaps defines if the engine must generate mip levels
  90299. * @param invertY defines if data must be stored with Y axis inverted
  90300. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90301. * @param compression defines the compressed used (can be null)
  90302. * @param textureType defines the compressed used (can be null)
  90303. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90304. */
  90305. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90306. /**
  90307. * Update a raw 2D array texture
  90308. * @param texture defines the texture to update
  90309. * @param data defines the data to store
  90310. * @param format defines the data format
  90311. * @param invertY defines if data must be stored with Y axis inverted
  90312. */
  90313. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90314. /**
  90315. * Update a raw 2D array texture
  90316. * @param texture defines the texture to update
  90317. * @param data defines the data to store
  90318. * @param format defines the data format
  90319. * @param invertY defines if data must be stored with Y axis inverted
  90320. * @param compression defines the used compression (can be null)
  90321. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90322. */
  90323. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90324. }
  90325. }
  90326. declare module BABYLON {
  90327. /**
  90328. * Raw texture can help creating a texture directly from an array of data.
  90329. * This can be super useful if you either get the data from an uncompressed source or
  90330. * if you wish to create your texture pixel by pixel.
  90331. */
  90332. export class RawTexture extends Texture {
  90333. /**
  90334. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90335. */
  90336. format: number;
  90337. /**
  90338. * Instantiates a new RawTexture.
  90339. * Raw texture can help creating a texture directly from an array of data.
  90340. * This can be super useful if you either get the data from an uncompressed source or
  90341. * if you wish to create your texture pixel by pixel.
  90342. * @param data define the array of data to use to create the texture
  90343. * @param width define the width of the texture
  90344. * @param height define the height of the texture
  90345. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90346. * @param scene define the scene the texture belongs to
  90347. * @param generateMipMaps define whether mip maps should be generated or not
  90348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90350. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90351. */
  90352. constructor(data: ArrayBufferView, width: number, height: number,
  90353. /**
  90354. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90355. */
  90356. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90357. /**
  90358. * Updates the texture underlying data.
  90359. * @param data Define the new data of the texture
  90360. */
  90361. update(data: ArrayBufferView): void;
  90362. /**
  90363. * Creates a luminance texture from some data.
  90364. * @param data Define the texture data
  90365. * @param width Define the width of the texture
  90366. * @param height Define the height of the texture
  90367. * @param scene Define the scene the texture belongs to
  90368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90371. * @returns the luminance texture
  90372. */
  90373. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90374. /**
  90375. * Creates a luminance alpha texture from some data.
  90376. * @param data Define the texture data
  90377. * @param width Define the width of the texture
  90378. * @param height Define the height of the texture
  90379. * @param scene Define the scene the texture belongs to
  90380. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90381. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90382. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90383. * @returns the luminance alpha texture
  90384. */
  90385. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90386. /**
  90387. * Creates an alpha texture from some data.
  90388. * @param data Define the texture data
  90389. * @param width Define the width of the texture
  90390. * @param height Define the height of the texture
  90391. * @param scene Define the scene the texture belongs to
  90392. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90393. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90394. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90395. * @returns the alpha texture
  90396. */
  90397. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90398. /**
  90399. * Creates a RGB texture from some data.
  90400. * @param data Define the texture data
  90401. * @param width Define the width of the texture
  90402. * @param height Define the height of the texture
  90403. * @param scene Define the scene the texture belongs to
  90404. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90405. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90406. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90407. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90408. * @returns the RGB alpha texture
  90409. */
  90410. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90411. /**
  90412. * Creates a RGBA texture from some data.
  90413. * @param data Define the texture data
  90414. * @param width Define the width of the texture
  90415. * @param height Define the height of the texture
  90416. * @param scene Define the scene the texture belongs to
  90417. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90420. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90421. * @returns the RGBA texture
  90422. */
  90423. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90424. /**
  90425. * Creates a R texture from some data.
  90426. * @param data Define the texture data
  90427. * @param width Define the width of the texture
  90428. * @param height Define the height of the texture
  90429. * @param scene Define the scene the texture belongs to
  90430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90433. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90434. * @returns the R texture
  90435. */
  90436. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90437. }
  90438. }
  90439. declare module BABYLON {
  90440. interface AbstractScene {
  90441. /**
  90442. * The list of procedural textures added to the scene
  90443. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90444. */
  90445. proceduralTextures: Array<ProceduralTexture>;
  90446. }
  90447. /**
  90448. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90449. * in a given scene.
  90450. */
  90451. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90452. /**
  90453. * The component name helpfull to identify the component in the list of scene components.
  90454. */
  90455. readonly name: string;
  90456. /**
  90457. * The scene the component belongs to.
  90458. */
  90459. scene: Scene;
  90460. /**
  90461. * Creates a new instance of the component for the given scene
  90462. * @param scene Defines the scene to register the component in
  90463. */
  90464. constructor(scene: Scene);
  90465. /**
  90466. * Registers the component in a given scene
  90467. */
  90468. register(): void;
  90469. /**
  90470. * Rebuilds the elements related to this component in case of
  90471. * context lost for instance.
  90472. */
  90473. rebuild(): void;
  90474. /**
  90475. * Disposes the component and the associated ressources.
  90476. */
  90477. dispose(): void;
  90478. private _beforeClear;
  90479. }
  90480. }
  90481. declare module BABYLON {
  90482. interface ThinEngine {
  90483. /**
  90484. * Creates a new render target cube texture
  90485. * @param size defines the size of the texture
  90486. * @param options defines the options used to create the texture
  90487. * @returns a new render target cube texture stored in an InternalTexture
  90488. */
  90489. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90490. }
  90491. }
  90492. declare module BABYLON {
  90493. /** @hidden */
  90494. export var proceduralVertexShader: {
  90495. name: string;
  90496. shader: string;
  90497. };
  90498. }
  90499. declare module BABYLON {
  90500. /**
  90501. * 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.
  90502. * This is the base class of any Procedural texture and contains most of the shareable code.
  90503. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90504. */
  90505. export class ProceduralTexture extends Texture {
  90506. isCube: boolean;
  90507. /**
  90508. * Define if the texture is enabled or not (disabled texture will not render)
  90509. */
  90510. isEnabled: boolean;
  90511. /**
  90512. * Define if the texture must be cleared before rendering (default is true)
  90513. */
  90514. autoClear: boolean;
  90515. /**
  90516. * Callback called when the texture is generated
  90517. */
  90518. onGenerated: () => void;
  90519. /**
  90520. * Event raised when the texture is generated
  90521. */
  90522. onGeneratedObservable: Observable<ProceduralTexture>;
  90523. /** @hidden */
  90524. _generateMipMaps: boolean;
  90525. /** @hidden **/
  90526. _effect: Effect;
  90527. /** @hidden */
  90528. _textures: {
  90529. [key: string]: Texture;
  90530. };
  90531. /** @hidden */
  90532. protected _fallbackTexture: Nullable<Texture>;
  90533. private _size;
  90534. private _currentRefreshId;
  90535. private _frameId;
  90536. private _refreshRate;
  90537. private _vertexBuffers;
  90538. private _indexBuffer;
  90539. private _uniforms;
  90540. private _samplers;
  90541. private _fragment;
  90542. private _floats;
  90543. private _ints;
  90544. private _floatsArrays;
  90545. private _colors3;
  90546. private _colors4;
  90547. private _vectors2;
  90548. private _vectors3;
  90549. private _matrices;
  90550. private _fallbackTextureUsed;
  90551. private _fullEngine;
  90552. private _cachedDefines;
  90553. private _contentUpdateId;
  90554. private _contentData;
  90555. /**
  90556. * Instantiates a new procedural texture.
  90557. * 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.
  90558. * This is the base class of any Procedural texture and contains most of the shareable code.
  90559. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90560. * @param name Define the name of the texture
  90561. * @param size Define the size of the texture to create
  90562. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90563. * @param scene Define the scene the texture belongs to
  90564. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90565. * @param generateMipMaps Define if the texture should creates mip maps or not
  90566. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90567. */
  90568. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90569. /**
  90570. * The effect that is created when initializing the post process.
  90571. * @returns The created effect corresponding the the postprocess.
  90572. */
  90573. getEffect(): Effect;
  90574. /**
  90575. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90576. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90577. */
  90578. getContent(): Nullable<ArrayBufferView>;
  90579. private _createIndexBuffer;
  90580. /** @hidden */
  90581. _rebuild(): void;
  90582. /**
  90583. * Resets the texture in order to recreate its associated resources.
  90584. * This can be called in case of context loss
  90585. */
  90586. reset(): void;
  90587. protected _getDefines(): string;
  90588. /**
  90589. * Is the texture ready to be used ? (rendered at least once)
  90590. * @returns true if ready, otherwise, false.
  90591. */
  90592. isReady(): boolean;
  90593. /**
  90594. * Resets the refresh counter of the texture and start bak from scratch.
  90595. * Could be useful to regenerate the texture if it is setup to render only once.
  90596. */
  90597. resetRefreshCounter(): void;
  90598. /**
  90599. * Set the fragment shader to use in order to render the texture.
  90600. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90601. */
  90602. setFragment(fragment: any): void;
  90603. /**
  90604. * Define the refresh rate of the texture or the rendering frequency.
  90605. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90606. */
  90607. get refreshRate(): number;
  90608. set refreshRate(value: number);
  90609. /** @hidden */
  90610. _shouldRender(): boolean;
  90611. /**
  90612. * Get the size the texture is rendering at.
  90613. * @returns the size (texture is always squared)
  90614. */
  90615. getRenderSize(): number;
  90616. /**
  90617. * Resize the texture to new value.
  90618. * @param size Define the new size the texture should have
  90619. * @param generateMipMaps Define whether the new texture should create mip maps
  90620. */
  90621. resize(size: number, generateMipMaps: boolean): void;
  90622. private _checkUniform;
  90623. /**
  90624. * Set a texture in the shader program used to render.
  90625. * @param name Define the name of the uniform samplers as defined in the shader
  90626. * @param texture Define the texture to bind to this sampler
  90627. * @return the texture itself allowing "fluent" like uniform updates
  90628. */
  90629. setTexture(name: string, texture: Texture): ProceduralTexture;
  90630. /**
  90631. * Set a float in the shader.
  90632. * @param name Define the name of the uniform as defined in the shader
  90633. * @param value Define the value to give to the uniform
  90634. * @return the texture itself allowing "fluent" like uniform updates
  90635. */
  90636. setFloat(name: string, value: number): ProceduralTexture;
  90637. /**
  90638. * Set a int in the shader.
  90639. * @param name Define the name of the uniform as defined in the shader
  90640. * @param value Define the value to give to the uniform
  90641. * @return the texture itself allowing "fluent" like uniform updates
  90642. */
  90643. setInt(name: string, value: number): ProceduralTexture;
  90644. /**
  90645. * Set an array of floats in the shader.
  90646. * @param name Define the name of the uniform as defined in the shader
  90647. * @param value Define the value to give to the uniform
  90648. * @return the texture itself allowing "fluent" like uniform updates
  90649. */
  90650. setFloats(name: string, value: number[]): ProceduralTexture;
  90651. /**
  90652. * Set a vec3 in the shader from a Color3.
  90653. * @param name Define the name of the uniform as defined in the shader
  90654. * @param value Define the value to give to the uniform
  90655. * @return the texture itself allowing "fluent" like uniform updates
  90656. */
  90657. setColor3(name: string, value: Color3): ProceduralTexture;
  90658. /**
  90659. * Set a vec4 in the shader from a Color4.
  90660. * @param name Define the name of the uniform as defined in the shader
  90661. * @param value Define the value to give to the uniform
  90662. * @return the texture itself allowing "fluent" like uniform updates
  90663. */
  90664. setColor4(name: string, value: Color4): ProceduralTexture;
  90665. /**
  90666. * Set a vec2 in the shader from a Vector2.
  90667. * @param name Define the name of the uniform as defined in the shader
  90668. * @param value Define the value to give to the uniform
  90669. * @return the texture itself allowing "fluent" like uniform updates
  90670. */
  90671. setVector2(name: string, value: Vector2): ProceduralTexture;
  90672. /**
  90673. * Set a vec3 in the shader from a Vector3.
  90674. * @param name Define the name of the uniform as defined in the shader
  90675. * @param value Define the value to give to the uniform
  90676. * @return the texture itself allowing "fluent" like uniform updates
  90677. */
  90678. setVector3(name: string, value: Vector3): ProceduralTexture;
  90679. /**
  90680. * Set a mat4 in the shader from a MAtrix.
  90681. * @param name Define the name of the uniform as defined in the shader
  90682. * @param value Define the value to give to the uniform
  90683. * @return the texture itself allowing "fluent" like uniform updates
  90684. */
  90685. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90686. /**
  90687. * Render the texture to its associated render target.
  90688. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90689. */
  90690. render(useCameraPostProcess?: boolean): void;
  90691. /**
  90692. * Clone the texture.
  90693. * @returns the cloned texture
  90694. */
  90695. clone(): ProceduralTexture;
  90696. /**
  90697. * Dispose the texture and release its asoociated resources.
  90698. */
  90699. dispose(): void;
  90700. }
  90701. }
  90702. declare module BABYLON {
  90703. /**
  90704. * This represents the base class for particle system in Babylon.
  90705. * 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.
  90706. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90707. * @example https://doc.babylonjs.com/babylon101/particles
  90708. */
  90709. export class BaseParticleSystem {
  90710. /**
  90711. * Source color is added to the destination color without alpha affecting the result
  90712. */
  90713. static BLENDMODE_ONEONE: number;
  90714. /**
  90715. * Blend current color and particle color using particle’s alpha
  90716. */
  90717. static BLENDMODE_STANDARD: number;
  90718. /**
  90719. * Add current color and particle color multiplied by particle’s alpha
  90720. */
  90721. static BLENDMODE_ADD: number;
  90722. /**
  90723. * Multiply current color with particle color
  90724. */
  90725. static BLENDMODE_MULTIPLY: number;
  90726. /**
  90727. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90728. */
  90729. static BLENDMODE_MULTIPLYADD: number;
  90730. /**
  90731. * List of animations used by the particle system.
  90732. */
  90733. animations: Animation[];
  90734. /**
  90735. * Gets or sets the unique id of the particle system
  90736. */
  90737. uniqueId: number;
  90738. /**
  90739. * The id of the Particle system.
  90740. */
  90741. id: string;
  90742. /**
  90743. * The friendly name of the Particle system.
  90744. */
  90745. name: string;
  90746. /**
  90747. * Snippet ID if the particle system was created from the snippet server
  90748. */
  90749. snippetId: string;
  90750. /**
  90751. * The rendering group used by the Particle system to chose when to render.
  90752. */
  90753. renderingGroupId: number;
  90754. /**
  90755. * The emitter represents the Mesh or position we are attaching the particle system to.
  90756. */
  90757. emitter: Nullable<AbstractMesh | Vector3>;
  90758. /**
  90759. * The maximum number of particles to emit per frame
  90760. */
  90761. emitRate: number;
  90762. /**
  90763. * If you want to launch only a few particles at once, that can be done, as well.
  90764. */
  90765. manualEmitCount: number;
  90766. /**
  90767. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90768. */
  90769. updateSpeed: number;
  90770. /**
  90771. * The amount of time the particle system is running (depends of the overall update speed).
  90772. */
  90773. targetStopDuration: number;
  90774. /**
  90775. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90776. */
  90777. disposeOnStop: boolean;
  90778. /**
  90779. * Minimum power of emitting particles.
  90780. */
  90781. minEmitPower: number;
  90782. /**
  90783. * Maximum power of emitting particles.
  90784. */
  90785. maxEmitPower: number;
  90786. /**
  90787. * Minimum life time of emitting particles.
  90788. */
  90789. minLifeTime: number;
  90790. /**
  90791. * Maximum life time of emitting particles.
  90792. */
  90793. maxLifeTime: number;
  90794. /**
  90795. * Minimum Size of emitting particles.
  90796. */
  90797. minSize: number;
  90798. /**
  90799. * Maximum Size of emitting particles.
  90800. */
  90801. maxSize: number;
  90802. /**
  90803. * Minimum scale of emitting particles on X axis.
  90804. */
  90805. minScaleX: number;
  90806. /**
  90807. * Maximum scale of emitting particles on X axis.
  90808. */
  90809. maxScaleX: number;
  90810. /**
  90811. * Minimum scale of emitting particles on Y axis.
  90812. */
  90813. minScaleY: number;
  90814. /**
  90815. * Maximum scale of emitting particles on Y axis.
  90816. */
  90817. maxScaleY: number;
  90818. /**
  90819. * Gets or sets the minimal initial rotation in radians.
  90820. */
  90821. minInitialRotation: number;
  90822. /**
  90823. * Gets or sets the maximal initial rotation in radians.
  90824. */
  90825. maxInitialRotation: number;
  90826. /**
  90827. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90828. */
  90829. minAngularSpeed: number;
  90830. /**
  90831. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90832. */
  90833. maxAngularSpeed: number;
  90834. /**
  90835. * The texture used to render each particle. (this can be a spritesheet)
  90836. */
  90837. particleTexture: Nullable<Texture>;
  90838. /**
  90839. * The layer mask we are rendering the particles through.
  90840. */
  90841. layerMask: number;
  90842. /**
  90843. * This can help using your own shader to render the particle system.
  90844. * The according effect will be created
  90845. */
  90846. customShader: any;
  90847. /**
  90848. * By default particle system starts as soon as they are created. This prevents the
  90849. * automatic start to happen and let you decide when to start emitting particles.
  90850. */
  90851. preventAutoStart: boolean;
  90852. private _noiseTexture;
  90853. /**
  90854. * Gets or sets a texture used to add random noise to particle positions
  90855. */
  90856. get noiseTexture(): Nullable<ProceduralTexture>;
  90857. set noiseTexture(value: Nullable<ProceduralTexture>);
  90858. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90859. noiseStrength: Vector3;
  90860. /**
  90861. * Callback triggered when the particle animation is ending.
  90862. */
  90863. onAnimationEnd: Nullable<() => void>;
  90864. /**
  90865. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90866. */
  90867. blendMode: number;
  90868. /**
  90869. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90870. * to override the particles.
  90871. */
  90872. forceDepthWrite: boolean;
  90873. /** 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 */
  90874. preWarmCycles: number;
  90875. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90876. preWarmStepOffset: number;
  90877. /**
  90878. * 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)
  90879. */
  90880. spriteCellChangeSpeed: number;
  90881. /**
  90882. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90883. */
  90884. startSpriteCellID: number;
  90885. /**
  90886. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90887. */
  90888. endSpriteCellID: number;
  90889. /**
  90890. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90891. */
  90892. spriteCellWidth: number;
  90893. /**
  90894. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90895. */
  90896. spriteCellHeight: number;
  90897. /**
  90898. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90899. */
  90900. spriteRandomStartCell: boolean;
  90901. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90902. translationPivot: Vector2;
  90903. /** @hidden */
  90904. protected _isAnimationSheetEnabled: boolean;
  90905. /**
  90906. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90907. */
  90908. beginAnimationOnStart: boolean;
  90909. /**
  90910. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90911. */
  90912. beginAnimationFrom: number;
  90913. /**
  90914. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90915. */
  90916. beginAnimationTo: number;
  90917. /**
  90918. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90919. */
  90920. beginAnimationLoop: boolean;
  90921. /**
  90922. * Gets or sets a world offset applied to all particles
  90923. */
  90924. worldOffset: Vector3;
  90925. /**
  90926. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90927. */
  90928. get isAnimationSheetEnabled(): boolean;
  90929. set isAnimationSheetEnabled(value: boolean);
  90930. /**
  90931. * Get hosting scene
  90932. * @returns the scene
  90933. */
  90934. getScene(): Scene;
  90935. /**
  90936. * You can use gravity if you want to give an orientation to your particles.
  90937. */
  90938. gravity: Vector3;
  90939. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90940. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90941. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90942. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90943. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90944. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90945. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90946. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90947. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90948. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90949. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90950. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90951. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90952. /**
  90953. * Defines the delay in milliseconds before starting the system (0 by default)
  90954. */
  90955. startDelay: number;
  90956. /**
  90957. * Gets the current list of drag gradients.
  90958. * You must use addDragGradient and removeDragGradient to udpate this list
  90959. * @returns the list of drag gradients
  90960. */
  90961. getDragGradients(): Nullable<Array<FactorGradient>>;
  90962. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90963. limitVelocityDamping: number;
  90964. /**
  90965. * Gets the current list of limit velocity gradients.
  90966. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90967. * @returns the list of limit velocity gradients
  90968. */
  90969. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90970. /**
  90971. * Gets the current list of color gradients.
  90972. * You must use addColorGradient and removeColorGradient to udpate this list
  90973. * @returns the list of color gradients
  90974. */
  90975. getColorGradients(): Nullable<Array<ColorGradient>>;
  90976. /**
  90977. * Gets the current list of size gradients.
  90978. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90979. * @returns the list of size gradients
  90980. */
  90981. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90982. /**
  90983. * Gets the current list of color remap gradients.
  90984. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90985. * @returns the list of color remap gradients
  90986. */
  90987. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90988. /**
  90989. * Gets the current list of alpha remap gradients.
  90990. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90991. * @returns the list of alpha remap gradients
  90992. */
  90993. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90994. /**
  90995. * Gets the current list of life time gradients.
  90996. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90997. * @returns the list of life time gradients
  90998. */
  90999. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91000. /**
  91001. * Gets the current list of angular speed gradients.
  91002. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91003. * @returns the list of angular speed gradients
  91004. */
  91005. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91006. /**
  91007. * Gets the current list of velocity gradients.
  91008. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91009. * @returns the list of velocity gradients
  91010. */
  91011. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91012. /**
  91013. * Gets the current list of start size gradients.
  91014. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91015. * @returns the list of start size gradients
  91016. */
  91017. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91018. /**
  91019. * Gets the current list of emit rate gradients.
  91020. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91021. * @returns the list of emit rate gradients
  91022. */
  91023. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91024. /**
  91025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91027. */
  91028. get direction1(): Vector3;
  91029. set direction1(value: Vector3);
  91030. /**
  91031. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91032. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91033. */
  91034. get direction2(): Vector3;
  91035. set direction2(value: Vector3);
  91036. /**
  91037. * 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.
  91038. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91039. */
  91040. get minEmitBox(): Vector3;
  91041. set minEmitBox(value: Vector3);
  91042. /**
  91043. * 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.
  91044. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91045. */
  91046. get maxEmitBox(): Vector3;
  91047. set maxEmitBox(value: Vector3);
  91048. /**
  91049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91050. */
  91051. color1: Color4;
  91052. /**
  91053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91054. */
  91055. color2: Color4;
  91056. /**
  91057. * Color the particle will have at the end of its lifetime
  91058. */
  91059. colorDead: Color4;
  91060. /**
  91061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91062. */
  91063. textureMask: Color4;
  91064. /**
  91065. * The particle emitter type defines the emitter used by the particle system.
  91066. * It can be for example box, sphere, or cone...
  91067. */
  91068. particleEmitterType: IParticleEmitterType;
  91069. /** @hidden */
  91070. _isSubEmitter: boolean;
  91071. /**
  91072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91074. */
  91075. billboardMode: number;
  91076. protected _isBillboardBased: boolean;
  91077. /**
  91078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91079. */
  91080. get isBillboardBased(): boolean;
  91081. set isBillboardBased(value: boolean);
  91082. /**
  91083. * The scene the particle system belongs to.
  91084. */
  91085. protected _scene: Scene;
  91086. /**
  91087. * Local cache of defines for image processing.
  91088. */
  91089. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91090. /**
  91091. * Default configuration related to image processing available in the standard Material.
  91092. */
  91093. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91094. /**
  91095. * Gets the image processing configuration used either in this material.
  91096. */
  91097. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  91098. /**
  91099. * Sets the Default image processing configuration used either in the this material.
  91100. *
  91101. * If sets to null, the scene one is in use.
  91102. */
  91103. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  91104. /**
  91105. * Attaches a new image processing configuration to the Standard Material.
  91106. * @param configuration
  91107. */
  91108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91109. /** @hidden */
  91110. protected _reset(): void;
  91111. /** @hidden */
  91112. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91113. /**
  91114. * Instantiates a particle system.
  91115. * 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.
  91116. * @param name The name of the particle system
  91117. */
  91118. constructor(name: string);
  91119. /**
  91120. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91123. * @returns the emitter
  91124. */
  91125. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91126. /**
  91127. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91128. * @param radius The radius of the hemisphere to emit from
  91129. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91130. * @returns the emitter
  91131. */
  91132. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91133. /**
  91134. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91135. * @param radius The radius of the sphere to emit from
  91136. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91137. * @returns the emitter
  91138. */
  91139. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91140. /**
  91141. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91142. * @param radius The radius of the sphere to emit from
  91143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91145. * @returns the emitter
  91146. */
  91147. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91148. /**
  91149. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91150. * @param radius The radius of the emission cylinder
  91151. * @param height The height of the emission cylinder
  91152. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91153. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91154. * @returns the emitter
  91155. */
  91156. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91157. /**
  91158. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91159. * @param radius The radius of the cylinder to emit from
  91160. * @param height The height of the emission cylinder
  91161. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91162. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91163. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91164. * @returns the emitter
  91165. */
  91166. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91167. /**
  91168. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91169. * @param radius The radius of the cone to emit from
  91170. * @param angle The base angle of the cone
  91171. * @returns the emitter
  91172. */
  91173. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91174. /**
  91175. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91176. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91177. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91178. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91179. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91180. * @returns the emitter
  91181. */
  91182. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91183. }
  91184. }
  91185. declare module BABYLON {
  91186. /**
  91187. * Type of sub emitter
  91188. */
  91189. export enum SubEmitterType {
  91190. /**
  91191. * Attached to the particle over it's lifetime
  91192. */
  91193. ATTACHED = 0,
  91194. /**
  91195. * Created when the particle dies
  91196. */
  91197. END = 1
  91198. }
  91199. /**
  91200. * Sub emitter class used to emit particles from an existing particle
  91201. */
  91202. export class SubEmitter {
  91203. /**
  91204. * the particle system to be used by the sub emitter
  91205. */
  91206. particleSystem: ParticleSystem;
  91207. /**
  91208. * Type of the submitter (Default: END)
  91209. */
  91210. type: SubEmitterType;
  91211. /**
  91212. * 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)
  91213. * Note: This only is supported when using an emitter of type Mesh
  91214. */
  91215. inheritDirection: boolean;
  91216. /**
  91217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91218. */
  91219. inheritedVelocityAmount: number;
  91220. /**
  91221. * Creates a sub emitter
  91222. * @param particleSystem the particle system to be used by the sub emitter
  91223. */
  91224. constructor(
  91225. /**
  91226. * the particle system to be used by the sub emitter
  91227. */
  91228. particleSystem: ParticleSystem);
  91229. /**
  91230. * Clones the sub emitter
  91231. * @returns the cloned sub emitter
  91232. */
  91233. clone(): SubEmitter;
  91234. /**
  91235. * Serialize current object to a JSON object
  91236. * @returns the serialized object
  91237. */
  91238. serialize(): any;
  91239. /** @hidden */
  91240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  91241. /**
  91242. * Creates a new SubEmitter from a serialized JSON version
  91243. * @param serializationObject defines the JSON object to read from
  91244. * @param scene defines the hosting scene
  91245. * @param rootUrl defines the rootUrl for data loading
  91246. * @returns a new SubEmitter
  91247. */
  91248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  91249. /** Release associated resources */
  91250. dispose(): void;
  91251. }
  91252. }
  91253. declare module BABYLON {
  91254. /** @hidden */
  91255. export var imageProcessingDeclaration: {
  91256. name: string;
  91257. shader: string;
  91258. };
  91259. }
  91260. declare module BABYLON {
  91261. /** @hidden */
  91262. export var imageProcessingFunctions: {
  91263. name: string;
  91264. shader: string;
  91265. };
  91266. }
  91267. declare module BABYLON {
  91268. /** @hidden */
  91269. export var particlesPixelShader: {
  91270. name: string;
  91271. shader: string;
  91272. };
  91273. }
  91274. declare module BABYLON {
  91275. /** @hidden */
  91276. export var particlesVertexShader: {
  91277. name: string;
  91278. shader: string;
  91279. };
  91280. }
  91281. declare module BABYLON {
  91282. /**
  91283. * This represents a particle system in Babylon.
  91284. * 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.
  91285. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91286. * @example https://doc.babylonjs.com/babylon101/particles
  91287. */
  91288. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91289. /**
  91290. * Billboard mode will only apply to Y axis
  91291. */
  91292. static readonly BILLBOARDMODE_Y: number;
  91293. /**
  91294. * Billboard mode will apply to all axes
  91295. */
  91296. static readonly BILLBOARDMODE_ALL: number;
  91297. /**
  91298. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91299. */
  91300. static readonly BILLBOARDMODE_STRETCHED: number;
  91301. /**
  91302. * This function can be defined to provide custom update for active particles.
  91303. * This function will be called instead of regular update (age, position, color, etc.).
  91304. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91305. */
  91306. updateFunction: (particles: Particle[]) => void;
  91307. private _emitterWorldMatrix;
  91308. /**
  91309. * This function can be defined to specify initial direction for every new particle.
  91310. * It by default use the emitterType defined function
  91311. */
  91312. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91313. /**
  91314. * This function can be defined to specify initial position for every new particle.
  91315. * It by default use the emitterType defined function
  91316. */
  91317. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91318. /**
  91319. * @hidden
  91320. */
  91321. _inheritedVelocityOffset: Vector3;
  91322. /**
  91323. * An event triggered when the system is disposed
  91324. */
  91325. onDisposeObservable: Observable<IParticleSystem>;
  91326. private _onDisposeObserver;
  91327. /**
  91328. * Sets a callback that will be triggered when the system is disposed
  91329. */
  91330. set onDispose(callback: () => void);
  91331. private _particles;
  91332. private _epsilon;
  91333. private _capacity;
  91334. private _stockParticles;
  91335. private _newPartsExcess;
  91336. private _vertexData;
  91337. private _vertexBuffer;
  91338. private _vertexBuffers;
  91339. private _spriteBuffer;
  91340. private _indexBuffer;
  91341. private _effect;
  91342. private _customEffect;
  91343. private _cachedDefines;
  91344. private _scaledColorStep;
  91345. private _colorDiff;
  91346. private _scaledDirection;
  91347. private _scaledGravity;
  91348. private _currentRenderId;
  91349. private _alive;
  91350. private _useInstancing;
  91351. private _started;
  91352. private _stopped;
  91353. private _actualFrame;
  91354. private _scaledUpdateSpeed;
  91355. private _vertexBufferSize;
  91356. /** @hidden */
  91357. _currentEmitRateGradient: Nullable<FactorGradient>;
  91358. /** @hidden */
  91359. _currentEmitRate1: number;
  91360. /** @hidden */
  91361. _currentEmitRate2: number;
  91362. /** @hidden */
  91363. _currentStartSizeGradient: Nullable<FactorGradient>;
  91364. /** @hidden */
  91365. _currentStartSize1: number;
  91366. /** @hidden */
  91367. _currentStartSize2: number;
  91368. private readonly _rawTextureWidth;
  91369. private _rampGradientsTexture;
  91370. private _useRampGradients;
  91371. /** Gets or sets a boolean indicating that ramp gradients must be used
  91372. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91373. */
  91374. get useRampGradients(): boolean;
  91375. set useRampGradients(value: boolean);
  91376. /**
  91377. * 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.
  91378. * 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: [])
  91379. */
  91380. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91381. private _subEmitters;
  91382. /**
  91383. * @hidden
  91384. * If the particle systems emitter should be disposed when the particle system is disposed
  91385. */
  91386. _disposeEmitterOnDispose: boolean;
  91387. /**
  91388. * The current active Sub-systems, this property is used by the root particle system only.
  91389. */
  91390. activeSubSystems: Array<ParticleSystem>;
  91391. /**
  91392. * Specifies if the particles are updated in emitter local space or world space
  91393. */
  91394. isLocal: boolean;
  91395. private _rootParticleSystem;
  91396. /**
  91397. * Gets the current list of active particles
  91398. */
  91399. get particles(): Particle[];
  91400. /**
  91401. * Gets the number of particles active at the same time.
  91402. * @returns The number of active particles.
  91403. */
  91404. getActiveCount(): number;
  91405. /**
  91406. * Returns the string "ParticleSystem"
  91407. * @returns a string containing the class name
  91408. */
  91409. getClassName(): string;
  91410. /**
  91411. * Gets a boolean indicating that the system is stopping
  91412. * @returns true if the system is currently stopping
  91413. */
  91414. isStopping(): boolean;
  91415. /**
  91416. * Gets the custom effect used to render the particles
  91417. * @param blendMode Blend mode for which the effect should be retrieved
  91418. * @returns The effect
  91419. */
  91420. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91421. /**
  91422. * Sets the custom effect used to render the particles
  91423. * @param effect The effect to set
  91424. * @param blendMode Blend mode for which the effect should be set
  91425. */
  91426. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91427. /** @hidden */
  91428. private _onBeforeDrawParticlesObservable;
  91429. /**
  91430. * Observable that will be called just before the particles are drawn
  91431. */
  91432. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91433. /**
  91434. * Gets the name of the particle vertex shader
  91435. */
  91436. get vertexShaderName(): string;
  91437. /**
  91438. * Instantiates a particle system.
  91439. * 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.
  91440. * @param name The name of the particle system
  91441. * @param capacity The max number of particles alive at the same time
  91442. * @param scene The scene the particle system belongs to
  91443. * @param customEffect a custom effect used to change the way particles are rendered by default
  91444. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91445. * @param epsilon Offset used to render the particles
  91446. */
  91447. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91448. private _addFactorGradient;
  91449. private _removeFactorGradient;
  91450. /**
  91451. * Adds a new life time gradient
  91452. * @param gradient defines the gradient to use (between 0 and 1)
  91453. * @param factor defines the life time factor to affect to the specified gradient
  91454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91455. * @returns the current particle system
  91456. */
  91457. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91458. /**
  91459. * Remove a specific life time gradient
  91460. * @param gradient defines the gradient to remove
  91461. * @returns the current particle system
  91462. */
  91463. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91464. /**
  91465. * Adds a new size gradient
  91466. * @param gradient defines the gradient to use (between 0 and 1)
  91467. * @param factor defines the size factor to affect to the specified gradient
  91468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91469. * @returns the current particle system
  91470. */
  91471. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91472. /**
  91473. * Remove a specific size gradient
  91474. * @param gradient defines the gradient to remove
  91475. * @returns the current particle system
  91476. */
  91477. removeSizeGradient(gradient: number): IParticleSystem;
  91478. /**
  91479. * Adds a new color remap gradient
  91480. * @param gradient defines the gradient to use (between 0 and 1)
  91481. * @param min defines the color remap minimal range
  91482. * @param max defines the color remap maximal range
  91483. * @returns the current particle system
  91484. */
  91485. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91486. /**
  91487. * Remove a specific color remap gradient
  91488. * @param gradient defines the gradient to remove
  91489. * @returns the current particle system
  91490. */
  91491. removeColorRemapGradient(gradient: number): IParticleSystem;
  91492. /**
  91493. * Adds a new alpha remap gradient
  91494. * @param gradient defines the gradient to use (between 0 and 1)
  91495. * @param min defines the alpha remap minimal range
  91496. * @param max defines the alpha remap maximal range
  91497. * @returns the current particle system
  91498. */
  91499. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91500. /**
  91501. * Remove a specific alpha remap gradient
  91502. * @param gradient defines the gradient to remove
  91503. * @returns the current particle system
  91504. */
  91505. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91506. /**
  91507. * Adds a new angular speed gradient
  91508. * @param gradient defines the gradient to use (between 0 and 1)
  91509. * @param factor defines the angular speed to affect to the specified gradient
  91510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91511. * @returns the current particle system
  91512. */
  91513. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91514. /**
  91515. * Remove a specific angular speed gradient
  91516. * @param gradient defines the gradient to remove
  91517. * @returns the current particle system
  91518. */
  91519. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91520. /**
  91521. * Adds a new velocity gradient
  91522. * @param gradient defines the gradient to use (between 0 and 1)
  91523. * @param factor defines the velocity to affect to the specified gradient
  91524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91525. * @returns the current particle system
  91526. */
  91527. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91528. /**
  91529. * Remove a specific velocity gradient
  91530. * @param gradient defines the gradient to remove
  91531. * @returns the current particle system
  91532. */
  91533. removeVelocityGradient(gradient: number): IParticleSystem;
  91534. /**
  91535. * Adds a new limit velocity gradient
  91536. * @param gradient defines the gradient to use (between 0 and 1)
  91537. * @param factor defines the limit velocity value to affect to the specified gradient
  91538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91539. * @returns the current particle system
  91540. */
  91541. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91542. /**
  91543. * Remove a specific limit velocity gradient
  91544. * @param gradient defines the gradient to remove
  91545. * @returns the current particle system
  91546. */
  91547. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91548. /**
  91549. * Adds a new drag gradient
  91550. * @param gradient defines the gradient to use (between 0 and 1)
  91551. * @param factor defines the drag value to affect to the specified gradient
  91552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91553. * @returns the current particle system
  91554. */
  91555. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91556. /**
  91557. * Remove a specific drag gradient
  91558. * @param gradient defines the gradient to remove
  91559. * @returns the current particle system
  91560. */
  91561. removeDragGradient(gradient: number): IParticleSystem;
  91562. /**
  91563. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91564. * @param gradient defines the gradient to use (between 0 and 1)
  91565. * @param factor defines the emit rate value to affect to the specified gradient
  91566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91567. * @returns the current particle system
  91568. */
  91569. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91570. /**
  91571. * Remove a specific emit rate gradient
  91572. * @param gradient defines the gradient to remove
  91573. * @returns the current particle system
  91574. */
  91575. removeEmitRateGradient(gradient: number): IParticleSystem;
  91576. /**
  91577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91578. * @param gradient defines the gradient to use (between 0 and 1)
  91579. * @param factor defines the start size value to affect to the specified gradient
  91580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91581. * @returns the current particle system
  91582. */
  91583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91584. /**
  91585. * Remove a specific start size gradient
  91586. * @param gradient defines the gradient to remove
  91587. * @returns the current particle system
  91588. */
  91589. removeStartSizeGradient(gradient: number): IParticleSystem;
  91590. private _createRampGradientTexture;
  91591. /**
  91592. * Gets the current list of ramp gradients.
  91593. * You must use addRampGradient and removeRampGradient to udpate this list
  91594. * @returns the list of ramp gradients
  91595. */
  91596. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91597. /** Force the system to rebuild all gradients that need to be resync */
  91598. forceRefreshGradients(): void;
  91599. private _syncRampGradientTexture;
  91600. /**
  91601. * Adds a new ramp gradient used to remap particle colors
  91602. * @param gradient defines the gradient to use (between 0 and 1)
  91603. * @param color defines the color to affect to the specified gradient
  91604. * @returns the current particle system
  91605. */
  91606. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91607. /**
  91608. * Remove a specific ramp gradient
  91609. * @param gradient defines the gradient to remove
  91610. * @returns the current particle system
  91611. */
  91612. removeRampGradient(gradient: number): ParticleSystem;
  91613. /**
  91614. * Adds a new color gradient
  91615. * @param gradient defines the gradient to use (between 0 and 1)
  91616. * @param color1 defines the color to affect to the specified gradient
  91617. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91618. * @returns this particle system
  91619. */
  91620. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91621. /**
  91622. * Remove a specific color gradient
  91623. * @param gradient defines the gradient to remove
  91624. * @returns this particle system
  91625. */
  91626. removeColorGradient(gradient: number): IParticleSystem;
  91627. private _fetchR;
  91628. protected _reset(): void;
  91629. private _resetEffect;
  91630. private _createVertexBuffers;
  91631. private _createIndexBuffer;
  91632. /**
  91633. * Gets the maximum number of particles active at the same time.
  91634. * @returns The max number of active particles.
  91635. */
  91636. getCapacity(): number;
  91637. /**
  91638. * Gets whether there are still active particles in the system.
  91639. * @returns True if it is alive, otherwise false.
  91640. */
  91641. isAlive(): boolean;
  91642. /**
  91643. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91644. * @returns True if it has been started, otherwise false.
  91645. */
  91646. isStarted(): boolean;
  91647. private _prepareSubEmitterInternalArray;
  91648. /**
  91649. * Starts the particle system and begins to emit
  91650. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91651. */
  91652. start(delay?: number): void;
  91653. /**
  91654. * Stops the particle system.
  91655. * @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.
  91656. */
  91657. stop(stopSubEmitters?: boolean): void;
  91658. /**
  91659. * Remove all active particles
  91660. */
  91661. reset(): void;
  91662. /**
  91663. * @hidden (for internal use only)
  91664. */
  91665. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91666. /**
  91667. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91668. * Its lifetime will start back at 0.
  91669. */
  91670. recycleParticle: (particle: Particle) => void;
  91671. private _stopSubEmitters;
  91672. private _createParticle;
  91673. private _removeFromRoot;
  91674. private _emitFromParticle;
  91675. private _update;
  91676. /** @hidden */
  91677. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91678. /** @hidden */
  91679. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91680. /**
  91681. * Fill the defines array according to the current settings of the particle system
  91682. * @param defines Array to be updated
  91683. * @param blendMode blend mode to take into account when updating the array
  91684. */
  91685. fillDefines(defines: Array<string>, blendMode: number): void;
  91686. /**
  91687. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91688. * @param uniforms Uniforms array to fill
  91689. * @param attributes Attributes array to fill
  91690. * @param samplers Samplers array to fill
  91691. */
  91692. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91693. /** @hidden */
  91694. private _getEffect;
  91695. /**
  91696. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91697. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91698. */
  91699. animate(preWarmOnly?: boolean): void;
  91700. private _appendParticleVertices;
  91701. /**
  91702. * Rebuilds the particle system.
  91703. */
  91704. rebuild(): void;
  91705. /**
  91706. * Is this system ready to be used/rendered
  91707. * @return true if the system is ready
  91708. */
  91709. isReady(): boolean;
  91710. private _render;
  91711. /**
  91712. * Renders the particle system in its current state.
  91713. * @returns the current number of particles
  91714. */
  91715. render(): number;
  91716. /**
  91717. * Disposes the particle system and free the associated resources
  91718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91719. */
  91720. dispose(disposeTexture?: boolean): void;
  91721. /**
  91722. * Clones the particle system.
  91723. * @param name The name of the cloned object
  91724. * @param newEmitter The new emitter to use
  91725. * @returns the cloned particle system
  91726. */
  91727. clone(name: string, newEmitter: any): ParticleSystem;
  91728. /**
  91729. * Serializes the particle system to a JSON object
  91730. * @param serializeTexture defines if the texture must be serialized as well
  91731. * @returns the JSON object
  91732. */
  91733. serialize(serializeTexture?: boolean): any;
  91734. /** @hidden */
  91735. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91736. /** @hidden */
  91737. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91738. /**
  91739. * Parses a JSON object to create a particle system.
  91740. * @param parsedParticleSystem The JSON object to parse
  91741. * @param scene The scene to create the particle system in
  91742. * @param rootUrl The root url to use to load external dependencies like texture
  91743. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91744. * @returns the Parsed particle system
  91745. */
  91746. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91747. }
  91748. }
  91749. declare module BABYLON {
  91750. /**
  91751. * A particle represents one of the element emitted by a particle system.
  91752. * This is mainly define by its coordinates, direction, velocity and age.
  91753. */
  91754. export class Particle {
  91755. /**
  91756. * The particle system the particle belongs to.
  91757. */
  91758. particleSystem: ParticleSystem;
  91759. private static _Count;
  91760. /**
  91761. * Unique ID of the particle
  91762. */
  91763. id: number;
  91764. /**
  91765. * The world position of the particle in the scene.
  91766. */
  91767. position: Vector3;
  91768. /**
  91769. * The world direction of the particle in the scene.
  91770. */
  91771. direction: Vector3;
  91772. /**
  91773. * The color of the particle.
  91774. */
  91775. color: Color4;
  91776. /**
  91777. * The color change of the particle per step.
  91778. */
  91779. colorStep: Color4;
  91780. /**
  91781. * Defines how long will the life of the particle be.
  91782. */
  91783. lifeTime: number;
  91784. /**
  91785. * The current age of the particle.
  91786. */
  91787. age: number;
  91788. /**
  91789. * The current size of the particle.
  91790. */
  91791. size: number;
  91792. /**
  91793. * The current scale of the particle.
  91794. */
  91795. scale: Vector2;
  91796. /**
  91797. * The current angle of the particle.
  91798. */
  91799. angle: number;
  91800. /**
  91801. * Defines how fast is the angle changing.
  91802. */
  91803. angularSpeed: number;
  91804. /**
  91805. * Defines the cell index used by the particle to be rendered from a sprite.
  91806. */
  91807. cellIndex: number;
  91808. /**
  91809. * The information required to support color remapping
  91810. */
  91811. remapData: Vector4;
  91812. /** @hidden */
  91813. _randomCellOffset?: number;
  91814. /** @hidden */
  91815. _initialDirection: Nullable<Vector3>;
  91816. /** @hidden */
  91817. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91818. /** @hidden */
  91819. _initialStartSpriteCellID: number;
  91820. /** @hidden */
  91821. _initialEndSpriteCellID: number;
  91822. /** @hidden */
  91823. _currentColorGradient: Nullable<ColorGradient>;
  91824. /** @hidden */
  91825. _currentColor1: Color4;
  91826. /** @hidden */
  91827. _currentColor2: Color4;
  91828. /** @hidden */
  91829. _currentSizeGradient: Nullable<FactorGradient>;
  91830. /** @hidden */
  91831. _currentSize1: number;
  91832. /** @hidden */
  91833. _currentSize2: number;
  91834. /** @hidden */
  91835. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91836. /** @hidden */
  91837. _currentAngularSpeed1: number;
  91838. /** @hidden */
  91839. _currentAngularSpeed2: number;
  91840. /** @hidden */
  91841. _currentVelocityGradient: Nullable<FactorGradient>;
  91842. /** @hidden */
  91843. _currentVelocity1: number;
  91844. /** @hidden */
  91845. _currentVelocity2: number;
  91846. /** @hidden */
  91847. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91848. /** @hidden */
  91849. _currentLimitVelocity1: number;
  91850. /** @hidden */
  91851. _currentLimitVelocity2: number;
  91852. /** @hidden */
  91853. _currentDragGradient: Nullable<FactorGradient>;
  91854. /** @hidden */
  91855. _currentDrag1: number;
  91856. /** @hidden */
  91857. _currentDrag2: number;
  91858. /** @hidden */
  91859. _randomNoiseCoordinates1: Vector3;
  91860. /** @hidden */
  91861. _randomNoiseCoordinates2: Vector3;
  91862. /** @hidden */
  91863. _localPosition?: Vector3;
  91864. /**
  91865. * Creates a new instance Particle
  91866. * @param particleSystem the particle system the particle belongs to
  91867. */
  91868. constructor(
  91869. /**
  91870. * The particle system the particle belongs to.
  91871. */
  91872. particleSystem: ParticleSystem);
  91873. private updateCellInfoFromSystem;
  91874. /**
  91875. * Defines how the sprite cell index is updated for the particle
  91876. */
  91877. updateCellIndex(): void;
  91878. /** @hidden */
  91879. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91880. /** @hidden */
  91881. _inheritParticleInfoToSubEmitters(): void;
  91882. /** @hidden */
  91883. _reset(): void;
  91884. /**
  91885. * Copy the properties of particle to another one.
  91886. * @param other the particle to copy the information to.
  91887. */
  91888. copyTo(other: Particle): void;
  91889. }
  91890. }
  91891. declare module BABYLON {
  91892. /**
  91893. * Particle emitter represents a volume emitting particles.
  91894. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91895. */
  91896. export interface IParticleEmitterType {
  91897. /**
  91898. * Called by the particle System when the direction is computed for the created particle.
  91899. * @param worldMatrix is the world matrix of the particle system
  91900. * @param directionToUpdate is the direction vector to update with the result
  91901. * @param particle is the particle we are computed the direction for
  91902. * @param isLocal defines if the direction should be set in local space
  91903. */
  91904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91905. /**
  91906. * Called by the particle System when the position is computed for the created particle.
  91907. * @param worldMatrix is the world matrix of the particle system
  91908. * @param positionToUpdate is the position vector to update with the result
  91909. * @param particle is the particle we are computed the position for
  91910. * @param isLocal defines if the position should be set in local space
  91911. */
  91912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91913. /**
  91914. * Clones the current emitter and returns a copy of it
  91915. * @returns the new emitter
  91916. */
  91917. clone(): IParticleEmitterType;
  91918. /**
  91919. * Called by the GPUParticleSystem to setup the update shader
  91920. * @param effect defines the update shader
  91921. */
  91922. applyToShader(effect: Effect): void;
  91923. /**
  91924. * Returns a string to use to update the GPU particles update shader
  91925. * @returns the effect defines string
  91926. */
  91927. getEffectDefines(): string;
  91928. /**
  91929. * Returns a string representing the class name
  91930. * @returns a string containing the class name
  91931. */
  91932. getClassName(): string;
  91933. /**
  91934. * Serializes the particle system to a JSON object.
  91935. * @returns the JSON object
  91936. */
  91937. serialize(): any;
  91938. /**
  91939. * Parse properties from a JSON object
  91940. * @param serializationObject defines the JSON object
  91941. * @param scene defines the hosting scene
  91942. */
  91943. parse(serializationObject: any, scene: Scene): void;
  91944. }
  91945. }
  91946. declare module BABYLON {
  91947. /**
  91948. * Particle emitter emitting particles from the inside of a box.
  91949. * It emits the particles randomly between 2 given directions.
  91950. */
  91951. export class BoxParticleEmitter implements IParticleEmitterType {
  91952. /**
  91953. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91954. */
  91955. direction1: Vector3;
  91956. /**
  91957. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91958. */
  91959. direction2: Vector3;
  91960. /**
  91961. * 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.
  91962. */
  91963. minEmitBox: Vector3;
  91964. /**
  91965. * 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.
  91966. */
  91967. maxEmitBox: Vector3;
  91968. /**
  91969. * Creates a new instance BoxParticleEmitter
  91970. */
  91971. constructor();
  91972. /**
  91973. * Called by the particle System when the direction is computed for the created particle.
  91974. * @param worldMatrix is the world matrix of the particle system
  91975. * @param directionToUpdate is the direction vector to update with the result
  91976. * @param particle is the particle we are computed the direction for
  91977. * @param isLocal defines if the direction should be set in local space
  91978. */
  91979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91980. /**
  91981. * Called by the particle System when the position is computed for the created particle.
  91982. * @param worldMatrix is the world matrix of the particle system
  91983. * @param positionToUpdate is the position vector to update with the result
  91984. * @param particle is the particle we are computed the position for
  91985. * @param isLocal defines if the position should be set in local space
  91986. */
  91987. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91988. /**
  91989. * Clones the current emitter and returns a copy of it
  91990. * @returns the new emitter
  91991. */
  91992. clone(): BoxParticleEmitter;
  91993. /**
  91994. * Called by the GPUParticleSystem to setup the update shader
  91995. * @param effect defines the update shader
  91996. */
  91997. applyToShader(effect: Effect): void;
  91998. /**
  91999. * Returns a string to use to update the GPU particles update shader
  92000. * @returns a string containng the defines string
  92001. */
  92002. getEffectDefines(): string;
  92003. /**
  92004. * Returns the string "BoxParticleEmitter"
  92005. * @returns a string containing the class name
  92006. */
  92007. getClassName(): string;
  92008. /**
  92009. * Serializes the particle system to a JSON object.
  92010. * @returns the JSON object
  92011. */
  92012. serialize(): any;
  92013. /**
  92014. * Parse properties from a JSON object
  92015. * @param serializationObject defines the JSON object
  92016. */
  92017. parse(serializationObject: any): void;
  92018. }
  92019. }
  92020. declare module BABYLON {
  92021. /**
  92022. * Particle emitter emitting particles from the inside of a cone.
  92023. * It emits the particles alongside the cone volume from the base to the particle.
  92024. * The emission direction might be randomized.
  92025. */
  92026. export class ConeParticleEmitter implements IParticleEmitterType {
  92027. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92028. directionRandomizer: number;
  92029. private _radius;
  92030. private _angle;
  92031. private _height;
  92032. /**
  92033. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92034. */
  92035. radiusRange: number;
  92036. /**
  92037. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92038. */
  92039. heightRange: number;
  92040. /**
  92041. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92042. */
  92043. emitFromSpawnPointOnly: boolean;
  92044. /**
  92045. * Gets or sets the radius of the emission cone
  92046. */
  92047. get radius(): number;
  92048. set radius(value: number);
  92049. /**
  92050. * Gets or sets the angle of the emission cone
  92051. */
  92052. get angle(): number;
  92053. set angle(value: number);
  92054. private _buildHeight;
  92055. /**
  92056. * Creates a new instance ConeParticleEmitter
  92057. * @param radius the radius of the emission cone (1 by default)
  92058. * @param angle the cone base angle (PI by default)
  92059. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92060. */
  92061. constructor(radius?: number, angle?: number,
  92062. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92063. directionRandomizer?: number);
  92064. /**
  92065. * Called by the particle System when the direction is computed for the created particle.
  92066. * @param worldMatrix is the world matrix of the particle system
  92067. * @param directionToUpdate is the direction vector to update with the result
  92068. * @param particle is the particle we are computed the direction for
  92069. * @param isLocal defines if the direction should be set in local space
  92070. */
  92071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92072. /**
  92073. * Called by the particle System when the position is computed for the created particle.
  92074. * @param worldMatrix is the world matrix of the particle system
  92075. * @param positionToUpdate is the position vector to update with the result
  92076. * @param particle is the particle we are computed the position for
  92077. * @param isLocal defines if the position should be set in local space
  92078. */
  92079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92080. /**
  92081. * Clones the current emitter and returns a copy of it
  92082. * @returns the new emitter
  92083. */
  92084. clone(): ConeParticleEmitter;
  92085. /**
  92086. * Called by the GPUParticleSystem to setup the update shader
  92087. * @param effect defines the update shader
  92088. */
  92089. applyToShader(effect: Effect): void;
  92090. /**
  92091. * Returns a string to use to update the GPU particles update shader
  92092. * @returns a string containng the defines string
  92093. */
  92094. getEffectDefines(): string;
  92095. /**
  92096. * Returns the string "ConeParticleEmitter"
  92097. * @returns a string containing the class name
  92098. */
  92099. getClassName(): string;
  92100. /**
  92101. * Serializes the particle system to a JSON object.
  92102. * @returns the JSON object
  92103. */
  92104. serialize(): any;
  92105. /**
  92106. * Parse properties from a JSON object
  92107. * @param serializationObject defines the JSON object
  92108. */
  92109. parse(serializationObject: any): void;
  92110. }
  92111. }
  92112. declare module BABYLON {
  92113. /**
  92114. * Particle emitter emitting particles from the inside of a cylinder.
  92115. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92116. */
  92117. export class CylinderParticleEmitter implements IParticleEmitterType {
  92118. /**
  92119. * The radius of the emission cylinder.
  92120. */
  92121. radius: number;
  92122. /**
  92123. * The height of the emission cylinder.
  92124. */
  92125. height: number;
  92126. /**
  92127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92128. */
  92129. radiusRange: number;
  92130. /**
  92131. * How much to randomize the particle direction [0-1].
  92132. */
  92133. directionRandomizer: number;
  92134. /**
  92135. * Creates a new instance CylinderParticleEmitter
  92136. * @param radius the radius of the emission cylinder (1 by default)
  92137. * @param height the height of the emission cylinder (1 by default)
  92138. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92139. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92140. */
  92141. constructor(
  92142. /**
  92143. * The radius of the emission cylinder.
  92144. */
  92145. radius?: number,
  92146. /**
  92147. * The height of the emission cylinder.
  92148. */
  92149. height?: number,
  92150. /**
  92151. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92152. */
  92153. radiusRange?: number,
  92154. /**
  92155. * How much to randomize the particle direction [0-1].
  92156. */
  92157. directionRandomizer?: number);
  92158. /**
  92159. * Called by the particle System when the direction is computed for the created particle.
  92160. * @param worldMatrix is the world matrix of the particle system
  92161. * @param directionToUpdate is the direction vector to update with the result
  92162. * @param particle is the particle we are computed the direction for
  92163. * @param isLocal defines if the direction should be set in local space
  92164. */
  92165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92166. /**
  92167. * Called by the particle System when the position is computed for the created particle.
  92168. * @param worldMatrix is the world matrix of the particle system
  92169. * @param positionToUpdate is the position vector to update with the result
  92170. * @param particle is the particle we are computed the position for
  92171. * @param isLocal defines if the position should be set in local space
  92172. */
  92173. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92174. /**
  92175. * Clones the current emitter and returns a copy of it
  92176. * @returns the new emitter
  92177. */
  92178. clone(): CylinderParticleEmitter;
  92179. /**
  92180. * Called by the GPUParticleSystem to setup the update shader
  92181. * @param effect defines the update shader
  92182. */
  92183. applyToShader(effect: Effect): void;
  92184. /**
  92185. * Returns a string to use to update the GPU particles update shader
  92186. * @returns a string containng the defines string
  92187. */
  92188. getEffectDefines(): string;
  92189. /**
  92190. * Returns the string "CylinderParticleEmitter"
  92191. * @returns a string containing the class name
  92192. */
  92193. getClassName(): string;
  92194. /**
  92195. * Serializes the particle system to a JSON object.
  92196. * @returns the JSON object
  92197. */
  92198. serialize(): any;
  92199. /**
  92200. * Parse properties from a JSON object
  92201. * @param serializationObject defines the JSON object
  92202. */
  92203. parse(serializationObject: any): void;
  92204. }
  92205. /**
  92206. * Particle emitter emitting particles from the inside of a cylinder.
  92207. * It emits the particles randomly between two vectors.
  92208. */
  92209. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92210. /**
  92211. * The min limit of the emission direction.
  92212. */
  92213. direction1: Vector3;
  92214. /**
  92215. * The max limit of the emission direction.
  92216. */
  92217. direction2: Vector3;
  92218. /**
  92219. * Creates a new instance CylinderDirectedParticleEmitter
  92220. * @param radius the radius of the emission cylinder (1 by default)
  92221. * @param height the height of the emission cylinder (1 by default)
  92222. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92223. * @param direction1 the min limit of the emission direction (up vector by default)
  92224. * @param direction2 the max limit of the emission direction (up vector by default)
  92225. */
  92226. constructor(radius?: number, height?: number, radiusRange?: number,
  92227. /**
  92228. * The min limit of the emission direction.
  92229. */
  92230. direction1?: Vector3,
  92231. /**
  92232. * The max limit of the emission direction.
  92233. */
  92234. direction2?: Vector3);
  92235. /**
  92236. * Called by the particle System when the direction is computed for the created particle.
  92237. * @param worldMatrix is the world matrix of the particle system
  92238. * @param directionToUpdate is the direction vector to update with the result
  92239. * @param particle is the particle we are computed the direction for
  92240. */
  92241. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92242. /**
  92243. * Clones the current emitter and returns a copy of it
  92244. * @returns the new emitter
  92245. */
  92246. clone(): CylinderDirectedParticleEmitter;
  92247. /**
  92248. * Called by the GPUParticleSystem to setup the update shader
  92249. * @param effect defines the update shader
  92250. */
  92251. applyToShader(effect: Effect): void;
  92252. /**
  92253. * Returns a string to use to update the GPU particles update shader
  92254. * @returns a string containng the defines string
  92255. */
  92256. getEffectDefines(): string;
  92257. /**
  92258. * Returns the string "CylinderDirectedParticleEmitter"
  92259. * @returns a string containing the class name
  92260. */
  92261. getClassName(): string;
  92262. /**
  92263. * Serializes the particle system to a JSON object.
  92264. * @returns the JSON object
  92265. */
  92266. serialize(): any;
  92267. /**
  92268. * Parse properties from a JSON object
  92269. * @param serializationObject defines the JSON object
  92270. */
  92271. parse(serializationObject: any): void;
  92272. }
  92273. }
  92274. declare module BABYLON {
  92275. /**
  92276. * Particle emitter emitting particles from the inside of a hemisphere.
  92277. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92278. */
  92279. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92280. /**
  92281. * The radius of the emission hemisphere.
  92282. */
  92283. radius: number;
  92284. /**
  92285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92286. */
  92287. radiusRange: number;
  92288. /**
  92289. * How much to randomize the particle direction [0-1].
  92290. */
  92291. directionRandomizer: number;
  92292. /**
  92293. * Creates a new instance HemisphericParticleEmitter
  92294. * @param radius the radius of the emission hemisphere (1 by default)
  92295. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92296. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92297. */
  92298. constructor(
  92299. /**
  92300. * The radius of the emission hemisphere.
  92301. */
  92302. radius?: number,
  92303. /**
  92304. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92305. */
  92306. radiusRange?: number,
  92307. /**
  92308. * How much to randomize the particle direction [0-1].
  92309. */
  92310. directionRandomizer?: number);
  92311. /**
  92312. * Called by the particle System when the direction is computed for the created particle.
  92313. * @param worldMatrix is the world matrix of the particle system
  92314. * @param directionToUpdate is the direction vector to update with the result
  92315. * @param particle is the particle we are computed the direction for
  92316. * @param isLocal defines if the direction should be set in local space
  92317. */
  92318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92319. /**
  92320. * Called by the particle System when the position is computed for the created particle.
  92321. * @param worldMatrix is the world matrix of the particle system
  92322. * @param positionToUpdate is the position vector to update with the result
  92323. * @param particle is the particle we are computed the position for
  92324. * @param isLocal defines if the position should be set in local space
  92325. */
  92326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92327. /**
  92328. * Clones the current emitter and returns a copy of it
  92329. * @returns the new emitter
  92330. */
  92331. clone(): HemisphericParticleEmitter;
  92332. /**
  92333. * Called by the GPUParticleSystem to setup the update shader
  92334. * @param effect defines the update shader
  92335. */
  92336. applyToShader(effect: Effect): void;
  92337. /**
  92338. * Returns a string to use to update the GPU particles update shader
  92339. * @returns a string containng the defines string
  92340. */
  92341. getEffectDefines(): string;
  92342. /**
  92343. * Returns the string "HemisphericParticleEmitter"
  92344. * @returns a string containing the class name
  92345. */
  92346. getClassName(): string;
  92347. /**
  92348. * Serializes the particle system to a JSON object.
  92349. * @returns the JSON object
  92350. */
  92351. serialize(): any;
  92352. /**
  92353. * Parse properties from a JSON object
  92354. * @param serializationObject defines the JSON object
  92355. */
  92356. parse(serializationObject: any): void;
  92357. }
  92358. }
  92359. declare module BABYLON {
  92360. /**
  92361. * Particle emitter emitting particles from a point.
  92362. * It emits the particles randomly between 2 given directions.
  92363. */
  92364. export class PointParticleEmitter implements IParticleEmitterType {
  92365. /**
  92366. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92367. */
  92368. direction1: Vector3;
  92369. /**
  92370. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92371. */
  92372. direction2: Vector3;
  92373. /**
  92374. * Creates a new instance PointParticleEmitter
  92375. */
  92376. constructor();
  92377. /**
  92378. * Called by the particle System when the direction is computed for the created particle.
  92379. * @param worldMatrix is the world matrix of the particle system
  92380. * @param directionToUpdate is the direction vector to update with the result
  92381. * @param particle is the particle we are computed the direction for
  92382. * @param isLocal defines if the direction should be set in local space
  92383. */
  92384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92385. /**
  92386. * Called by the particle System when the position is computed for the created particle.
  92387. * @param worldMatrix is the world matrix of the particle system
  92388. * @param positionToUpdate is the position vector to update with the result
  92389. * @param particle is the particle we are computed the position for
  92390. * @param isLocal defines if the position should be set in local space
  92391. */
  92392. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92393. /**
  92394. * Clones the current emitter and returns a copy of it
  92395. * @returns the new emitter
  92396. */
  92397. clone(): PointParticleEmitter;
  92398. /**
  92399. * Called by the GPUParticleSystem to setup the update shader
  92400. * @param effect defines the update shader
  92401. */
  92402. applyToShader(effect: Effect): void;
  92403. /**
  92404. * Returns a string to use to update the GPU particles update shader
  92405. * @returns a string containng the defines string
  92406. */
  92407. getEffectDefines(): string;
  92408. /**
  92409. * Returns the string "PointParticleEmitter"
  92410. * @returns a string containing the class name
  92411. */
  92412. getClassName(): string;
  92413. /**
  92414. * Serializes the particle system to a JSON object.
  92415. * @returns the JSON object
  92416. */
  92417. serialize(): any;
  92418. /**
  92419. * Parse properties from a JSON object
  92420. * @param serializationObject defines the JSON object
  92421. */
  92422. parse(serializationObject: any): void;
  92423. }
  92424. }
  92425. declare module BABYLON {
  92426. /**
  92427. * Particle emitter emitting particles from the inside of a sphere.
  92428. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92429. */
  92430. export class SphereParticleEmitter implements IParticleEmitterType {
  92431. /**
  92432. * The radius of the emission sphere.
  92433. */
  92434. radius: number;
  92435. /**
  92436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92437. */
  92438. radiusRange: number;
  92439. /**
  92440. * How much to randomize the particle direction [0-1].
  92441. */
  92442. directionRandomizer: number;
  92443. /**
  92444. * Creates a new instance SphereParticleEmitter
  92445. * @param radius the radius of the emission sphere (1 by default)
  92446. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92447. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92448. */
  92449. constructor(
  92450. /**
  92451. * The radius of the emission sphere.
  92452. */
  92453. radius?: number,
  92454. /**
  92455. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92456. */
  92457. radiusRange?: number,
  92458. /**
  92459. * How much to randomize the particle direction [0-1].
  92460. */
  92461. directionRandomizer?: number);
  92462. /**
  92463. * Called by the particle System when the direction is computed for the created particle.
  92464. * @param worldMatrix is the world matrix of the particle system
  92465. * @param directionToUpdate is the direction vector to update with the result
  92466. * @param particle is the particle we are computed the direction for
  92467. * @param isLocal defines if the direction should be set in local space
  92468. */
  92469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92470. /**
  92471. * Called by the particle System when the position is computed for the created particle.
  92472. * @param worldMatrix is the world matrix of the particle system
  92473. * @param positionToUpdate is the position vector to update with the result
  92474. * @param particle is the particle we are computed the position for
  92475. * @param isLocal defines if the position should be set in local space
  92476. */
  92477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92478. /**
  92479. * Clones the current emitter and returns a copy of it
  92480. * @returns the new emitter
  92481. */
  92482. clone(): SphereParticleEmitter;
  92483. /**
  92484. * Called by the GPUParticleSystem to setup the update shader
  92485. * @param effect defines the update shader
  92486. */
  92487. applyToShader(effect: Effect): void;
  92488. /**
  92489. * Returns a string to use to update the GPU particles update shader
  92490. * @returns a string containng the defines string
  92491. */
  92492. getEffectDefines(): string;
  92493. /**
  92494. * Returns the string "SphereParticleEmitter"
  92495. * @returns a string containing the class name
  92496. */
  92497. getClassName(): string;
  92498. /**
  92499. * Serializes the particle system to a JSON object.
  92500. * @returns the JSON object
  92501. */
  92502. serialize(): any;
  92503. /**
  92504. * Parse properties from a JSON object
  92505. * @param serializationObject defines the JSON object
  92506. */
  92507. parse(serializationObject: any): void;
  92508. }
  92509. /**
  92510. * Particle emitter emitting particles from the inside of a sphere.
  92511. * It emits the particles randomly between two vectors.
  92512. */
  92513. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92514. /**
  92515. * The min limit of the emission direction.
  92516. */
  92517. direction1: Vector3;
  92518. /**
  92519. * The max limit of the emission direction.
  92520. */
  92521. direction2: Vector3;
  92522. /**
  92523. * Creates a new instance SphereDirectedParticleEmitter
  92524. * @param radius the radius of the emission sphere (1 by default)
  92525. * @param direction1 the min limit of the emission direction (up vector by default)
  92526. * @param direction2 the max limit of the emission direction (up vector by default)
  92527. */
  92528. constructor(radius?: number,
  92529. /**
  92530. * The min limit of the emission direction.
  92531. */
  92532. direction1?: Vector3,
  92533. /**
  92534. * The max limit of the emission direction.
  92535. */
  92536. direction2?: Vector3);
  92537. /**
  92538. * Called by the particle System when the direction is computed for the created particle.
  92539. * @param worldMatrix is the world matrix of the particle system
  92540. * @param directionToUpdate is the direction vector to update with the result
  92541. * @param particle is the particle we are computed the direction for
  92542. */
  92543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92544. /**
  92545. * Clones the current emitter and returns a copy of it
  92546. * @returns the new emitter
  92547. */
  92548. clone(): SphereDirectedParticleEmitter;
  92549. /**
  92550. * Called by the GPUParticleSystem to setup the update shader
  92551. * @param effect defines the update shader
  92552. */
  92553. applyToShader(effect: Effect): void;
  92554. /**
  92555. * Returns a string to use to update the GPU particles update shader
  92556. * @returns a string containng the defines string
  92557. */
  92558. getEffectDefines(): string;
  92559. /**
  92560. * Returns the string "SphereDirectedParticleEmitter"
  92561. * @returns a string containing the class name
  92562. */
  92563. getClassName(): string;
  92564. /**
  92565. * Serializes the particle system to a JSON object.
  92566. * @returns the JSON object
  92567. */
  92568. serialize(): any;
  92569. /**
  92570. * Parse properties from a JSON object
  92571. * @param serializationObject defines the JSON object
  92572. */
  92573. parse(serializationObject: any): void;
  92574. }
  92575. }
  92576. declare module BABYLON {
  92577. /**
  92578. * Particle emitter emitting particles from a custom list of positions.
  92579. */
  92580. export class CustomParticleEmitter implements IParticleEmitterType {
  92581. /**
  92582. * Gets or sets the position generator that will create the inital position of each particle.
  92583. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92584. */
  92585. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92586. /**
  92587. * Gets or sets the destination generator that will create the final destination of each particle.
  92588. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92589. */
  92590. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92591. /**
  92592. * Creates a new instance CustomParticleEmitter
  92593. */
  92594. constructor();
  92595. /**
  92596. * Called by the particle System when the direction is computed for the created particle.
  92597. * @param worldMatrix is the world matrix of the particle system
  92598. * @param directionToUpdate is the direction vector to update with the result
  92599. * @param particle is the particle we are computed the direction for
  92600. * @param isLocal defines if the direction should be set in local space
  92601. */
  92602. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92603. /**
  92604. * Called by the particle System when the position is computed for the created particle.
  92605. * @param worldMatrix is the world matrix of the particle system
  92606. * @param positionToUpdate is the position vector to update with the result
  92607. * @param particle is the particle we are computed the position for
  92608. * @param isLocal defines if the position should be set in local space
  92609. */
  92610. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92611. /**
  92612. * Clones the current emitter and returns a copy of it
  92613. * @returns the new emitter
  92614. */
  92615. clone(): CustomParticleEmitter;
  92616. /**
  92617. * Called by the GPUParticleSystem to setup the update shader
  92618. * @param effect defines the update shader
  92619. */
  92620. applyToShader(effect: Effect): void;
  92621. /**
  92622. * Returns a string to use to update the GPU particles update shader
  92623. * @returns a string containng the defines string
  92624. */
  92625. getEffectDefines(): string;
  92626. /**
  92627. * Returns the string "PointParticleEmitter"
  92628. * @returns a string containing the class name
  92629. */
  92630. getClassName(): string;
  92631. /**
  92632. * Serializes the particle system to a JSON object.
  92633. * @returns the JSON object
  92634. */
  92635. serialize(): any;
  92636. /**
  92637. * Parse properties from a JSON object
  92638. * @param serializationObject defines the JSON object
  92639. */
  92640. parse(serializationObject: any): void;
  92641. }
  92642. }
  92643. declare module BABYLON {
  92644. /**
  92645. * Particle emitter emitting particles from the inside of a box.
  92646. * It emits the particles randomly between 2 given directions.
  92647. */
  92648. export class MeshParticleEmitter implements IParticleEmitterType {
  92649. private _indices;
  92650. private _positions;
  92651. private _normals;
  92652. private _storedNormal;
  92653. private _mesh;
  92654. /**
  92655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92656. */
  92657. direction1: Vector3;
  92658. /**
  92659. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92660. */
  92661. direction2: Vector3;
  92662. /**
  92663. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92664. */
  92665. useMeshNormalsForDirection: boolean;
  92666. /** Defines the mesh to use as source */
  92667. get mesh(): Nullable<AbstractMesh>;
  92668. set mesh(value: Nullable<AbstractMesh>);
  92669. /**
  92670. * Creates a new instance MeshParticleEmitter
  92671. * @param mesh defines the mesh to use as source
  92672. */
  92673. constructor(mesh?: Nullable<AbstractMesh>);
  92674. /**
  92675. * Called by the particle System when the direction is computed for the created particle.
  92676. * @param worldMatrix is the world matrix of the particle system
  92677. * @param directionToUpdate is the direction vector to update with the result
  92678. * @param particle is the particle we are computed the direction for
  92679. * @param isLocal defines if the direction should be set in local space
  92680. */
  92681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92682. /**
  92683. * Called by the particle System when the position is computed for the created particle.
  92684. * @param worldMatrix is the world matrix of the particle system
  92685. * @param positionToUpdate is the position vector to update with the result
  92686. * @param particle is the particle we are computed the position for
  92687. * @param isLocal defines if the position should be set in local space
  92688. */
  92689. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92690. /**
  92691. * Clones the current emitter and returns a copy of it
  92692. * @returns the new emitter
  92693. */
  92694. clone(): MeshParticleEmitter;
  92695. /**
  92696. * Called by the GPUParticleSystem to setup the update shader
  92697. * @param effect defines the update shader
  92698. */
  92699. applyToShader(effect: Effect): void;
  92700. /**
  92701. * Returns a string to use to update the GPU particles update shader
  92702. * @returns a string containng the defines string
  92703. */
  92704. getEffectDefines(): string;
  92705. /**
  92706. * Returns the string "BoxParticleEmitter"
  92707. * @returns a string containing the class name
  92708. */
  92709. getClassName(): string;
  92710. /**
  92711. * Serializes the particle system to a JSON object.
  92712. * @returns the JSON object
  92713. */
  92714. serialize(): any;
  92715. /**
  92716. * Parse properties from a JSON object
  92717. * @param serializationObject defines the JSON object
  92718. * @param scene defines the hosting scene
  92719. */
  92720. parse(serializationObject: any, scene: Scene): void;
  92721. }
  92722. }
  92723. declare module BABYLON {
  92724. /**
  92725. * Interface representing a particle system in Babylon.js.
  92726. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92727. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92728. */
  92729. export interface IParticleSystem {
  92730. /**
  92731. * List of animations used by the particle system.
  92732. */
  92733. animations: Animation[];
  92734. /**
  92735. * The id of the Particle system.
  92736. */
  92737. id: string;
  92738. /**
  92739. * The name of the Particle system.
  92740. */
  92741. name: string;
  92742. /**
  92743. * The emitter represents the Mesh or position we are attaching the particle system to.
  92744. */
  92745. emitter: Nullable<AbstractMesh | Vector3>;
  92746. /**
  92747. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92748. */
  92749. isBillboardBased: boolean;
  92750. /**
  92751. * The rendering group used by the Particle system to chose when to render.
  92752. */
  92753. renderingGroupId: number;
  92754. /**
  92755. * The layer mask we are rendering the particles through.
  92756. */
  92757. layerMask: number;
  92758. /**
  92759. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92760. */
  92761. updateSpeed: number;
  92762. /**
  92763. * The amount of time the particle system is running (depends of the overall update speed).
  92764. */
  92765. targetStopDuration: number;
  92766. /**
  92767. * The texture used to render each particle. (this can be a spritesheet)
  92768. */
  92769. particleTexture: Nullable<Texture>;
  92770. /**
  92771. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92772. */
  92773. blendMode: number;
  92774. /**
  92775. * Minimum life time of emitting particles.
  92776. */
  92777. minLifeTime: number;
  92778. /**
  92779. * Maximum life time of emitting particles.
  92780. */
  92781. maxLifeTime: number;
  92782. /**
  92783. * Minimum Size of emitting particles.
  92784. */
  92785. minSize: number;
  92786. /**
  92787. * Maximum Size of emitting particles.
  92788. */
  92789. maxSize: number;
  92790. /**
  92791. * Minimum scale of emitting particles on X axis.
  92792. */
  92793. minScaleX: number;
  92794. /**
  92795. * Maximum scale of emitting particles on X axis.
  92796. */
  92797. maxScaleX: number;
  92798. /**
  92799. * Minimum scale of emitting particles on Y axis.
  92800. */
  92801. minScaleY: number;
  92802. /**
  92803. * Maximum scale of emitting particles on Y axis.
  92804. */
  92805. maxScaleY: number;
  92806. /**
  92807. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92808. */
  92809. color1: Color4;
  92810. /**
  92811. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92812. */
  92813. color2: Color4;
  92814. /**
  92815. * Color the particle will have at the end of its lifetime.
  92816. */
  92817. colorDead: Color4;
  92818. /**
  92819. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92820. */
  92821. emitRate: number;
  92822. /**
  92823. * You can use gravity if you want to give an orientation to your particles.
  92824. */
  92825. gravity: Vector3;
  92826. /**
  92827. * Minimum power of emitting particles.
  92828. */
  92829. minEmitPower: number;
  92830. /**
  92831. * Maximum power of emitting particles.
  92832. */
  92833. maxEmitPower: number;
  92834. /**
  92835. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92836. */
  92837. minAngularSpeed: number;
  92838. /**
  92839. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92840. */
  92841. maxAngularSpeed: number;
  92842. /**
  92843. * Gets or sets the minimal initial rotation in radians.
  92844. */
  92845. minInitialRotation: number;
  92846. /**
  92847. * Gets or sets the maximal initial rotation in radians.
  92848. */
  92849. maxInitialRotation: number;
  92850. /**
  92851. * The particle emitter type defines the emitter used by the particle system.
  92852. * It can be for example box, sphere, or cone...
  92853. */
  92854. particleEmitterType: Nullable<IParticleEmitterType>;
  92855. /**
  92856. * Defines the delay in milliseconds before starting the system (0 by default)
  92857. */
  92858. startDelay: number;
  92859. /**
  92860. * 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
  92861. */
  92862. preWarmCycles: number;
  92863. /**
  92864. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92865. */
  92866. preWarmStepOffset: number;
  92867. /**
  92868. * 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)
  92869. */
  92870. spriteCellChangeSpeed: number;
  92871. /**
  92872. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92873. */
  92874. startSpriteCellID: number;
  92875. /**
  92876. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92877. */
  92878. endSpriteCellID: number;
  92879. /**
  92880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92881. */
  92882. spriteCellWidth: number;
  92883. /**
  92884. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92885. */
  92886. spriteCellHeight: number;
  92887. /**
  92888. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92889. */
  92890. spriteRandomStartCell: boolean;
  92891. /**
  92892. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92893. */
  92894. isAnimationSheetEnabled: boolean;
  92895. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92896. translationPivot: Vector2;
  92897. /**
  92898. * Gets or sets a texture used to add random noise to particle positions
  92899. */
  92900. noiseTexture: Nullable<BaseTexture>;
  92901. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92902. noiseStrength: Vector3;
  92903. /**
  92904. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92905. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92906. */
  92907. billboardMode: number;
  92908. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92909. limitVelocityDamping: number;
  92910. /**
  92911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92912. */
  92913. beginAnimationOnStart: boolean;
  92914. /**
  92915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92916. */
  92917. beginAnimationFrom: number;
  92918. /**
  92919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92920. */
  92921. beginAnimationTo: number;
  92922. /**
  92923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92924. */
  92925. beginAnimationLoop: boolean;
  92926. /**
  92927. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92928. */
  92929. disposeOnStop: boolean;
  92930. /**
  92931. * Specifies if the particles are updated in emitter local space or world space
  92932. */
  92933. isLocal: boolean;
  92934. /** Snippet ID if the particle system was created from the snippet server */
  92935. snippetId: string;
  92936. /**
  92937. * Gets the maximum number of particles active at the same time.
  92938. * @returns The max number of active particles.
  92939. */
  92940. getCapacity(): number;
  92941. /**
  92942. * Gets the number of particles active at the same time.
  92943. * @returns The number of active particles.
  92944. */
  92945. getActiveCount(): number;
  92946. /**
  92947. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92948. * @returns True if it has been started, otherwise false.
  92949. */
  92950. isStarted(): boolean;
  92951. /**
  92952. * Animates the particle system for this frame.
  92953. */
  92954. animate(): void;
  92955. /**
  92956. * Renders the particle system in its current state.
  92957. * @returns the current number of particles
  92958. */
  92959. render(): number;
  92960. /**
  92961. * Dispose the particle system and frees its associated resources.
  92962. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92963. */
  92964. dispose(disposeTexture?: boolean): void;
  92965. /**
  92966. * An event triggered when the system is disposed
  92967. */
  92968. onDisposeObservable: Observable<IParticleSystem>;
  92969. /**
  92970. * Clones the particle system.
  92971. * @param name The name of the cloned object
  92972. * @param newEmitter The new emitter to use
  92973. * @returns the cloned particle system
  92974. */
  92975. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92976. /**
  92977. * Serializes the particle system to a JSON object
  92978. * @param serializeTexture defines if the texture must be serialized as well
  92979. * @returns the JSON object
  92980. */
  92981. serialize(serializeTexture: boolean): any;
  92982. /**
  92983. * Rebuild the particle system
  92984. */
  92985. rebuild(): void;
  92986. /** Force the system to rebuild all gradients that need to be resync */
  92987. forceRefreshGradients(): void;
  92988. /**
  92989. * Starts the particle system and begins to emit
  92990. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92991. */
  92992. start(delay?: number): void;
  92993. /**
  92994. * Stops the particle system.
  92995. */
  92996. stop(): void;
  92997. /**
  92998. * Remove all active particles
  92999. */
  93000. reset(): void;
  93001. /**
  93002. * Gets a boolean indicating that the system is stopping
  93003. * @returns true if the system is currently stopping
  93004. */
  93005. isStopping(): boolean;
  93006. /**
  93007. * Is this system ready to be used/rendered
  93008. * @return true if the system is ready
  93009. */
  93010. isReady(): boolean;
  93011. /**
  93012. * Returns the string "ParticleSystem"
  93013. * @returns a string containing the class name
  93014. */
  93015. getClassName(): string;
  93016. /**
  93017. * Gets the custom effect used to render the particles
  93018. * @param blendMode Blend mode for which the effect should be retrieved
  93019. * @returns The effect
  93020. */
  93021. getCustomEffect(blendMode: number): Nullable<Effect>;
  93022. /**
  93023. * Sets the custom effect used to render the particles
  93024. * @param effect The effect to set
  93025. * @param blendMode Blend mode for which the effect should be set
  93026. */
  93027. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93028. /**
  93029. * Fill the defines array according to the current settings of the particle system
  93030. * @param defines Array to be updated
  93031. * @param blendMode blend mode to take into account when updating the array
  93032. */
  93033. fillDefines(defines: Array<string>, blendMode: number): void;
  93034. /**
  93035. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93036. * @param uniforms Uniforms array to fill
  93037. * @param attributes Attributes array to fill
  93038. * @param samplers Samplers array to fill
  93039. */
  93040. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93041. /**
  93042. * Observable that will be called just before the particles are drawn
  93043. */
  93044. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93045. /**
  93046. * Gets the name of the particle vertex shader
  93047. */
  93048. vertexShaderName: string;
  93049. /**
  93050. * Adds a new color gradient
  93051. * @param gradient defines the gradient to use (between 0 and 1)
  93052. * @param color1 defines the color to affect to the specified gradient
  93053. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93054. * @returns the current particle system
  93055. */
  93056. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93057. /**
  93058. * Remove a specific color gradient
  93059. * @param gradient defines the gradient to remove
  93060. * @returns the current particle system
  93061. */
  93062. removeColorGradient(gradient: number): IParticleSystem;
  93063. /**
  93064. * Adds a new size gradient
  93065. * @param gradient defines the gradient to use (between 0 and 1)
  93066. * @param factor defines the size factor to affect to the specified gradient
  93067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93068. * @returns the current particle system
  93069. */
  93070. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93071. /**
  93072. * Remove a specific size gradient
  93073. * @param gradient defines the gradient to remove
  93074. * @returns the current particle system
  93075. */
  93076. removeSizeGradient(gradient: number): IParticleSystem;
  93077. /**
  93078. * Gets the current list of color gradients.
  93079. * You must use addColorGradient and removeColorGradient to udpate this list
  93080. * @returns the list of color gradients
  93081. */
  93082. getColorGradients(): Nullable<Array<ColorGradient>>;
  93083. /**
  93084. * Gets the current list of size gradients.
  93085. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93086. * @returns the list of size gradients
  93087. */
  93088. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93089. /**
  93090. * Gets the current list of angular speed gradients.
  93091. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93092. * @returns the list of angular speed gradients
  93093. */
  93094. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93095. /**
  93096. * Adds a new angular speed gradient
  93097. * @param gradient defines the gradient to use (between 0 and 1)
  93098. * @param factor defines the angular speed to affect to the specified gradient
  93099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93100. * @returns the current particle system
  93101. */
  93102. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93103. /**
  93104. * Remove a specific angular speed gradient
  93105. * @param gradient defines the gradient to remove
  93106. * @returns the current particle system
  93107. */
  93108. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93109. /**
  93110. * Gets the current list of velocity gradients.
  93111. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93112. * @returns the list of velocity gradients
  93113. */
  93114. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93115. /**
  93116. * Adds a new velocity gradient
  93117. * @param gradient defines the gradient to use (between 0 and 1)
  93118. * @param factor defines the velocity to affect to the specified gradient
  93119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93120. * @returns the current particle system
  93121. */
  93122. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93123. /**
  93124. * Remove a specific velocity gradient
  93125. * @param gradient defines the gradient to remove
  93126. * @returns the current particle system
  93127. */
  93128. removeVelocityGradient(gradient: number): IParticleSystem;
  93129. /**
  93130. * Gets the current list of limit velocity gradients.
  93131. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93132. * @returns the list of limit velocity gradients
  93133. */
  93134. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93135. /**
  93136. * Adds a new limit velocity gradient
  93137. * @param gradient defines the gradient to use (between 0 and 1)
  93138. * @param factor defines the limit velocity to affect to the specified gradient
  93139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93140. * @returns the current particle system
  93141. */
  93142. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93143. /**
  93144. * Remove a specific limit velocity gradient
  93145. * @param gradient defines the gradient to remove
  93146. * @returns the current particle system
  93147. */
  93148. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93149. /**
  93150. * Adds a new drag gradient
  93151. * @param gradient defines the gradient to use (between 0 and 1)
  93152. * @param factor defines the drag to affect to the specified gradient
  93153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93154. * @returns the current particle system
  93155. */
  93156. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93157. /**
  93158. * Remove a specific drag gradient
  93159. * @param gradient defines the gradient to remove
  93160. * @returns the current particle system
  93161. */
  93162. removeDragGradient(gradient: number): IParticleSystem;
  93163. /**
  93164. * Gets the current list of drag gradients.
  93165. * You must use addDragGradient and removeDragGradient to udpate this list
  93166. * @returns the list of drag gradients
  93167. */
  93168. getDragGradients(): Nullable<Array<FactorGradient>>;
  93169. /**
  93170. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93171. * @param gradient defines the gradient to use (between 0 and 1)
  93172. * @param factor defines the emit rate to affect to the specified gradient
  93173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93174. * @returns the current particle system
  93175. */
  93176. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93177. /**
  93178. * Remove a specific emit rate gradient
  93179. * @param gradient defines the gradient to remove
  93180. * @returns the current particle system
  93181. */
  93182. removeEmitRateGradient(gradient: number): IParticleSystem;
  93183. /**
  93184. * Gets the current list of emit rate gradients.
  93185. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93186. * @returns the list of emit rate gradients
  93187. */
  93188. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93189. /**
  93190. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93191. * @param gradient defines the gradient to use (between 0 and 1)
  93192. * @param factor defines the start size to affect to the specified gradient
  93193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93194. * @returns the current particle system
  93195. */
  93196. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93197. /**
  93198. * Remove a specific start size gradient
  93199. * @param gradient defines the gradient to remove
  93200. * @returns the current particle system
  93201. */
  93202. removeStartSizeGradient(gradient: number): IParticleSystem;
  93203. /**
  93204. * Gets the current list of start size gradients.
  93205. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93206. * @returns the list of start size gradients
  93207. */
  93208. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93209. /**
  93210. * Adds a new life time gradient
  93211. * @param gradient defines the gradient to use (between 0 and 1)
  93212. * @param factor defines the life time factor to affect to the specified gradient
  93213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93214. * @returns the current particle system
  93215. */
  93216. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93217. /**
  93218. * Remove a specific life time gradient
  93219. * @param gradient defines the gradient to remove
  93220. * @returns the current particle system
  93221. */
  93222. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93223. /**
  93224. * Gets the current list of life time gradients.
  93225. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93226. * @returns the list of life time gradients
  93227. */
  93228. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93229. /**
  93230. * Gets the current list of color gradients.
  93231. * You must use addColorGradient and removeColorGradient to udpate this list
  93232. * @returns the list of color gradients
  93233. */
  93234. getColorGradients(): Nullable<Array<ColorGradient>>;
  93235. /**
  93236. * Adds a new ramp gradient used to remap particle colors
  93237. * @param gradient defines the gradient to use (between 0 and 1)
  93238. * @param color defines the color to affect to the specified gradient
  93239. * @returns the current particle system
  93240. */
  93241. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93242. /**
  93243. * Gets the current list of ramp gradients.
  93244. * You must use addRampGradient and removeRampGradient to udpate this list
  93245. * @returns the list of ramp gradients
  93246. */
  93247. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93248. /** Gets or sets a boolean indicating that ramp gradients must be used
  93249. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93250. */
  93251. useRampGradients: boolean;
  93252. /**
  93253. * Adds a new color remap gradient
  93254. * @param gradient defines the gradient to use (between 0 and 1)
  93255. * @param min defines the color remap minimal range
  93256. * @param max defines the color remap maximal range
  93257. * @returns the current particle system
  93258. */
  93259. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93260. /**
  93261. * Gets the current list of color remap gradients.
  93262. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93263. * @returns the list of color remap gradients
  93264. */
  93265. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93266. /**
  93267. * Adds a new alpha remap gradient
  93268. * @param gradient defines the gradient to use (between 0 and 1)
  93269. * @param min defines the alpha remap minimal range
  93270. * @param max defines the alpha remap maximal range
  93271. * @returns the current particle system
  93272. */
  93273. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93274. /**
  93275. * Gets the current list of alpha remap gradients.
  93276. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93277. * @returns the list of alpha remap gradients
  93278. */
  93279. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93280. /**
  93281. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93282. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93283. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93284. * @returns the emitter
  93285. */
  93286. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93287. /**
  93288. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93289. * @param radius The radius of the hemisphere to emit from
  93290. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93291. * @returns the emitter
  93292. */
  93293. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93294. /**
  93295. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93296. * @param radius The radius of the sphere to emit from
  93297. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93298. * @returns the emitter
  93299. */
  93300. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93301. /**
  93302. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93303. * @param radius The radius of the sphere to emit from
  93304. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93305. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93306. * @returns the emitter
  93307. */
  93308. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93309. /**
  93310. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93311. * @param radius The radius of the emission cylinder
  93312. * @param height The height of the emission cylinder
  93313. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93314. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93315. * @returns the emitter
  93316. */
  93317. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93318. /**
  93319. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93320. * @param radius The radius of the cylinder to emit from
  93321. * @param height The height of the emission cylinder
  93322. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93323. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93324. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93325. * @returns the emitter
  93326. */
  93327. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93328. /**
  93329. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93330. * @param radius The radius of the cone to emit from
  93331. * @param angle The base angle of the cone
  93332. * @returns the emitter
  93333. */
  93334. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93335. /**
  93336. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93337. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93338. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93339. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93340. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93341. * @returns the emitter
  93342. */
  93343. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93344. /**
  93345. * Get hosting scene
  93346. * @returns the scene
  93347. */
  93348. getScene(): Scene;
  93349. }
  93350. }
  93351. declare module BABYLON {
  93352. /**
  93353. * 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.
  93354. * @see https://doc.babylonjs.com/how_to/transformnode
  93355. */
  93356. export class TransformNode extends Node {
  93357. /**
  93358. * Object will not rotate to face the camera
  93359. */
  93360. static BILLBOARDMODE_NONE: number;
  93361. /**
  93362. * Object will rotate to face the camera but only on the x axis
  93363. */
  93364. static BILLBOARDMODE_X: number;
  93365. /**
  93366. * Object will rotate to face the camera but only on the y axis
  93367. */
  93368. static BILLBOARDMODE_Y: number;
  93369. /**
  93370. * Object will rotate to face the camera but only on the z axis
  93371. */
  93372. static BILLBOARDMODE_Z: number;
  93373. /**
  93374. * Object will rotate to face the camera
  93375. */
  93376. static BILLBOARDMODE_ALL: number;
  93377. /**
  93378. * Object will rotate to face the camera's position instead of orientation
  93379. */
  93380. static BILLBOARDMODE_USE_POSITION: number;
  93381. private static _TmpRotation;
  93382. private static _TmpScaling;
  93383. private static _TmpTranslation;
  93384. private _forward;
  93385. private _forwardInverted;
  93386. private _up;
  93387. private _right;
  93388. private _rightInverted;
  93389. private _position;
  93390. private _rotation;
  93391. private _rotationQuaternion;
  93392. protected _scaling: Vector3;
  93393. protected _isDirty: boolean;
  93394. private _transformToBoneReferal;
  93395. private _isAbsoluteSynced;
  93396. private _billboardMode;
  93397. /**
  93398. * Gets or sets the billboard mode. Default is 0.
  93399. *
  93400. * | Value | Type | Description |
  93401. * | --- | --- | --- |
  93402. * | 0 | BILLBOARDMODE_NONE | |
  93403. * | 1 | BILLBOARDMODE_X | |
  93404. * | 2 | BILLBOARDMODE_Y | |
  93405. * | 4 | BILLBOARDMODE_Z | |
  93406. * | 7 | BILLBOARDMODE_ALL | |
  93407. *
  93408. */
  93409. get billboardMode(): number;
  93410. set billboardMode(value: number);
  93411. private _preserveParentRotationForBillboard;
  93412. /**
  93413. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93414. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93415. */
  93416. get preserveParentRotationForBillboard(): boolean;
  93417. set preserveParentRotationForBillboard(value: boolean);
  93418. /**
  93419. * 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
  93420. */
  93421. scalingDeterminant: number;
  93422. private _infiniteDistance;
  93423. /**
  93424. * Gets or sets the distance of the object to max, often used by skybox
  93425. */
  93426. get infiniteDistance(): boolean;
  93427. set infiniteDistance(value: boolean);
  93428. /**
  93429. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93430. * By default the system will update normals to compensate
  93431. */
  93432. ignoreNonUniformScaling: boolean;
  93433. /**
  93434. * 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
  93435. */
  93436. reIntegrateRotationIntoRotationQuaternion: boolean;
  93437. /** @hidden */
  93438. _poseMatrix: Nullable<Matrix>;
  93439. /** @hidden */
  93440. _localMatrix: Matrix;
  93441. private _usePivotMatrix;
  93442. private _absolutePosition;
  93443. private _absoluteScaling;
  93444. private _absoluteRotationQuaternion;
  93445. private _pivotMatrix;
  93446. private _pivotMatrixInverse;
  93447. protected _postMultiplyPivotMatrix: boolean;
  93448. protected _isWorldMatrixFrozen: boolean;
  93449. /** @hidden */
  93450. _indexInSceneTransformNodesArray: number;
  93451. /**
  93452. * An event triggered after the world matrix is updated
  93453. */
  93454. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93455. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93456. /**
  93457. * Gets a string identifying the name of the class
  93458. * @returns "TransformNode" string
  93459. */
  93460. getClassName(): string;
  93461. /**
  93462. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93463. */
  93464. get position(): Vector3;
  93465. set position(newPosition: Vector3);
  93466. /**
  93467. * 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)).
  93468. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93469. */
  93470. get rotation(): Vector3;
  93471. set rotation(newRotation: Vector3);
  93472. /**
  93473. * 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)).
  93474. */
  93475. get scaling(): Vector3;
  93476. set scaling(newScaling: Vector3);
  93477. /**
  93478. * 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).
  93479. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93480. */
  93481. get rotationQuaternion(): Nullable<Quaternion>;
  93482. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93483. /**
  93484. * The forward direction of that transform in world space.
  93485. */
  93486. get forward(): Vector3;
  93487. /**
  93488. * The up direction of that transform in world space.
  93489. */
  93490. get up(): Vector3;
  93491. /**
  93492. * The right direction of that transform in world space.
  93493. */
  93494. get right(): Vector3;
  93495. /**
  93496. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93497. * @param matrix the matrix to copy the pose from
  93498. * @returns this TransformNode.
  93499. */
  93500. updatePoseMatrix(matrix: Matrix): TransformNode;
  93501. /**
  93502. * Returns the mesh Pose matrix.
  93503. * @returns the pose matrix
  93504. */
  93505. getPoseMatrix(): Matrix;
  93506. /** @hidden */
  93507. _isSynchronized(): boolean;
  93508. /** @hidden */
  93509. _initCache(): void;
  93510. /**
  93511. * Flag the transform node as dirty (Forcing it to update everything)
  93512. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93513. * @returns this transform node
  93514. */
  93515. markAsDirty(property: string): TransformNode;
  93516. /**
  93517. * Returns the current mesh absolute position.
  93518. * Returns a Vector3.
  93519. */
  93520. get absolutePosition(): Vector3;
  93521. /**
  93522. * Returns the current mesh absolute scaling.
  93523. * Returns a Vector3.
  93524. */
  93525. get absoluteScaling(): Vector3;
  93526. /**
  93527. * Returns the current mesh absolute rotation.
  93528. * Returns a Quaternion.
  93529. */
  93530. get absoluteRotationQuaternion(): Quaternion;
  93531. /**
  93532. * Sets a new matrix to apply before all other transformation
  93533. * @param matrix defines the transform matrix
  93534. * @returns the current TransformNode
  93535. */
  93536. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93537. /**
  93538. * Sets a new pivot matrix to the current node
  93539. * @param matrix defines the new pivot matrix to use
  93540. * @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
  93541. * @returns the current TransformNode
  93542. */
  93543. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93544. /**
  93545. * Returns the mesh pivot matrix.
  93546. * Default : Identity.
  93547. * @returns the matrix
  93548. */
  93549. getPivotMatrix(): Matrix;
  93550. /**
  93551. * Instantiate (when possible) or clone that node with its hierarchy
  93552. * @param newParent defines the new parent to use for the instance (or clone)
  93553. * @param options defines options to configure how copy is done
  93554. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93555. * @returns an instance (or a clone) of the current node with its hiearchy
  93556. */
  93557. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93558. doNotInstantiate: boolean;
  93559. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93560. /**
  93561. * Prevents the World matrix to be computed any longer
  93562. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93563. * @returns the TransformNode.
  93564. */
  93565. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93566. /**
  93567. * Allows back the World matrix computation.
  93568. * @returns the TransformNode.
  93569. */
  93570. unfreezeWorldMatrix(): this;
  93571. /**
  93572. * True if the World matrix has been frozen.
  93573. */
  93574. get isWorldMatrixFrozen(): boolean;
  93575. /**
  93576. * Retuns the mesh absolute position in the World.
  93577. * @returns a Vector3.
  93578. */
  93579. getAbsolutePosition(): Vector3;
  93580. /**
  93581. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93582. * @param absolutePosition the absolute position to set
  93583. * @returns the TransformNode.
  93584. */
  93585. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93586. /**
  93587. * Sets the mesh position in its local space.
  93588. * @param vector3 the position to set in localspace
  93589. * @returns the TransformNode.
  93590. */
  93591. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93592. /**
  93593. * Returns the mesh position in the local space from the current World matrix values.
  93594. * @returns a new Vector3.
  93595. */
  93596. getPositionExpressedInLocalSpace(): Vector3;
  93597. /**
  93598. * Translates the mesh along the passed Vector3 in its local space.
  93599. * @param vector3 the distance to translate in localspace
  93600. * @returns the TransformNode.
  93601. */
  93602. locallyTranslate(vector3: Vector3): TransformNode;
  93603. private static _lookAtVectorCache;
  93604. /**
  93605. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93606. * @param targetPoint the position (must be in same space as current mesh) to look at
  93607. * @param yawCor optional yaw (y-axis) correction in radians
  93608. * @param pitchCor optional pitch (x-axis) correction in radians
  93609. * @param rollCor optional roll (z-axis) correction in radians
  93610. * @param space the choosen space of the target
  93611. * @returns the TransformNode.
  93612. */
  93613. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93614. /**
  93615. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93616. * This Vector3 is expressed in the World space.
  93617. * @param localAxis axis to rotate
  93618. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93619. */
  93620. getDirection(localAxis: Vector3): Vector3;
  93621. /**
  93622. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93623. * localAxis is expressed in the mesh local space.
  93624. * result is computed in the Wordl space from the mesh World matrix.
  93625. * @param localAxis axis to rotate
  93626. * @param result the resulting transformnode
  93627. * @returns this TransformNode.
  93628. */
  93629. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93630. /**
  93631. * Sets this transform node rotation to the given local axis.
  93632. * @param localAxis the axis in local space
  93633. * @param yawCor optional yaw (y-axis) correction in radians
  93634. * @param pitchCor optional pitch (x-axis) correction in radians
  93635. * @param rollCor optional roll (z-axis) correction in radians
  93636. * @returns this TransformNode
  93637. */
  93638. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93639. /**
  93640. * Sets a new pivot point to the current node
  93641. * @param point defines the new pivot point to use
  93642. * @param space defines if the point is in world or local space (local by default)
  93643. * @returns the current TransformNode
  93644. */
  93645. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93646. /**
  93647. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93648. * @returns the pivot point
  93649. */
  93650. getPivotPoint(): Vector3;
  93651. /**
  93652. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93653. * @param result the vector3 to store the result
  93654. * @returns this TransformNode.
  93655. */
  93656. getPivotPointToRef(result: Vector3): TransformNode;
  93657. /**
  93658. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93659. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93660. */
  93661. getAbsolutePivotPoint(): Vector3;
  93662. /**
  93663. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93664. * @param result vector3 to store the result
  93665. * @returns this TransformNode.
  93666. */
  93667. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93668. /**
  93669. * Defines the passed node as the parent of the current node.
  93670. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93671. * @see https://doc.babylonjs.com/how_to/parenting
  93672. * @param node the node ot set as the parent
  93673. * @returns this TransformNode.
  93674. */
  93675. setParent(node: Nullable<Node>): TransformNode;
  93676. private _nonUniformScaling;
  93677. /**
  93678. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93679. */
  93680. get nonUniformScaling(): boolean;
  93681. /** @hidden */
  93682. _updateNonUniformScalingState(value: boolean): boolean;
  93683. /**
  93684. * Attach the current TransformNode to another TransformNode associated with a bone
  93685. * @param bone Bone affecting the TransformNode
  93686. * @param affectedTransformNode TransformNode associated with the bone
  93687. * @returns this object
  93688. */
  93689. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93690. /**
  93691. * Detach the transform node if its associated with a bone
  93692. * @returns this object
  93693. */
  93694. detachFromBone(): TransformNode;
  93695. private static _rotationAxisCache;
  93696. /**
  93697. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93698. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93699. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93700. * The passed axis is also normalized.
  93701. * @param axis the axis to rotate around
  93702. * @param amount the amount to rotate in radians
  93703. * @param space Space to rotate in (Default: local)
  93704. * @returns the TransformNode.
  93705. */
  93706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93707. /**
  93708. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93709. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93710. * The passed axis is also normalized. .
  93711. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93712. * @param point the point to rotate around
  93713. * @param axis the axis to rotate around
  93714. * @param amount the amount to rotate in radians
  93715. * @returns the TransformNode
  93716. */
  93717. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93718. /**
  93719. * Translates the mesh along the axis vector for the passed distance in the given space.
  93720. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93721. * @param axis the axis to translate in
  93722. * @param distance the distance to translate
  93723. * @param space Space to rotate in (Default: local)
  93724. * @returns the TransformNode.
  93725. */
  93726. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93727. /**
  93728. * Adds a rotation step to the mesh current rotation.
  93729. * x, y, z are Euler angles expressed in radians.
  93730. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93731. * This means this rotation is made in the mesh local space only.
  93732. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93733. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93734. * ```javascript
  93735. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93736. * ```
  93737. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93738. * 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.
  93739. * @param x Rotation to add
  93740. * @param y Rotation to add
  93741. * @param z Rotation to add
  93742. * @returns the TransformNode.
  93743. */
  93744. addRotation(x: number, y: number, z: number): TransformNode;
  93745. /**
  93746. * @hidden
  93747. */
  93748. protected _getEffectiveParent(): Nullable<Node>;
  93749. /**
  93750. * Computes the world matrix of the node
  93751. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93752. * @returns the world matrix
  93753. */
  93754. computeWorldMatrix(force?: boolean): Matrix;
  93755. /**
  93756. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93757. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93758. */
  93759. resetLocalMatrix(independentOfChildren?: boolean): void;
  93760. protected _afterComputeWorldMatrix(): void;
  93761. /**
  93762. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93763. * @param func callback function to add
  93764. *
  93765. * @returns the TransformNode.
  93766. */
  93767. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93768. /**
  93769. * Removes a registered callback function.
  93770. * @param func callback function to remove
  93771. * @returns the TransformNode.
  93772. */
  93773. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93774. /**
  93775. * Gets the position of the current mesh in camera space
  93776. * @param camera defines the camera to use
  93777. * @returns a position
  93778. */
  93779. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93780. /**
  93781. * Returns the distance from the mesh to the active camera
  93782. * @param camera defines the camera to use
  93783. * @returns the distance
  93784. */
  93785. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93786. /**
  93787. * Clone the current transform node
  93788. * @param name Name of the new clone
  93789. * @param newParent New parent for the clone
  93790. * @param doNotCloneChildren Do not clone children hierarchy
  93791. * @returns the new transform node
  93792. */
  93793. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93794. /**
  93795. * Serializes the objects information.
  93796. * @param currentSerializationObject defines the object to serialize in
  93797. * @returns the serialized object
  93798. */
  93799. serialize(currentSerializationObject?: any): any;
  93800. /**
  93801. * Returns a new TransformNode object parsed from the source provided.
  93802. * @param parsedTransformNode is the source.
  93803. * @param scene the scne the object belongs to
  93804. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93805. * @returns a new TransformNode object parsed from the source provided.
  93806. */
  93807. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93808. /**
  93809. * Get all child-transformNodes of this node
  93810. * @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
  93811. * @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
  93812. * @returns an array of TransformNode
  93813. */
  93814. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93815. /**
  93816. * Releases resources associated with this transform node.
  93817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93819. */
  93820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93821. /**
  93822. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93823. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93824. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93825. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93826. * @returns the current mesh
  93827. */
  93828. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93829. private _syncAbsoluteScalingAndRotation;
  93830. }
  93831. }
  93832. declare module BABYLON {
  93833. /**
  93834. * Class used to override all child animations of a given target
  93835. */
  93836. export class AnimationPropertiesOverride {
  93837. /**
  93838. * Gets or sets a value indicating if animation blending must be used
  93839. */
  93840. enableBlending: boolean;
  93841. /**
  93842. * Gets or sets the blending speed to use when enableBlending is true
  93843. */
  93844. blendingSpeed: number;
  93845. /**
  93846. * Gets or sets the default loop mode to use
  93847. */
  93848. loopMode: number;
  93849. }
  93850. }
  93851. declare module BABYLON {
  93852. /**
  93853. * Class used to store bone information
  93854. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93855. */
  93856. export class Bone extends Node {
  93857. /**
  93858. * defines the bone name
  93859. */
  93860. name: string;
  93861. private static _tmpVecs;
  93862. private static _tmpQuat;
  93863. private static _tmpMats;
  93864. /**
  93865. * Gets the list of child bones
  93866. */
  93867. children: Bone[];
  93868. /** Gets the animations associated with this bone */
  93869. animations: Animation[];
  93870. /**
  93871. * Gets or sets bone length
  93872. */
  93873. length: number;
  93874. /**
  93875. * @hidden Internal only
  93876. * Set this value to map this bone to a different index in the transform matrices
  93877. * Set this value to -1 to exclude the bone from the transform matrices
  93878. */
  93879. _index: Nullable<number>;
  93880. private _skeleton;
  93881. private _localMatrix;
  93882. private _restPose;
  93883. private _baseMatrix;
  93884. private _absoluteTransform;
  93885. private _invertedAbsoluteTransform;
  93886. private _parent;
  93887. private _scalingDeterminant;
  93888. private _worldTransform;
  93889. private _localScaling;
  93890. private _localRotation;
  93891. private _localPosition;
  93892. private _needToDecompose;
  93893. private _needToCompose;
  93894. /** @hidden */
  93895. _linkedTransformNode: Nullable<TransformNode>;
  93896. /** @hidden */
  93897. _waitingTransformNodeId: Nullable<string>;
  93898. /** @hidden */
  93899. get _matrix(): Matrix;
  93900. /** @hidden */
  93901. set _matrix(value: Matrix);
  93902. /**
  93903. * Create a new bone
  93904. * @param name defines the bone name
  93905. * @param skeleton defines the parent skeleton
  93906. * @param parentBone defines the parent (can be null if the bone is the root)
  93907. * @param localMatrix defines the local matrix
  93908. * @param restPose defines the rest pose matrix
  93909. * @param baseMatrix defines the base matrix
  93910. * @param index defines index of the bone in the hiearchy
  93911. */
  93912. constructor(
  93913. /**
  93914. * defines the bone name
  93915. */
  93916. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93917. /**
  93918. * Gets the current object class name.
  93919. * @return the class name
  93920. */
  93921. getClassName(): string;
  93922. /**
  93923. * Gets the parent skeleton
  93924. * @returns a skeleton
  93925. */
  93926. getSkeleton(): Skeleton;
  93927. /**
  93928. * Gets parent bone
  93929. * @returns a bone or null if the bone is the root of the bone hierarchy
  93930. */
  93931. getParent(): Nullable<Bone>;
  93932. /**
  93933. * Returns an array containing the root bones
  93934. * @returns an array containing the root bones
  93935. */
  93936. getChildren(): Array<Bone>;
  93937. /**
  93938. * Gets the node index in matrix array generated for rendering
  93939. * @returns the node index
  93940. */
  93941. getIndex(): number;
  93942. /**
  93943. * Sets the parent bone
  93944. * @param parent defines the parent (can be null if the bone is the root)
  93945. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93946. */
  93947. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93948. /**
  93949. * Gets the local matrix
  93950. * @returns a matrix
  93951. */
  93952. getLocalMatrix(): Matrix;
  93953. /**
  93954. * Gets the base matrix (initial matrix which remains unchanged)
  93955. * @returns a matrix
  93956. */
  93957. getBaseMatrix(): Matrix;
  93958. /**
  93959. * Gets the rest pose matrix
  93960. * @returns a matrix
  93961. */
  93962. getRestPose(): Matrix;
  93963. /**
  93964. * Sets the rest pose matrix
  93965. * @param matrix the local-space rest pose to set for this bone
  93966. */
  93967. setRestPose(matrix: Matrix): void;
  93968. /**
  93969. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93970. */
  93971. getWorldMatrix(): Matrix;
  93972. /**
  93973. * Sets the local matrix to rest pose matrix
  93974. */
  93975. returnToRest(): void;
  93976. /**
  93977. * Gets the inverse of the absolute transform matrix.
  93978. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93979. * @returns a matrix
  93980. */
  93981. getInvertedAbsoluteTransform(): Matrix;
  93982. /**
  93983. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93984. * @returns a matrix
  93985. */
  93986. getAbsoluteTransform(): Matrix;
  93987. /**
  93988. * Links with the given transform node.
  93989. * The local matrix of this bone is copied from the transform node every frame.
  93990. * @param transformNode defines the transform node to link to
  93991. */
  93992. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93993. /**
  93994. * Gets the node used to drive the bone's transformation
  93995. * @returns a transform node or null
  93996. */
  93997. getTransformNode(): Nullable<TransformNode>;
  93998. /** Gets or sets current position (in local space) */
  93999. get position(): Vector3;
  94000. set position(newPosition: Vector3);
  94001. /** Gets or sets current rotation (in local space) */
  94002. get rotation(): Vector3;
  94003. set rotation(newRotation: Vector3);
  94004. /** Gets or sets current rotation quaternion (in local space) */
  94005. get rotationQuaternion(): Quaternion;
  94006. set rotationQuaternion(newRotation: Quaternion);
  94007. /** Gets or sets current scaling (in local space) */
  94008. get scaling(): Vector3;
  94009. set scaling(newScaling: Vector3);
  94010. /**
  94011. * Gets the animation properties override
  94012. */
  94013. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94014. private _decompose;
  94015. private _compose;
  94016. /**
  94017. * Update the base and local matrices
  94018. * @param matrix defines the new base or local matrix
  94019. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94020. * @param updateLocalMatrix defines if the local matrix should be updated
  94021. */
  94022. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94023. /** @hidden */
  94024. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94025. /**
  94026. * Flag the bone as dirty (Forcing it to update everything)
  94027. */
  94028. markAsDirty(): void;
  94029. /** @hidden */
  94030. _markAsDirtyAndCompose(): void;
  94031. private _markAsDirtyAndDecompose;
  94032. /**
  94033. * Translate the bone in local or world space
  94034. * @param vec The amount to translate the bone
  94035. * @param space The space that the translation is in
  94036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94037. */
  94038. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94039. /**
  94040. * Set the postion of the bone in local or world space
  94041. * @param position The position to set the bone
  94042. * @param space The space that the position is in
  94043. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94044. */
  94045. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94046. /**
  94047. * Set the absolute position of the bone (world space)
  94048. * @param position The position to set the bone
  94049. * @param mesh The mesh that this bone is attached to
  94050. */
  94051. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94052. /**
  94053. * Scale the bone on the x, y and z axes (in local space)
  94054. * @param x The amount to scale the bone on the x axis
  94055. * @param y The amount to scale the bone on the y axis
  94056. * @param z The amount to scale the bone on the z axis
  94057. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94058. */
  94059. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94060. /**
  94061. * Set the bone scaling in local space
  94062. * @param scale defines the scaling vector
  94063. */
  94064. setScale(scale: Vector3): void;
  94065. /**
  94066. * Gets the current scaling in local space
  94067. * @returns the current scaling vector
  94068. */
  94069. getScale(): Vector3;
  94070. /**
  94071. * Gets the current scaling in local space and stores it in a target vector
  94072. * @param result defines the target vector
  94073. */
  94074. getScaleToRef(result: Vector3): void;
  94075. /**
  94076. * Set the yaw, pitch, and roll of the bone in local or world space
  94077. * @param yaw The rotation of the bone on the y axis
  94078. * @param pitch The rotation of the bone on the x axis
  94079. * @param roll The rotation of the bone on the z axis
  94080. * @param space The space that the axes of rotation are in
  94081. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94082. */
  94083. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94084. /**
  94085. * Add a rotation to the bone on an axis in local or world space
  94086. * @param axis The axis to rotate the bone on
  94087. * @param amount The amount to rotate the bone
  94088. * @param space The space that the axis is in
  94089. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94090. */
  94091. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94092. /**
  94093. * Set the rotation of the bone to a particular axis angle in local or world space
  94094. * @param axis The axis to rotate the bone on
  94095. * @param angle The angle that the bone should be rotated to
  94096. * @param space The space that the axis is in
  94097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94098. */
  94099. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94100. /**
  94101. * Set the euler rotation of the bone in local of world space
  94102. * @param rotation The euler rotation that the bone should be set to
  94103. * @param space The space that the rotation is in
  94104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94105. */
  94106. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94107. /**
  94108. * Set the quaternion rotation of the bone in local of world space
  94109. * @param quat The quaternion rotation that the bone should be set to
  94110. * @param space The space that the rotation is in
  94111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94112. */
  94113. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94114. /**
  94115. * Set the rotation matrix of the bone in local of world space
  94116. * @param rotMat The rotation matrix that the bone should be set to
  94117. * @param space The space that the rotation is in
  94118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94119. */
  94120. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94121. private _rotateWithMatrix;
  94122. private _getNegativeRotationToRef;
  94123. /**
  94124. * Get the position of the bone in local or world space
  94125. * @param space The space that the returned position is in
  94126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94127. * @returns The position of the bone
  94128. */
  94129. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94130. /**
  94131. * Copy the position of the bone to a vector3 in local or world space
  94132. * @param space The space that the returned position is in
  94133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94134. * @param result The vector3 to copy the position to
  94135. */
  94136. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94137. /**
  94138. * Get the absolute position of the bone (world space)
  94139. * @param mesh The mesh that this bone is attached to
  94140. * @returns The absolute position of the bone
  94141. */
  94142. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94143. /**
  94144. * Copy the absolute position of the bone (world space) to the result param
  94145. * @param mesh The mesh that this bone is attached to
  94146. * @param result The vector3 to copy the absolute position to
  94147. */
  94148. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94149. /**
  94150. * Compute the absolute transforms of this bone and its children
  94151. */
  94152. computeAbsoluteTransforms(): void;
  94153. /**
  94154. * Get the world direction from an axis that is in the local space of the bone
  94155. * @param localAxis The local direction that is used to compute the world direction
  94156. * @param mesh The mesh that this bone is attached to
  94157. * @returns The world direction
  94158. */
  94159. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94160. /**
  94161. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94162. * @param localAxis The local direction that is used to compute the world direction
  94163. * @param mesh The mesh that this bone is attached to
  94164. * @param result The vector3 that the world direction will be copied to
  94165. */
  94166. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94167. /**
  94168. * Get the euler rotation of the bone in local or world space
  94169. * @param space The space that the rotation should be in
  94170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94171. * @returns The euler rotation
  94172. */
  94173. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94174. /**
  94175. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94176. * @param space The space that the rotation should be in
  94177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94178. * @param result The vector3 that the rotation should be copied to
  94179. */
  94180. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94181. /**
  94182. * Get the quaternion rotation of the bone in either local or world space
  94183. * @param space The space that the rotation should be in
  94184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94185. * @returns The quaternion rotation
  94186. */
  94187. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94188. /**
  94189. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94190. * @param space The space that the rotation should be in
  94191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94192. * @param result The quaternion that the rotation should be copied to
  94193. */
  94194. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94195. /**
  94196. * Get the rotation matrix of the bone in local or world space
  94197. * @param space The space that the rotation should be in
  94198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94199. * @returns The rotation matrix
  94200. */
  94201. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94202. /**
  94203. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94204. * @param space The space that the rotation should be in
  94205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94206. * @param result The quaternion that the rotation should be copied to
  94207. */
  94208. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94209. /**
  94210. * Get the world position of a point that is in the local space of the bone
  94211. * @param position The local position
  94212. * @param mesh The mesh that this bone is attached to
  94213. * @returns The world position
  94214. */
  94215. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94216. /**
  94217. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94218. * @param position The local position
  94219. * @param mesh The mesh that this bone is attached to
  94220. * @param result The vector3 that the world position should be copied to
  94221. */
  94222. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94223. /**
  94224. * Get the local position of a point that is in world space
  94225. * @param position The world position
  94226. * @param mesh The mesh that this bone is attached to
  94227. * @returns The local position
  94228. */
  94229. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94230. /**
  94231. * Get the local position of a point that is in world space and copy it to the result param
  94232. * @param position The world position
  94233. * @param mesh The mesh that this bone is attached to
  94234. * @param result The vector3 that the local position should be copied to
  94235. */
  94236. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94237. }
  94238. }
  94239. declare module BABYLON {
  94240. /**
  94241. * Defines a runtime animation
  94242. */
  94243. export class RuntimeAnimation {
  94244. private _events;
  94245. /**
  94246. * The current frame of the runtime animation
  94247. */
  94248. private _currentFrame;
  94249. /**
  94250. * The animation used by the runtime animation
  94251. */
  94252. private _animation;
  94253. /**
  94254. * The target of the runtime animation
  94255. */
  94256. private _target;
  94257. /**
  94258. * The initiating animatable
  94259. */
  94260. private _host;
  94261. /**
  94262. * The original value of the runtime animation
  94263. */
  94264. private _originalValue;
  94265. /**
  94266. * The original blend value of the runtime animation
  94267. */
  94268. private _originalBlendValue;
  94269. /**
  94270. * The offsets cache of the runtime animation
  94271. */
  94272. private _offsetsCache;
  94273. /**
  94274. * The high limits cache of the runtime animation
  94275. */
  94276. private _highLimitsCache;
  94277. /**
  94278. * Specifies if the runtime animation has been stopped
  94279. */
  94280. private _stopped;
  94281. /**
  94282. * The blending factor of the runtime animation
  94283. */
  94284. private _blendingFactor;
  94285. /**
  94286. * The BabylonJS scene
  94287. */
  94288. private _scene;
  94289. /**
  94290. * The current value of the runtime animation
  94291. */
  94292. private _currentValue;
  94293. /** @hidden */
  94294. _animationState: _IAnimationState;
  94295. /**
  94296. * The active target of the runtime animation
  94297. */
  94298. private _activeTargets;
  94299. private _currentActiveTarget;
  94300. private _directTarget;
  94301. /**
  94302. * The target path of the runtime animation
  94303. */
  94304. private _targetPath;
  94305. /**
  94306. * The weight of the runtime animation
  94307. */
  94308. private _weight;
  94309. /**
  94310. * The ratio offset of the runtime animation
  94311. */
  94312. private _ratioOffset;
  94313. /**
  94314. * The previous delay of the runtime animation
  94315. */
  94316. private _previousDelay;
  94317. /**
  94318. * The previous ratio of the runtime animation
  94319. */
  94320. private _previousRatio;
  94321. private _enableBlending;
  94322. private _keys;
  94323. private _minFrame;
  94324. private _maxFrame;
  94325. private _minValue;
  94326. private _maxValue;
  94327. private _targetIsArray;
  94328. /**
  94329. * Gets the current frame of the runtime animation
  94330. */
  94331. get currentFrame(): number;
  94332. /**
  94333. * Gets the weight of the runtime animation
  94334. */
  94335. get weight(): number;
  94336. /**
  94337. * Gets the current value of the runtime animation
  94338. */
  94339. get currentValue(): any;
  94340. /**
  94341. * Gets the target path of the runtime animation
  94342. */
  94343. get targetPath(): string;
  94344. /**
  94345. * Gets the actual target of the runtime animation
  94346. */
  94347. get target(): any;
  94348. /**
  94349. * Gets the additive state of the runtime animation
  94350. */
  94351. get isAdditive(): boolean;
  94352. /** @hidden */
  94353. _onLoop: () => void;
  94354. /**
  94355. * Create a new RuntimeAnimation object
  94356. * @param target defines the target of the animation
  94357. * @param animation defines the source animation object
  94358. * @param scene defines the hosting scene
  94359. * @param host defines the initiating Animatable
  94360. */
  94361. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94362. private _preparePath;
  94363. /**
  94364. * Gets the animation from the runtime animation
  94365. */
  94366. get animation(): Animation;
  94367. /**
  94368. * Resets the runtime animation to the beginning
  94369. * @param restoreOriginal defines whether to restore the target property to the original value
  94370. */
  94371. reset(restoreOriginal?: boolean): void;
  94372. /**
  94373. * Specifies if the runtime animation is stopped
  94374. * @returns Boolean specifying if the runtime animation is stopped
  94375. */
  94376. isStopped(): boolean;
  94377. /**
  94378. * Disposes of the runtime animation
  94379. */
  94380. dispose(): void;
  94381. /**
  94382. * Apply the interpolated value to the target
  94383. * @param currentValue defines the value computed by the animation
  94384. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94385. */
  94386. setValue(currentValue: any, weight: number): void;
  94387. private _getOriginalValues;
  94388. private _setValue;
  94389. /**
  94390. * Gets the loop pmode of the runtime animation
  94391. * @returns Loop Mode
  94392. */
  94393. private _getCorrectLoopMode;
  94394. /**
  94395. * Move the current animation to a given frame
  94396. * @param frame defines the frame to move to
  94397. */
  94398. goToFrame(frame: number): void;
  94399. /**
  94400. * @hidden Internal use only
  94401. */
  94402. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94403. /**
  94404. * Execute the current animation
  94405. * @param delay defines the delay to add to the current frame
  94406. * @param from defines the lower bound of the animation range
  94407. * @param to defines the upper bound of the animation range
  94408. * @param loop defines if the current animation must loop
  94409. * @param speedRatio defines the current speed ratio
  94410. * @param weight defines the weight of the animation (default is -1 so no weight)
  94411. * @param onLoop optional callback called when animation loops
  94412. * @returns a boolean indicating if the animation is running
  94413. */
  94414. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94415. }
  94416. }
  94417. declare module BABYLON {
  94418. /**
  94419. * Class used to store an actual running animation
  94420. */
  94421. export class Animatable {
  94422. /** defines the target object */
  94423. target: any;
  94424. /** defines the starting frame number (default is 0) */
  94425. fromFrame: number;
  94426. /** defines the ending frame number (default is 100) */
  94427. toFrame: number;
  94428. /** defines if the animation must loop (default is false) */
  94429. loopAnimation: boolean;
  94430. /** defines a callback to call when animation ends if it is not looping */
  94431. onAnimationEnd?: (() => void) | null | undefined;
  94432. /** defines a callback to call when animation loops */
  94433. onAnimationLoop?: (() => void) | null | undefined;
  94434. /** defines whether the animation should be evaluated additively */
  94435. isAdditive: boolean;
  94436. private _localDelayOffset;
  94437. private _pausedDelay;
  94438. private _runtimeAnimations;
  94439. private _paused;
  94440. private _scene;
  94441. private _speedRatio;
  94442. private _weight;
  94443. private _syncRoot;
  94444. /**
  94445. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94446. * This will only apply for non looping animation (default is true)
  94447. */
  94448. disposeOnEnd: boolean;
  94449. /**
  94450. * Gets a boolean indicating if the animation has started
  94451. */
  94452. animationStarted: boolean;
  94453. /**
  94454. * Observer raised when the animation ends
  94455. */
  94456. onAnimationEndObservable: Observable<Animatable>;
  94457. /**
  94458. * Observer raised when the animation loops
  94459. */
  94460. onAnimationLoopObservable: Observable<Animatable>;
  94461. /**
  94462. * Gets the root Animatable used to synchronize and normalize animations
  94463. */
  94464. get syncRoot(): Nullable<Animatable>;
  94465. /**
  94466. * Gets the current frame of the first RuntimeAnimation
  94467. * Used to synchronize Animatables
  94468. */
  94469. get masterFrame(): number;
  94470. /**
  94471. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94472. */
  94473. get weight(): number;
  94474. set weight(value: number);
  94475. /**
  94476. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94477. */
  94478. get speedRatio(): number;
  94479. set speedRatio(value: number);
  94480. /**
  94481. * Creates a new Animatable
  94482. * @param scene defines the hosting scene
  94483. * @param target defines the target object
  94484. * @param fromFrame defines the starting frame number (default is 0)
  94485. * @param toFrame defines the ending frame number (default is 100)
  94486. * @param loopAnimation defines if the animation must loop (default is false)
  94487. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94488. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94489. * @param animations defines a group of animation to add to the new Animatable
  94490. * @param onAnimationLoop defines a callback to call when animation loops
  94491. * @param isAdditive defines whether the animation should be evaluated additively
  94492. */
  94493. constructor(scene: Scene,
  94494. /** defines the target object */
  94495. target: any,
  94496. /** defines the starting frame number (default is 0) */
  94497. fromFrame?: number,
  94498. /** defines the ending frame number (default is 100) */
  94499. toFrame?: number,
  94500. /** defines if the animation must loop (default is false) */
  94501. loopAnimation?: boolean, speedRatio?: number,
  94502. /** defines a callback to call when animation ends if it is not looping */
  94503. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94504. /** defines a callback to call when animation loops */
  94505. onAnimationLoop?: (() => void) | null | undefined,
  94506. /** defines whether the animation should be evaluated additively */
  94507. isAdditive?: boolean);
  94508. /**
  94509. * Synchronize and normalize current Animatable with a source Animatable
  94510. * This is useful when using animation weights and when animations are not of the same length
  94511. * @param root defines the root Animatable to synchronize with
  94512. * @returns the current Animatable
  94513. */
  94514. syncWith(root: Animatable): Animatable;
  94515. /**
  94516. * Gets the list of runtime animations
  94517. * @returns an array of RuntimeAnimation
  94518. */
  94519. getAnimations(): RuntimeAnimation[];
  94520. /**
  94521. * Adds more animations to the current animatable
  94522. * @param target defines the target of the animations
  94523. * @param animations defines the new animations to add
  94524. */
  94525. appendAnimations(target: any, animations: Animation[]): void;
  94526. /**
  94527. * Gets the source animation for a specific property
  94528. * @param property defines the propertyu to look for
  94529. * @returns null or the source animation for the given property
  94530. */
  94531. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94532. /**
  94533. * Gets the runtime animation for a specific property
  94534. * @param property defines the propertyu to look for
  94535. * @returns null or the runtime animation for the given property
  94536. */
  94537. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94538. /**
  94539. * Resets the animatable to its original state
  94540. */
  94541. reset(): void;
  94542. /**
  94543. * Allows the animatable to blend with current running animations
  94544. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94545. * @param blendingSpeed defines the blending speed to use
  94546. */
  94547. enableBlending(blendingSpeed: number): void;
  94548. /**
  94549. * Disable animation blending
  94550. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94551. */
  94552. disableBlending(): void;
  94553. /**
  94554. * Jump directly to a given frame
  94555. * @param frame defines the frame to jump to
  94556. */
  94557. goToFrame(frame: number): void;
  94558. /**
  94559. * Pause the animation
  94560. */
  94561. pause(): void;
  94562. /**
  94563. * Restart the animation
  94564. */
  94565. restart(): void;
  94566. private _raiseOnAnimationEnd;
  94567. /**
  94568. * Stop and delete the current animation
  94569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94570. * @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)
  94571. */
  94572. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94573. /**
  94574. * Wait asynchronously for the animation to end
  94575. * @returns a promise which will be fullfilled when the animation ends
  94576. */
  94577. waitAsync(): Promise<Animatable>;
  94578. /** @hidden */
  94579. _animate(delay: number): boolean;
  94580. }
  94581. interface Scene {
  94582. /** @hidden */
  94583. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94584. /** @hidden */
  94585. _processLateAnimationBindingsForMatrices(holder: {
  94586. totalWeight: number;
  94587. totalAdditiveWeight: number;
  94588. animations: RuntimeAnimation[];
  94589. additiveAnimations: RuntimeAnimation[];
  94590. originalValue: Matrix;
  94591. }): any;
  94592. /** @hidden */
  94593. _processLateAnimationBindingsForQuaternions(holder: {
  94594. totalWeight: number;
  94595. totalAdditiveWeight: number;
  94596. animations: RuntimeAnimation[];
  94597. additiveAnimations: RuntimeAnimation[];
  94598. originalValue: Quaternion;
  94599. }, refQuaternion: Quaternion): Quaternion;
  94600. /** @hidden */
  94601. _processLateAnimationBindings(): void;
  94602. /**
  94603. * Will start the animation sequence of a given target
  94604. * @param target defines the target
  94605. * @param from defines from which frame should animation start
  94606. * @param to defines until which frame should animation run.
  94607. * @param weight defines the weight to apply to the animation (1.0 by default)
  94608. * @param loop defines if the animation loops
  94609. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94610. * @param onAnimationEnd defines the function to be executed when the animation ends
  94611. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94612. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94613. * @param onAnimationLoop defines the callback to call when an animation loops
  94614. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94615. * @returns the animatable object created for this animation
  94616. */
  94617. 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;
  94618. /**
  94619. * Will start the animation sequence of a given target
  94620. * @param target defines the target
  94621. * @param from defines from which frame should animation start
  94622. * @param to defines until which frame should animation run.
  94623. * @param loop defines if the animation loops
  94624. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94625. * @param onAnimationEnd defines the function to be executed when the animation ends
  94626. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94627. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94628. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94629. * @param onAnimationLoop defines the callback to call when an animation loops
  94630. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94631. * @returns the animatable object created for this animation
  94632. */
  94633. 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;
  94634. /**
  94635. * Will start the animation sequence of a given target and its hierarchy
  94636. * @param target defines the target
  94637. * @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.
  94638. * @param from defines from which frame should animation start
  94639. * @param to defines until which frame should animation run.
  94640. * @param loop defines if the animation loops
  94641. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94642. * @param onAnimationEnd defines the function to be executed when the animation ends
  94643. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94644. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94645. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94646. * @param onAnimationLoop defines the callback to call when an animation loops
  94647. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94648. * @returns the list of created animatables
  94649. */
  94650. 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[];
  94651. /**
  94652. * Begin a new animation on a given node
  94653. * @param target defines the target where the animation will take place
  94654. * @param animations defines the list of animations to start
  94655. * @param from defines the initial value
  94656. * @param to defines the final value
  94657. * @param loop defines if you want animation to loop (off by default)
  94658. * @param speedRatio defines the speed ratio to apply to all animations
  94659. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94660. * @param onAnimationLoop defines the callback to call when an animation loops
  94661. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94662. * @returns the list of created animatables
  94663. */
  94664. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94665. /**
  94666. * Begin a new animation on a given node and its hierarchy
  94667. * @param target defines the root node where the animation will take place
  94668. * @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.
  94669. * @param animations defines the list of animations to start
  94670. * @param from defines the initial value
  94671. * @param to defines the final value
  94672. * @param loop defines if you want animation to loop (off by default)
  94673. * @param speedRatio defines the speed ratio to apply to all animations
  94674. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94675. * @param onAnimationLoop defines the callback to call when an animation loops
  94676. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94677. * @returns the list of animatables created for all nodes
  94678. */
  94679. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94680. /**
  94681. * Gets the animatable associated with a specific target
  94682. * @param target defines the target of the animatable
  94683. * @returns the required animatable if found
  94684. */
  94685. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94686. /**
  94687. * Gets all animatables associated with a given target
  94688. * @param target defines the target to look animatables for
  94689. * @returns an array of Animatables
  94690. */
  94691. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94692. /**
  94693. * Stops and removes all animations that have been applied to the scene
  94694. */
  94695. stopAllAnimations(): void;
  94696. /**
  94697. * Gets the current delta time used by animation engine
  94698. */
  94699. deltaTime: number;
  94700. }
  94701. interface Bone {
  94702. /**
  94703. * Copy an animation range from another bone
  94704. * @param source defines the source bone
  94705. * @param rangeName defines the range name to copy
  94706. * @param frameOffset defines the frame offset
  94707. * @param rescaleAsRequired defines if rescaling must be applied if required
  94708. * @param skelDimensionsRatio defines the scaling ratio
  94709. * @returns true if operation was successful
  94710. */
  94711. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94712. }
  94713. }
  94714. declare module BABYLON {
  94715. /**
  94716. * Class used to handle skinning animations
  94717. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94718. */
  94719. export class Skeleton implements IAnimatable {
  94720. /** defines the skeleton name */
  94721. name: string;
  94722. /** defines the skeleton Id */
  94723. id: string;
  94724. /**
  94725. * Defines the list of child bones
  94726. */
  94727. bones: Bone[];
  94728. /**
  94729. * Defines an estimate of the dimension of the skeleton at rest
  94730. */
  94731. dimensionsAtRest: Vector3;
  94732. /**
  94733. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94734. */
  94735. needInitialSkinMatrix: boolean;
  94736. /**
  94737. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94738. */
  94739. overrideMesh: Nullable<AbstractMesh>;
  94740. /**
  94741. * Gets the list of animations attached to this skeleton
  94742. */
  94743. animations: Array<Animation>;
  94744. private _scene;
  94745. private _isDirty;
  94746. private _transformMatrices;
  94747. private _transformMatrixTexture;
  94748. private _meshesWithPoseMatrix;
  94749. private _animatables;
  94750. private _identity;
  94751. private _synchronizedWithMesh;
  94752. private _ranges;
  94753. private _lastAbsoluteTransformsUpdateId;
  94754. private _canUseTextureForBones;
  94755. private _uniqueId;
  94756. /** @hidden */
  94757. _numBonesWithLinkedTransformNode: number;
  94758. /** @hidden */
  94759. _hasWaitingData: Nullable<boolean>;
  94760. /**
  94761. * Specifies if the skeleton should be serialized
  94762. */
  94763. doNotSerialize: boolean;
  94764. private _useTextureToStoreBoneMatrices;
  94765. /**
  94766. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94767. * Please note that this option is not available if the hardware does not support it
  94768. */
  94769. get useTextureToStoreBoneMatrices(): boolean;
  94770. set useTextureToStoreBoneMatrices(value: boolean);
  94771. private _animationPropertiesOverride;
  94772. /**
  94773. * Gets or sets the animation properties override
  94774. */
  94775. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94776. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94777. /**
  94778. * List of inspectable custom properties (used by the Inspector)
  94779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94780. */
  94781. inspectableCustomProperties: IInspectable[];
  94782. /**
  94783. * An observable triggered before computing the skeleton's matrices
  94784. */
  94785. onBeforeComputeObservable: Observable<Skeleton>;
  94786. /**
  94787. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94788. */
  94789. get isUsingTextureForMatrices(): boolean;
  94790. /**
  94791. * Gets the unique ID of this skeleton
  94792. */
  94793. get uniqueId(): number;
  94794. /**
  94795. * Creates a new skeleton
  94796. * @param name defines the skeleton name
  94797. * @param id defines the skeleton Id
  94798. * @param scene defines the hosting scene
  94799. */
  94800. constructor(
  94801. /** defines the skeleton name */
  94802. name: string,
  94803. /** defines the skeleton Id */
  94804. id: string, scene: Scene);
  94805. /**
  94806. * Gets the current object class name.
  94807. * @return the class name
  94808. */
  94809. getClassName(): string;
  94810. /**
  94811. * Returns an array containing the root bones
  94812. * @returns an array containing the root bones
  94813. */
  94814. getChildren(): Array<Bone>;
  94815. /**
  94816. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94817. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94818. * @returns a Float32Array containing matrices data
  94819. */
  94820. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94821. /**
  94822. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94823. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94824. * @returns a raw texture containing the data
  94825. */
  94826. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94827. /**
  94828. * Gets the current hosting scene
  94829. * @returns a scene object
  94830. */
  94831. getScene(): Scene;
  94832. /**
  94833. * Gets a string representing the current skeleton data
  94834. * @param fullDetails defines a boolean indicating if we want a verbose version
  94835. * @returns a string representing the current skeleton data
  94836. */
  94837. toString(fullDetails?: boolean): string;
  94838. /**
  94839. * Get bone's index searching by name
  94840. * @param name defines bone's name to search for
  94841. * @return the indice of the bone. Returns -1 if not found
  94842. */
  94843. getBoneIndexByName(name: string): number;
  94844. /**
  94845. * Creater a new animation range
  94846. * @param name defines the name of the range
  94847. * @param from defines the start key
  94848. * @param to defines the end key
  94849. */
  94850. createAnimationRange(name: string, from: number, to: number): void;
  94851. /**
  94852. * Delete a specific animation range
  94853. * @param name defines the name of the range
  94854. * @param deleteFrames defines if frames must be removed as well
  94855. */
  94856. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94857. /**
  94858. * Gets a specific animation range
  94859. * @param name defines the name of the range to look for
  94860. * @returns the requested animation range or null if not found
  94861. */
  94862. getAnimationRange(name: string): Nullable<AnimationRange>;
  94863. /**
  94864. * Gets the list of all animation ranges defined on this skeleton
  94865. * @returns an array
  94866. */
  94867. getAnimationRanges(): Nullable<AnimationRange>[];
  94868. /**
  94869. * Copy animation range from a source skeleton.
  94870. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94871. * @param source defines the source skeleton
  94872. * @param name defines the name of the range to copy
  94873. * @param rescaleAsRequired defines if rescaling must be applied if required
  94874. * @returns true if operation was successful
  94875. */
  94876. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94877. /**
  94878. * Forces the skeleton to go to rest pose
  94879. */
  94880. returnToRest(): void;
  94881. private _getHighestAnimationFrame;
  94882. /**
  94883. * Begin a specific animation range
  94884. * @param name defines the name of the range to start
  94885. * @param loop defines if looping must be turned on (false by default)
  94886. * @param speedRatio defines the speed ratio to apply (1 by default)
  94887. * @param onAnimationEnd defines a callback which will be called when animation will end
  94888. * @returns a new animatable
  94889. */
  94890. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94891. /**
  94892. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94893. * @param skeleton defines the Skeleton containing the animation range to convert
  94894. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94895. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94896. * @returns the original skeleton
  94897. */
  94898. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94899. /** @hidden */
  94900. _markAsDirty(): void;
  94901. /** @hidden */
  94902. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94903. /** @hidden */
  94904. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94905. private _computeTransformMatrices;
  94906. /**
  94907. * Build all resources required to render a skeleton
  94908. */
  94909. prepare(): void;
  94910. /**
  94911. * Gets the list of animatables currently running for this skeleton
  94912. * @returns an array of animatables
  94913. */
  94914. getAnimatables(): IAnimatable[];
  94915. /**
  94916. * Clone the current skeleton
  94917. * @param name defines the name of the new skeleton
  94918. * @param id defines the id of the new skeleton
  94919. * @returns the new skeleton
  94920. */
  94921. clone(name: string, id?: string): Skeleton;
  94922. /**
  94923. * Enable animation blending for this skeleton
  94924. * @param blendingSpeed defines the blending speed to apply
  94925. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94926. */
  94927. enableBlending(blendingSpeed?: number): void;
  94928. /**
  94929. * Releases all resources associated with the current skeleton
  94930. */
  94931. dispose(): void;
  94932. /**
  94933. * Serialize the skeleton in a JSON object
  94934. * @returns a JSON object
  94935. */
  94936. serialize(): any;
  94937. /**
  94938. * Creates a new skeleton from serialized data
  94939. * @param parsedSkeleton defines the serialized data
  94940. * @param scene defines the hosting scene
  94941. * @returns a new skeleton
  94942. */
  94943. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94944. /**
  94945. * Compute all node absolute transforms
  94946. * @param forceUpdate defines if computation must be done even if cache is up to date
  94947. */
  94948. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94949. /**
  94950. * Gets the root pose matrix
  94951. * @returns a matrix
  94952. */
  94953. getPoseMatrix(): Nullable<Matrix>;
  94954. /**
  94955. * Sorts bones per internal index
  94956. */
  94957. sortBones(): void;
  94958. private _sortBones;
  94959. }
  94960. }
  94961. declare module BABYLON {
  94962. /**
  94963. * Creates an instance based on a source mesh.
  94964. */
  94965. export class InstancedMesh extends AbstractMesh {
  94966. private _sourceMesh;
  94967. private _currentLOD;
  94968. /** @hidden */
  94969. _indexInSourceMeshInstanceArray: number;
  94970. constructor(name: string, source: Mesh);
  94971. /**
  94972. * Returns the string "InstancedMesh".
  94973. */
  94974. getClassName(): string;
  94975. /** Gets the list of lights affecting that mesh */
  94976. get lightSources(): Light[];
  94977. _resyncLightSources(): void;
  94978. _resyncLightSource(light: Light): void;
  94979. _removeLightSource(light: Light, dispose: boolean): void;
  94980. /**
  94981. * If the source mesh receives shadows
  94982. */
  94983. get receiveShadows(): boolean;
  94984. /**
  94985. * The material of the source mesh
  94986. */
  94987. get material(): Nullable<Material>;
  94988. /**
  94989. * Visibility of the source mesh
  94990. */
  94991. get visibility(): number;
  94992. /**
  94993. * Skeleton of the source mesh
  94994. */
  94995. get skeleton(): Nullable<Skeleton>;
  94996. /**
  94997. * Rendering ground id of the source mesh
  94998. */
  94999. get renderingGroupId(): number;
  95000. set renderingGroupId(value: number);
  95001. /**
  95002. * Returns the total number of vertices (integer).
  95003. */
  95004. getTotalVertices(): number;
  95005. /**
  95006. * Returns a positive integer : the total number of indices in this mesh geometry.
  95007. * @returns the numner of indices or zero if the mesh has no geometry.
  95008. */
  95009. getTotalIndices(): number;
  95010. /**
  95011. * The source mesh of the instance
  95012. */
  95013. get sourceMesh(): Mesh;
  95014. /**
  95015. * Creates a new InstancedMesh object from the mesh model.
  95016. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95017. * @param name defines the name of the new instance
  95018. * @returns a new InstancedMesh
  95019. */
  95020. createInstance(name: string): InstancedMesh;
  95021. /**
  95022. * Is this node ready to be used/rendered
  95023. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95024. * @return {boolean} is it ready
  95025. */
  95026. isReady(completeCheck?: boolean): boolean;
  95027. /**
  95028. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95029. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95030. * @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.
  95031. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95032. */
  95033. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95034. /**
  95035. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95036. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95037. * The `data` are either a numeric array either a Float32Array.
  95038. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95039. * 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).
  95040. * Note that a new underlying VertexBuffer object is created each call.
  95041. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95042. *
  95043. * Possible `kind` values :
  95044. * - VertexBuffer.PositionKind
  95045. * - VertexBuffer.UVKind
  95046. * - VertexBuffer.UV2Kind
  95047. * - VertexBuffer.UV3Kind
  95048. * - VertexBuffer.UV4Kind
  95049. * - VertexBuffer.UV5Kind
  95050. * - VertexBuffer.UV6Kind
  95051. * - VertexBuffer.ColorKind
  95052. * - VertexBuffer.MatricesIndicesKind
  95053. * - VertexBuffer.MatricesIndicesExtraKind
  95054. * - VertexBuffer.MatricesWeightsKind
  95055. * - VertexBuffer.MatricesWeightsExtraKind
  95056. *
  95057. * Returns the Mesh.
  95058. */
  95059. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95060. /**
  95061. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95062. * If the mesh has no geometry, it is simply returned as it is.
  95063. * The `data` are either a numeric array either a Float32Array.
  95064. * No new underlying VertexBuffer object is created.
  95065. * 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.
  95066. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95067. *
  95068. * Possible `kind` values :
  95069. * - VertexBuffer.PositionKind
  95070. * - VertexBuffer.UVKind
  95071. * - VertexBuffer.UV2Kind
  95072. * - VertexBuffer.UV3Kind
  95073. * - VertexBuffer.UV4Kind
  95074. * - VertexBuffer.UV5Kind
  95075. * - VertexBuffer.UV6Kind
  95076. * - VertexBuffer.ColorKind
  95077. * - VertexBuffer.MatricesIndicesKind
  95078. * - VertexBuffer.MatricesIndicesExtraKind
  95079. * - VertexBuffer.MatricesWeightsKind
  95080. * - VertexBuffer.MatricesWeightsExtraKind
  95081. *
  95082. * Returns the Mesh.
  95083. */
  95084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95085. /**
  95086. * Sets the mesh indices.
  95087. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95088. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95089. * This method creates a new index buffer each call.
  95090. * Returns the Mesh.
  95091. */
  95092. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95093. /**
  95094. * Boolean : True if the mesh owns the requested kind of data.
  95095. */
  95096. isVerticesDataPresent(kind: string): boolean;
  95097. /**
  95098. * Returns an array of indices (IndicesArray).
  95099. */
  95100. getIndices(): Nullable<IndicesArray>;
  95101. get _positions(): Nullable<Vector3[]>;
  95102. /**
  95103. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95104. * This means the mesh underlying bounding box and sphere are recomputed.
  95105. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95106. * @returns the current mesh
  95107. */
  95108. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95109. /** @hidden */
  95110. _preActivate(): InstancedMesh;
  95111. /** @hidden */
  95112. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95113. /** @hidden */
  95114. _postActivate(): void;
  95115. getWorldMatrix(): Matrix;
  95116. get isAnInstance(): boolean;
  95117. /**
  95118. * Returns the current associated LOD AbstractMesh.
  95119. */
  95120. getLOD(camera: Camera): AbstractMesh;
  95121. /** @hidden */
  95122. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95123. /** @hidden */
  95124. _syncSubMeshes(): InstancedMesh;
  95125. /** @hidden */
  95126. _generatePointsArray(): boolean;
  95127. /**
  95128. * Creates a new InstancedMesh from the current mesh.
  95129. * - name (string) : the cloned mesh name
  95130. * - newParent (optional Node) : the optional Node to parent the clone to.
  95131. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95132. *
  95133. * Returns the clone.
  95134. */
  95135. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95136. /**
  95137. * Disposes the InstancedMesh.
  95138. * Returns nothing.
  95139. */
  95140. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95141. }
  95142. interface Mesh {
  95143. /**
  95144. * Register a custom buffer that will be instanced
  95145. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95146. * @param kind defines the buffer kind
  95147. * @param stride defines the stride in floats
  95148. */
  95149. registerInstancedBuffer(kind: string, stride: number): void;
  95150. /**
  95151. * true to use the edge renderer for all instances of this mesh
  95152. */
  95153. edgesShareWithInstances: boolean;
  95154. /** @hidden */
  95155. _userInstancedBuffersStorage: {
  95156. data: {
  95157. [key: string]: Float32Array;
  95158. };
  95159. sizes: {
  95160. [key: string]: number;
  95161. };
  95162. vertexBuffers: {
  95163. [key: string]: Nullable<VertexBuffer>;
  95164. };
  95165. strides: {
  95166. [key: string]: number;
  95167. };
  95168. };
  95169. }
  95170. interface AbstractMesh {
  95171. /**
  95172. * Object used to store instanced buffers defined by user
  95173. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95174. */
  95175. instancedBuffers: {
  95176. [key: string]: any;
  95177. };
  95178. }
  95179. }
  95180. declare module BABYLON {
  95181. /**
  95182. * Defines the options associated with the creation of a shader material.
  95183. */
  95184. export interface IShaderMaterialOptions {
  95185. /**
  95186. * Does the material work in alpha blend mode
  95187. */
  95188. needAlphaBlending: boolean;
  95189. /**
  95190. * Does the material work in alpha test mode
  95191. */
  95192. needAlphaTesting: boolean;
  95193. /**
  95194. * The list of attribute names used in the shader
  95195. */
  95196. attributes: string[];
  95197. /**
  95198. * The list of unifrom names used in the shader
  95199. */
  95200. uniforms: string[];
  95201. /**
  95202. * The list of UBO names used in the shader
  95203. */
  95204. uniformBuffers: string[];
  95205. /**
  95206. * The list of sampler names used in the shader
  95207. */
  95208. samplers: string[];
  95209. /**
  95210. * The list of defines used in the shader
  95211. */
  95212. defines: string[];
  95213. }
  95214. /**
  95215. * 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.
  95216. *
  95217. * This returned material effects how the mesh will look based on the code in the shaders.
  95218. *
  95219. * @see https://doc.babylonjs.com/how_to/shader_material
  95220. */
  95221. export class ShaderMaterial extends Material {
  95222. private _shaderPath;
  95223. private _options;
  95224. private _textures;
  95225. private _textureArrays;
  95226. private _floats;
  95227. private _ints;
  95228. private _floatsArrays;
  95229. private _colors3;
  95230. private _colors3Arrays;
  95231. private _colors4;
  95232. private _colors4Arrays;
  95233. private _vectors2;
  95234. private _vectors3;
  95235. private _vectors4;
  95236. private _matrices;
  95237. private _matrixArrays;
  95238. private _matrices3x3;
  95239. private _matrices2x2;
  95240. private _vectors2Arrays;
  95241. private _vectors3Arrays;
  95242. private _vectors4Arrays;
  95243. private _cachedWorldViewMatrix;
  95244. private _cachedWorldViewProjectionMatrix;
  95245. private _renderId;
  95246. private _multiview;
  95247. private _cachedDefines;
  95248. /** Define the Url to load snippets */
  95249. static SnippetUrl: string;
  95250. /** Snippet ID if the material was created from the snippet server */
  95251. snippetId: string;
  95252. /**
  95253. * Instantiate a new shader material.
  95254. * 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.
  95255. * This returned material effects how the mesh will look based on the code in the shaders.
  95256. * @see https://doc.babylonjs.com/how_to/shader_material
  95257. * @param name Define the name of the material in the scene
  95258. * @param scene Define the scene the material belongs to
  95259. * @param shaderPath Defines the route to the shader code in one of three ways:
  95260. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95261. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95262. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95263. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95264. * @param options Define the options used to create the shader
  95265. */
  95266. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95267. /**
  95268. * Gets the shader path used to define the shader code
  95269. * It can be modified to trigger a new compilation
  95270. */
  95271. get shaderPath(): any;
  95272. /**
  95273. * Sets the shader path used to define the shader code
  95274. * It can be modified to trigger a new compilation
  95275. */
  95276. set shaderPath(shaderPath: any);
  95277. /**
  95278. * Gets the options used to compile the shader.
  95279. * They can be modified to trigger a new compilation
  95280. */
  95281. get options(): IShaderMaterialOptions;
  95282. /**
  95283. * Gets the current class name of the material e.g. "ShaderMaterial"
  95284. * Mainly use in serialization.
  95285. * @returns the class name
  95286. */
  95287. getClassName(): string;
  95288. /**
  95289. * Specifies if the material will require alpha blending
  95290. * @returns a boolean specifying if alpha blending is needed
  95291. */
  95292. needAlphaBlending(): boolean;
  95293. /**
  95294. * Specifies if this material should be rendered in alpha test mode
  95295. * @returns a boolean specifying if an alpha test is needed.
  95296. */
  95297. needAlphaTesting(): boolean;
  95298. private _checkUniform;
  95299. /**
  95300. * Set a texture in the shader.
  95301. * @param name Define the name of the uniform samplers as defined in the shader
  95302. * @param texture Define the texture to bind to this sampler
  95303. * @return the material itself allowing "fluent" like uniform updates
  95304. */
  95305. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95306. /**
  95307. * Set a texture array in the shader.
  95308. * @param name Define the name of the uniform sampler array as defined in the shader
  95309. * @param textures Define the list of textures to bind to this sampler
  95310. * @return the material itself allowing "fluent" like uniform updates
  95311. */
  95312. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95313. /**
  95314. * Set a float in the shader.
  95315. * @param name Define the name of the uniform as defined in the shader
  95316. * @param value Define the value to give to the uniform
  95317. * @return the material itself allowing "fluent" like uniform updates
  95318. */
  95319. setFloat(name: string, value: number): ShaderMaterial;
  95320. /**
  95321. * Set a int in the shader.
  95322. * @param name Define the name of the uniform as defined in the shader
  95323. * @param value Define the value to give to the uniform
  95324. * @return the material itself allowing "fluent" like uniform updates
  95325. */
  95326. setInt(name: string, value: number): ShaderMaterial;
  95327. /**
  95328. * Set an array of floats in the shader.
  95329. * @param name Define the name of the uniform as defined in the shader
  95330. * @param value Define the value to give to the uniform
  95331. * @return the material itself allowing "fluent" like uniform updates
  95332. */
  95333. setFloats(name: string, value: number[]): ShaderMaterial;
  95334. /**
  95335. * Set a vec3 in the shader from a Color3.
  95336. * @param name Define the name of the uniform as defined in the shader
  95337. * @param value Define the value to give to the uniform
  95338. * @return the material itself allowing "fluent" like uniform updates
  95339. */
  95340. setColor3(name: string, value: Color3): ShaderMaterial;
  95341. /**
  95342. * Set a vec3 array in the shader from a Color3 array.
  95343. * @param name Define the name of the uniform as defined in the shader
  95344. * @param value Define the value to give to the uniform
  95345. * @return the material itself allowing "fluent" like uniform updates
  95346. */
  95347. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95348. /**
  95349. * Set a vec4 in the shader from a Color4.
  95350. * @param name Define the name of the uniform as defined in the shader
  95351. * @param value Define the value to give to the uniform
  95352. * @return the material itself allowing "fluent" like uniform updates
  95353. */
  95354. setColor4(name: string, value: Color4): ShaderMaterial;
  95355. /**
  95356. * Set a vec4 array in the shader from a Color4 array.
  95357. * @param name Define the name of the uniform as defined in the shader
  95358. * @param value Define the value to give to the uniform
  95359. * @return the material itself allowing "fluent" like uniform updates
  95360. */
  95361. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95362. /**
  95363. * Set a vec2 in the shader from a Vector2.
  95364. * @param name Define the name of the uniform as defined in the shader
  95365. * @param value Define the value to give to the uniform
  95366. * @return the material itself allowing "fluent" like uniform updates
  95367. */
  95368. setVector2(name: string, value: Vector2): ShaderMaterial;
  95369. /**
  95370. * Set a vec3 in the shader from a Vector3.
  95371. * @param name Define the name of the uniform as defined in the shader
  95372. * @param value Define the value to give to the uniform
  95373. * @return the material itself allowing "fluent" like uniform updates
  95374. */
  95375. setVector3(name: string, value: Vector3): ShaderMaterial;
  95376. /**
  95377. * Set a vec4 in the shader from a Vector4.
  95378. * @param name Define the name of the uniform as defined in the shader
  95379. * @param value Define the value to give to the uniform
  95380. * @return the material itself allowing "fluent" like uniform updates
  95381. */
  95382. setVector4(name: string, value: Vector4): ShaderMaterial;
  95383. /**
  95384. * Set a mat4 in the shader from a Matrix.
  95385. * @param name Define the name of the uniform as defined in the shader
  95386. * @param value Define the value to give to the uniform
  95387. * @return the material itself allowing "fluent" like uniform updates
  95388. */
  95389. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95390. /**
  95391. * Set a float32Array in the shader from a matrix array.
  95392. * @param name Define the name of the uniform as defined in the shader
  95393. * @param value Define the value to give to the uniform
  95394. * @return the material itself allowing "fluent" like uniform updates
  95395. */
  95396. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95397. /**
  95398. * Set a mat3 in the shader from a Float32Array.
  95399. * @param name Define the name of the uniform as defined in the shader
  95400. * @param value Define the value to give to the uniform
  95401. * @return the material itself allowing "fluent" like uniform updates
  95402. */
  95403. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95404. /**
  95405. * Set a mat2 in the shader from a Float32Array.
  95406. * @param name Define the name of the uniform as defined in the shader
  95407. * @param value Define the value to give to the uniform
  95408. * @return the material itself allowing "fluent" like uniform updates
  95409. */
  95410. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95411. /**
  95412. * Set a vec2 array in the shader from a number array.
  95413. * @param name Define the name of the uniform as defined in the shader
  95414. * @param value Define the value to give to the uniform
  95415. * @return the material itself allowing "fluent" like uniform updates
  95416. */
  95417. setArray2(name: string, value: number[]): ShaderMaterial;
  95418. /**
  95419. * Set a vec3 array in the shader from a number array.
  95420. * @param name Define the name of the uniform as defined in the shader
  95421. * @param value Define the value to give to the uniform
  95422. * @return the material itself allowing "fluent" like uniform updates
  95423. */
  95424. setArray3(name: string, value: number[]): ShaderMaterial;
  95425. /**
  95426. * Set a vec4 array in the shader from a number array.
  95427. * @param name Define the name of the uniform as defined in the shader
  95428. * @param value Define the value to give to the uniform
  95429. * @return the material itself allowing "fluent" like uniform updates
  95430. */
  95431. setArray4(name: string, value: number[]): ShaderMaterial;
  95432. private _checkCache;
  95433. /**
  95434. * Specifies that the submesh is ready to be used
  95435. * @param mesh defines the mesh to check
  95436. * @param subMesh defines which submesh to check
  95437. * @param useInstances specifies that instances should be used
  95438. * @returns a boolean indicating that the submesh is ready or not
  95439. */
  95440. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95441. /**
  95442. * Checks if the material is ready to render the requested mesh
  95443. * @param mesh Define the mesh to render
  95444. * @param useInstances Define whether or not the material is used with instances
  95445. * @returns true if ready, otherwise false
  95446. */
  95447. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95448. /**
  95449. * Binds the world matrix to the material
  95450. * @param world defines the world transformation matrix
  95451. * @param effectOverride - If provided, use this effect instead of internal effect
  95452. */
  95453. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95454. /**
  95455. * Binds the submesh to this material by preparing the effect and shader to draw
  95456. * @param world defines the world transformation matrix
  95457. * @param mesh defines the mesh containing the submesh
  95458. * @param subMesh defines the submesh to bind the material to
  95459. */
  95460. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95461. /**
  95462. * Binds the material to the mesh
  95463. * @param world defines the world transformation matrix
  95464. * @param mesh defines the mesh to bind the material to
  95465. * @param effectOverride - If provided, use this effect instead of internal effect
  95466. */
  95467. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95468. protected _afterBind(mesh?: Mesh): void;
  95469. /**
  95470. * Gets the active textures from the material
  95471. * @returns an array of textures
  95472. */
  95473. getActiveTextures(): BaseTexture[];
  95474. /**
  95475. * Specifies if the material uses a texture
  95476. * @param texture defines the texture to check against the material
  95477. * @returns a boolean specifying if the material uses the texture
  95478. */
  95479. hasTexture(texture: BaseTexture): boolean;
  95480. /**
  95481. * Makes a duplicate of the material, and gives it a new name
  95482. * @param name defines the new name for the duplicated material
  95483. * @returns the cloned material
  95484. */
  95485. clone(name: string): ShaderMaterial;
  95486. /**
  95487. * Disposes the material
  95488. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95489. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95490. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95491. */
  95492. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95493. /**
  95494. * Serializes this material in a JSON representation
  95495. * @returns the serialized material object
  95496. */
  95497. serialize(): any;
  95498. /**
  95499. * Creates a shader material from parsed shader material data
  95500. * @param source defines the JSON represnetation of the material
  95501. * @param scene defines the hosting scene
  95502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95503. * @returns a new material
  95504. */
  95505. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95506. /**
  95507. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95508. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95509. * @param url defines the url to load from
  95510. * @param scene defines the hosting scene
  95511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95512. * @returns a promise that will resolve to the new ShaderMaterial
  95513. */
  95514. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95515. /**
  95516. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95517. * @param snippetId defines the snippet to load
  95518. * @param scene defines the hosting scene
  95519. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95520. * @returns a promise that will resolve to the new ShaderMaterial
  95521. */
  95522. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95523. }
  95524. }
  95525. declare module BABYLON {
  95526. /** @hidden */
  95527. export var colorPixelShader: {
  95528. name: string;
  95529. shader: string;
  95530. };
  95531. }
  95532. declare module BABYLON {
  95533. /** @hidden */
  95534. export var colorVertexShader: {
  95535. name: string;
  95536. shader: string;
  95537. };
  95538. }
  95539. declare module BABYLON {
  95540. /**
  95541. * Line mesh
  95542. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95543. */
  95544. export class LinesMesh extends Mesh {
  95545. /**
  95546. * If vertex color should be applied to the mesh
  95547. */
  95548. readonly useVertexColor?: boolean | undefined;
  95549. /**
  95550. * If vertex alpha should be applied to the mesh
  95551. */
  95552. readonly useVertexAlpha?: boolean | undefined;
  95553. /**
  95554. * Color of the line (Default: White)
  95555. */
  95556. color: Color3;
  95557. /**
  95558. * Alpha of the line (Default: 1)
  95559. */
  95560. alpha: number;
  95561. /**
  95562. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95563. * This margin is expressed in world space coordinates, so its value may vary.
  95564. * Default value is 0.1
  95565. */
  95566. intersectionThreshold: number;
  95567. private _colorShader;
  95568. private color4;
  95569. /**
  95570. * Creates a new LinesMesh
  95571. * @param name defines the name
  95572. * @param scene defines the hosting scene
  95573. * @param parent defines the parent mesh if any
  95574. * @param source defines the optional source LinesMesh used to clone data from
  95575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95576. * When false, achieved by calling a clone(), also passing False.
  95577. * This will make creation of children, recursive.
  95578. * @param useVertexColor defines if this LinesMesh supports vertex color
  95579. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95580. */
  95581. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95582. /**
  95583. * If vertex color should be applied to the mesh
  95584. */
  95585. useVertexColor?: boolean | undefined,
  95586. /**
  95587. * If vertex alpha should be applied to the mesh
  95588. */
  95589. useVertexAlpha?: boolean | undefined);
  95590. private _addClipPlaneDefine;
  95591. private _removeClipPlaneDefine;
  95592. isReady(): boolean;
  95593. /**
  95594. * Returns the string "LineMesh"
  95595. */
  95596. getClassName(): string;
  95597. /**
  95598. * @hidden
  95599. */
  95600. get material(): Material;
  95601. /**
  95602. * @hidden
  95603. */
  95604. set material(value: Material);
  95605. /**
  95606. * @hidden
  95607. */
  95608. get checkCollisions(): boolean;
  95609. /** @hidden */
  95610. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95611. /** @hidden */
  95612. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95613. /**
  95614. * Disposes of the line mesh
  95615. * @param doNotRecurse If children should be disposed
  95616. */
  95617. dispose(doNotRecurse?: boolean): void;
  95618. /**
  95619. * Returns a new LineMesh object cloned from the current one.
  95620. */
  95621. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95622. /**
  95623. * Creates a new InstancedLinesMesh object from the mesh model.
  95624. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95625. * @param name defines the name of the new instance
  95626. * @returns a new InstancedLinesMesh
  95627. */
  95628. createInstance(name: string): InstancedLinesMesh;
  95629. }
  95630. /**
  95631. * Creates an instance based on a source LinesMesh
  95632. */
  95633. export class InstancedLinesMesh extends InstancedMesh {
  95634. /**
  95635. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95636. * This margin is expressed in world space coordinates, so its value may vary.
  95637. * Initilized with the intersectionThreshold value of the source LinesMesh
  95638. */
  95639. intersectionThreshold: number;
  95640. constructor(name: string, source: LinesMesh);
  95641. /**
  95642. * Returns the string "InstancedLinesMesh".
  95643. */
  95644. getClassName(): string;
  95645. }
  95646. }
  95647. declare module BABYLON {
  95648. /** @hidden */
  95649. export var linePixelShader: {
  95650. name: string;
  95651. shader: string;
  95652. };
  95653. }
  95654. declare module BABYLON {
  95655. /** @hidden */
  95656. export var lineVertexShader: {
  95657. name: string;
  95658. shader: string;
  95659. };
  95660. }
  95661. declare module BABYLON {
  95662. interface Scene {
  95663. /** @hidden */
  95664. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95665. }
  95666. interface AbstractMesh {
  95667. /**
  95668. * Gets the edgesRenderer associated with the mesh
  95669. */
  95670. edgesRenderer: Nullable<EdgesRenderer>;
  95671. }
  95672. interface LinesMesh {
  95673. /**
  95674. * Enables the edge rendering mode on the mesh.
  95675. * This mode makes the mesh edges visible
  95676. * @param epsilon defines the maximal distance between two angles to detect a face
  95677. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95678. * @returns the currentAbstractMesh
  95679. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95680. */
  95681. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95682. }
  95683. interface InstancedLinesMesh {
  95684. /**
  95685. * Enables the edge rendering mode on the mesh.
  95686. * This mode makes the mesh edges visible
  95687. * @param epsilon defines the maximal distance between two angles to detect a face
  95688. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95689. * @returns the current InstancedLinesMesh
  95690. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95691. */
  95692. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95693. }
  95694. /**
  95695. * Defines the minimum contract an Edges renderer should follow.
  95696. */
  95697. export interface IEdgesRenderer extends IDisposable {
  95698. /**
  95699. * Gets or sets a boolean indicating if the edgesRenderer is active
  95700. */
  95701. isEnabled: boolean;
  95702. /**
  95703. * Renders the edges of the attached mesh,
  95704. */
  95705. render(): void;
  95706. /**
  95707. * Checks wether or not the edges renderer is ready to render.
  95708. * @return true if ready, otherwise false.
  95709. */
  95710. isReady(): boolean;
  95711. /**
  95712. * List of instances to render in case the source mesh has instances
  95713. */
  95714. customInstances: SmartArray<Matrix>;
  95715. }
  95716. /**
  95717. * Defines the additional options of the edges renderer
  95718. */
  95719. export interface IEdgesRendererOptions {
  95720. /**
  95721. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95722. * If not defined, the default value is true
  95723. */
  95724. useAlternateEdgeFinder?: boolean;
  95725. /**
  95726. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95727. * If not defined, the default value is true.
  95728. * 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)
  95729. * This option is used only if useAlternateEdgeFinder = true
  95730. */
  95731. useFastVertexMerger?: boolean;
  95732. /**
  95733. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95734. * The default value is 1e-6
  95735. * This option is used only if useAlternateEdgeFinder = true
  95736. */
  95737. epsilonVertexMerge?: number;
  95738. /**
  95739. * 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
  95740. * 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.
  95741. * This option is used only if useAlternateEdgeFinder = true
  95742. */
  95743. applyTessellation?: boolean;
  95744. /**
  95745. * 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
  95746. * The default value is 1e-6
  95747. * This option is used only if useAlternateEdgeFinder = true
  95748. */
  95749. epsilonVertexAligned?: number;
  95750. }
  95751. /**
  95752. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95753. */
  95754. export class EdgesRenderer implements IEdgesRenderer {
  95755. /**
  95756. * Define the size of the edges with an orthographic camera
  95757. */
  95758. edgesWidthScalerForOrthographic: number;
  95759. /**
  95760. * Define the size of the edges with a perspective camera
  95761. */
  95762. edgesWidthScalerForPerspective: number;
  95763. protected _source: AbstractMesh;
  95764. protected _linesPositions: number[];
  95765. protected _linesNormals: number[];
  95766. protected _linesIndices: number[];
  95767. protected _epsilon: number;
  95768. protected _indicesCount: number;
  95769. protected _lineShader: ShaderMaterial;
  95770. protected _ib: DataBuffer;
  95771. protected _buffers: {
  95772. [key: string]: Nullable<VertexBuffer>;
  95773. };
  95774. protected _buffersForInstances: {
  95775. [key: string]: Nullable<VertexBuffer>;
  95776. };
  95777. protected _checkVerticesInsteadOfIndices: boolean;
  95778. protected _options: Nullable<IEdgesRendererOptions>;
  95779. private _meshRebuildObserver;
  95780. private _meshDisposeObserver;
  95781. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95782. isEnabled: boolean;
  95783. /**
  95784. * List of instances to render in case the source mesh has instances
  95785. */
  95786. customInstances: SmartArray<Matrix>;
  95787. private static GetShader;
  95788. /**
  95789. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95790. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95791. * @param source Mesh used to create edges
  95792. * @param epsilon sum of angles in adjacency to check for edge
  95793. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95794. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95795. * @param options The options to apply when generating the edges
  95796. */
  95797. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95798. protected _prepareRessources(): void;
  95799. /** @hidden */
  95800. _rebuild(): void;
  95801. /**
  95802. * Releases the required resources for the edges renderer
  95803. */
  95804. dispose(): void;
  95805. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95806. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95807. /**
  95808. * Checks if the pair of p0 and p1 is en edge
  95809. * @param faceIndex
  95810. * @param edge
  95811. * @param faceNormals
  95812. * @param p0
  95813. * @param p1
  95814. * @private
  95815. */
  95816. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95817. /**
  95818. * push line into the position, normal and index buffer
  95819. * @protected
  95820. */
  95821. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95822. /**
  95823. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95824. */
  95825. private _tessellateTriangle;
  95826. private _generateEdgesLinesAlternate;
  95827. /**
  95828. * Generates lines edges from adjacencjes
  95829. * @private
  95830. */
  95831. _generateEdgesLines(): void;
  95832. /**
  95833. * Checks wether or not the edges renderer is ready to render.
  95834. * @return true if ready, otherwise false.
  95835. */
  95836. isReady(): boolean;
  95837. /**
  95838. * Renders the edges of the attached mesh,
  95839. */
  95840. render(): void;
  95841. }
  95842. /**
  95843. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95844. */
  95845. export class LineEdgesRenderer extends EdgesRenderer {
  95846. /**
  95847. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95848. * @param source LineMesh used to generate edges
  95849. * @param epsilon not important (specified angle for edge detection)
  95850. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95851. */
  95852. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95853. /**
  95854. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95855. */
  95856. _generateEdgesLines(): void;
  95857. }
  95858. }
  95859. declare module BABYLON {
  95860. /**
  95861. * This represents the object necessary to create a rendering group.
  95862. * This is exclusively used and created by the rendering manager.
  95863. * To modify the behavior, you use the available helpers in your scene or meshes.
  95864. * @hidden
  95865. */
  95866. export class RenderingGroup {
  95867. index: number;
  95868. private static _zeroVector;
  95869. private _scene;
  95870. private _opaqueSubMeshes;
  95871. private _transparentSubMeshes;
  95872. private _alphaTestSubMeshes;
  95873. private _depthOnlySubMeshes;
  95874. private _particleSystems;
  95875. private _spriteManagers;
  95876. private _opaqueSortCompareFn;
  95877. private _alphaTestSortCompareFn;
  95878. private _transparentSortCompareFn;
  95879. private _renderOpaque;
  95880. private _renderAlphaTest;
  95881. private _renderTransparent;
  95882. /** @hidden */
  95883. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95884. onBeforeTransparentRendering: () => void;
  95885. /**
  95886. * Set the opaque sort comparison function.
  95887. * If null the sub meshes will be render in the order they were created
  95888. */
  95889. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95890. /**
  95891. * Set the alpha test sort comparison function.
  95892. * If null the sub meshes will be render in the order they were created
  95893. */
  95894. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95895. /**
  95896. * Set the transparent sort comparison function.
  95897. * If null the sub meshes will be render in the order they were created
  95898. */
  95899. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95900. /**
  95901. * Creates a new rendering group.
  95902. * @param index The rendering group index
  95903. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95904. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95905. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95906. */
  95907. 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>);
  95908. /**
  95909. * Render all the sub meshes contained in the group.
  95910. * @param customRenderFunction Used to override the default render behaviour of the group.
  95911. * @returns true if rendered some submeshes.
  95912. */
  95913. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95914. /**
  95915. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95916. * @param subMeshes The submeshes to render
  95917. */
  95918. private renderOpaqueSorted;
  95919. /**
  95920. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95921. * @param subMeshes The submeshes to render
  95922. */
  95923. private renderAlphaTestSorted;
  95924. /**
  95925. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95926. * @param subMeshes The submeshes to render
  95927. */
  95928. private renderTransparentSorted;
  95929. /**
  95930. * Renders the submeshes in a specified order.
  95931. * @param subMeshes The submeshes to sort before render
  95932. * @param sortCompareFn The comparison function use to sort
  95933. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95934. * @param transparent Specifies to activate blending if true
  95935. */
  95936. private static renderSorted;
  95937. /**
  95938. * Renders the submeshes in the order they were dispatched (no sort applied).
  95939. * @param subMeshes The submeshes to render
  95940. */
  95941. private static renderUnsorted;
  95942. /**
  95943. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95944. * are rendered back to front if in the same alpha index.
  95945. *
  95946. * @param a The first submesh
  95947. * @param b The second submesh
  95948. * @returns The result of the comparison
  95949. */
  95950. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95951. /**
  95952. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95953. * are rendered back to front.
  95954. *
  95955. * @param a The first submesh
  95956. * @param b The second submesh
  95957. * @returns The result of the comparison
  95958. */
  95959. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95960. /**
  95961. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95962. * are rendered front to back (prevent overdraw).
  95963. *
  95964. * @param a The first submesh
  95965. * @param b The second submesh
  95966. * @returns The result of the comparison
  95967. */
  95968. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95969. /**
  95970. * Resets the different lists of submeshes to prepare a new frame.
  95971. */
  95972. prepare(): void;
  95973. dispose(): void;
  95974. /**
  95975. * Inserts the submesh in its correct queue depending on its material.
  95976. * @param subMesh The submesh to dispatch
  95977. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95978. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95979. */
  95980. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95981. dispatchSprites(spriteManager: ISpriteManager): void;
  95982. dispatchParticles(particleSystem: IParticleSystem): void;
  95983. private _renderParticles;
  95984. private _renderSprites;
  95985. }
  95986. }
  95987. declare module BABYLON {
  95988. /**
  95989. * Interface describing the different options available in the rendering manager
  95990. * regarding Auto Clear between groups.
  95991. */
  95992. export interface IRenderingManagerAutoClearSetup {
  95993. /**
  95994. * Defines whether or not autoclear is enable.
  95995. */
  95996. autoClear: boolean;
  95997. /**
  95998. * Defines whether or not to autoclear the depth buffer.
  95999. */
  96000. depth: boolean;
  96001. /**
  96002. * Defines whether or not to autoclear the stencil buffer.
  96003. */
  96004. stencil: boolean;
  96005. }
  96006. /**
  96007. * This class is used by the onRenderingGroupObservable
  96008. */
  96009. export class RenderingGroupInfo {
  96010. /**
  96011. * The Scene that being rendered
  96012. */
  96013. scene: Scene;
  96014. /**
  96015. * The camera currently used for the rendering pass
  96016. */
  96017. camera: Nullable<Camera>;
  96018. /**
  96019. * The ID of the renderingGroup being processed
  96020. */
  96021. renderingGroupId: number;
  96022. }
  96023. /**
  96024. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96025. * It is enable to manage the different groups as well as the different necessary sort functions.
  96026. * This should not be used directly aside of the few static configurations
  96027. */
  96028. export class RenderingManager {
  96029. /**
  96030. * The max id used for rendering groups (not included)
  96031. */
  96032. static MAX_RENDERINGGROUPS: number;
  96033. /**
  96034. * The min id used for rendering groups (included)
  96035. */
  96036. static MIN_RENDERINGGROUPS: number;
  96037. /**
  96038. * Used to globally prevent autoclearing scenes.
  96039. */
  96040. static AUTOCLEAR: boolean;
  96041. /**
  96042. * @hidden
  96043. */
  96044. _useSceneAutoClearSetup: boolean;
  96045. private _scene;
  96046. private _renderingGroups;
  96047. private _depthStencilBufferAlreadyCleaned;
  96048. private _autoClearDepthStencil;
  96049. private _customOpaqueSortCompareFn;
  96050. private _customAlphaTestSortCompareFn;
  96051. private _customTransparentSortCompareFn;
  96052. private _renderingGroupInfo;
  96053. /**
  96054. * Instantiates a new rendering group for a particular scene
  96055. * @param scene Defines the scene the groups belongs to
  96056. */
  96057. constructor(scene: Scene);
  96058. private _clearDepthStencilBuffer;
  96059. /**
  96060. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96061. * @hidden
  96062. */
  96063. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96064. /**
  96065. * Resets the different information of the group to prepare a new frame
  96066. * @hidden
  96067. */
  96068. reset(): void;
  96069. /**
  96070. * Dispose and release the group and its associated resources.
  96071. * @hidden
  96072. */
  96073. dispose(): void;
  96074. /**
  96075. * Clear the info related to rendering groups preventing retention points during dispose.
  96076. */
  96077. freeRenderingGroups(): void;
  96078. private _prepareRenderingGroup;
  96079. /**
  96080. * Add a sprite manager to the rendering manager in order to render it this frame.
  96081. * @param spriteManager Define the sprite manager to render
  96082. */
  96083. dispatchSprites(spriteManager: ISpriteManager): void;
  96084. /**
  96085. * Add a particle system to the rendering manager in order to render it this frame.
  96086. * @param particleSystem Define the particle system to render
  96087. */
  96088. dispatchParticles(particleSystem: IParticleSystem): void;
  96089. /**
  96090. * Add a submesh to the manager in order to render it this frame
  96091. * @param subMesh The submesh to dispatch
  96092. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96093. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96094. */
  96095. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96096. /**
  96097. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96098. * This allowed control for front to back rendering or reversly depending of the special needs.
  96099. *
  96100. * @param renderingGroupId The rendering group id corresponding to its index
  96101. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96102. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96103. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96104. */
  96105. 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;
  96106. /**
  96107. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96108. *
  96109. * @param renderingGroupId The rendering group id corresponding to its index
  96110. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96111. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96112. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96113. */
  96114. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96115. /**
  96116. * Gets the current auto clear configuration for one rendering group of the rendering
  96117. * manager.
  96118. * @param index the rendering group index to get the information for
  96119. * @returns The auto clear setup for the requested rendering group
  96120. */
  96121. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96122. }
  96123. }
  96124. declare module BABYLON {
  96125. /**
  96126. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96127. */
  96128. export interface ICustomShaderOptions {
  96129. /**
  96130. * Gets or sets the custom shader name to use
  96131. */
  96132. shaderName: string;
  96133. /**
  96134. * The list of attribute names used in the shader
  96135. */
  96136. attributes?: string[];
  96137. /**
  96138. * The list of unifrom names used in the shader
  96139. */
  96140. uniforms?: string[];
  96141. /**
  96142. * The list of sampler names used in the shader
  96143. */
  96144. samplers?: string[];
  96145. /**
  96146. * The list of defines used in the shader
  96147. */
  96148. defines?: string[];
  96149. }
  96150. /**
  96151. * Interface to implement to create a shadow generator compatible with BJS.
  96152. */
  96153. export interface IShadowGenerator {
  96154. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96155. id: string;
  96156. /**
  96157. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96158. * @returns The render target texture if present otherwise, null
  96159. */
  96160. getShadowMap(): Nullable<RenderTargetTexture>;
  96161. /**
  96162. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96163. * @param subMesh The submesh we want to render in the shadow map
  96164. * @param useInstances Defines wether will draw in the map using instances
  96165. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96166. * @returns true if ready otherwise, false
  96167. */
  96168. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96169. /**
  96170. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96171. * @param defines Defines of the material we want to update
  96172. * @param lightIndex Index of the light in the enabled light list of the material
  96173. */
  96174. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96175. /**
  96176. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96177. * defined in the generator but impacting the effect).
  96178. * It implies the unifroms available on the materials are the standard BJS ones.
  96179. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96180. * @param effect The effect we are binfing the information for
  96181. */
  96182. bindShadowLight(lightIndex: string, effect: Effect): void;
  96183. /**
  96184. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96185. * (eq to shadow prjection matrix * light transform matrix)
  96186. * @returns The transform matrix used to create the shadow map
  96187. */
  96188. getTransformMatrix(): Matrix;
  96189. /**
  96190. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96191. * Cube and 2D textures for instance.
  96192. */
  96193. recreateShadowMap(): void;
  96194. /**
  96195. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96196. * @param onCompiled Callback triggered at the and of the effects compilation
  96197. * @param options Sets of optional options forcing the compilation with different modes
  96198. */
  96199. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96200. useInstances: boolean;
  96201. }>): void;
  96202. /**
  96203. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96204. * @param options Sets of optional options forcing the compilation with different modes
  96205. * @returns A promise that resolves when the compilation completes
  96206. */
  96207. forceCompilationAsync(options?: Partial<{
  96208. useInstances: boolean;
  96209. }>): Promise<void>;
  96210. /**
  96211. * Serializes the shadow generator setup to a json object.
  96212. * @returns The serialized JSON object
  96213. */
  96214. serialize(): any;
  96215. /**
  96216. * Disposes the Shadow map and related Textures and effects.
  96217. */
  96218. dispose(): void;
  96219. }
  96220. /**
  96221. * Default implementation IShadowGenerator.
  96222. * This is the main object responsible of generating shadows in the framework.
  96223. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96224. */
  96225. export class ShadowGenerator implements IShadowGenerator {
  96226. /**
  96227. * Name of the shadow generator class
  96228. */
  96229. static CLASSNAME: string;
  96230. /**
  96231. * Shadow generator mode None: no filtering applied.
  96232. */
  96233. static readonly FILTER_NONE: number;
  96234. /**
  96235. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96236. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96237. */
  96238. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96239. /**
  96240. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96241. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96242. */
  96243. static readonly FILTER_POISSONSAMPLING: number;
  96244. /**
  96245. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96246. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96247. */
  96248. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96249. /**
  96250. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96251. * edge artifacts on steep falloff.
  96252. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96253. */
  96254. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96255. /**
  96256. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96257. * edge artifacts on steep falloff.
  96258. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96259. */
  96260. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96261. /**
  96262. * Shadow generator mode PCF: Percentage Closer Filtering
  96263. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96264. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96265. */
  96266. static readonly FILTER_PCF: number;
  96267. /**
  96268. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96269. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96270. * Contact Hardening
  96271. */
  96272. static readonly FILTER_PCSS: number;
  96273. /**
  96274. * Reserved for PCF and PCSS
  96275. * Highest Quality.
  96276. *
  96277. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96278. *
  96279. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96280. */
  96281. static readonly QUALITY_HIGH: number;
  96282. /**
  96283. * Reserved for PCF and PCSS
  96284. * Good tradeoff for quality/perf cross devices
  96285. *
  96286. * Execute PCF on a 3*3 kernel.
  96287. *
  96288. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96289. */
  96290. static readonly QUALITY_MEDIUM: number;
  96291. /**
  96292. * Reserved for PCF and PCSS
  96293. * The lowest quality but the fastest.
  96294. *
  96295. * Execute PCF on a 1*1 kernel.
  96296. *
  96297. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96298. */
  96299. static readonly QUALITY_LOW: number;
  96300. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96301. id: string;
  96302. /** Gets or sets the custom shader name to use */
  96303. customShaderOptions: ICustomShaderOptions;
  96304. /**
  96305. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96306. */
  96307. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96308. /**
  96309. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96310. */
  96311. onAfterShadowMapRenderObservable: Observable<Effect>;
  96312. /**
  96313. * Observable triggered before a mesh is rendered in the shadow map.
  96314. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96315. */
  96316. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96317. /**
  96318. * Observable triggered after a mesh is rendered in the shadow map.
  96319. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96320. */
  96321. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96322. protected _bias: number;
  96323. /**
  96324. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96325. */
  96326. get bias(): number;
  96327. /**
  96328. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96329. */
  96330. set bias(bias: number);
  96331. protected _normalBias: number;
  96332. /**
  96333. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96334. */
  96335. get normalBias(): number;
  96336. /**
  96337. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96338. */
  96339. set normalBias(normalBias: number);
  96340. protected _blurBoxOffset: number;
  96341. /**
  96342. * Gets the blur box offset: offset applied during the blur pass.
  96343. * Only useful if useKernelBlur = false
  96344. */
  96345. get blurBoxOffset(): number;
  96346. /**
  96347. * Sets the blur box offset: offset applied during the blur pass.
  96348. * Only useful if useKernelBlur = false
  96349. */
  96350. set blurBoxOffset(value: number);
  96351. protected _blurScale: number;
  96352. /**
  96353. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96354. * 2 means half of the size.
  96355. */
  96356. get blurScale(): number;
  96357. /**
  96358. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96359. * 2 means half of the size.
  96360. */
  96361. set blurScale(value: number);
  96362. protected _blurKernel: number;
  96363. /**
  96364. * Gets the blur kernel: kernel size of the blur pass.
  96365. * Only useful if useKernelBlur = true
  96366. */
  96367. get blurKernel(): number;
  96368. /**
  96369. * Sets the blur kernel: kernel size of the blur pass.
  96370. * Only useful if useKernelBlur = true
  96371. */
  96372. set blurKernel(value: number);
  96373. protected _useKernelBlur: boolean;
  96374. /**
  96375. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96376. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96377. */
  96378. get useKernelBlur(): boolean;
  96379. /**
  96380. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96381. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96382. */
  96383. set useKernelBlur(value: boolean);
  96384. protected _depthScale: number;
  96385. /**
  96386. * Gets the depth scale used in ESM mode.
  96387. */
  96388. get depthScale(): number;
  96389. /**
  96390. * Sets the depth scale used in ESM mode.
  96391. * This can override the scale stored on the light.
  96392. */
  96393. set depthScale(value: number);
  96394. protected _validateFilter(filter: number): number;
  96395. protected _filter: number;
  96396. /**
  96397. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96398. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96399. */
  96400. get filter(): number;
  96401. /**
  96402. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96403. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96404. */
  96405. set filter(value: number);
  96406. /**
  96407. * Gets if the current filter is set to Poisson Sampling.
  96408. */
  96409. get usePoissonSampling(): boolean;
  96410. /**
  96411. * Sets the current filter to Poisson Sampling.
  96412. */
  96413. set usePoissonSampling(value: boolean);
  96414. /**
  96415. * Gets if the current filter is set to ESM.
  96416. */
  96417. get useExponentialShadowMap(): boolean;
  96418. /**
  96419. * Sets the current filter is to ESM.
  96420. */
  96421. set useExponentialShadowMap(value: boolean);
  96422. /**
  96423. * Gets if the current filter is set to filtered ESM.
  96424. */
  96425. get useBlurExponentialShadowMap(): boolean;
  96426. /**
  96427. * Gets if the current filter is set to filtered ESM.
  96428. */
  96429. set useBlurExponentialShadowMap(value: boolean);
  96430. /**
  96431. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96432. * exponential to prevent steep falloff artifacts).
  96433. */
  96434. get useCloseExponentialShadowMap(): boolean;
  96435. /**
  96436. * Sets the current filter to "close ESM" (using the inverse of the
  96437. * exponential to prevent steep falloff artifacts).
  96438. */
  96439. set useCloseExponentialShadowMap(value: boolean);
  96440. /**
  96441. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96442. * exponential to prevent steep falloff artifacts).
  96443. */
  96444. get useBlurCloseExponentialShadowMap(): boolean;
  96445. /**
  96446. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96447. * exponential to prevent steep falloff artifacts).
  96448. */
  96449. set useBlurCloseExponentialShadowMap(value: boolean);
  96450. /**
  96451. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96452. */
  96453. get usePercentageCloserFiltering(): boolean;
  96454. /**
  96455. * Sets the current filter to "PCF" (percentage closer filtering).
  96456. */
  96457. set usePercentageCloserFiltering(value: boolean);
  96458. protected _filteringQuality: number;
  96459. /**
  96460. * Gets the PCF or PCSS Quality.
  96461. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96462. */
  96463. get filteringQuality(): number;
  96464. /**
  96465. * Sets the PCF or PCSS Quality.
  96466. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96467. */
  96468. set filteringQuality(filteringQuality: number);
  96469. /**
  96470. * Gets if the current filter is set to "PCSS" (contact hardening).
  96471. */
  96472. get useContactHardeningShadow(): boolean;
  96473. /**
  96474. * Sets the current filter to "PCSS" (contact hardening).
  96475. */
  96476. set useContactHardeningShadow(value: boolean);
  96477. protected _contactHardeningLightSizeUVRatio: number;
  96478. /**
  96479. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96480. * Using a ratio helps keeping shape stability independently of the map size.
  96481. *
  96482. * It does not account for the light projection as it was having too much
  96483. * instability during the light setup or during light position changes.
  96484. *
  96485. * Only valid if useContactHardeningShadow is true.
  96486. */
  96487. get contactHardeningLightSizeUVRatio(): number;
  96488. /**
  96489. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96490. * Using a ratio helps keeping shape stability independently of the map size.
  96491. *
  96492. * It does not account for the light projection as it was having too much
  96493. * instability during the light setup or during light position changes.
  96494. *
  96495. * Only valid if useContactHardeningShadow is true.
  96496. */
  96497. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96498. protected _darkness: number;
  96499. /** Gets or sets the actual darkness of a shadow */
  96500. get darkness(): number;
  96501. set darkness(value: number);
  96502. /**
  96503. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96504. * 0 means strongest and 1 would means no shadow.
  96505. * @returns the darkness.
  96506. */
  96507. getDarkness(): number;
  96508. /**
  96509. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96510. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96511. * @returns the shadow generator allowing fluent coding.
  96512. */
  96513. setDarkness(darkness: number): ShadowGenerator;
  96514. protected _transparencyShadow: boolean;
  96515. /** Gets or sets the ability to have transparent shadow */
  96516. get transparencyShadow(): boolean;
  96517. set transparencyShadow(value: boolean);
  96518. /**
  96519. * Sets the ability to have transparent shadow (boolean).
  96520. * @param transparent True if transparent else False
  96521. * @returns the shadow generator allowing fluent coding
  96522. */
  96523. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96524. /**
  96525. * Enables or disables shadows with varying strength based on the transparency
  96526. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96527. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96528. * mesh.visibility * alphaTexture.a
  96529. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96530. */
  96531. enableSoftTransparentShadow: boolean;
  96532. protected _shadowMap: Nullable<RenderTargetTexture>;
  96533. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96534. /**
  96535. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96536. * @returns The render target texture if present otherwise, null
  96537. */
  96538. getShadowMap(): Nullable<RenderTargetTexture>;
  96539. /**
  96540. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96541. * @returns The render target texture if the shadow map is present otherwise, null
  96542. */
  96543. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96544. /**
  96545. * Gets the class name of that object
  96546. * @returns "ShadowGenerator"
  96547. */
  96548. getClassName(): string;
  96549. /**
  96550. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96551. * @param mesh Mesh to add
  96552. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96553. * @returns the Shadow Generator itself
  96554. */
  96555. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96556. /**
  96557. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96558. * @param mesh Mesh to remove
  96559. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96560. * @returns the Shadow Generator itself
  96561. */
  96562. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96563. /**
  96564. * Controls the extent to which the shadows fade out at the edge of the frustum
  96565. */
  96566. frustumEdgeFalloff: number;
  96567. protected _light: IShadowLight;
  96568. /**
  96569. * Returns the associated light object.
  96570. * @returns the light generating the shadow
  96571. */
  96572. getLight(): IShadowLight;
  96573. /**
  96574. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96575. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96576. * It might on the other hand introduce peter panning.
  96577. */
  96578. forceBackFacesOnly: boolean;
  96579. protected _scene: Scene;
  96580. protected _lightDirection: Vector3;
  96581. protected _effect: Effect;
  96582. protected _viewMatrix: Matrix;
  96583. protected _projectionMatrix: Matrix;
  96584. protected _transformMatrix: Matrix;
  96585. protected _cachedPosition: Vector3;
  96586. protected _cachedDirection: Vector3;
  96587. protected _cachedDefines: string;
  96588. protected _currentRenderID: number;
  96589. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96590. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96591. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96592. protected _blurPostProcesses: PostProcess[];
  96593. protected _mapSize: number;
  96594. protected _currentFaceIndex: number;
  96595. protected _currentFaceIndexCache: number;
  96596. protected _textureType: number;
  96597. protected _defaultTextureMatrix: Matrix;
  96598. protected _storedUniqueId: Nullable<number>;
  96599. /** @hidden */
  96600. static _SceneComponentInitialization: (scene: Scene) => void;
  96601. /**
  96602. * Creates a ShadowGenerator object.
  96603. * A ShadowGenerator is the required tool to use the shadows.
  96604. * Each light casting shadows needs to use its own ShadowGenerator.
  96605. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96606. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96607. * @param light The light object generating the shadows.
  96608. * @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.
  96609. */
  96610. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96611. protected _initializeGenerator(): void;
  96612. protected _createTargetRenderTexture(): void;
  96613. protected _initializeShadowMap(): void;
  96614. protected _initializeBlurRTTAndPostProcesses(): void;
  96615. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96616. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96617. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96618. protected _applyFilterValues(): void;
  96619. /**
  96620. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96621. * @param onCompiled Callback triggered at the and of the effects compilation
  96622. * @param options Sets of optional options forcing the compilation with different modes
  96623. */
  96624. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96625. useInstances: boolean;
  96626. }>): void;
  96627. /**
  96628. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96629. * @param options Sets of optional options forcing the compilation with different modes
  96630. * @returns A promise that resolves when the compilation completes
  96631. */
  96632. forceCompilationAsync(options?: Partial<{
  96633. useInstances: boolean;
  96634. }>): Promise<void>;
  96635. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96636. private _prepareShadowDefines;
  96637. /**
  96638. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96639. * @param subMesh The submesh we want to render in the shadow map
  96640. * @param useInstances Defines wether will draw in the map using instances
  96641. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96642. * @returns true if ready otherwise, false
  96643. */
  96644. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96645. /**
  96646. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96647. * @param defines Defines of the material we want to update
  96648. * @param lightIndex Index of the light in the enabled light list of the material
  96649. */
  96650. prepareDefines(defines: any, lightIndex: number): void;
  96651. /**
  96652. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96653. * defined in the generator but impacting the effect).
  96654. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96655. * @param effect The effect we are binfing the information for
  96656. */
  96657. bindShadowLight(lightIndex: string, effect: Effect): void;
  96658. /**
  96659. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96660. * (eq to shadow prjection matrix * light transform matrix)
  96661. * @returns The transform matrix used to create the shadow map
  96662. */
  96663. getTransformMatrix(): Matrix;
  96664. /**
  96665. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96666. * Cube and 2D textures for instance.
  96667. */
  96668. recreateShadowMap(): void;
  96669. protected _disposeBlurPostProcesses(): void;
  96670. protected _disposeRTTandPostProcesses(): void;
  96671. /**
  96672. * Disposes the ShadowGenerator.
  96673. * Returns nothing.
  96674. */
  96675. dispose(): void;
  96676. /**
  96677. * Serializes the shadow generator setup to a json object.
  96678. * @returns The serialized JSON object
  96679. */
  96680. serialize(): any;
  96681. /**
  96682. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96683. * @param parsedShadowGenerator The JSON object to parse
  96684. * @param scene The scene to create the shadow map for
  96685. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96686. * @returns The parsed shadow generator
  96687. */
  96688. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96689. }
  96690. }
  96691. declare module BABYLON {
  96692. /**
  96693. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96694. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96695. * 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.
  96696. */
  96697. export abstract class Light extends Node {
  96698. /**
  96699. * Falloff Default: light is falling off following the material specification:
  96700. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96701. */
  96702. static readonly FALLOFF_DEFAULT: number;
  96703. /**
  96704. * Falloff Physical: light is falling off following the inverse squared distance law.
  96705. */
  96706. static readonly FALLOFF_PHYSICAL: number;
  96707. /**
  96708. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96709. * to enhance interoperability with other engines.
  96710. */
  96711. static readonly FALLOFF_GLTF: number;
  96712. /**
  96713. * Falloff Standard: light is falling off like in the standard material
  96714. * to enhance interoperability with other materials.
  96715. */
  96716. static readonly FALLOFF_STANDARD: number;
  96717. /**
  96718. * If every light affecting the material is in this lightmapMode,
  96719. * material.lightmapTexture adds or multiplies
  96720. * (depends on material.useLightmapAsShadowmap)
  96721. * after every other light calculations.
  96722. */
  96723. static readonly LIGHTMAP_DEFAULT: number;
  96724. /**
  96725. * material.lightmapTexture as only diffuse lighting from this light
  96726. * adds only specular lighting from this light
  96727. * adds dynamic shadows
  96728. */
  96729. static readonly LIGHTMAP_SPECULAR: number;
  96730. /**
  96731. * material.lightmapTexture as only lighting
  96732. * no light calculation from this light
  96733. * only adds dynamic shadows from this light
  96734. */
  96735. static readonly LIGHTMAP_SHADOWSONLY: number;
  96736. /**
  96737. * Each light type uses the default quantity according to its type:
  96738. * point/spot lights use luminous intensity
  96739. * directional lights use illuminance
  96740. */
  96741. static readonly INTENSITYMODE_AUTOMATIC: number;
  96742. /**
  96743. * lumen (lm)
  96744. */
  96745. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96746. /**
  96747. * candela (lm/sr)
  96748. */
  96749. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96750. /**
  96751. * lux (lm/m^2)
  96752. */
  96753. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96754. /**
  96755. * nit (cd/m^2)
  96756. */
  96757. static readonly INTENSITYMODE_LUMINANCE: number;
  96758. /**
  96759. * Light type const id of the point light.
  96760. */
  96761. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96762. /**
  96763. * Light type const id of the directional light.
  96764. */
  96765. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96766. /**
  96767. * Light type const id of the spot light.
  96768. */
  96769. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96770. /**
  96771. * Light type const id of the hemispheric light.
  96772. */
  96773. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96774. /**
  96775. * Diffuse gives the basic color to an object.
  96776. */
  96777. diffuse: Color3;
  96778. /**
  96779. * Specular produces a highlight color on an object.
  96780. * Note: This is note affecting PBR materials.
  96781. */
  96782. specular: Color3;
  96783. /**
  96784. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96785. * falling off base on range or angle.
  96786. * This can be set to any values in Light.FALLOFF_x.
  96787. *
  96788. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96789. * other types of materials.
  96790. */
  96791. falloffType: number;
  96792. /**
  96793. * Strength of the light.
  96794. * Note: By default it is define in the framework own unit.
  96795. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96796. */
  96797. intensity: number;
  96798. private _range;
  96799. protected _inverseSquaredRange: number;
  96800. /**
  96801. * Defines how far from the source the light is impacting in scene units.
  96802. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96803. */
  96804. get range(): number;
  96805. /**
  96806. * Defines how far from the source the light is impacting in scene units.
  96807. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96808. */
  96809. set range(value: number);
  96810. /**
  96811. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96812. * of light.
  96813. */
  96814. private _photometricScale;
  96815. private _intensityMode;
  96816. /**
  96817. * Gets the photometric scale used to interpret the intensity.
  96818. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96819. */
  96820. get intensityMode(): number;
  96821. /**
  96822. * Sets the photometric scale used to interpret the intensity.
  96823. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96824. */
  96825. set intensityMode(value: number);
  96826. private _radius;
  96827. /**
  96828. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96829. */
  96830. get radius(): number;
  96831. /**
  96832. * sets the light radius used by PBR Materials to simulate soft area lights.
  96833. */
  96834. set radius(value: number);
  96835. private _renderPriority;
  96836. /**
  96837. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96838. * exceeding the number allowed of the materials.
  96839. */
  96840. renderPriority: number;
  96841. private _shadowEnabled;
  96842. /**
  96843. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96844. * the current shadow generator.
  96845. */
  96846. get shadowEnabled(): boolean;
  96847. /**
  96848. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96849. * the current shadow generator.
  96850. */
  96851. set shadowEnabled(value: boolean);
  96852. private _includedOnlyMeshes;
  96853. /**
  96854. * Gets the only meshes impacted by this light.
  96855. */
  96856. get includedOnlyMeshes(): AbstractMesh[];
  96857. /**
  96858. * Sets the only meshes impacted by this light.
  96859. */
  96860. set includedOnlyMeshes(value: AbstractMesh[]);
  96861. private _excludedMeshes;
  96862. /**
  96863. * Gets the meshes not impacted by this light.
  96864. */
  96865. get excludedMeshes(): AbstractMesh[];
  96866. /**
  96867. * Sets the meshes not impacted by this light.
  96868. */
  96869. set excludedMeshes(value: AbstractMesh[]);
  96870. private _excludeWithLayerMask;
  96871. /**
  96872. * Gets the layer id use to find what meshes are not impacted by the light.
  96873. * Inactive if 0
  96874. */
  96875. get excludeWithLayerMask(): number;
  96876. /**
  96877. * Sets the layer id use to find what meshes are not impacted by the light.
  96878. * Inactive if 0
  96879. */
  96880. set excludeWithLayerMask(value: number);
  96881. private _includeOnlyWithLayerMask;
  96882. /**
  96883. * Gets the layer id use to find what meshes are impacted by the light.
  96884. * Inactive if 0
  96885. */
  96886. get includeOnlyWithLayerMask(): number;
  96887. /**
  96888. * Sets the layer id use to find what meshes are impacted by the light.
  96889. * Inactive if 0
  96890. */
  96891. set includeOnlyWithLayerMask(value: number);
  96892. private _lightmapMode;
  96893. /**
  96894. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96895. */
  96896. get lightmapMode(): number;
  96897. /**
  96898. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96899. */
  96900. set lightmapMode(value: number);
  96901. /**
  96902. * Shadow generator associted to the light.
  96903. * @hidden Internal use only.
  96904. */
  96905. _shadowGenerator: Nullable<IShadowGenerator>;
  96906. /**
  96907. * @hidden Internal use only.
  96908. */
  96909. _excludedMeshesIds: string[];
  96910. /**
  96911. * @hidden Internal use only.
  96912. */
  96913. _includedOnlyMeshesIds: string[];
  96914. /**
  96915. * The current light unifom buffer.
  96916. * @hidden Internal use only.
  96917. */
  96918. _uniformBuffer: UniformBuffer;
  96919. /** @hidden */
  96920. _renderId: number;
  96921. /**
  96922. * Creates a Light object in the scene.
  96923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96924. * @param name The firendly name of the light
  96925. * @param scene The scene the light belongs too
  96926. */
  96927. constructor(name: string, scene: Scene);
  96928. protected abstract _buildUniformLayout(): void;
  96929. /**
  96930. * Sets the passed Effect "effect" with the Light information.
  96931. * @param effect The effect to update
  96932. * @param lightIndex The index of the light in the effect to update
  96933. * @returns The light
  96934. */
  96935. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96936. /**
  96937. * Sets the passed Effect "effect" with the Light textures.
  96938. * @param effect The effect to update
  96939. * @param lightIndex The index of the light in the effect to update
  96940. * @returns The light
  96941. */
  96942. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96943. /**
  96944. * Binds the lights information from the scene to the effect for the given mesh.
  96945. * @param lightIndex Light index
  96946. * @param scene The scene where the light belongs to
  96947. * @param effect The effect we are binding the data to
  96948. * @param useSpecular Defines if specular is supported
  96949. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96950. */
  96951. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96952. /**
  96953. * Sets the passed Effect "effect" with the Light information.
  96954. * @param effect The effect to update
  96955. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96956. * @returns The light
  96957. */
  96958. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96959. /**
  96960. * Returns the string "Light".
  96961. * @returns the class name
  96962. */
  96963. getClassName(): string;
  96964. /** @hidden */
  96965. readonly _isLight: boolean;
  96966. /**
  96967. * Converts the light information to a readable string for debug purpose.
  96968. * @param fullDetails Supports for multiple levels of logging within scene loading
  96969. * @returns the human readable light info
  96970. */
  96971. toString(fullDetails?: boolean): string;
  96972. /** @hidden */
  96973. protected _syncParentEnabledState(): void;
  96974. /**
  96975. * Set the enabled state of this node.
  96976. * @param value - the new enabled state
  96977. */
  96978. setEnabled(value: boolean): void;
  96979. /**
  96980. * Returns the Light associated shadow generator if any.
  96981. * @return the associated shadow generator.
  96982. */
  96983. getShadowGenerator(): Nullable<IShadowGenerator>;
  96984. /**
  96985. * Returns a Vector3, the absolute light position in the World.
  96986. * @returns the world space position of the light
  96987. */
  96988. getAbsolutePosition(): Vector3;
  96989. /**
  96990. * Specifies if the light will affect the passed mesh.
  96991. * @param mesh The mesh to test against the light
  96992. * @return true the mesh is affected otherwise, false.
  96993. */
  96994. canAffectMesh(mesh: AbstractMesh): boolean;
  96995. /**
  96996. * Sort function to order lights for rendering.
  96997. * @param a First Light object to compare to second.
  96998. * @param b Second Light object to compare first.
  96999. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97000. */
  97001. static CompareLightsPriority(a: Light, b: Light): number;
  97002. /**
  97003. * Releases resources associated with this node.
  97004. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97005. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97006. */
  97007. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97008. /**
  97009. * Returns the light type ID (integer).
  97010. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97011. */
  97012. getTypeID(): number;
  97013. /**
  97014. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97015. * @returns the scaled intensity in intensity mode unit
  97016. */
  97017. getScaledIntensity(): number;
  97018. /**
  97019. * Returns a new Light object, named "name", from the current one.
  97020. * @param name The name of the cloned light
  97021. * @param newParent The parent of this light, if it has one
  97022. * @returns the new created light
  97023. */
  97024. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97025. /**
  97026. * Serializes the current light into a Serialization object.
  97027. * @returns the serialized object.
  97028. */
  97029. serialize(): any;
  97030. /**
  97031. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97032. * This new light is named "name" and added to the passed scene.
  97033. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97034. * @param name The friendly name of the light
  97035. * @param scene The scene the new light will belong to
  97036. * @returns the constructor function
  97037. */
  97038. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97039. /**
  97040. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97041. * @param parsedLight The JSON representation of the light
  97042. * @param scene The scene to create the parsed light in
  97043. * @returns the created light after parsing
  97044. */
  97045. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97046. private _hookArrayForExcluded;
  97047. private _hookArrayForIncludedOnly;
  97048. private _resyncMeshes;
  97049. /**
  97050. * Forces the meshes to update their light related information in their rendering used effects
  97051. * @hidden Internal Use Only
  97052. */
  97053. _markMeshesAsLightDirty(): void;
  97054. /**
  97055. * Recomputes the cached photometric scale if needed.
  97056. */
  97057. private _computePhotometricScale;
  97058. /**
  97059. * Returns the Photometric Scale according to the light type and intensity mode.
  97060. */
  97061. private _getPhotometricScale;
  97062. /**
  97063. * Reorder the light in the scene according to their defined priority.
  97064. * @hidden Internal Use Only
  97065. */
  97066. _reorderLightsInScene(): void;
  97067. /**
  97068. * Prepares the list of defines specific to the light type.
  97069. * @param defines the list of defines
  97070. * @param lightIndex defines the index of the light for the effect
  97071. */
  97072. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97073. }
  97074. }
  97075. declare module BABYLON {
  97076. /**
  97077. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97078. * This is the base of the follow, arc rotate cameras and Free camera
  97079. * @see https://doc.babylonjs.com/features/cameras
  97080. */
  97081. export class TargetCamera extends Camera {
  97082. private static _RigCamTransformMatrix;
  97083. private static _TargetTransformMatrix;
  97084. private static _TargetFocalPoint;
  97085. private _tmpUpVector;
  97086. private _tmpTargetVector;
  97087. /**
  97088. * Define the current direction the camera is moving to
  97089. */
  97090. cameraDirection: Vector3;
  97091. /**
  97092. * Define the current rotation the camera is rotating to
  97093. */
  97094. cameraRotation: Vector2;
  97095. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97096. ignoreParentScaling: boolean;
  97097. /**
  97098. * When set, the up vector of the camera will be updated by the rotation of the camera
  97099. */
  97100. updateUpVectorFromRotation: boolean;
  97101. private _tmpQuaternion;
  97102. /**
  97103. * Define the current rotation of the camera
  97104. */
  97105. rotation: Vector3;
  97106. /**
  97107. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97108. */
  97109. rotationQuaternion: Quaternion;
  97110. /**
  97111. * Define the current speed of the camera
  97112. */
  97113. speed: number;
  97114. /**
  97115. * Add constraint to the camera to prevent it to move freely in all directions and
  97116. * around all axis.
  97117. */
  97118. noRotationConstraint: boolean;
  97119. /**
  97120. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97121. * panning
  97122. */
  97123. invertRotation: boolean;
  97124. /**
  97125. * Speed multiplier for inverse camera panning
  97126. */
  97127. inverseRotationSpeed: number;
  97128. /**
  97129. * Define the current target of the camera as an object or a position.
  97130. */
  97131. lockedTarget: any;
  97132. /** @hidden */
  97133. _currentTarget: Vector3;
  97134. /** @hidden */
  97135. _initialFocalDistance: number;
  97136. /** @hidden */
  97137. _viewMatrix: Matrix;
  97138. /** @hidden */
  97139. _camMatrix: Matrix;
  97140. /** @hidden */
  97141. _cameraTransformMatrix: Matrix;
  97142. /** @hidden */
  97143. _cameraRotationMatrix: Matrix;
  97144. /** @hidden */
  97145. _referencePoint: Vector3;
  97146. /** @hidden */
  97147. _transformedReferencePoint: Vector3;
  97148. /** @hidden */
  97149. _reset: () => void;
  97150. private _defaultUp;
  97151. /**
  97152. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97153. * This is the base of the follow, arc rotate cameras and Free camera
  97154. * @see https://doc.babylonjs.com/features/cameras
  97155. * @param name Defines the name of the camera in the scene
  97156. * @param position Defines the start position of the camera in the scene
  97157. * @param scene Defines the scene the camera belongs to
  97158. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97159. */
  97160. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97161. /**
  97162. * Gets the position in front of the camera at a given distance.
  97163. * @param distance The distance from the camera we want the position to be
  97164. * @returns the position
  97165. */
  97166. getFrontPosition(distance: number): Vector3;
  97167. /** @hidden */
  97168. _getLockedTargetPosition(): Nullable<Vector3>;
  97169. private _storedPosition;
  97170. private _storedRotation;
  97171. private _storedRotationQuaternion;
  97172. /**
  97173. * Store current camera state of the camera (fov, position, rotation, etc..)
  97174. * @returns the camera
  97175. */
  97176. storeState(): Camera;
  97177. /**
  97178. * Restored camera state. You must call storeState() first
  97179. * @returns whether it was successful or not
  97180. * @hidden
  97181. */
  97182. _restoreStateValues(): boolean;
  97183. /** @hidden */
  97184. _initCache(): void;
  97185. /** @hidden */
  97186. _updateCache(ignoreParentClass?: boolean): void;
  97187. /** @hidden */
  97188. _isSynchronizedViewMatrix(): boolean;
  97189. /** @hidden */
  97190. _computeLocalCameraSpeed(): number;
  97191. /**
  97192. * Defines the target the camera should look at.
  97193. * @param target Defines the new target as a Vector or a mesh
  97194. */
  97195. setTarget(target: Vector3): void;
  97196. /**
  97197. * Return the current target position of the camera. This value is expressed in local space.
  97198. * @returns the target position
  97199. */
  97200. getTarget(): Vector3;
  97201. /** @hidden */
  97202. _decideIfNeedsToMove(): boolean;
  97203. /** @hidden */
  97204. _updatePosition(): void;
  97205. /** @hidden */
  97206. _checkInputs(): void;
  97207. protected _updateCameraRotationMatrix(): void;
  97208. /**
  97209. * 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)
  97210. * @returns the current camera
  97211. */
  97212. private _rotateUpVectorWithCameraRotationMatrix;
  97213. private _cachedRotationZ;
  97214. private _cachedQuaternionRotationZ;
  97215. /** @hidden */
  97216. _getViewMatrix(): Matrix;
  97217. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97218. /**
  97219. * @hidden
  97220. */
  97221. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97222. /**
  97223. * @hidden
  97224. */
  97225. _updateRigCameras(): void;
  97226. private _getRigCamPositionAndTarget;
  97227. /**
  97228. * Gets the current object class name.
  97229. * @return the class name
  97230. */
  97231. getClassName(): string;
  97232. }
  97233. }
  97234. declare module BABYLON {
  97235. /**
  97236. * Gather the list of keyboard event types as constants.
  97237. */
  97238. export class KeyboardEventTypes {
  97239. /**
  97240. * The keydown event is fired when a key becomes active (pressed).
  97241. */
  97242. static readonly KEYDOWN: number;
  97243. /**
  97244. * The keyup event is fired when a key has been released.
  97245. */
  97246. static readonly KEYUP: number;
  97247. }
  97248. /**
  97249. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97250. */
  97251. export class KeyboardInfo {
  97252. /**
  97253. * Defines the type of event (KeyboardEventTypes)
  97254. */
  97255. type: number;
  97256. /**
  97257. * Defines the related dom event
  97258. */
  97259. event: KeyboardEvent;
  97260. /**
  97261. * Instantiates a new keyboard info.
  97262. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97263. * @param type Defines the type of event (KeyboardEventTypes)
  97264. * @param event Defines the related dom event
  97265. */
  97266. constructor(
  97267. /**
  97268. * Defines the type of event (KeyboardEventTypes)
  97269. */
  97270. type: number,
  97271. /**
  97272. * Defines the related dom event
  97273. */
  97274. event: KeyboardEvent);
  97275. }
  97276. /**
  97277. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97278. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97279. */
  97280. export class KeyboardInfoPre extends KeyboardInfo {
  97281. /**
  97282. * Defines the type of event (KeyboardEventTypes)
  97283. */
  97284. type: number;
  97285. /**
  97286. * Defines the related dom event
  97287. */
  97288. event: KeyboardEvent;
  97289. /**
  97290. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97291. */
  97292. skipOnPointerObservable: boolean;
  97293. /**
  97294. * Instantiates a new keyboard pre info.
  97295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97296. * @param type Defines the type of event (KeyboardEventTypes)
  97297. * @param event Defines the related dom event
  97298. */
  97299. constructor(
  97300. /**
  97301. * Defines the type of event (KeyboardEventTypes)
  97302. */
  97303. type: number,
  97304. /**
  97305. * Defines the related dom event
  97306. */
  97307. event: KeyboardEvent);
  97308. }
  97309. }
  97310. declare module BABYLON {
  97311. /**
  97312. * Manage the keyboard inputs to control the movement of a free camera.
  97313. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97314. */
  97315. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97316. /**
  97317. * Defines the camera the input is attached to.
  97318. */
  97319. camera: FreeCamera;
  97320. /**
  97321. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97322. */
  97323. keysUp: number[];
  97324. /**
  97325. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97326. */
  97327. keysUpward: number[];
  97328. /**
  97329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97330. */
  97331. keysDown: number[];
  97332. /**
  97333. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97334. */
  97335. keysDownward: number[];
  97336. /**
  97337. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97338. */
  97339. keysLeft: number[];
  97340. /**
  97341. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97342. */
  97343. keysRight: number[];
  97344. private _keys;
  97345. private _onCanvasBlurObserver;
  97346. private _onKeyboardObserver;
  97347. private _engine;
  97348. private _scene;
  97349. /**
  97350. * Attach the input controls to a specific dom element to get the input from.
  97351. * @param element Defines the element the controls should be listened from
  97352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97353. */
  97354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97355. /**
  97356. * Detach the current controls from the specified dom element.
  97357. * @param element Defines the element to stop listening the inputs from
  97358. */
  97359. detachControl(element: Nullable<HTMLElement>): void;
  97360. /**
  97361. * Update the current camera state depending on the inputs that have been used this frame.
  97362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97363. */
  97364. checkInputs(): void;
  97365. /**
  97366. * Gets the class name of the current intput.
  97367. * @returns the class name
  97368. */
  97369. getClassName(): string;
  97370. /** @hidden */
  97371. _onLostFocus(): void;
  97372. /**
  97373. * Get the friendly name associated with the input class.
  97374. * @returns the input friendly name
  97375. */
  97376. getSimpleName(): string;
  97377. }
  97378. }
  97379. declare module BABYLON {
  97380. /**
  97381. * Gather the list of pointer event types as constants.
  97382. */
  97383. export class PointerEventTypes {
  97384. /**
  97385. * 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.
  97386. */
  97387. static readonly POINTERDOWN: number;
  97388. /**
  97389. * The pointerup event is fired when a pointer is no longer active.
  97390. */
  97391. static readonly POINTERUP: number;
  97392. /**
  97393. * The pointermove event is fired when a pointer changes coordinates.
  97394. */
  97395. static readonly POINTERMOVE: number;
  97396. /**
  97397. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97398. */
  97399. static readonly POINTERWHEEL: number;
  97400. /**
  97401. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97402. */
  97403. static readonly POINTERPICK: number;
  97404. /**
  97405. * The pointertap event is fired when a the object has been touched and released without drag.
  97406. */
  97407. static readonly POINTERTAP: number;
  97408. /**
  97409. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97410. */
  97411. static readonly POINTERDOUBLETAP: number;
  97412. }
  97413. /**
  97414. * Base class of pointer info types.
  97415. */
  97416. export class PointerInfoBase {
  97417. /**
  97418. * Defines the type of event (PointerEventTypes)
  97419. */
  97420. type: number;
  97421. /**
  97422. * Defines the related dom event
  97423. */
  97424. event: PointerEvent | MouseWheelEvent;
  97425. /**
  97426. * Instantiates the base class of pointers info.
  97427. * @param type Defines the type of event (PointerEventTypes)
  97428. * @param event Defines the related dom event
  97429. */
  97430. constructor(
  97431. /**
  97432. * Defines the type of event (PointerEventTypes)
  97433. */
  97434. type: number,
  97435. /**
  97436. * Defines the related dom event
  97437. */
  97438. event: PointerEvent | MouseWheelEvent);
  97439. }
  97440. /**
  97441. * This class is used to store pointer related info for the onPrePointerObservable event.
  97442. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97443. */
  97444. export class PointerInfoPre extends PointerInfoBase {
  97445. /**
  97446. * Ray from a pointer if availible (eg. 6dof controller)
  97447. */
  97448. ray: Nullable<Ray>;
  97449. /**
  97450. * Defines the local position of the pointer on the canvas.
  97451. */
  97452. localPosition: Vector2;
  97453. /**
  97454. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97455. */
  97456. skipOnPointerObservable: boolean;
  97457. /**
  97458. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97459. * @param type Defines the type of event (PointerEventTypes)
  97460. * @param event Defines the related dom event
  97461. * @param localX Defines the local x coordinates of the pointer when the event occured
  97462. * @param localY Defines the local y coordinates of the pointer when the event occured
  97463. */
  97464. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97465. }
  97466. /**
  97467. * This type contains all the data related to a pointer event in Babylon.js.
  97468. * 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.
  97469. */
  97470. export class PointerInfo extends PointerInfoBase {
  97471. /**
  97472. * Defines the picking info associated to the info (if any)\
  97473. */
  97474. pickInfo: Nullable<PickingInfo>;
  97475. /**
  97476. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97477. * @param type Defines the type of event (PointerEventTypes)
  97478. * @param event Defines the related dom event
  97479. * @param pickInfo Defines the picking info associated to the info (if any)\
  97480. */
  97481. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97482. /**
  97483. * Defines the picking info associated to the info (if any)\
  97484. */
  97485. pickInfo: Nullable<PickingInfo>);
  97486. }
  97487. /**
  97488. * Data relating to a touch event on the screen.
  97489. */
  97490. export interface PointerTouch {
  97491. /**
  97492. * X coordinate of touch.
  97493. */
  97494. x: number;
  97495. /**
  97496. * Y coordinate of touch.
  97497. */
  97498. y: number;
  97499. /**
  97500. * Id of touch. Unique for each finger.
  97501. */
  97502. pointerId: number;
  97503. /**
  97504. * Event type passed from DOM.
  97505. */
  97506. type: any;
  97507. }
  97508. }
  97509. declare module BABYLON {
  97510. /**
  97511. * Manage the mouse inputs to control the movement of a free camera.
  97512. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97513. */
  97514. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97515. /**
  97516. * Define if touch is enabled in the mouse input
  97517. */
  97518. touchEnabled: boolean;
  97519. /**
  97520. * Defines the camera the input is attached to.
  97521. */
  97522. camera: FreeCamera;
  97523. /**
  97524. * Defines the buttons associated with the input to handle camera move.
  97525. */
  97526. buttons: number[];
  97527. /**
  97528. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97529. */
  97530. angularSensibility: number;
  97531. private _pointerInput;
  97532. private _onMouseMove;
  97533. private _observer;
  97534. private previousPosition;
  97535. /**
  97536. * Observable for when a pointer move event occurs containing the move offset
  97537. */
  97538. onPointerMovedObservable: Observable<{
  97539. offsetX: number;
  97540. offsetY: number;
  97541. }>;
  97542. /**
  97543. * @hidden
  97544. * If the camera should be rotated automatically based on pointer movement
  97545. */
  97546. _allowCameraRotation: boolean;
  97547. /**
  97548. * Manage the mouse inputs to control the movement of a free camera.
  97549. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97550. * @param touchEnabled Defines if touch is enabled or not
  97551. */
  97552. constructor(
  97553. /**
  97554. * Define if touch is enabled in the mouse input
  97555. */
  97556. touchEnabled?: boolean);
  97557. /**
  97558. * Attach the input controls to a specific dom element to get the input from.
  97559. * @param element Defines the element the controls should be listened from
  97560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97561. */
  97562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97563. /**
  97564. * Called on JS contextmenu event.
  97565. * Override this method to provide functionality.
  97566. */
  97567. protected onContextMenu(evt: PointerEvent): void;
  97568. /**
  97569. * Detach the current controls from the specified dom element.
  97570. * @param element Defines the element to stop listening the inputs from
  97571. */
  97572. detachControl(element: Nullable<HTMLElement>): void;
  97573. /**
  97574. * Gets the class name of the current intput.
  97575. * @returns the class name
  97576. */
  97577. getClassName(): string;
  97578. /**
  97579. * Get the friendly name associated with the input class.
  97580. * @returns the input friendly name
  97581. */
  97582. getSimpleName(): string;
  97583. }
  97584. }
  97585. declare module BABYLON {
  97586. /**
  97587. * Manage the touch inputs to control the movement of a free camera.
  97588. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97589. */
  97590. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97591. /**
  97592. * Defines the camera the input is attached to.
  97593. */
  97594. camera: FreeCamera;
  97595. /**
  97596. * Defines the touch sensibility for rotation.
  97597. * The higher the faster.
  97598. */
  97599. touchAngularSensibility: number;
  97600. /**
  97601. * Defines the touch sensibility for move.
  97602. * The higher the faster.
  97603. */
  97604. touchMoveSensibility: number;
  97605. private _offsetX;
  97606. private _offsetY;
  97607. private _pointerPressed;
  97608. private _pointerInput;
  97609. private _observer;
  97610. private _onLostFocus;
  97611. /**
  97612. * Attach the input controls to a specific dom element to get the input from.
  97613. * @param element Defines the element the controls should be listened from
  97614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97615. */
  97616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97617. /**
  97618. * Detach the current controls from the specified dom element.
  97619. * @param element Defines the element to stop listening the inputs from
  97620. */
  97621. detachControl(element: Nullable<HTMLElement>): void;
  97622. /**
  97623. * Update the current camera state depending on the inputs that have been used this frame.
  97624. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97625. */
  97626. checkInputs(): void;
  97627. /**
  97628. * Gets the class name of the current intput.
  97629. * @returns the class name
  97630. */
  97631. getClassName(): string;
  97632. /**
  97633. * Get the friendly name associated with the input class.
  97634. * @returns the input friendly name
  97635. */
  97636. getSimpleName(): string;
  97637. }
  97638. }
  97639. declare module BABYLON {
  97640. /**
  97641. * Default Inputs manager for the FreeCamera.
  97642. * It groups all the default supported inputs for ease of use.
  97643. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97644. */
  97645. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97646. /**
  97647. * @hidden
  97648. */
  97649. _mouseInput: Nullable<FreeCameraMouseInput>;
  97650. /**
  97651. * Instantiates a new FreeCameraInputsManager.
  97652. * @param camera Defines the camera the inputs belong to
  97653. */
  97654. constructor(camera: FreeCamera);
  97655. /**
  97656. * Add keyboard input support to the input manager.
  97657. * @returns the current input manager
  97658. */
  97659. addKeyboard(): FreeCameraInputsManager;
  97660. /**
  97661. * Add mouse input support to the input manager.
  97662. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97663. * @returns the current input manager
  97664. */
  97665. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97666. /**
  97667. * Removes the mouse input support from the manager
  97668. * @returns the current input manager
  97669. */
  97670. removeMouse(): FreeCameraInputsManager;
  97671. /**
  97672. * Add touch input support to the input manager.
  97673. * @returns the current input manager
  97674. */
  97675. addTouch(): FreeCameraInputsManager;
  97676. /**
  97677. * Remove all attached input methods from a camera
  97678. */
  97679. clear(): void;
  97680. }
  97681. }
  97682. declare module BABYLON {
  97683. /**
  97684. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97685. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97686. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97687. */
  97688. export class FreeCamera extends TargetCamera {
  97689. /**
  97690. * Define the collision ellipsoid of the camera.
  97691. * This is helpful to simulate a camera body like the player body around the camera
  97692. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97693. */
  97694. ellipsoid: Vector3;
  97695. /**
  97696. * Define an offset for the position of the ellipsoid around the camera.
  97697. * This can be helpful to determine the center of the body near the gravity center of the body
  97698. * instead of its head.
  97699. */
  97700. ellipsoidOffset: Vector3;
  97701. /**
  97702. * Enable or disable collisions of the camera with the rest of the scene objects.
  97703. */
  97704. checkCollisions: boolean;
  97705. /**
  97706. * Enable or disable gravity on the camera.
  97707. */
  97708. applyGravity: boolean;
  97709. /**
  97710. * Define the input manager associated to the camera.
  97711. */
  97712. inputs: FreeCameraInputsManager;
  97713. /**
  97714. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97715. * Higher values reduce sensitivity.
  97716. */
  97717. get angularSensibility(): number;
  97718. /**
  97719. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97720. * Higher values reduce sensitivity.
  97721. */
  97722. set angularSensibility(value: number);
  97723. /**
  97724. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97725. */
  97726. get keysUp(): number[];
  97727. set keysUp(value: number[]);
  97728. /**
  97729. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97730. */
  97731. get keysUpward(): number[];
  97732. set keysUpward(value: number[]);
  97733. /**
  97734. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97735. */
  97736. get keysDown(): number[];
  97737. set keysDown(value: number[]);
  97738. /**
  97739. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97740. */
  97741. get keysDownward(): number[];
  97742. set keysDownward(value: number[]);
  97743. /**
  97744. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97745. */
  97746. get keysLeft(): number[];
  97747. set keysLeft(value: number[]);
  97748. /**
  97749. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97750. */
  97751. get keysRight(): number[];
  97752. set keysRight(value: number[]);
  97753. /**
  97754. * Event raised when the camera collide with a mesh in the scene.
  97755. */
  97756. onCollide: (collidedMesh: AbstractMesh) => void;
  97757. private _collider;
  97758. private _needMoveForGravity;
  97759. private _oldPosition;
  97760. private _diffPosition;
  97761. private _newPosition;
  97762. /** @hidden */
  97763. _localDirection: Vector3;
  97764. /** @hidden */
  97765. _transformedDirection: Vector3;
  97766. /**
  97767. * Instantiates a Free Camera.
  97768. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97769. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97770. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97771. * @param name Define the name of the camera in the scene
  97772. * @param position Define the start position of the camera in the scene
  97773. * @param scene Define the scene the camera belongs to
  97774. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97775. */
  97776. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97777. /**
  97778. * Attached controls to the current camera.
  97779. * @param element Defines the element the controls should be listened from
  97780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97781. */
  97782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97783. /**
  97784. * Detach the current controls from the camera.
  97785. * The camera will stop reacting to inputs.
  97786. * @param element Defines the element to stop listening the inputs from
  97787. */
  97788. detachControl(element: HTMLElement): void;
  97789. private _collisionMask;
  97790. /**
  97791. * Define a collision mask to limit the list of object the camera can collide with
  97792. */
  97793. get collisionMask(): number;
  97794. set collisionMask(mask: number);
  97795. /** @hidden */
  97796. _collideWithWorld(displacement: Vector3): void;
  97797. private _onCollisionPositionChange;
  97798. /** @hidden */
  97799. _checkInputs(): void;
  97800. /** @hidden */
  97801. _decideIfNeedsToMove(): boolean;
  97802. /** @hidden */
  97803. _updatePosition(): void;
  97804. /**
  97805. * Destroy the camera and release the current resources hold by it.
  97806. */
  97807. dispose(): void;
  97808. /**
  97809. * Gets the current object class name.
  97810. * @return the class name
  97811. */
  97812. getClassName(): string;
  97813. }
  97814. }
  97815. declare module BABYLON {
  97816. /**
  97817. * Represents a gamepad control stick position
  97818. */
  97819. export class StickValues {
  97820. /**
  97821. * The x component of the control stick
  97822. */
  97823. x: number;
  97824. /**
  97825. * The y component of the control stick
  97826. */
  97827. y: number;
  97828. /**
  97829. * Initializes the gamepad x and y control stick values
  97830. * @param x The x component of the gamepad control stick value
  97831. * @param y The y component of the gamepad control stick value
  97832. */
  97833. constructor(
  97834. /**
  97835. * The x component of the control stick
  97836. */
  97837. x: number,
  97838. /**
  97839. * The y component of the control stick
  97840. */
  97841. y: number);
  97842. }
  97843. /**
  97844. * An interface which manages callbacks for gamepad button changes
  97845. */
  97846. export interface GamepadButtonChanges {
  97847. /**
  97848. * Called when a gamepad has been changed
  97849. */
  97850. changed: boolean;
  97851. /**
  97852. * Called when a gamepad press event has been triggered
  97853. */
  97854. pressChanged: boolean;
  97855. /**
  97856. * Called when a touch event has been triggered
  97857. */
  97858. touchChanged: boolean;
  97859. /**
  97860. * Called when a value has changed
  97861. */
  97862. valueChanged: boolean;
  97863. }
  97864. /**
  97865. * Represents a gamepad
  97866. */
  97867. export class Gamepad {
  97868. /**
  97869. * The id of the gamepad
  97870. */
  97871. id: string;
  97872. /**
  97873. * The index of the gamepad
  97874. */
  97875. index: number;
  97876. /**
  97877. * The browser gamepad
  97878. */
  97879. browserGamepad: any;
  97880. /**
  97881. * Specifies what type of gamepad this represents
  97882. */
  97883. type: number;
  97884. private _leftStick;
  97885. private _rightStick;
  97886. /** @hidden */
  97887. _isConnected: boolean;
  97888. private _leftStickAxisX;
  97889. private _leftStickAxisY;
  97890. private _rightStickAxisX;
  97891. private _rightStickAxisY;
  97892. /**
  97893. * Triggered when the left control stick has been changed
  97894. */
  97895. private _onleftstickchanged;
  97896. /**
  97897. * Triggered when the right control stick has been changed
  97898. */
  97899. private _onrightstickchanged;
  97900. /**
  97901. * Represents a gamepad controller
  97902. */
  97903. static GAMEPAD: number;
  97904. /**
  97905. * Represents a generic controller
  97906. */
  97907. static GENERIC: number;
  97908. /**
  97909. * Represents an XBox controller
  97910. */
  97911. static XBOX: number;
  97912. /**
  97913. * Represents a pose-enabled controller
  97914. */
  97915. static POSE_ENABLED: number;
  97916. /**
  97917. * Represents an Dual Shock controller
  97918. */
  97919. static DUALSHOCK: number;
  97920. /**
  97921. * Specifies whether the left control stick should be Y-inverted
  97922. */
  97923. protected _invertLeftStickY: boolean;
  97924. /**
  97925. * Specifies if the gamepad has been connected
  97926. */
  97927. get isConnected(): boolean;
  97928. /**
  97929. * Initializes the gamepad
  97930. * @param id The id of the gamepad
  97931. * @param index The index of the gamepad
  97932. * @param browserGamepad The browser gamepad
  97933. * @param leftStickX The x component of the left joystick
  97934. * @param leftStickY The y component of the left joystick
  97935. * @param rightStickX The x component of the right joystick
  97936. * @param rightStickY The y component of the right joystick
  97937. */
  97938. constructor(
  97939. /**
  97940. * The id of the gamepad
  97941. */
  97942. id: string,
  97943. /**
  97944. * The index of the gamepad
  97945. */
  97946. index: number,
  97947. /**
  97948. * The browser gamepad
  97949. */
  97950. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97951. /**
  97952. * Callback triggered when the left joystick has changed
  97953. * @param callback
  97954. */
  97955. onleftstickchanged(callback: (values: StickValues) => void): void;
  97956. /**
  97957. * Callback triggered when the right joystick has changed
  97958. * @param callback
  97959. */
  97960. onrightstickchanged(callback: (values: StickValues) => void): void;
  97961. /**
  97962. * Gets the left joystick
  97963. */
  97964. get leftStick(): StickValues;
  97965. /**
  97966. * Sets the left joystick values
  97967. */
  97968. set leftStick(newValues: StickValues);
  97969. /**
  97970. * Gets the right joystick
  97971. */
  97972. get rightStick(): StickValues;
  97973. /**
  97974. * Sets the right joystick value
  97975. */
  97976. set rightStick(newValues: StickValues);
  97977. /**
  97978. * Updates the gamepad joystick positions
  97979. */
  97980. update(): void;
  97981. /**
  97982. * Disposes the gamepad
  97983. */
  97984. dispose(): void;
  97985. }
  97986. /**
  97987. * Represents a generic gamepad
  97988. */
  97989. export class GenericPad extends Gamepad {
  97990. private _buttons;
  97991. private _onbuttondown;
  97992. private _onbuttonup;
  97993. /**
  97994. * Observable triggered when a button has been pressed
  97995. */
  97996. onButtonDownObservable: Observable<number>;
  97997. /**
  97998. * Observable triggered when a button has been released
  97999. */
  98000. onButtonUpObservable: Observable<number>;
  98001. /**
  98002. * Callback triggered when a button has been pressed
  98003. * @param callback Called when a button has been pressed
  98004. */
  98005. onbuttondown(callback: (buttonPressed: number) => void): void;
  98006. /**
  98007. * Callback triggered when a button has been released
  98008. * @param callback Called when a button has been released
  98009. */
  98010. onbuttonup(callback: (buttonReleased: number) => void): void;
  98011. /**
  98012. * Initializes the generic gamepad
  98013. * @param id The id of the generic gamepad
  98014. * @param index The index of the generic gamepad
  98015. * @param browserGamepad The browser gamepad
  98016. */
  98017. constructor(id: string, index: number, browserGamepad: any);
  98018. private _setButtonValue;
  98019. /**
  98020. * Updates the generic gamepad
  98021. */
  98022. update(): void;
  98023. /**
  98024. * Disposes the generic gamepad
  98025. */
  98026. dispose(): void;
  98027. }
  98028. }
  98029. declare module BABYLON {
  98030. /**
  98031. * Defines the types of pose enabled controllers that are supported
  98032. */
  98033. export enum PoseEnabledControllerType {
  98034. /**
  98035. * HTC Vive
  98036. */
  98037. VIVE = 0,
  98038. /**
  98039. * Oculus Rift
  98040. */
  98041. OCULUS = 1,
  98042. /**
  98043. * Windows mixed reality
  98044. */
  98045. WINDOWS = 2,
  98046. /**
  98047. * Samsung gear VR
  98048. */
  98049. GEAR_VR = 3,
  98050. /**
  98051. * Google Daydream
  98052. */
  98053. DAYDREAM = 4,
  98054. /**
  98055. * Generic
  98056. */
  98057. GENERIC = 5
  98058. }
  98059. /**
  98060. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98061. */
  98062. export interface MutableGamepadButton {
  98063. /**
  98064. * Value of the button/trigger
  98065. */
  98066. value: number;
  98067. /**
  98068. * If the button/trigger is currently touched
  98069. */
  98070. touched: boolean;
  98071. /**
  98072. * If the button/trigger is currently pressed
  98073. */
  98074. pressed: boolean;
  98075. }
  98076. /**
  98077. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98078. * @hidden
  98079. */
  98080. export interface ExtendedGamepadButton extends GamepadButton {
  98081. /**
  98082. * If the button/trigger is currently pressed
  98083. */
  98084. readonly pressed: boolean;
  98085. /**
  98086. * If the button/trigger is currently touched
  98087. */
  98088. readonly touched: boolean;
  98089. /**
  98090. * Value of the button/trigger
  98091. */
  98092. readonly value: number;
  98093. }
  98094. /** @hidden */
  98095. export interface _GamePadFactory {
  98096. /**
  98097. * Returns whether or not the current gamepad can be created for this type of controller.
  98098. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98099. * @returns true if it can be created, otherwise false
  98100. */
  98101. canCreate(gamepadInfo: any): boolean;
  98102. /**
  98103. * Creates a new instance of the Gamepad.
  98104. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98105. * @returns the new gamepad instance
  98106. */
  98107. create(gamepadInfo: any): Gamepad;
  98108. }
  98109. /**
  98110. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98111. */
  98112. export class PoseEnabledControllerHelper {
  98113. /** @hidden */
  98114. static _ControllerFactories: _GamePadFactory[];
  98115. /** @hidden */
  98116. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98117. /**
  98118. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98119. * @param vrGamepad the gamepad to initialized
  98120. * @returns a vr controller of the type the gamepad identified as
  98121. */
  98122. static InitiateController(vrGamepad: any): Gamepad;
  98123. }
  98124. /**
  98125. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98126. */
  98127. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98128. /**
  98129. * If the controller is used in a webXR session
  98130. */
  98131. isXR: boolean;
  98132. private _deviceRoomPosition;
  98133. private _deviceRoomRotationQuaternion;
  98134. /**
  98135. * The device position in babylon space
  98136. */
  98137. devicePosition: Vector3;
  98138. /**
  98139. * The device rotation in babylon space
  98140. */
  98141. deviceRotationQuaternion: Quaternion;
  98142. /**
  98143. * The scale factor of the device in babylon space
  98144. */
  98145. deviceScaleFactor: number;
  98146. /**
  98147. * (Likely devicePosition should be used instead) The device position in its room space
  98148. */
  98149. position: Vector3;
  98150. /**
  98151. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98152. */
  98153. rotationQuaternion: Quaternion;
  98154. /**
  98155. * The type of controller (Eg. Windows mixed reality)
  98156. */
  98157. controllerType: PoseEnabledControllerType;
  98158. protected _calculatedPosition: Vector3;
  98159. private _calculatedRotation;
  98160. /**
  98161. * The raw pose from the device
  98162. */
  98163. rawPose: DevicePose;
  98164. private _trackPosition;
  98165. private _maxRotationDistFromHeadset;
  98166. private _draggedRoomRotation;
  98167. /**
  98168. * @hidden
  98169. */
  98170. _disableTrackPosition(fixedPosition: Vector3): void;
  98171. /**
  98172. * Internal, the mesh attached to the controller
  98173. * @hidden
  98174. */
  98175. _mesh: Nullable<AbstractMesh>;
  98176. private _poseControlledCamera;
  98177. private _leftHandSystemQuaternion;
  98178. /**
  98179. * Internal, matrix used to convert room space to babylon space
  98180. * @hidden
  98181. */
  98182. _deviceToWorld: Matrix;
  98183. /**
  98184. * Node to be used when casting a ray from the controller
  98185. * @hidden
  98186. */
  98187. _pointingPoseNode: Nullable<TransformNode>;
  98188. /**
  98189. * Name of the child mesh that can be used to cast a ray from the controller
  98190. */
  98191. static readonly POINTING_POSE: string;
  98192. /**
  98193. * Creates a new PoseEnabledController from a gamepad
  98194. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98195. */
  98196. constructor(browserGamepad: any);
  98197. private _workingMatrix;
  98198. /**
  98199. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98200. */
  98201. update(): void;
  98202. /**
  98203. * Updates only the pose device and mesh without doing any button event checking
  98204. */
  98205. protected _updatePoseAndMesh(): void;
  98206. /**
  98207. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98208. * @param poseData raw pose fromthe device
  98209. */
  98210. updateFromDevice(poseData: DevicePose): void;
  98211. /**
  98212. * @hidden
  98213. */
  98214. _meshAttachedObservable: Observable<AbstractMesh>;
  98215. /**
  98216. * Attaches a mesh to the controller
  98217. * @param mesh the mesh to be attached
  98218. */
  98219. attachToMesh(mesh: AbstractMesh): void;
  98220. /**
  98221. * Attaches the controllers mesh to a camera
  98222. * @param camera the camera the mesh should be attached to
  98223. */
  98224. attachToPoseControlledCamera(camera: TargetCamera): void;
  98225. /**
  98226. * Disposes of the controller
  98227. */
  98228. dispose(): void;
  98229. /**
  98230. * The mesh that is attached to the controller
  98231. */
  98232. get mesh(): Nullable<AbstractMesh>;
  98233. /**
  98234. * Gets the ray of the controller in the direction the controller is pointing
  98235. * @param length the length the resulting ray should be
  98236. * @returns a ray in the direction the controller is pointing
  98237. */
  98238. getForwardRay(length?: number): Ray;
  98239. }
  98240. }
  98241. declare module BABYLON {
  98242. /**
  98243. * Defines the WebVRController object that represents controllers tracked in 3D space
  98244. */
  98245. export abstract class WebVRController extends PoseEnabledController {
  98246. /**
  98247. * Internal, the default controller model for the controller
  98248. */
  98249. protected _defaultModel: Nullable<AbstractMesh>;
  98250. /**
  98251. * Fired when the trigger state has changed
  98252. */
  98253. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98254. /**
  98255. * Fired when the main button state has changed
  98256. */
  98257. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98258. /**
  98259. * Fired when the secondary button state has changed
  98260. */
  98261. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98262. /**
  98263. * Fired when the pad state has changed
  98264. */
  98265. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98266. /**
  98267. * Fired when controllers stick values have changed
  98268. */
  98269. onPadValuesChangedObservable: Observable<StickValues>;
  98270. /**
  98271. * Array of button availible on the controller
  98272. */
  98273. protected _buttons: Array<MutableGamepadButton>;
  98274. private _onButtonStateChange;
  98275. /**
  98276. * Fired when a controller button's state has changed
  98277. * @param callback the callback containing the button that was modified
  98278. */
  98279. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98280. /**
  98281. * X and Y axis corresponding to the controllers joystick
  98282. */
  98283. pad: StickValues;
  98284. /**
  98285. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98286. */
  98287. hand: string;
  98288. /**
  98289. * The default controller model for the controller
  98290. */
  98291. get defaultModel(): Nullable<AbstractMesh>;
  98292. /**
  98293. * Creates a new WebVRController from a gamepad
  98294. * @param vrGamepad the gamepad that the WebVRController should be created from
  98295. */
  98296. constructor(vrGamepad: any);
  98297. /**
  98298. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98299. */
  98300. update(): void;
  98301. /**
  98302. * Function to be called when a button is modified
  98303. */
  98304. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98305. /**
  98306. * Loads a mesh and attaches it to the controller
  98307. * @param scene the scene the mesh should be added to
  98308. * @param meshLoaded callback for when the mesh has been loaded
  98309. */
  98310. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98311. private _setButtonValue;
  98312. private _changes;
  98313. private _checkChanges;
  98314. /**
  98315. * Disposes of th webVRCOntroller
  98316. */
  98317. dispose(): void;
  98318. }
  98319. }
  98320. declare module BABYLON {
  98321. /**
  98322. * The HemisphericLight simulates the ambient environment light,
  98323. * so the passed direction is the light reflection direction, not the incoming direction.
  98324. */
  98325. export class HemisphericLight extends Light {
  98326. /**
  98327. * The groundColor is the light in the opposite direction to the one specified during creation.
  98328. * 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.
  98329. */
  98330. groundColor: Color3;
  98331. /**
  98332. * The light reflection direction, not the incoming direction.
  98333. */
  98334. direction: Vector3;
  98335. /**
  98336. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98337. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98338. * The HemisphericLight can't cast shadows.
  98339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98340. * @param name The friendly name of the light
  98341. * @param direction The direction of the light reflection
  98342. * @param scene The scene the light belongs to
  98343. */
  98344. constructor(name: string, direction: Vector3, scene: Scene);
  98345. protected _buildUniformLayout(): void;
  98346. /**
  98347. * Returns the string "HemisphericLight".
  98348. * @return The class name
  98349. */
  98350. getClassName(): string;
  98351. /**
  98352. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98353. * Returns the updated direction.
  98354. * @param target The target the direction should point to
  98355. * @return The computed direction
  98356. */
  98357. setDirectionToTarget(target: Vector3): Vector3;
  98358. /**
  98359. * Returns the shadow generator associated to the light.
  98360. * @returns Always null for hemispheric lights because it does not support shadows.
  98361. */
  98362. getShadowGenerator(): Nullable<IShadowGenerator>;
  98363. /**
  98364. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98365. * @param effect The effect to update
  98366. * @param lightIndex The index of the light in the effect to update
  98367. * @returns The hemispheric light
  98368. */
  98369. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98370. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98371. /**
  98372. * Computes the world matrix of the node
  98373. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98374. * @param useWasUpdatedFlag defines a reserved property
  98375. * @returns the world matrix
  98376. */
  98377. computeWorldMatrix(): Matrix;
  98378. /**
  98379. * Returns the integer 3.
  98380. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98381. */
  98382. getTypeID(): number;
  98383. /**
  98384. * Prepares the list of defines specific to the light type.
  98385. * @param defines the list of defines
  98386. * @param lightIndex defines the index of the light for the effect
  98387. */
  98388. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98389. }
  98390. }
  98391. declare module BABYLON {
  98392. /** @hidden */
  98393. export var vrMultiviewToSingleviewPixelShader: {
  98394. name: string;
  98395. shader: string;
  98396. };
  98397. }
  98398. declare module BABYLON {
  98399. /**
  98400. * Renders to multiple views with a single draw call
  98401. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98402. */
  98403. export class MultiviewRenderTarget extends RenderTargetTexture {
  98404. /**
  98405. * Creates a multiview render target
  98406. * @param scene scene used with the render target
  98407. * @param size the size of the render target (used for each view)
  98408. */
  98409. constructor(scene: Scene, size?: number | {
  98410. width: number;
  98411. height: number;
  98412. } | {
  98413. ratio: number;
  98414. });
  98415. /**
  98416. * @hidden
  98417. * @param faceIndex the face index, if its a cube texture
  98418. */
  98419. _bindFrameBuffer(faceIndex?: number): void;
  98420. /**
  98421. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98422. * @returns the view count
  98423. */
  98424. getViewCount(): number;
  98425. }
  98426. }
  98427. declare module BABYLON {
  98428. interface Engine {
  98429. /**
  98430. * Creates a new multiview render target
  98431. * @param width defines the width of the texture
  98432. * @param height defines the height of the texture
  98433. * @returns the created multiview texture
  98434. */
  98435. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98436. /**
  98437. * Binds a multiview framebuffer to be drawn to
  98438. * @param multiviewTexture texture to bind
  98439. */
  98440. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98441. }
  98442. interface Camera {
  98443. /**
  98444. * @hidden
  98445. * 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)
  98446. */
  98447. _useMultiviewToSingleView: boolean;
  98448. /**
  98449. * @hidden
  98450. * 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)
  98451. */
  98452. _multiviewTexture: Nullable<RenderTargetTexture>;
  98453. /**
  98454. * @hidden
  98455. * ensures the multiview texture of the camera exists and has the specified width/height
  98456. * @param width height to set on the multiview texture
  98457. * @param height width to set on the multiview texture
  98458. */
  98459. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98460. }
  98461. interface Scene {
  98462. /** @hidden */
  98463. _transformMatrixR: Matrix;
  98464. /** @hidden */
  98465. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98466. /** @hidden */
  98467. _createMultiviewUbo(): void;
  98468. /** @hidden */
  98469. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98470. /** @hidden */
  98471. _renderMultiviewToSingleView(camera: Camera): void;
  98472. }
  98473. }
  98474. declare module BABYLON {
  98475. /**
  98476. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98477. * This will not be used for webXR as it supports displaying texture arrays directly
  98478. */
  98479. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98480. /**
  98481. * Initializes a VRMultiviewToSingleview
  98482. * @param name name of the post process
  98483. * @param camera camera to be applied to
  98484. * @param scaleFactor scaling factor to the size of the output texture
  98485. */
  98486. constructor(name: string, camera: Camera, scaleFactor: number);
  98487. }
  98488. }
  98489. declare module BABYLON {
  98490. /**
  98491. * Interface used to define additional presentation attributes
  98492. */
  98493. export interface IVRPresentationAttributes {
  98494. /**
  98495. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98496. */
  98497. highRefreshRate: boolean;
  98498. /**
  98499. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98500. */
  98501. foveationLevel: number;
  98502. }
  98503. interface Engine {
  98504. /** @hidden */
  98505. _vrDisplay: any;
  98506. /** @hidden */
  98507. _vrSupported: boolean;
  98508. /** @hidden */
  98509. _oldSize: Size;
  98510. /** @hidden */
  98511. _oldHardwareScaleFactor: number;
  98512. /** @hidden */
  98513. _vrExclusivePointerMode: boolean;
  98514. /** @hidden */
  98515. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98516. /** @hidden */
  98517. _onVRDisplayPointerRestricted: () => void;
  98518. /** @hidden */
  98519. _onVRDisplayPointerUnrestricted: () => void;
  98520. /** @hidden */
  98521. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98522. /** @hidden */
  98523. _onVrDisplayDisconnect: Nullable<() => void>;
  98524. /** @hidden */
  98525. _onVrDisplayPresentChange: Nullable<() => void>;
  98526. /**
  98527. * Observable signaled when VR display mode changes
  98528. */
  98529. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98530. /**
  98531. * Observable signaled when VR request present is complete
  98532. */
  98533. onVRRequestPresentComplete: Observable<boolean>;
  98534. /**
  98535. * Observable signaled when VR request present starts
  98536. */
  98537. onVRRequestPresentStart: Observable<Engine>;
  98538. /**
  98539. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98540. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98541. */
  98542. isInVRExclusivePointerMode: boolean;
  98543. /**
  98544. * Gets a boolean indicating if a webVR device was detected
  98545. * @returns true if a webVR device was detected
  98546. */
  98547. isVRDevicePresent(): boolean;
  98548. /**
  98549. * Gets the current webVR device
  98550. * @returns the current webVR device (or null)
  98551. */
  98552. getVRDevice(): any;
  98553. /**
  98554. * Initializes a webVR display and starts listening to display change events
  98555. * The onVRDisplayChangedObservable will be notified upon these changes
  98556. * @returns A promise containing a VRDisplay and if vr is supported
  98557. */
  98558. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98559. /** @hidden */
  98560. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98561. /**
  98562. * Gets or sets the presentation attributes used to configure VR rendering
  98563. */
  98564. vrPresentationAttributes?: IVRPresentationAttributes;
  98565. /**
  98566. * Call this function to switch to webVR mode
  98567. * Will do nothing if webVR is not supported or if there is no webVR device
  98568. * @param options the webvr options provided to the camera. mainly used for multiview
  98569. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98570. */
  98571. enableVR(options: WebVROptions): void;
  98572. /** @hidden */
  98573. _onVRFullScreenTriggered(): void;
  98574. }
  98575. }
  98576. declare module BABYLON {
  98577. /**
  98578. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98579. * IMPORTANT!! The data is right-hand data.
  98580. * @export
  98581. * @interface DevicePose
  98582. */
  98583. export interface DevicePose {
  98584. /**
  98585. * The position of the device, values in array are [x,y,z].
  98586. */
  98587. readonly position: Nullable<Float32Array>;
  98588. /**
  98589. * The linearVelocity of the device, values in array are [x,y,z].
  98590. */
  98591. readonly linearVelocity: Nullable<Float32Array>;
  98592. /**
  98593. * The linearAcceleration of the device, values in array are [x,y,z].
  98594. */
  98595. readonly linearAcceleration: Nullable<Float32Array>;
  98596. /**
  98597. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98598. */
  98599. readonly orientation: Nullable<Float32Array>;
  98600. /**
  98601. * The angularVelocity of the device, values in array are [x,y,z].
  98602. */
  98603. readonly angularVelocity: Nullable<Float32Array>;
  98604. /**
  98605. * The angularAcceleration of the device, values in array are [x,y,z].
  98606. */
  98607. readonly angularAcceleration: Nullable<Float32Array>;
  98608. }
  98609. /**
  98610. * Interface representing a pose controlled object in Babylon.
  98611. * A pose controlled object has both regular pose values as well as pose values
  98612. * from an external device such as a VR head mounted display
  98613. */
  98614. export interface PoseControlled {
  98615. /**
  98616. * The position of the object in babylon space.
  98617. */
  98618. position: Vector3;
  98619. /**
  98620. * The rotation quaternion of the object in babylon space.
  98621. */
  98622. rotationQuaternion: Quaternion;
  98623. /**
  98624. * The position of the device in babylon space.
  98625. */
  98626. devicePosition?: Vector3;
  98627. /**
  98628. * The rotation quaternion of the device in babylon space.
  98629. */
  98630. deviceRotationQuaternion: Quaternion;
  98631. /**
  98632. * The raw pose coming from the device.
  98633. */
  98634. rawPose: Nullable<DevicePose>;
  98635. /**
  98636. * The scale of the device to be used when translating from device space to babylon space.
  98637. */
  98638. deviceScaleFactor: number;
  98639. /**
  98640. * Updates the poseControlled values based on the input device pose.
  98641. * @param poseData the pose data to update the object with
  98642. */
  98643. updateFromDevice(poseData: DevicePose): void;
  98644. }
  98645. /**
  98646. * Set of options to customize the webVRCamera
  98647. */
  98648. export interface WebVROptions {
  98649. /**
  98650. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98651. */
  98652. trackPosition?: boolean;
  98653. /**
  98654. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98655. */
  98656. positionScale?: number;
  98657. /**
  98658. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98659. */
  98660. displayName?: string;
  98661. /**
  98662. * Should the native controller meshes be initialized. (default: true)
  98663. */
  98664. controllerMeshes?: boolean;
  98665. /**
  98666. * Creating a default HemiLight only on controllers. (default: true)
  98667. */
  98668. defaultLightingOnControllers?: boolean;
  98669. /**
  98670. * If you don't want to use the default VR button of the helper. (default: false)
  98671. */
  98672. useCustomVRButton?: boolean;
  98673. /**
  98674. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98675. */
  98676. customVRButton?: HTMLButtonElement;
  98677. /**
  98678. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98679. */
  98680. rayLength?: number;
  98681. /**
  98682. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98683. */
  98684. defaultHeight?: number;
  98685. /**
  98686. * If multiview should be used if availible (default: false)
  98687. */
  98688. useMultiview?: boolean;
  98689. }
  98690. /**
  98691. * This represents a WebVR camera.
  98692. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98693. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98694. */
  98695. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98696. private webVROptions;
  98697. /**
  98698. * @hidden
  98699. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98700. */
  98701. _vrDevice: any;
  98702. /**
  98703. * The rawPose of the vrDevice.
  98704. */
  98705. rawPose: Nullable<DevicePose>;
  98706. private _onVREnabled;
  98707. private _specsVersion;
  98708. private _attached;
  98709. private _frameData;
  98710. protected _descendants: Array<Node>;
  98711. private _deviceRoomPosition;
  98712. /** @hidden */
  98713. _deviceRoomRotationQuaternion: Quaternion;
  98714. private _standingMatrix;
  98715. /**
  98716. * Represents device position in babylon space.
  98717. */
  98718. devicePosition: Vector3;
  98719. /**
  98720. * Represents device rotation in babylon space.
  98721. */
  98722. deviceRotationQuaternion: Quaternion;
  98723. /**
  98724. * The scale of the device to be used when translating from device space to babylon space.
  98725. */
  98726. deviceScaleFactor: number;
  98727. private _deviceToWorld;
  98728. private _worldToDevice;
  98729. /**
  98730. * References to the webVR controllers for the vrDevice.
  98731. */
  98732. controllers: Array<WebVRController>;
  98733. /**
  98734. * Emits an event when a controller is attached.
  98735. */
  98736. onControllersAttachedObservable: Observable<WebVRController[]>;
  98737. /**
  98738. * Emits an event when a controller's mesh has been loaded;
  98739. */
  98740. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98741. /**
  98742. * Emits an event when the HMD's pose has been updated.
  98743. */
  98744. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98745. private _poseSet;
  98746. /**
  98747. * If the rig cameras be used as parent instead of this camera.
  98748. */
  98749. rigParenting: boolean;
  98750. private _lightOnControllers;
  98751. private _defaultHeight?;
  98752. /**
  98753. * Instantiates a WebVRFreeCamera.
  98754. * @param name The name of the WebVRFreeCamera
  98755. * @param position The starting anchor position for the camera
  98756. * @param scene The scene the camera belongs to
  98757. * @param webVROptions a set of customizable options for the webVRCamera
  98758. */
  98759. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98760. /**
  98761. * Gets the device distance from the ground in meters.
  98762. * @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.
  98763. */
  98764. deviceDistanceToRoomGround(): number;
  98765. /**
  98766. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98767. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98768. */
  98769. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98770. /**
  98771. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98772. * @returns A promise with a boolean set to if the standing matrix is supported.
  98773. */
  98774. useStandingMatrixAsync(): Promise<boolean>;
  98775. /**
  98776. * Disposes the camera
  98777. */
  98778. dispose(): void;
  98779. /**
  98780. * Gets a vrController by name.
  98781. * @param name The name of the controller to retreive
  98782. * @returns the controller matching the name specified or null if not found
  98783. */
  98784. getControllerByName(name: string): Nullable<WebVRController>;
  98785. private _leftController;
  98786. /**
  98787. * The controller corresponding to the users left hand.
  98788. */
  98789. get leftController(): Nullable<WebVRController>;
  98790. private _rightController;
  98791. /**
  98792. * The controller corresponding to the users right hand.
  98793. */
  98794. get rightController(): Nullable<WebVRController>;
  98795. /**
  98796. * Casts a ray forward from the vrCamera's gaze.
  98797. * @param length Length of the ray (default: 100)
  98798. * @returns the ray corresponding to the gaze
  98799. */
  98800. getForwardRay(length?: number): Ray;
  98801. /**
  98802. * @hidden
  98803. * Updates the camera based on device's frame data
  98804. */
  98805. _checkInputs(): void;
  98806. /**
  98807. * Updates the poseControlled values based on the input device pose.
  98808. * @param poseData Pose coming from the device
  98809. */
  98810. updateFromDevice(poseData: DevicePose): void;
  98811. private _htmlElementAttached;
  98812. private _detachIfAttached;
  98813. /**
  98814. * WebVR's attach control will start broadcasting frames to the device.
  98815. * Note that in certain browsers (chrome for example) this function must be called
  98816. * within a user-interaction callback. Example:
  98817. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98818. *
  98819. * @param element html element to attach the vrDevice to
  98820. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98821. */
  98822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98823. /**
  98824. * Detaches the camera from the html element and disables VR
  98825. *
  98826. * @param element html element to detach from
  98827. */
  98828. detachControl(element: HTMLElement): void;
  98829. /**
  98830. * @returns the name of this class
  98831. */
  98832. getClassName(): string;
  98833. /**
  98834. * Calls resetPose on the vrDisplay
  98835. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98836. */
  98837. resetToCurrentRotation(): void;
  98838. /**
  98839. * @hidden
  98840. * Updates the rig cameras (left and right eye)
  98841. */
  98842. _updateRigCameras(): void;
  98843. private _workingVector;
  98844. private _oneVector;
  98845. private _workingMatrix;
  98846. private updateCacheCalled;
  98847. private _correctPositionIfNotTrackPosition;
  98848. /**
  98849. * @hidden
  98850. * Updates the cached values of the camera
  98851. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98852. */
  98853. _updateCache(ignoreParentClass?: boolean): void;
  98854. /**
  98855. * @hidden
  98856. * Get current device position in babylon world
  98857. */
  98858. _computeDevicePosition(): void;
  98859. /**
  98860. * Updates the current device position and rotation in the babylon world
  98861. */
  98862. update(): void;
  98863. /**
  98864. * @hidden
  98865. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98866. * @returns an identity matrix
  98867. */
  98868. _getViewMatrix(): Matrix;
  98869. private _tmpMatrix;
  98870. /**
  98871. * This function is called by the two RIG cameras.
  98872. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98873. * @hidden
  98874. */
  98875. _getWebVRViewMatrix(): Matrix;
  98876. /** @hidden */
  98877. _getWebVRProjectionMatrix(): Matrix;
  98878. private _onGamepadConnectedObserver;
  98879. private _onGamepadDisconnectedObserver;
  98880. private _updateCacheWhenTrackingDisabledObserver;
  98881. /**
  98882. * Initializes the controllers and their meshes
  98883. */
  98884. initControllers(): void;
  98885. }
  98886. }
  98887. declare module BABYLON {
  98888. /**
  98889. * "Static Class" containing the most commonly used helper while dealing with material for
  98890. * rendering purpose.
  98891. *
  98892. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98893. *
  98894. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98895. */
  98896. export class MaterialHelper {
  98897. /**
  98898. * Bind the current view position to an effect.
  98899. * @param effect The effect to be bound
  98900. * @param scene The scene the eyes position is used from
  98901. * @param variableName name of the shader variable that will hold the eye position
  98902. */
  98903. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98904. /**
  98905. * Helps preparing the defines values about the UVs in used in the effect.
  98906. * UVs are shared as much as we can accross channels in the shaders.
  98907. * @param texture The texture we are preparing the UVs for
  98908. * @param defines The defines to update
  98909. * @param key The channel key "diffuse", "specular"... used in the shader
  98910. */
  98911. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98912. /**
  98913. * Binds a texture matrix value to its corrsponding uniform
  98914. * @param texture The texture to bind the matrix for
  98915. * @param uniformBuffer The uniform buffer receivin the data
  98916. * @param key The channel key "diffuse", "specular"... used in the shader
  98917. */
  98918. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98919. /**
  98920. * Gets the current status of the fog (should it be enabled?)
  98921. * @param mesh defines the mesh to evaluate for fog support
  98922. * @param scene defines the hosting scene
  98923. * @returns true if fog must be enabled
  98924. */
  98925. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98926. /**
  98927. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98928. * @param mesh defines the current mesh
  98929. * @param scene defines the current scene
  98930. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98931. * @param pointsCloud defines if point cloud rendering has to be turned on
  98932. * @param fogEnabled defines if fog has to be turned on
  98933. * @param alphaTest defines if alpha testing has to be turned on
  98934. * @param defines defines the current list of defines
  98935. */
  98936. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98937. /**
  98938. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98939. * @param scene defines the current scene
  98940. * @param engine defines the current engine
  98941. * @param defines specifies the list of active defines
  98942. * @param useInstances defines if instances have to be turned on
  98943. * @param useClipPlane defines if clip plane have to be turned on
  98944. * @param useInstances defines if instances have to be turned on
  98945. * @param useThinInstances defines if thin instances have to be turned on
  98946. */
  98947. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98948. /**
  98949. * Prepares the defines for bones
  98950. * @param mesh The mesh containing the geometry data we will draw
  98951. * @param defines The defines to update
  98952. */
  98953. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98954. /**
  98955. * Prepares the defines for morph targets
  98956. * @param mesh The mesh containing the geometry data we will draw
  98957. * @param defines The defines to update
  98958. */
  98959. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98960. /**
  98961. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98962. * @param mesh The mesh containing the geometry data we will draw
  98963. * @param defines The defines to update
  98964. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98965. * @param useBones Precise whether bones should be used or not (override mesh info)
  98966. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98967. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98968. * @returns false if defines are considered not dirty and have not been checked
  98969. */
  98970. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98971. /**
  98972. * Prepares the defines related to multiview
  98973. * @param scene The scene we are intending to draw
  98974. * @param defines The defines to update
  98975. */
  98976. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98977. /**
  98978. * Prepares the defines related to the prepass
  98979. * @param scene The scene we are intending to draw
  98980. * @param defines The defines to update
  98981. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  98982. */
  98983. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  98984. /**
  98985. * Prepares the defines related to the light information passed in parameter
  98986. * @param scene The scene we are intending to draw
  98987. * @param mesh The mesh the effect is compiling for
  98988. * @param light The light the effect is compiling for
  98989. * @param lightIndex The index of the light
  98990. * @param defines The defines to update
  98991. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98992. * @param state Defines the current state regarding what is needed (normals, etc...)
  98993. */
  98994. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98995. needNormals: boolean;
  98996. needRebuild: boolean;
  98997. shadowEnabled: boolean;
  98998. specularEnabled: boolean;
  98999. lightmapMode: boolean;
  99000. }): void;
  99001. /**
  99002. * Prepares the defines related to the light information passed in parameter
  99003. * @param scene The scene we are intending to draw
  99004. * @param mesh The mesh the effect is compiling for
  99005. * @param defines The defines to update
  99006. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99007. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99008. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99009. * @returns true if normals will be required for the rest of the effect
  99010. */
  99011. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99012. /**
  99013. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99014. * @param lightIndex defines the light index
  99015. * @param uniformsList The uniform list
  99016. * @param samplersList The sampler list
  99017. * @param projectedLightTexture defines if projected texture must be used
  99018. * @param uniformBuffersList defines an optional list of uniform buffers
  99019. */
  99020. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99021. /**
  99022. * Prepares the uniforms and samplers list to be used in the effect
  99023. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99024. * @param samplersList The sampler list
  99025. * @param defines The defines helping in the list generation
  99026. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99027. */
  99028. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99029. /**
  99030. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99031. * @param defines The defines to update while falling back
  99032. * @param fallbacks The authorized effect fallbacks
  99033. * @param maxSimultaneousLights The maximum number of lights allowed
  99034. * @param rank the current rank of the Effect
  99035. * @returns The newly affected rank
  99036. */
  99037. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99038. private static _TmpMorphInfluencers;
  99039. /**
  99040. * Prepares the list of attributes required for morph targets according to the effect defines.
  99041. * @param attribs The current list of supported attribs
  99042. * @param mesh The mesh to prepare the morph targets attributes for
  99043. * @param influencers The number of influencers
  99044. */
  99045. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99046. /**
  99047. * Prepares the list of attributes required for morph targets according to the effect defines.
  99048. * @param attribs The current list of supported attribs
  99049. * @param mesh The mesh to prepare the morph targets attributes for
  99050. * @param defines The current Defines of the effect
  99051. */
  99052. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99053. /**
  99054. * Prepares the list of attributes required for bones according to the effect defines.
  99055. * @param attribs The current list of supported attribs
  99056. * @param mesh The mesh to prepare the bones attributes for
  99057. * @param defines The current Defines of the effect
  99058. * @param fallbacks The current efffect fallback strategy
  99059. */
  99060. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99061. /**
  99062. * Check and prepare the list of attributes required for instances according to the effect defines.
  99063. * @param attribs The current list of supported attribs
  99064. * @param defines The current MaterialDefines of the effect
  99065. */
  99066. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99067. /**
  99068. * Add the list of attributes required for instances to the attribs array.
  99069. * @param attribs The current list of supported attribs
  99070. */
  99071. static PushAttributesForInstances(attribs: string[]): void;
  99072. /**
  99073. * Binds the light information to the effect.
  99074. * @param light The light containing the generator
  99075. * @param effect The effect we are binding the data to
  99076. * @param lightIndex The light index in the effect used to render
  99077. */
  99078. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99079. /**
  99080. * Binds the lights information from the scene to the effect for the given mesh.
  99081. * @param light Light to bind
  99082. * @param lightIndex Light index
  99083. * @param scene The scene where the light belongs to
  99084. * @param effect The effect we are binding the data to
  99085. * @param useSpecular Defines if specular is supported
  99086. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99087. */
  99088. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99089. /**
  99090. * Binds the lights information from the scene to the effect for the given mesh.
  99091. * @param scene The scene the lights belongs to
  99092. * @param mesh The mesh we are binding the information to render
  99093. * @param effect The effect we are binding the data to
  99094. * @param defines The generated defines for the effect
  99095. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99096. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99097. */
  99098. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99099. private static _tempFogColor;
  99100. /**
  99101. * Binds the fog information from the scene to the effect for the given mesh.
  99102. * @param scene The scene the lights belongs to
  99103. * @param mesh The mesh we are binding the information to render
  99104. * @param effect The effect we are binding the data to
  99105. * @param linearSpace Defines if the fog effect is applied in linear space
  99106. */
  99107. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99108. /**
  99109. * Binds the bones information from the mesh to the effect.
  99110. * @param mesh The mesh we are binding the information to render
  99111. * @param effect The effect we are binding the data to
  99112. */
  99113. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99114. /**
  99115. * Binds the morph targets information from the mesh to the effect.
  99116. * @param abstractMesh The mesh we are binding the information to render
  99117. * @param effect The effect we are binding the data to
  99118. */
  99119. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99120. /**
  99121. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99122. * @param defines The generated defines used in the effect
  99123. * @param effect The effect we are binding the data to
  99124. * @param scene The scene we are willing to render with logarithmic scale for
  99125. */
  99126. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99127. /**
  99128. * Binds the clip plane information from the scene to the effect.
  99129. * @param scene The scene the clip plane information are extracted from
  99130. * @param effect The effect we are binding the data to
  99131. */
  99132. static BindClipPlane(effect: Effect, scene: Scene): void;
  99133. }
  99134. }
  99135. declare module BABYLON {
  99136. /**
  99137. * Block used to expose an input value
  99138. */
  99139. export class InputBlock extends NodeMaterialBlock {
  99140. private _mode;
  99141. private _associatedVariableName;
  99142. private _storedValue;
  99143. private _valueCallback;
  99144. private _type;
  99145. private _animationType;
  99146. /** Gets or set a value used to limit the range of float values */
  99147. min: number;
  99148. /** Gets or set a value used to limit the range of float values */
  99149. max: number;
  99150. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99151. isBoolean: boolean;
  99152. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99153. matrixMode: number;
  99154. /** @hidden */
  99155. _systemValue: Nullable<NodeMaterialSystemValues>;
  99156. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99157. visibleInInspector: boolean;
  99158. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99159. isConstant: boolean;
  99160. /** Gets or sets the group to use to display this block in the Inspector */
  99161. groupInInspector: string;
  99162. /** Gets an observable raised when the value is changed */
  99163. onValueChangedObservable: Observable<InputBlock>;
  99164. /**
  99165. * Gets or sets the connection point type (default is float)
  99166. */
  99167. get type(): NodeMaterialBlockConnectionPointTypes;
  99168. /**
  99169. * Creates a new InputBlock
  99170. * @param name defines the block name
  99171. * @param target defines the target of that block (Vertex by default)
  99172. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99173. */
  99174. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99175. /**
  99176. * Validates if a name is a reserve word.
  99177. * @param newName the new name to be given to the node.
  99178. * @returns false if the name is a reserve word, else true.
  99179. */
  99180. validateBlockName(newName: string): boolean;
  99181. /**
  99182. * Gets the output component
  99183. */
  99184. get output(): NodeMaterialConnectionPoint;
  99185. /**
  99186. * Set the source of this connection point to a vertex attribute
  99187. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99188. * @returns the current connection point
  99189. */
  99190. setAsAttribute(attributeName?: string): InputBlock;
  99191. /**
  99192. * Set the source of this connection point to a system value
  99193. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99194. * @returns the current connection point
  99195. */
  99196. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99197. /**
  99198. * Gets or sets the value of that point.
  99199. * Please note that this value will be ignored if valueCallback is defined
  99200. */
  99201. get value(): any;
  99202. set value(value: any);
  99203. /**
  99204. * Gets or sets a callback used to get the value of that point.
  99205. * Please note that setting this value will force the connection point to ignore the value property
  99206. */
  99207. get valueCallback(): () => any;
  99208. set valueCallback(value: () => any);
  99209. /**
  99210. * Gets or sets the associated variable name in the shader
  99211. */
  99212. get associatedVariableName(): string;
  99213. set associatedVariableName(value: string);
  99214. /** Gets or sets the type of animation applied to the input */
  99215. get animationType(): AnimatedInputBlockTypes;
  99216. set animationType(value: AnimatedInputBlockTypes);
  99217. /**
  99218. * Gets a boolean indicating that this connection point not defined yet
  99219. */
  99220. get isUndefined(): boolean;
  99221. /**
  99222. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99223. * In this case the connection point name must be the name of the uniform to use.
  99224. * Can only be set on inputs
  99225. */
  99226. get isUniform(): boolean;
  99227. set isUniform(value: boolean);
  99228. /**
  99229. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99230. * In this case the connection point name must be the name of the attribute to use
  99231. * Can only be set on inputs
  99232. */
  99233. get isAttribute(): boolean;
  99234. set isAttribute(value: boolean);
  99235. /**
  99236. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99237. * Can only be set on exit points
  99238. */
  99239. get isVarying(): boolean;
  99240. set isVarying(value: boolean);
  99241. /**
  99242. * Gets a boolean indicating that the current connection point is a system value
  99243. */
  99244. get isSystemValue(): boolean;
  99245. /**
  99246. * Gets or sets the current well known value or null if not defined as a system value
  99247. */
  99248. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99249. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99250. /**
  99251. * Gets the current class name
  99252. * @returns the class name
  99253. */
  99254. getClassName(): string;
  99255. /**
  99256. * Animate the input if animationType !== None
  99257. * @param scene defines the rendering scene
  99258. */
  99259. animate(scene: Scene): void;
  99260. private _emitDefine;
  99261. initialize(state: NodeMaterialBuildState): void;
  99262. /**
  99263. * Set the input block to its default value (based on its type)
  99264. */
  99265. setDefaultValue(): void;
  99266. private _emitConstant;
  99267. /** @hidden */
  99268. get _noContextSwitch(): boolean;
  99269. private _emit;
  99270. /** @hidden */
  99271. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99272. /** @hidden */
  99273. _transmit(effect: Effect, scene: Scene): void;
  99274. protected _buildBlock(state: NodeMaterialBuildState): void;
  99275. protected _dumpPropertiesCode(): string;
  99276. dispose(): void;
  99277. serialize(): any;
  99278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99279. }
  99280. }
  99281. declare module BABYLON {
  99282. /**
  99283. * Enum used to define the compatibility state between two connection points
  99284. */
  99285. export enum NodeMaterialConnectionPointCompatibilityStates {
  99286. /** Points are compatibles */
  99287. Compatible = 0,
  99288. /** Points are incompatible because of their types */
  99289. TypeIncompatible = 1,
  99290. /** Points are incompatible because of their targets (vertex vs fragment) */
  99291. TargetIncompatible = 2
  99292. }
  99293. /**
  99294. * Defines the direction of a connection point
  99295. */
  99296. export enum NodeMaterialConnectionPointDirection {
  99297. /** Input */
  99298. Input = 0,
  99299. /** Output */
  99300. Output = 1
  99301. }
  99302. /**
  99303. * Defines a connection point for a block
  99304. */
  99305. export class NodeMaterialConnectionPoint {
  99306. /** @hidden */
  99307. _ownerBlock: NodeMaterialBlock;
  99308. /** @hidden */
  99309. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99310. private _endpoints;
  99311. private _associatedVariableName;
  99312. private _direction;
  99313. /** @hidden */
  99314. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99315. /** @hidden */
  99316. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99317. private _type;
  99318. /** @hidden */
  99319. _enforceAssociatedVariableName: boolean;
  99320. /** Gets the direction of the point */
  99321. get direction(): NodeMaterialConnectionPointDirection;
  99322. /** Indicates that this connection point needs dual validation before being connected to another point */
  99323. needDualDirectionValidation: boolean;
  99324. /**
  99325. * Gets or sets the additional types supported by this connection point
  99326. */
  99327. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99328. /**
  99329. * Gets or sets the additional types excluded by this connection point
  99330. */
  99331. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99332. /**
  99333. * Observable triggered when this point is connected
  99334. */
  99335. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99336. /**
  99337. * Gets or sets the associated variable name in the shader
  99338. */
  99339. get associatedVariableName(): string;
  99340. set associatedVariableName(value: string);
  99341. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99342. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99343. /**
  99344. * Gets or sets the connection point type (default is float)
  99345. */
  99346. get type(): NodeMaterialBlockConnectionPointTypes;
  99347. set type(value: NodeMaterialBlockConnectionPointTypes);
  99348. /**
  99349. * Gets or sets the connection point name
  99350. */
  99351. name: string;
  99352. /**
  99353. * Gets or sets the connection point name
  99354. */
  99355. displayName: string;
  99356. /**
  99357. * Gets or sets a boolean indicating that this connection point can be omitted
  99358. */
  99359. isOptional: boolean;
  99360. /**
  99361. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99362. */
  99363. isExposedOnFrame: boolean;
  99364. /**
  99365. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99366. */
  99367. define: string;
  99368. /** @hidden */
  99369. _prioritizeVertex: boolean;
  99370. private _target;
  99371. /** Gets or sets the target of that connection point */
  99372. get target(): NodeMaterialBlockTargets;
  99373. set target(value: NodeMaterialBlockTargets);
  99374. /**
  99375. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99376. */
  99377. get isConnected(): boolean;
  99378. /**
  99379. * Gets a boolean indicating that the current point is connected to an input block
  99380. */
  99381. get isConnectedToInputBlock(): boolean;
  99382. /**
  99383. * Gets a the connected input block (if any)
  99384. */
  99385. get connectInputBlock(): Nullable<InputBlock>;
  99386. /** Get the other side of the connection (if any) */
  99387. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99388. /** Get the block that owns this connection point */
  99389. get ownerBlock(): NodeMaterialBlock;
  99390. /** Get the block connected on the other side of this connection (if any) */
  99391. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99392. /** Get the block connected on the endpoints of this connection (if any) */
  99393. get connectedBlocks(): Array<NodeMaterialBlock>;
  99394. /** Gets the list of connected endpoints */
  99395. get endpoints(): NodeMaterialConnectionPoint[];
  99396. /** Gets a boolean indicating if that output point is connected to at least one input */
  99397. get hasEndpoints(): boolean;
  99398. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99399. get isConnectedInVertexShader(): boolean;
  99400. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99401. get isConnectedInFragmentShader(): boolean;
  99402. /**
  99403. * Creates a block suitable to be used as an input for this input point.
  99404. * If null is returned, a block based on the point type will be created.
  99405. * @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
  99406. */
  99407. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99408. /**
  99409. * Creates a new connection point
  99410. * @param name defines the connection point name
  99411. * @param ownerBlock defines the block hosting this connection point
  99412. * @param direction defines the direction of the connection point
  99413. */
  99414. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99415. /**
  99416. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99417. * @returns the class name
  99418. */
  99419. getClassName(): string;
  99420. /**
  99421. * Gets a boolean indicating if the current point can be connected to another point
  99422. * @param connectionPoint defines the other connection point
  99423. * @returns a boolean
  99424. */
  99425. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99426. /**
  99427. * Gets a number indicating if the current point can be connected to another point
  99428. * @param connectionPoint defines the other connection point
  99429. * @returns a number defining the compatibility state
  99430. */
  99431. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99432. /**
  99433. * Connect this point to another connection point
  99434. * @param connectionPoint defines the other connection point
  99435. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99436. * @returns the current connection point
  99437. */
  99438. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99439. /**
  99440. * Disconnect this point from one of his endpoint
  99441. * @param endpoint defines the other connection point
  99442. * @returns the current connection point
  99443. */
  99444. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99445. /**
  99446. * Serializes this point in a JSON representation
  99447. * @param isInput defines if the connection point is an input (default is true)
  99448. * @returns the serialized point object
  99449. */
  99450. serialize(isInput?: boolean): any;
  99451. /**
  99452. * Release resources
  99453. */
  99454. dispose(): void;
  99455. }
  99456. }
  99457. declare module BABYLON {
  99458. /**
  99459. * Enum used to define the material modes
  99460. */
  99461. export enum NodeMaterialModes {
  99462. /** Regular material */
  99463. Material = 0,
  99464. /** For post process */
  99465. PostProcess = 1,
  99466. /** For particle system */
  99467. Particle = 2
  99468. }
  99469. }
  99470. declare module BABYLON {
  99471. /**
  99472. * Block used to read a texture from a sampler
  99473. */
  99474. export class TextureBlock extends NodeMaterialBlock {
  99475. private _defineName;
  99476. private _linearDefineName;
  99477. private _gammaDefineName;
  99478. private _tempTextureRead;
  99479. private _samplerName;
  99480. private _transformedUVName;
  99481. private _textureTransformName;
  99482. private _textureInfoName;
  99483. private _mainUVName;
  99484. private _mainUVDefineName;
  99485. private _fragmentOnly;
  99486. /**
  99487. * Gets or sets the texture associated with the node
  99488. */
  99489. texture: Nullable<Texture>;
  99490. /**
  99491. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99492. */
  99493. convertToGammaSpace: boolean;
  99494. /**
  99495. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99496. */
  99497. convertToLinearSpace: boolean;
  99498. /**
  99499. * Create a new TextureBlock
  99500. * @param name defines the block name
  99501. */
  99502. constructor(name: string, fragmentOnly?: boolean);
  99503. /**
  99504. * Gets the current class name
  99505. * @returns the class name
  99506. */
  99507. getClassName(): string;
  99508. /**
  99509. * Gets the uv input component
  99510. */
  99511. get uv(): NodeMaterialConnectionPoint;
  99512. /**
  99513. * Gets the rgba output component
  99514. */
  99515. get rgba(): NodeMaterialConnectionPoint;
  99516. /**
  99517. * Gets the rgb output component
  99518. */
  99519. get rgb(): NodeMaterialConnectionPoint;
  99520. /**
  99521. * Gets the r output component
  99522. */
  99523. get r(): NodeMaterialConnectionPoint;
  99524. /**
  99525. * Gets the g output component
  99526. */
  99527. get g(): NodeMaterialConnectionPoint;
  99528. /**
  99529. * Gets the b output component
  99530. */
  99531. get b(): NodeMaterialConnectionPoint;
  99532. /**
  99533. * Gets the a output component
  99534. */
  99535. get a(): NodeMaterialConnectionPoint;
  99536. get target(): NodeMaterialBlockTargets;
  99537. autoConfigure(material: NodeMaterial): void;
  99538. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99540. isReady(): boolean;
  99541. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99542. private get _isMixed();
  99543. private _injectVertexCode;
  99544. private _writeTextureRead;
  99545. private _writeOutput;
  99546. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99547. protected _dumpPropertiesCode(): string;
  99548. serialize(): any;
  99549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99550. }
  99551. }
  99552. declare module BABYLON {
  99553. /** @hidden */
  99554. export var reflectionFunction: {
  99555. name: string;
  99556. shader: string;
  99557. };
  99558. }
  99559. declare module BABYLON {
  99560. /**
  99561. * Base block used to read a reflection texture from a sampler
  99562. */
  99563. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99564. /** @hidden */
  99565. _define3DName: string;
  99566. /** @hidden */
  99567. _defineCubicName: string;
  99568. /** @hidden */
  99569. _defineExplicitName: string;
  99570. /** @hidden */
  99571. _defineProjectionName: string;
  99572. /** @hidden */
  99573. _defineLocalCubicName: string;
  99574. /** @hidden */
  99575. _defineSphericalName: string;
  99576. /** @hidden */
  99577. _definePlanarName: string;
  99578. /** @hidden */
  99579. _defineEquirectangularName: string;
  99580. /** @hidden */
  99581. _defineMirroredEquirectangularFixedName: string;
  99582. /** @hidden */
  99583. _defineEquirectangularFixedName: string;
  99584. /** @hidden */
  99585. _defineSkyboxName: string;
  99586. /** @hidden */
  99587. _defineOppositeZ: string;
  99588. /** @hidden */
  99589. _cubeSamplerName: string;
  99590. /** @hidden */
  99591. _2DSamplerName: string;
  99592. protected _positionUVWName: string;
  99593. protected _directionWName: string;
  99594. protected _reflectionVectorName: string;
  99595. /** @hidden */
  99596. _reflectionCoordsName: string;
  99597. /** @hidden */
  99598. _reflectionMatrixName: string;
  99599. protected _reflectionColorName: string;
  99600. /**
  99601. * Gets or sets the texture associated with the node
  99602. */
  99603. texture: Nullable<BaseTexture>;
  99604. /**
  99605. * Create a new ReflectionTextureBaseBlock
  99606. * @param name defines the block name
  99607. */
  99608. constructor(name: string);
  99609. /**
  99610. * Gets the current class name
  99611. * @returns the class name
  99612. */
  99613. getClassName(): string;
  99614. /**
  99615. * Gets the world position input component
  99616. */
  99617. abstract get position(): NodeMaterialConnectionPoint;
  99618. /**
  99619. * Gets the world position input component
  99620. */
  99621. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99622. /**
  99623. * Gets the world normal input component
  99624. */
  99625. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99626. /**
  99627. * Gets the world input component
  99628. */
  99629. abstract get world(): NodeMaterialConnectionPoint;
  99630. /**
  99631. * Gets the camera (or eye) position component
  99632. */
  99633. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99634. /**
  99635. * Gets the view input component
  99636. */
  99637. abstract get view(): NodeMaterialConnectionPoint;
  99638. protected _getTexture(): Nullable<BaseTexture>;
  99639. autoConfigure(material: NodeMaterial): void;
  99640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99641. isReady(): boolean;
  99642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99643. /**
  99644. * Gets the code to inject in the vertex shader
  99645. * @param state current state of the node material building
  99646. * @returns the shader code
  99647. */
  99648. handleVertexSide(state: NodeMaterialBuildState): string;
  99649. /**
  99650. * Handles the inits for the fragment code path
  99651. * @param state node material build state
  99652. */
  99653. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99654. /**
  99655. * Generates the reflection coords code for the fragment code path
  99656. * @param worldNormalVarName name of the world normal variable
  99657. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99658. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99659. * @returns the shader code
  99660. */
  99661. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99662. /**
  99663. * Generates the reflection color code for the fragment code path
  99664. * @param lodVarName name of the lod variable
  99665. * @param swizzleLookupTexture swizzle to use for the final color variable
  99666. * @returns the shader code
  99667. */
  99668. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99669. /**
  99670. * Generates the code corresponding to the connected output points
  99671. * @param state node material build state
  99672. * @param varName name of the variable to output
  99673. * @returns the shader code
  99674. */
  99675. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99676. protected _buildBlock(state: NodeMaterialBuildState): this;
  99677. protected _dumpPropertiesCode(): string;
  99678. serialize(): any;
  99679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99680. }
  99681. }
  99682. declare module BABYLON {
  99683. /**
  99684. * Defines a connection point to be used for points with a custom object type
  99685. */
  99686. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99687. private _blockType;
  99688. private _blockName;
  99689. private _nameForCheking?;
  99690. /**
  99691. * Creates a new connection point
  99692. * @param name defines the connection point name
  99693. * @param ownerBlock defines the block hosting this connection point
  99694. * @param direction defines the direction of the connection point
  99695. */
  99696. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99697. /**
  99698. * Gets a number indicating if the current point can be connected to another point
  99699. * @param connectionPoint defines the other connection point
  99700. * @returns a number defining the compatibility state
  99701. */
  99702. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99703. /**
  99704. * Creates a block suitable to be used as an input for this input point.
  99705. * If null is returned, a block based on the point type will be created.
  99706. * @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
  99707. */
  99708. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99709. }
  99710. }
  99711. declare module BABYLON {
  99712. /**
  99713. * Enum defining the type of properties that can be edited in the property pages in the NME
  99714. */
  99715. export enum PropertyTypeForEdition {
  99716. /** property is a boolean */
  99717. Boolean = 0,
  99718. /** property is a float */
  99719. Float = 1,
  99720. /** property is a Vector2 */
  99721. Vector2 = 2,
  99722. /** property is a list of values */
  99723. List = 3
  99724. }
  99725. /**
  99726. * Interface that defines an option in a variable of type list
  99727. */
  99728. export interface IEditablePropertyListOption {
  99729. /** label of the option */
  99730. "label": string;
  99731. /** value of the option */
  99732. "value": number;
  99733. }
  99734. /**
  99735. * Interface that defines the options available for an editable property
  99736. */
  99737. export interface IEditablePropertyOption {
  99738. /** min value */
  99739. "min"?: number;
  99740. /** max value */
  99741. "max"?: number;
  99742. /** notifiers: indicates which actions to take when the property is changed */
  99743. "notifiers"?: {
  99744. /** the material should be rebuilt */
  99745. "rebuild"?: boolean;
  99746. /** the preview should be updated */
  99747. "update"?: boolean;
  99748. };
  99749. /** list of the options for a variable of type list */
  99750. "options"?: IEditablePropertyListOption[];
  99751. }
  99752. /**
  99753. * Interface that describes an editable property
  99754. */
  99755. export interface IPropertyDescriptionForEdition {
  99756. /** name of the property */
  99757. "propertyName": string;
  99758. /** display name of the property */
  99759. "displayName": string;
  99760. /** type of the property */
  99761. "type": PropertyTypeForEdition;
  99762. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99763. "groupName": string;
  99764. /** options for the property */
  99765. "options": IEditablePropertyOption;
  99766. }
  99767. /**
  99768. * Decorator that flags a property in a node material block as being editable
  99769. */
  99770. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99771. }
  99772. declare module BABYLON {
  99773. /**
  99774. * Block used to implement the refraction part of the sub surface module of the PBR material
  99775. */
  99776. export class RefractionBlock extends NodeMaterialBlock {
  99777. /** @hidden */
  99778. _define3DName: string;
  99779. /** @hidden */
  99780. _refractionMatrixName: string;
  99781. /** @hidden */
  99782. _defineLODRefractionAlpha: string;
  99783. /** @hidden */
  99784. _defineLinearSpecularRefraction: string;
  99785. /** @hidden */
  99786. _defineOppositeZ: string;
  99787. /** @hidden */
  99788. _cubeSamplerName: string;
  99789. /** @hidden */
  99790. _2DSamplerName: string;
  99791. /** @hidden */
  99792. _vRefractionMicrosurfaceInfosName: string;
  99793. /** @hidden */
  99794. _vRefractionInfosName: string;
  99795. private _scene;
  99796. /**
  99797. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99798. * Materials half opaque for instance using refraction could benefit from this control.
  99799. */
  99800. linkRefractionWithTransparency: boolean;
  99801. /**
  99802. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99803. */
  99804. invertRefractionY: boolean;
  99805. /**
  99806. * Gets or sets the texture associated with the node
  99807. */
  99808. texture: Nullable<BaseTexture>;
  99809. /**
  99810. * Create a new RefractionBlock
  99811. * @param name defines the block name
  99812. */
  99813. constructor(name: string);
  99814. /**
  99815. * Gets the current class name
  99816. * @returns the class name
  99817. */
  99818. getClassName(): string;
  99819. /**
  99820. * Gets the intensity input component
  99821. */
  99822. get intensity(): NodeMaterialConnectionPoint;
  99823. /**
  99824. * Gets the index of refraction input component
  99825. */
  99826. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99827. /**
  99828. * Gets the tint at distance input component
  99829. */
  99830. get tintAtDistance(): NodeMaterialConnectionPoint;
  99831. /**
  99832. * Gets the view input component
  99833. */
  99834. get view(): NodeMaterialConnectionPoint;
  99835. /**
  99836. * Gets the refraction object output component
  99837. */
  99838. get refraction(): NodeMaterialConnectionPoint;
  99839. /**
  99840. * Returns true if the block has a texture
  99841. */
  99842. get hasTexture(): boolean;
  99843. protected _getTexture(): Nullable<BaseTexture>;
  99844. autoConfigure(material: NodeMaterial): void;
  99845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99846. isReady(): boolean;
  99847. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99848. /**
  99849. * Gets the main code of the block (fragment side)
  99850. * @param state current state of the node material building
  99851. * @returns the shader code
  99852. */
  99853. getCode(state: NodeMaterialBuildState): string;
  99854. protected _buildBlock(state: NodeMaterialBuildState): this;
  99855. protected _dumpPropertiesCode(): string;
  99856. serialize(): any;
  99857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99858. }
  99859. }
  99860. declare module BABYLON {
  99861. /**
  99862. * Base block used as input for post process
  99863. */
  99864. export class CurrentScreenBlock extends NodeMaterialBlock {
  99865. private _samplerName;
  99866. private _linearDefineName;
  99867. private _gammaDefineName;
  99868. private _mainUVName;
  99869. private _tempTextureRead;
  99870. /**
  99871. * Gets or sets the texture associated with the node
  99872. */
  99873. texture: Nullable<BaseTexture>;
  99874. /**
  99875. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99876. */
  99877. convertToGammaSpace: boolean;
  99878. /**
  99879. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99880. */
  99881. convertToLinearSpace: boolean;
  99882. /**
  99883. * Create a new CurrentScreenBlock
  99884. * @param name defines the block name
  99885. */
  99886. constructor(name: string);
  99887. /**
  99888. * Gets the current class name
  99889. * @returns the class name
  99890. */
  99891. getClassName(): string;
  99892. /**
  99893. * Gets the uv input component
  99894. */
  99895. get uv(): NodeMaterialConnectionPoint;
  99896. /**
  99897. * Gets the rgba output component
  99898. */
  99899. get rgba(): NodeMaterialConnectionPoint;
  99900. /**
  99901. * Gets the rgb output component
  99902. */
  99903. get rgb(): NodeMaterialConnectionPoint;
  99904. /**
  99905. * Gets the r output component
  99906. */
  99907. get r(): NodeMaterialConnectionPoint;
  99908. /**
  99909. * Gets the g output component
  99910. */
  99911. get g(): NodeMaterialConnectionPoint;
  99912. /**
  99913. * Gets the b output component
  99914. */
  99915. get b(): NodeMaterialConnectionPoint;
  99916. /**
  99917. * Gets the a output component
  99918. */
  99919. get a(): NodeMaterialConnectionPoint;
  99920. /**
  99921. * Initialize the block and prepare the context for build
  99922. * @param state defines the state that will be used for the build
  99923. */
  99924. initialize(state: NodeMaterialBuildState): void;
  99925. get target(): NodeMaterialBlockTargets;
  99926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99927. isReady(): boolean;
  99928. private _injectVertexCode;
  99929. private _writeTextureRead;
  99930. private _writeOutput;
  99931. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99932. serialize(): any;
  99933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99934. }
  99935. }
  99936. declare module BABYLON {
  99937. /**
  99938. * Base block used for the particle texture
  99939. */
  99940. export class ParticleTextureBlock extends NodeMaterialBlock {
  99941. private _samplerName;
  99942. private _linearDefineName;
  99943. private _gammaDefineName;
  99944. private _tempTextureRead;
  99945. /**
  99946. * Gets or sets the texture associated with the node
  99947. */
  99948. texture: Nullable<BaseTexture>;
  99949. /**
  99950. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99951. */
  99952. convertToGammaSpace: boolean;
  99953. /**
  99954. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99955. */
  99956. convertToLinearSpace: boolean;
  99957. /**
  99958. * Create a new ParticleTextureBlock
  99959. * @param name defines the block name
  99960. */
  99961. constructor(name: string);
  99962. /**
  99963. * Gets the current class name
  99964. * @returns the class name
  99965. */
  99966. getClassName(): string;
  99967. /**
  99968. * Gets the uv input component
  99969. */
  99970. get uv(): NodeMaterialConnectionPoint;
  99971. /**
  99972. * Gets the rgba output component
  99973. */
  99974. get rgba(): NodeMaterialConnectionPoint;
  99975. /**
  99976. * Gets the rgb output component
  99977. */
  99978. get rgb(): NodeMaterialConnectionPoint;
  99979. /**
  99980. * Gets the r output component
  99981. */
  99982. get r(): NodeMaterialConnectionPoint;
  99983. /**
  99984. * Gets the g output component
  99985. */
  99986. get g(): NodeMaterialConnectionPoint;
  99987. /**
  99988. * Gets the b output component
  99989. */
  99990. get b(): NodeMaterialConnectionPoint;
  99991. /**
  99992. * Gets the a output component
  99993. */
  99994. get a(): NodeMaterialConnectionPoint;
  99995. /**
  99996. * Initialize the block and prepare the context for build
  99997. * @param state defines the state that will be used for the build
  99998. */
  99999. initialize(state: NodeMaterialBuildState): void;
  100000. autoConfigure(material: NodeMaterial): void;
  100001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100002. isReady(): boolean;
  100003. private _writeOutput;
  100004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100005. serialize(): any;
  100006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100007. }
  100008. }
  100009. declare module BABYLON {
  100010. /**
  100011. * Class used to store shared data between 2 NodeMaterialBuildState
  100012. */
  100013. export class NodeMaterialBuildStateSharedData {
  100014. /**
  100015. * Gets the list of emitted varyings
  100016. */
  100017. temps: string[];
  100018. /**
  100019. * Gets the list of emitted varyings
  100020. */
  100021. varyings: string[];
  100022. /**
  100023. * Gets the varying declaration string
  100024. */
  100025. varyingDeclaration: string;
  100026. /**
  100027. * Input blocks
  100028. */
  100029. inputBlocks: InputBlock[];
  100030. /**
  100031. * Input blocks
  100032. */
  100033. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100034. /**
  100035. * Bindable blocks (Blocks that need to set data to the effect)
  100036. */
  100037. bindableBlocks: NodeMaterialBlock[];
  100038. /**
  100039. * List of blocks that can provide a compilation fallback
  100040. */
  100041. blocksWithFallbacks: NodeMaterialBlock[];
  100042. /**
  100043. * List of blocks that can provide a define update
  100044. */
  100045. blocksWithDefines: NodeMaterialBlock[];
  100046. /**
  100047. * List of blocks that can provide a repeatable content
  100048. */
  100049. repeatableContentBlocks: NodeMaterialBlock[];
  100050. /**
  100051. * List of blocks that can provide a dynamic list of uniforms
  100052. */
  100053. dynamicUniformBlocks: NodeMaterialBlock[];
  100054. /**
  100055. * List of blocks that can block the isReady function for the material
  100056. */
  100057. blockingBlocks: NodeMaterialBlock[];
  100058. /**
  100059. * Gets the list of animated inputs
  100060. */
  100061. animatedInputs: InputBlock[];
  100062. /**
  100063. * Build Id used to avoid multiple recompilations
  100064. */
  100065. buildId: number;
  100066. /** List of emitted variables */
  100067. variableNames: {
  100068. [key: string]: number;
  100069. };
  100070. /** List of emitted defines */
  100071. defineNames: {
  100072. [key: string]: number;
  100073. };
  100074. /** Should emit comments? */
  100075. emitComments: boolean;
  100076. /** Emit build activity */
  100077. verbose: boolean;
  100078. /** Gets or sets the hosting scene */
  100079. scene: Scene;
  100080. /**
  100081. * Gets the compilation hints emitted at compilation time
  100082. */
  100083. hints: {
  100084. needWorldViewMatrix: boolean;
  100085. needWorldViewProjectionMatrix: boolean;
  100086. needAlphaBlending: boolean;
  100087. needAlphaTesting: boolean;
  100088. };
  100089. /**
  100090. * List of compilation checks
  100091. */
  100092. checks: {
  100093. emitVertex: boolean;
  100094. emitFragment: boolean;
  100095. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100096. };
  100097. /**
  100098. * Is vertex program allowed to be empty?
  100099. */
  100100. allowEmptyVertexProgram: boolean;
  100101. /** Creates a new shared data */
  100102. constructor();
  100103. /**
  100104. * Emits console errors and exceptions if there is a failing check
  100105. */
  100106. emitErrors(): void;
  100107. }
  100108. }
  100109. declare module BABYLON {
  100110. /**
  100111. * Class used to store node based material build state
  100112. */
  100113. export class NodeMaterialBuildState {
  100114. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100115. supportUniformBuffers: boolean;
  100116. /**
  100117. * Gets the list of emitted attributes
  100118. */
  100119. attributes: string[];
  100120. /**
  100121. * Gets the list of emitted uniforms
  100122. */
  100123. uniforms: string[];
  100124. /**
  100125. * Gets the list of emitted constants
  100126. */
  100127. constants: string[];
  100128. /**
  100129. * Gets the list of emitted samplers
  100130. */
  100131. samplers: string[];
  100132. /**
  100133. * Gets the list of emitted functions
  100134. */
  100135. functions: {
  100136. [key: string]: string;
  100137. };
  100138. /**
  100139. * Gets the list of emitted extensions
  100140. */
  100141. extensions: {
  100142. [key: string]: string;
  100143. };
  100144. /**
  100145. * Gets the target of the compilation state
  100146. */
  100147. target: NodeMaterialBlockTargets;
  100148. /**
  100149. * Gets the list of emitted counters
  100150. */
  100151. counters: {
  100152. [key: string]: number;
  100153. };
  100154. /**
  100155. * Shared data between multiple NodeMaterialBuildState instances
  100156. */
  100157. sharedData: NodeMaterialBuildStateSharedData;
  100158. /** @hidden */
  100159. _vertexState: NodeMaterialBuildState;
  100160. /** @hidden */
  100161. _attributeDeclaration: string;
  100162. /** @hidden */
  100163. _uniformDeclaration: string;
  100164. /** @hidden */
  100165. _constantDeclaration: string;
  100166. /** @hidden */
  100167. _samplerDeclaration: string;
  100168. /** @hidden */
  100169. _varyingTransfer: string;
  100170. /** @hidden */
  100171. _injectAtEnd: string;
  100172. private _repeatableContentAnchorIndex;
  100173. /** @hidden */
  100174. _builtCompilationString: string;
  100175. /**
  100176. * Gets the emitted compilation strings
  100177. */
  100178. compilationString: string;
  100179. /**
  100180. * Finalize the compilation strings
  100181. * @param state defines the current compilation state
  100182. */
  100183. finalize(state: NodeMaterialBuildState): void;
  100184. /** @hidden */
  100185. get _repeatableContentAnchor(): string;
  100186. /** @hidden */
  100187. _getFreeVariableName(prefix: string): string;
  100188. /** @hidden */
  100189. _getFreeDefineName(prefix: string): string;
  100190. /** @hidden */
  100191. _excludeVariableName(name: string): void;
  100192. /** @hidden */
  100193. _emit2DSampler(name: string): void;
  100194. /** @hidden */
  100195. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100196. /** @hidden */
  100197. _emitExtension(name: string, extension: string, define?: string): void;
  100198. /** @hidden */
  100199. _emitFunction(name: string, code: string, comments: string): void;
  100200. /** @hidden */
  100201. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100202. replaceStrings?: {
  100203. search: RegExp;
  100204. replace: string;
  100205. }[];
  100206. repeatKey?: string;
  100207. }): string;
  100208. /** @hidden */
  100209. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100210. repeatKey?: string;
  100211. removeAttributes?: boolean;
  100212. removeUniforms?: boolean;
  100213. removeVaryings?: boolean;
  100214. removeIfDef?: boolean;
  100215. replaceStrings?: {
  100216. search: RegExp;
  100217. replace: string;
  100218. }[];
  100219. }, storeKey?: string): void;
  100220. /** @hidden */
  100221. _registerTempVariable(name: string): boolean;
  100222. /** @hidden */
  100223. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100224. /** @hidden */
  100225. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100226. /** @hidden */
  100227. _emitFloat(value: number): string;
  100228. }
  100229. }
  100230. declare module BABYLON {
  100231. /**
  100232. * Helper class used to generate session unique ID
  100233. */
  100234. export class UniqueIdGenerator {
  100235. private static _UniqueIdCounter;
  100236. /**
  100237. * Gets an unique (relatively to the current scene) Id
  100238. */
  100239. static get UniqueId(): number;
  100240. }
  100241. }
  100242. declare module BABYLON {
  100243. /**
  100244. * Defines a block that can be used inside a node based material
  100245. */
  100246. export class NodeMaterialBlock {
  100247. private _buildId;
  100248. private _buildTarget;
  100249. private _target;
  100250. private _isFinalMerger;
  100251. private _isInput;
  100252. private _name;
  100253. protected _isUnique: boolean;
  100254. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100255. inputsAreExclusive: boolean;
  100256. /** @hidden */
  100257. _codeVariableName: string;
  100258. /** @hidden */
  100259. _inputs: NodeMaterialConnectionPoint[];
  100260. /** @hidden */
  100261. _outputs: NodeMaterialConnectionPoint[];
  100262. /** @hidden */
  100263. _preparationId: number;
  100264. /**
  100265. * Gets the name of the block
  100266. */
  100267. get name(): string;
  100268. /**
  100269. * Sets the name of the block. Will check if the name is valid.
  100270. */
  100271. set name(newName: string);
  100272. /**
  100273. * Gets or sets the unique id of the node
  100274. */
  100275. uniqueId: number;
  100276. /**
  100277. * Gets or sets the comments associated with this block
  100278. */
  100279. comments: string;
  100280. /**
  100281. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100282. */
  100283. get isUnique(): boolean;
  100284. /**
  100285. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100286. */
  100287. get isFinalMerger(): boolean;
  100288. /**
  100289. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100290. */
  100291. get isInput(): boolean;
  100292. /**
  100293. * Gets or sets the build Id
  100294. */
  100295. get buildId(): number;
  100296. set buildId(value: number);
  100297. /**
  100298. * Gets or sets the target of the block
  100299. */
  100300. get target(): NodeMaterialBlockTargets;
  100301. set target(value: NodeMaterialBlockTargets);
  100302. /**
  100303. * Gets the list of input points
  100304. */
  100305. get inputs(): NodeMaterialConnectionPoint[];
  100306. /** Gets the list of output points */
  100307. get outputs(): NodeMaterialConnectionPoint[];
  100308. /**
  100309. * Find an input by its name
  100310. * @param name defines the name of the input to look for
  100311. * @returns the input or null if not found
  100312. */
  100313. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100314. /**
  100315. * Find an output by its name
  100316. * @param name defines the name of the outputto look for
  100317. * @returns the output or null if not found
  100318. */
  100319. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100320. /**
  100321. * Creates a new NodeMaterialBlock
  100322. * @param name defines the block name
  100323. * @param target defines the target of that block (Vertex by default)
  100324. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100325. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100326. */
  100327. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100328. /**
  100329. * Initialize the block and prepare the context for build
  100330. * @param state defines the state that will be used for the build
  100331. */
  100332. initialize(state: NodeMaterialBuildState): void;
  100333. /**
  100334. * Bind data to effect. Will only be called for blocks with isBindable === true
  100335. * @param effect defines the effect to bind data to
  100336. * @param nodeMaterial defines the hosting NodeMaterial
  100337. * @param mesh defines the mesh that will be rendered
  100338. * @param subMesh defines the submesh that will be rendered
  100339. */
  100340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100341. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100342. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100343. protected _writeFloat(value: number): string;
  100344. /**
  100345. * Gets the current class name e.g. "NodeMaterialBlock"
  100346. * @returns the class name
  100347. */
  100348. getClassName(): string;
  100349. /**
  100350. * Register a new input. Must be called inside a block constructor
  100351. * @param name defines the connection point name
  100352. * @param type defines the connection point type
  100353. * @param isOptional defines a boolean indicating that this input can be omitted
  100354. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100355. * @param point an already created connection point. If not provided, create a new one
  100356. * @returns the current block
  100357. */
  100358. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100359. /**
  100360. * Register a new output. Must be called inside a block constructor
  100361. * @param name defines the connection point name
  100362. * @param type defines the connection point type
  100363. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100364. * @param point an already created connection point. If not provided, create a new one
  100365. * @returns the current block
  100366. */
  100367. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100368. /**
  100369. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100370. * @param forOutput defines an optional connection point to check compatibility with
  100371. * @returns the first available input or null
  100372. */
  100373. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100374. /**
  100375. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100376. * @param forBlock defines an optional block to check compatibility with
  100377. * @returns the first available input or null
  100378. */
  100379. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100380. /**
  100381. * Gets the sibling of the given output
  100382. * @param current defines the current output
  100383. * @returns the next output in the list or null
  100384. */
  100385. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100386. /**
  100387. * Connect current block with another block
  100388. * @param other defines the block to connect with
  100389. * @param options define the various options to help pick the right connections
  100390. * @returns the current block
  100391. */
  100392. connectTo(other: NodeMaterialBlock, options?: {
  100393. input?: string;
  100394. output?: string;
  100395. outputSwizzle?: string;
  100396. }): this | undefined;
  100397. protected _buildBlock(state: NodeMaterialBuildState): void;
  100398. /**
  100399. * Add uniforms, samplers and uniform buffers at compilation time
  100400. * @param state defines the state to update
  100401. * @param nodeMaterial defines the node material requesting the update
  100402. * @param defines defines the material defines to update
  100403. * @param uniformBuffers defines the list of uniform buffer names
  100404. */
  100405. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100406. /**
  100407. * Add potential fallbacks if shader compilation fails
  100408. * @param mesh defines the mesh to be rendered
  100409. * @param fallbacks defines the current prioritized list of fallbacks
  100410. */
  100411. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100412. /**
  100413. * Initialize defines for shader compilation
  100414. * @param mesh defines the mesh to be rendered
  100415. * @param nodeMaterial defines the node material requesting the update
  100416. * @param defines defines the material defines to update
  100417. * @param useInstances specifies that instances should be used
  100418. */
  100419. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100420. /**
  100421. * Update defines for shader compilation
  100422. * @param mesh defines the mesh to be rendered
  100423. * @param nodeMaterial defines the node material requesting the update
  100424. * @param defines defines the material defines to update
  100425. * @param useInstances specifies that instances should be used
  100426. * @param subMesh defines which submesh to render
  100427. */
  100428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100429. /**
  100430. * Lets the block try to connect some inputs automatically
  100431. * @param material defines the hosting NodeMaterial
  100432. */
  100433. autoConfigure(material: NodeMaterial): void;
  100434. /**
  100435. * Function called when a block is declared as repeatable content generator
  100436. * @param vertexShaderState defines the current compilation state for the vertex shader
  100437. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100438. * @param mesh defines the mesh to be rendered
  100439. * @param defines defines the material defines to update
  100440. */
  100441. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100442. /**
  100443. * Checks if the block is ready
  100444. * @param mesh defines the mesh to be rendered
  100445. * @param nodeMaterial defines the node material requesting the update
  100446. * @param defines defines the material defines to update
  100447. * @param useInstances specifies that instances should be used
  100448. * @returns true if the block is ready
  100449. */
  100450. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100451. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100452. private _processBuild;
  100453. /**
  100454. * Validates the new name for the block node.
  100455. * @param newName the new name to be given to the node.
  100456. * @returns false if the name is a reserve word, else true.
  100457. */
  100458. validateBlockName(newName: string): boolean;
  100459. /**
  100460. * Compile the current node and generate the shader code
  100461. * @param state defines the current compilation state (uniforms, samplers, current string)
  100462. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100463. * @returns true if already built
  100464. */
  100465. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100466. protected _inputRename(name: string): string;
  100467. protected _outputRename(name: string): string;
  100468. protected _dumpPropertiesCode(): string;
  100469. /** @hidden */
  100470. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100471. /** @hidden */
  100472. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100473. /**
  100474. * Clone the current block to a new identical block
  100475. * @param scene defines the hosting scene
  100476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100477. * @returns a copy of the current block
  100478. */
  100479. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100480. /**
  100481. * Serializes this block in a JSON representation
  100482. * @returns the serialized block object
  100483. */
  100484. serialize(): any;
  100485. /** @hidden */
  100486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100487. private _deserializePortDisplayNamesAndExposedOnFrame;
  100488. /**
  100489. * Release resources
  100490. */
  100491. dispose(): void;
  100492. }
  100493. }
  100494. declare module BABYLON {
  100495. /**
  100496. * Base class of materials working in push mode in babylon JS
  100497. * @hidden
  100498. */
  100499. export class PushMaterial extends Material {
  100500. protected _activeEffect: Effect;
  100501. protected _normalMatrix: Matrix;
  100502. constructor(name: string, scene: Scene);
  100503. getEffect(): Effect;
  100504. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100505. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100506. /**
  100507. * Binds the given world matrix to the active effect
  100508. *
  100509. * @param world the matrix to bind
  100510. */
  100511. bindOnlyWorldMatrix(world: Matrix): void;
  100512. /**
  100513. * Binds the given normal matrix to the active effect
  100514. *
  100515. * @param normalMatrix the matrix to bind
  100516. */
  100517. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100518. bind(world: Matrix, mesh?: Mesh): void;
  100519. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100520. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100521. }
  100522. }
  100523. declare module BABYLON {
  100524. /**
  100525. * Root class for all node material optimizers
  100526. */
  100527. export class NodeMaterialOptimizer {
  100528. /**
  100529. * Function used to optimize a NodeMaterial graph
  100530. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100531. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100532. */
  100533. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100534. }
  100535. }
  100536. declare module BABYLON {
  100537. /**
  100538. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100539. */
  100540. export class TransformBlock extends NodeMaterialBlock {
  100541. /**
  100542. * Defines the value to use to complement W value to transform it to a Vector4
  100543. */
  100544. complementW: number;
  100545. /**
  100546. * Defines the value to use to complement z value to transform it to a Vector4
  100547. */
  100548. complementZ: number;
  100549. /**
  100550. * Creates a new TransformBlock
  100551. * @param name defines the block name
  100552. */
  100553. constructor(name: string);
  100554. /**
  100555. * Gets the current class name
  100556. * @returns the class name
  100557. */
  100558. getClassName(): string;
  100559. /**
  100560. * Gets the vector input
  100561. */
  100562. get vector(): NodeMaterialConnectionPoint;
  100563. /**
  100564. * Gets the output component
  100565. */
  100566. get output(): NodeMaterialConnectionPoint;
  100567. /**
  100568. * Gets the xyz output component
  100569. */
  100570. get xyz(): NodeMaterialConnectionPoint;
  100571. /**
  100572. * Gets the matrix transform input
  100573. */
  100574. get transform(): NodeMaterialConnectionPoint;
  100575. protected _buildBlock(state: NodeMaterialBuildState): this;
  100576. /**
  100577. * Update defines for shader compilation
  100578. * @param mesh defines the mesh to be rendered
  100579. * @param nodeMaterial defines the node material requesting the update
  100580. * @param defines defines the material defines to update
  100581. * @param useInstances specifies that instances should be used
  100582. * @param subMesh defines which submesh to render
  100583. */
  100584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100585. serialize(): any;
  100586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100587. protected _dumpPropertiesCode(): string;
  100588. }
  100589. }
  100590. declare module BABYLON {
  100591. /**
  100592. * Block used to output the vertex position
  100593. */
  100594. export class VertexOutputBlock extends NodeMaterialBlock {
  100595. /**
  100596. * Creates a new VertexOutputBlock
  100597. * @param name defines the block name
  100598. */
  100599. constructor(name: string);
  100600. /**
  100601. * Gets the current class name
  100602. * @returns the class name
  100603. */
  100604. getClassName(): string;
  100605. /**
  100606. * Gets the vector input component
  100607. */
  100608. get vector(): NodeMaterialConnectionPoint;
  100609. protected _buildBlock(state: NodeMaterialBuildState): this;
  100610. }
  100611. }
  100612. declare module BABYLON {
  100613. /**
  100614. * Block used to output the final color
  100615. */
  100616. export class FragmentOutputBlock extends NodeMaterialBlock {
  100617. /**
  100618. * Create a new FragmentOutputBlock
  100619. * @param name defines the block name
  100620. */
  100621. constructor(name: string);
  100622. /**
  100623. * Gets the current class name
  100624. * @returns the class name
  100625. */
  100626. getClassName(): string;
  100627. /**
  100628. * Gets the rgba input component
  100629. */
  100630. get rgba(): NodeMaterialConnectionPoint;
  100631. /**
  100632. * Gets the rgb input component
  100633. */
  100634. get rgb(): NodeMaterialConnectionPoint;
  100635. /**
  100636. * Gets the a input component
  100637. */
  100638. get a(): NodeMaterialConnectionPoint;
  100639. protected _buildBlock(state: NodeMaterialBuildState): this;
  100640. }
  100641. }
  100642. declare module BABYLON {
  100643. /**
  100644. * Block used for the particle ramp gradient section
  100645. */
  100646. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100647. /**
  100648. * Create a new ParticleRampGradientBlock
  100649. * @param name defines the block name
  100650. */
  100651. constructor(name: string);
  100652. /**
  100653. * Gets the current class name
  100654. * @returns the class name
  100655. */
  100656. getClassName(): string;
  100657. /**
  100658. * Gets the color input component
  100659. */
  100660. get color(): NodeMaterialConnectionPoint;
  100661. /**
  100662. * Gets the rampColor output component
  100663. */
  100664. get rampColor(): NodeMaterialConnectionPoint;
  100665. /**
  100666. * Initialize the block and prepare the context for build
  100667. * @param state defines the state that will be used for the build
  100668. */
  100669. initialize(state: NodeMaterialBuildState): void;
  100670. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100671. }
  100672. }
  100673. declare module BABYLON {
  100674. /**
  100675. * Block used for the particle blend multiply section
  100676. */
  100677. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100678. /**
  100679. * Create a new ParticleBlendMultiplyBlock
  100680. * @param name defines the block name
  100681. */
  100682. constructor(name: string);
  100683. /**
  100684. * Gets the current class name
  100685. * @returns the class name
  100686. */
  100687. getClassName(): string;
  100688. /**
  100689. * Gets the color input component
  100690. */
  100691. get color(): NodeMaterialConnectionPoint;
  100692. /**
  100693. * Gets the alphaTexture input component
  100694. */
  100695. get alphaTexture(): NodeMaterialConnectionPoint;
  100696. /**
  100697. * Gets the alphaColor input component
  100698. */
  100699. get alphaColor(): NodeMaterialConnectionPoint;
  100700. /**
  100701. * Gets the blendColor output component
  100702. */
  100703. get blendColor(): NodeMaterialConnectionPoint;
  100704. /**
  100705. * Initialize the block and prepare the context for build
  100706. * @param state defines the state that will be used for the build
  100707. */
  100708. initialize(state: NodeMaterialBuildState): void;
  100709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100710. }
  100711. }
  100712. declare module BABYLON {
  100713. /**
  100714. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100715. */
  100716. export class VectorMergerBlock extends NodeMaterialBlock {
  100717. /**
  100718. * Create a new VectorMergerBlock
  100719. * @param name defines the block name
  100720. */
  100721. constructor(name: string);
  100722. /**
  100723. * Gets the current class name
  100724. * @returns the class name
  100725. */
  100726. getClassName(): string;
  100727. /**
  100728. * Gets the xyz component (input)
  100729. */
  100730. get xyzIn(): NodeMaterialConnectionPoint;
  100731. /**
  100732. * Gets the xy component (input)
  100733. */
  100734. get xyIn(): NodeMaterialConnectionPoint;
  100735. /**
  100736. * Gets the x component (input)
  100737. */
  100738. get x(): NodeMaterialConnectionPoint;
  100739. /**
  100740. * Gets the y component (input)
  100741. */
  100742. get y(): NodeMaterialConnectionPoint;
  100743. /**
  100744. * Gets the z component (input)
  100745. */
  100746. get z(): NodeMaterialConnectionPoint;
  100747. /**
  100748. * Gets the w component (input)
  100749. */
  100750. get w(): NodeMaterialConnectionPoint;
  100751. /**
  100752. * Gets the xyzw component (output)
  100753. */
  100754. get xyzw(): NodeMaterialConnectionPoint;
  100755. /**
  100756. * Gets the xyz component (output)
  100757. */
  100758. get xyzOut(): NodeMaterialConnectionPoint;
  100759. /**
  100760. * Gets the xy component (output)
  100761. */
  100762. get xyOut(): NodeMaterialConnectionPoint;
  100763. /**
  100764. * Gets the xy component (output)
  100765. * @deprecated Please use xyOut instead.
  100766. */
  100767. get xy(): NodeMaterialConnectionPoint;
  100768. /**
  100769. * Gets the xyz component (output)
  100770. * @deprecated Please use xyzOut instead.
  100771. */
  100772. get xyz(): NodeMaterialConnectionPoint;
  100773. protected _buildBlock(state: NodeMaterialBuildState): this;
  100774. }
  100775. }
  100776. declare module BABYLON {
  100777. /**
  100778. * Block used to remap a float from a range to a new one
  100779. */
  100780. export class RemapBlock extends NodeMaterialBlock {
  100781. /**
  100782. * Gets or sets the source range
  100783. */
  100784. sourceRange: Vector2;
  100785. /**
  100786. * Gets or sets the target range
  100787. */
  100788. targetRange: Vector2;
  100789. /**
  100790. * Creates a new RemapBlock
  100791. * @param name defines the block name
  100792. */
  100793. constructor(name: string);
  100794. /**
  100795. * Gets the current class name
  100796. * @returns the class name
  100797. */
  100798. getClassName(): string;
  100799. /**
  100800. * Gets the input component
  100801. */
  100802. get input(): NodeMaterialConnectionPoint;
  100803. /**
  100804. * Gets the source min input component
  100805. */
  100806. get sourceMin(): NodeMaterialConnectionPoint;
  100807. /**
  100808. * Gets the source max input component
  100809. */
  100810. get sourceMax(): NodeMaterialConnectionPoint;
  100811. /**
  100812. * Gets the target min input component
  100813. */
  100814. get targetMin(): NodeMaterialConnectionPoint;
  100815. /**
  100816. * Gets the target max input component
  100817. */
  100818. get targetMax(): NodeMaterialConnectionPoint;
  100819. /**
  100820. * Gets the output component
  100821. */
  100822. get output(): NodeMaterialConnectionPoint;
  100823. protected _buildBlock(state: NodeMaterialBuildState): this;
  100824. protected _dumpPropertiesCode(): string;
  100825. serialize(): any;
  100826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100827. }
  100828. }
  100829. declare module BABYLON {
  100830. /**
  100831. * Block used to multiply 2 values
  100832. */
  100833. export class MultiplyBlock extends NodeMaterialBlock {
  100834. /**
  100835. * Creates a new MultiplyBlock
  100836. * @param name defines the block name
  100837. */
  100838. constructor(name: string);
  100839. /**
  100840. * Gets the current class name
  100841. * @returns the class name
  100842. */
  100843. getClassName(): string;
  100844. /**
  100845. * Gets the left operand input component
  100846. */
  100847. get left(): NodeMaterialConnectionPoint;
  100848. /**
  100849. * Gets the right operand input component
  100850. */
  100851. get right(): NodeMaterialConnectionPoint;
  100852. /**
  100853. * Gets the output component
  100854. */
  100855. get output(): NodeMaterialConnectionPoint;
  100856. protected _buildBlock(state: NodeMaterialBuildState): this;
  100857. }
  100858. }
  100859. declare module BABYLON {
  100860. /**
  100861. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100862. */
  100863. export class ColorSplitterBlock extends NodeMaterialBlock {
  100864. /**
  100865. * Create a new ColorSplitterBlock
  100866. * @param name defines the block name
  100867. */
  100868. constructor(name: string);
  100869. /**
  100870. * Gets the current class name
  100871. * @returns the class name
  100872. */
  100873. getClassName(): string;
  100874. /**
  100875. * Gets the rgba component (input)
  100876. */
  100877. get rgba(): NodeMaterialConnectionPoint;
  100878. /**
  100879. * Gets the rgb component (input)
  100880. */
  100881. get rgbIn(): NodeMaterialConnectionPoint;
  100882. /**
  100883. * Gets the rgb component (output)
  100884. */
  100885. get rgbOut(): NodeMaterialConnectionPoint;
  100886. /**
  100887. * Gets the r component (output)
  100888. */
  100889. get r(): NodeMaterialConnectionPoint;
  100890. /**
  100891. * Gets the g component (output)
  100892. */
  100893. get g(): NodeMaterialConnectionPoint;
  100894. /**
  100895. * Gets the b component (output)
  100896. */
  100897. get b(): NodeMaterialConnectionPoint;
  100898. /**
  100899. * Gets the a component (output)
  100900. */
  100901. get a(): NodeMaterialConnectionPoint;
  100902. protected _inputRename(name: string): string;
  100903. protected _outputRename(name: string): string;
  100904. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100905. }
  100906. }
  100907. declare module BABYLON {
  100908. /**
  100909. * Interface used to configure the node material editor
  100910. */
  100911. export interface INodeMaterialEditorOptions {
  100912. /** Define the URl to load node editor script */
  100913. editorURL?: string;
  100914. }
  100915. /** @hidden */
  100916. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100917. NORMAL: boolean;
  100918. TANGENT: boolean;
  100919. UV1: boolean;
  100920. /** BONES */
  100921. NUM_BONE_INFLUENCERS: number;
  100922. BonesPerMesh: number;
  100923. BONETEXTURE: boolean;
  100924. /** MORPH TARGETS */
  100925. MORPHTARGETS: boolean;
  100926. MORPHTARGETS_NORMAL: boolean;
  100927. MORPHTARGETS_TANGENT: boolean;
  100928. MORPHTARGETS_UV: boolean;
  100929. NUM_MORPH_INFLUENCERS: number;
  100930. /** IMAGE PROCESSING */
  100931. IMAGEPROCESSING: boolean;
  100932. VIGNETTE: boolean;
  100933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100934. VIGNETTEBLENDMODEOPAQUE: boolean;
  100935. TONEMAPPING: boolean;
  100936. TONEMAPPING_ACES: boolean;
  100937. CONTRAST: boolean;
  100938. EXPOSURE: boolean;
  100939. COLORCURVES: boolean;
  100940. COLORGRADING: boolean;
  100941. COLORGRADING3D: boolean;
  100942. SAMPLER3DGREENDEPTH: boolean;
  100943. SAMPLER3DBGRMAP: boolean;
  100944. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100945. /** MISC. */
  100946. BUMPDIRECTUV: number;
  100947. constructor();
  100948. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100949. }
  100950. /**
  100951. * Class used to configure NodeMaterial
  100952. */
  100953. export interface INodeMaterialOptions {
  100954. /**
  100955. * Defines if blocks should emit comments
  100956. */
  100957. emitComments: boolean;
  100958. }
  100959. /**
  100960. * Class used to create a node based material built by assembling shader blocks
  100961. */
  100962. export class NodeMaterial extends PushMaterial {
  100963. private static _BuildIdGenerator;
  100964. private _options;
  100965. private _vertexCompilationState;
  100966. private _fragmentCompilationState;
  100967. private _sharedData;
  100968. private _buildId;
  100969. private _buildWasSuccessful;
  100970. private _cachedWorldViewMatrix;
  100971. private _cachedWorldViewProjectionMatrix;
  100972. private _optimizers;
  100973. private _animationFrame;
  100974. /** Define the Url to load node editor script */
  100975. static EditorURL: string;
  100976. /** Define the Url to load snippets */
  100977. static SnippetUrl: string;
  100978. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100979. static IgnoreTexturesAtLoadTime: boolean;
  100980. private BJSNODEMATERIALEDITOR;
  100981. /** Get the inspector from bundle or global */
  100982. private _getGlobalNodeMaterialEditor;
  100983. /**
  100984. * Snippet ID if the material was created from the snippet server
  100985. */
  100986. snippetId: string;
  100987. /**
  100988. * Gets or sets data used by visual editor
  100989. * @see https://nme.babylonjs.com
  100990. */
  100991. editorData: any;
  100992. /**
  100993. * 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)
  100994. */
  100995. ignoreAlpha: boolean;
  100996. /**
  100997. * Defines the maximum number of lights that can be used in the material
  100998. */
  100999. maxSimultaneousLights: number;
  101000. /**
  101001. * Observable raised when the material is built
  101002. */
  101003. onBuildObservable: Observable<NodeMaterial>;
  101004. /**
  101005. * Gets or sets the root nodes of the material vertex shader
  101006. */
  101007. _vertexOutputNodes: NodeMaterialBlock[];
  101008. /**
  101009. * Gets or sets the root nodes of the material fragment (pixel) shader
  101010. */
  101011. _fragmentOutputNodes: NodeMaterialBlock[];
  101012. /** Gets or sets options to control the node material overall behavior */
  101013. get options(): INodeMaterialOptions;
  101014. set options(options: INodeMaterialOptions);
  101015. /**
  101016. * Default configuration related to image processing available in the standard Material.
  101017. */
  101018. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101019. /**
  101020. * Gets the image processing configuration used either in this material.
  101021. */
  101022. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101023. /**
  101024. * Sets the Default image processing configuration used either in the this material.
  101025. *
  101026. * If sets to null, the scene one is in use.
  101027. */
  101028. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101029. /**
  101030. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101031. */
  101032. attachedBlocks: NodeMaterialBlock[];
  101033. /**
  101034. * Specifies the mode of the node material
  101035. * @hidden
  101036. */
  101037. _mode: NodeMaterialModes;
  101038. /**
  101039. * Gets the mode property
  101040. */
  101041. get mode(): NodeMaterialModes;
  101042. /**
  101043. * Create a new node based material
  101044. * @param name defines the material name
  101045. * @param scene defines the hosting scene
  101046. * @param options defines creation option
  101047. */
  101048. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101049. /**
  101050. * Gets the current class name of the material e.g. "NodeMaterial"
  101051. * @returns the class name
  101052. */
  101053. getClassName(): string;
  101054. /**
  101055. * Keep track of the image processing observer to allow dispose and replace.
  101056. */
  101057. private _imageProcessingObserver;
  101058. /**
  101059. * Attaches a new image processing configuration to the Standard Material.
  101060. * @param configuration
  101061. */
  101062. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101063. /**
  101064. * Get a block by its name
  101065. * @param name defines the name of the block to retrieve
  101066. * @returns the required block or null if not found
  101067. */
  101068. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101069. /**
  101070. * Get a block by its name
  101071. * @param predicate defines the predicate used to find the good candidate
  101072. * @returns the required block or null if not found
  101073. */
  101074. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101075. /**
  101076. * Get an input block by its name
  101077. * @param predicate defines the predicate used to find the good candidate
  101078. * @returns the required input block or null if not found
  101079. */
  101080. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101081. /**
  101082. * Gets the list of input blocks attached to this material
  101083. * @returns an array of InputBlocks
  101084. */
  101085. getInputBlocks(): InputBlock[];
  101086. /**
  101087. * Adds a new optimizer to the list of optimizers
  101088. * @param optimizer defines the optimizers to add
  101089. * @returns the current material
  101090. */
  101091. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101092. /**
  101093. * Remove an optimizer from the list of optimizers
  101094. * @param optimizer defines the optimizers to remove
  101095. * @returns the current material
  101096. */
  101097. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101098. /**
  101099. * Add a new block to the list of output nodes
  101100. * @param node defines the node to add
  101101. * @returns the current material
  101102. */
  101103. addOutputNode(node: NodeMaterialBlock): this;
  101104. /**
  101105. * Remove a block from the list of root nodes
  101106. * @param node defines the node to remove
  101107. * @returns the current material
  101108. */
  101109. removeOutputNode(node: NodeMaterialBlock): this;
  101110. private _addVertexOutputNode;
  101111. private _removeVertexOutputNode;
  101112. private _addFragmentOutputNode;
  101113. private _removeFragmentOutputNode;
  101114. /**
  101115. * Specifies if the material will require alpha blending
  101116. * @returns a boolean specifying if alpha blending is needed
  101117. */
  101118. needAlphaBlending(): boolean;
  101119. /**
  101120. * Specifies if this material should be rendered in alpha test mode
  101121. * @returns a boolean specifying if an alpha test is needed.
  101122. */
  101123. needAlphaTesting(): boolean;
  101124. private _initializeBlock;
  101125. private _resetDualBlocks;
  101126. /**
  101127. * Remove a block from the current node material
  101128. * @param block defines the block to remove
  101129. */
  101130. removeBlock(block: NodeMaterialBlock): void;
  101131. /**
  101132. * Build the material and generates the inner effect
  101133. * @param verbose defines if the build should log activity
  101134. */
  101135. build(verbose?: boolean): void;
  101136. /**
  101137. * Runs an otpimization phase to try to improve the shader code
  101138. */
  101139. optimize(): void;
  101140. private _prepareDefinesForAttributes;
  101141. /**
  101142. * Create a post process from the material
  101143. * @param camera The camera to apply the render pass to.
  101144. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101146. * @param engine The engine which the post process will be applied. (default: current engine)
  101147. * @param reusable If the post process can be reused on the same frame. (default: false)
  101148. * @param textureType Type of textures used when performing the post process. (default: 0)
  101149. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101150. * @returns the post process created
  101151. */
  101152. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101153. /**
  101154. * Create the post process effect from the material
  101155. * @param postProcess The post process to create the effect for
  101156. */
  101157. createEffectForPostProcess(postProcess: PostProcess): void;
  101158. private _createEffectOrPostProcess;
  101159. private _createEffectForParticles;
  101160. /**
  101161. * Create the effect to be used as the custom effect for a particle system
  101162. * @param particleSystem Particle system to create the effect for
  101163. * @param onCompiled defines a function to call when the effect creation is successful
  101164. * @param onError defines a function to call when the effect creation has failed
  101165. */
  101166. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101167. private _processDefines;
  101168. /**
  101169. * Get if the submesh is ready to be used and all its information available.
  101170. * Child classes can use it to update shaders
  101171. * @param mesh defines the mesh to check
  101172. * @param subMesh defines which submesh to check
  101173. * @param useInstances specifies that instances should be used
  101174. * @returns a boolean indicating that the submesh is ready or not
  101175. */
  101176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101177. /**
  101178. * Get a string representing the shaders built by the current node graph
  101179. */
  101180. get compiledShaders(): string;
  101181. /**
  101182. * Binds the world matrix to the material
  101183. * @param world defines the world transformation matrix
  101184. */
  101185. bindOnlyWorldMatrix(world: Matrix): void;
  101186. /**
  101187. * Binds the submesh to this material by preparing the effect and shader to draw
  101188. * @param world defines the world transformation matrix
  101189. * @param mesh defines the mesh containing the submesh
  101190. * @param subMesh defines the submesh to bind the material to
  101191. */
  101192. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101193. /**
  101194. * Gets the active textures from the material
  101195. * @returns an array of textures
  101196. */
  101197. getActiveTextures(): BaseTexture[];
  101198. /**
  101199. * Gets the list of texture blocks
  101200. * @returns an array of texture blocks
  101201. */
  101202. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101203. /**
  101204. * Specifies if the material uses a texture
  101205. * @param texture defines the texture to check against the material
  101206. * @returns a boolean specifying if the material uses the texture
  101207. */
  101208. hasTexture(texture: BaseTexture): boolean;
  101209. /**
  101210. * Disposes the material
  101211. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101212. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101213. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101214. */
  101215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101216. /** Creates the node editor window. */
  101217. private _createNodeEditor;
  101218. /**
  101219. * Launch the node material editor
  101220. * @param config Define the configuration of the editor
  101221. * @return a promise fulfilled when the node editor is visible
  101222. */
  101223. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101224. /**
  101225. * Clear the current material
  101226. */
  101227. clear(): void;
  101228. /**
  101229. * Clear the current material and set it to a default state
  101230. */
  101231. setToDefault(): void;
  101232. /**
  101233. * Clear the current material and set it to a default state for post process
  101234. */
  101235. setToDefaultPostProcess(): void;
  101236. /**
  101237. * Clear the current material and set it to a default state for particle
  101238. */
  101239. setToDefaultParticle(): void;
  101240. /**
  101241. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101242. * @param url defines the url to load from
  101243. * @returns a promise that will fullfil when the material is fully loaded
  101244. */
  101245. loadAsync(url: string): Promise<void>;
  101246. private _gatherBlocks;
  101247. /**
  101248. * Generate a string containing the code declaration required to create an equivalent of this material
  101249. * @returns a string
  101250. */
  101251. generateCode(): string;
  101252. /**
  101253. * Serializes this material in a JSON representation
  101254. * @returns the serialized material object
  101255. */
  101256. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101257. private _restoreConnections;
  101258. /**
  101259. * Clear the current graph and load a new one from a serialization object
  101260. * @param source defines the JSON representation of the material
  101261. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101262. * @param merge defines whether or not the source must be merged or replace the current content
  101263. */
  101264. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101265. /**
  101266. * Makes a duplicate of the current material.
  101267. * @param name - name to use for the new material.
  101268. */
  101269. clone(name: string): NodeMaterial;
  101270. /**
  101271. * Creates a node material from parsed material data
  101272. * @param source defines the JSON representation of the material
  101273. * @param scene defines the hosting scene
  101274. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101275. * @returns a new node material
  101276. */
  101277. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101278. /**
  101279. * Creates a node material from a snippet saved in a remote file
  101280. * @param name defines the name of the material to create
  101281. * @param url defines the url to load from
  101282. * @param scene defines the hosting scene
  101283. * @returns a promise that will resolve to the new node material
  101284. */
  101285. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101286. /**
  101287. * Creates a node material from a snippet saved by the node material editor
  101288. * @param snippetId defines the snippet to load
  101289. * @param scene defines the hosting scene
  101290. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101291. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101292. * @returns a promise that will resolve to the new node material
  101293. */
  101294. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101295. /**
  101296. * Creates a new node material set to default basic configuration
  101297. * @param name defines the name of the material
  101298. * @param scene defines the hosting scene
  101299. * @returns a new NodeMaterial
  101300. */
  101301. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101302. }
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * Size options for a post process
  101307. */
  101308. export type PostProcessOptions = {
  101309. width: number;
  101310. height: number;
  101311. };
  101312. /**
  101313. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101314. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101315. */
  101316. export class PostProcess {
  101317. /** Name of the PostProcess. */
  101318. name: string;
  101319. /**
  101320. * Gets or sets the unique id of the post process
  101321. */
  101322. uniqueId: number;
  101323. /**
  101324. * Width of the texture to apply the post process on
  101325. */
  101326. width: number;
  101327. /**
  101328. * Height of the texture to apply the post process on
  101329. */
  101330. height: number;
  101331. /**
  101332. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101333. */
  101334. nodeMaterialSource: Nullable<NodeMaterial>;
  101335. /**
  101336. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101337. * @hidden
  101338. */
  101339. _outputTexture: Nullable<InternalTexture>;
  101340. /**
  101341. * Sampling mode used by the shader
  101342. * See https://doc.babylonjs.com/classes/3.1/texture
  101343. */
  101344. renderTargetSamplingMode: number;
  101345. /**
  101346. * Clear color to use when screen clearing
  101347. */
  101348. clearColor: Color4;
  101349. /**
  101350. * If the buffer needs to be cleared before applying the post process. (default: true)
  101351. * Should be set to false if shader will overwrite all previous pixels.
  101352. */
  101353. autoClear: boolean;
  101354. /**
  101355. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101356. */
  101357. alphaMode: number;
  101358. /**
  101359. * Sets the setAlphaBlendConstants of the babylon engine
  101360. */
  101361. alphaConstants: Color4;
  101362. /**
  101363. * Animations to be used for the post processing
  101364. */
  101365. animations: Animation[];
  101366. /**
  101367. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101368. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101369. */
  101370. enablePixelPerfectMode: boolean;
  101371. /**
  101372. * Force the postprocess to be applied without taking in account viewport
  101373. */
  101374. forceFullscreenViewport: boolean;
  101375. /**
  101376. * List of inspectable custom properties (used by the Inspector)
  101377. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101378. */
  101379. inspectableCustomProperties: IInspectable[];
  101380. /**
  101381. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101382. *
  101383. * | Value | Type | Description |
  101384. * | ----- | ----------------------------------- | ----------- |
  101385. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101386. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101387. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101388. *
  101389. */
  101390. scaleMode: number;
  101391. /**
  101392. * Force textures to be a power of two (default: false)
  101393. */
  101394. alwaysForcePOT: boolean;
  101395. private _samples;
  101396. /**
  101397. * Number of sample textures (default: 1)
  101398. */
  101399. get samples(): number;
  101400. set samples(n: number);
  101401. /**
  101402. * Modify the scale of the post process to be the same as the viewport (default: false)
  101403. */
  101404. adaptScaleToCurrentViewport: boolean;
  101405. private _camera;
  101406. protected _scene: Scene;
  101407. private _engine;
  101408. private _options;
  101409. private _reusable;
  101410. private _textureType;
  101411. private _textureFormat;
  101412. /**
  101413. * Smart array of input and output textures for the post process.
  101414. * @hidden
  101415. */
  101416. _textures: SmartArray<InternalTexture>;
  101417. /**
  101418. * The index in _textures that corresponds to the output texture.
  101419. * @hidden
  101420. */
  101421. _currentRenderTextureInd: number;
  101422. private _effect;
  101423. private _samplers;
  101424. private _fragmentUrl;
  101425. private _vertexUrl;
  101426. private _parameters;
  101427. private _scaleRatio;
  101428. protected _indexParameters: any;
  101429. private _shareOutputWithPostProcess;
  101430. private _texelSize;
  101431. private _forcedOutputTexture;
  101432. /**
  101433. * Returns the fragment url or shader name used in the post process.
  101434. * @returns the fragment url or name in the shader store.
  101435. */
  101436. getEffectName(): string;
  101437. /**
  101438. * An event triggered when the postprocess is activated.
  101439. */
  101440. onActivateObservable: Observable<Camera>;
  101441. private _onActivateObserver;
  101442. /**
  101443. * A function that is added to the onActivateObservable
  101444. */
  101445. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101446. /**
  101447. * An event triggered when the postprocess changes its size.
  101448. */
  101449. onSizeChangedObservable: Observable<PostProcess>;
  101450. private _onSizeChangedObserver;
  101451. /**
  101452. * A function that is added to the onSizeChangedObservable
  101453. */
  101454. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101455. /**
  101456. * An event triggered when the postprocess applies its effect.
  101457. */
  101458. onApplyObservable: Observable<Effect>;
  101459. private _onApplyObserver;
  101460. /**
  101461. * A function that is added to the onApplyObservable
  101462. */
  101463. set onApply(callback: (effect: Effect) => void);
  101464. /**
  101465. * An event triggered before rendering the postprocess
  101466. */
  101467. onBeforeRenderObservable: Observable<Effect>;
  101468. private _onBeforeRenderObserver;
  101469. /**
  101470. * A function that is added to the onBeforeRenderObservable
  101471. */
  101472. set onBeforeRender(callback: (effect: Effect) => void);
  101473. /**
  101474. * An event triggered after rendering the postprocess
  101475. */
  101476. onAfterRenderObservable: Observable<Effect>;
  101477. private _onAfterRenderObserver;
  101478. /**
  101479. * A function that is added to the onAfterRenderObservable
  101480. */
  101481. set onAfterRender(callback: (efect: Effect) => void);
  101482. /**
  101483. * 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
  101484. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101485. */
  101486. get inputTexture(): InternalTexture;
  101487. set inputTexture(value: InternalTexture);
  101488. /**
  101489. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101490. * the only way to unset it is to use this function to restore its internal state
  101491. */
  101492. restoreDefaultInputTexture(): void;
  101493. /**
  101494. * Gets the camera which post process is applied to.
  101495. * @returns The camera the post process is applied to.
  101496. */
  101497. getCamera(): Camera;
  101498. /**
  101499. * Gets the texel size of the postprocess.
  101500. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101501. */
  101502. get texelSize(): Vector2;
  101503. /**
  101504. * Creates a new instance PostProcess
  101505. * @param name The name of the PostProcess.
  101506. * @param fragmentUrl The url of the fragment shader to be used.
  101507. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101508. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101509. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101510. * @param camera The camera to apply the render pass to.
  101511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101512. * @param engine The engine which the post process will be applied. (default: current engine)
  101513. * @param reusable If the post process can be reused on the same frame. (default: false)
  101514. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101515. * @param textureType Type of textures used when performing the post process. (default: 0)
  101516. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101517. * @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
  101518. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101519. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101520. */
  101521. constructor(
  101522. /** Name of the PostProcess. */
  101523. 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);
  101524. /**
  101525. * Gets a string idenfifying the name of the class
  101526. * @returns "PostProcess" string
  101527. */
  101528. getClassName(): string;
  101529. /**
  101530. * Gets the engine which this post process belongs to.
  101531. * @returns The engine the post process was enabled with.
  101532. */
  101533. getEngine(): Engine;
  101534. /**
  101535. * The effect that is created when initializing the post process.
  101536. * @returns The created effect corresponding the the postprocess.
  101537. */
  101538. getEffect(): Effect;
  101539. /**
  101540. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101541. * @param postProcess The post process to share the output with.
  101542. * @returns This post process.
  101543. */
  101544. shareOutputWith(postProcess: PostProcess): PostProcess;
  101545. /**
  101546. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101547. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101548. */
  101549. useOwnOutput(): void;
  101550. /**
  101551. * Updates the effect with the current post process compile time values and recompiles the shader.
  101552. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101553. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101554. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101555. * @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
  101556. * @param onCompiled Called when the shader has been compiled.
  101557. * @param onError Called if there is an error when compiling a shader.
  101558. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101559. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101560. */
  101561. 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;
  101562. /**
  101563. * The post process is reusable if it can be used multiple times within one frame.
  101564. * @returns If the post process is reusable
  101565. */
  101566. isReusable(): boolean;
  101567. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101568. markTextureDirty(): void;
  101569. /**
  101570. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101571. * 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.
  101572. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101573. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101574. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101575. * @returns The target texture that was bound to be written to.
  101576. */
  101577. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101578. /**
  101579. * If the post process is supported.
  101580. */
  101581. get isSupported(): boolean;
  101582. /**
  101583. * The aspect ratio of the output texture.
  101584. */
  101585. get aspectRatio(): number;
  101586. /**
  101587. * Get a value indicating if the post-process is ready to be used
  101588. * @returns true if the post-process is ready (shader is compiled)
  101589. */
  101590. isReady(): boolean;
  101591. /**
  101592. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101593. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101594. */
  101595. apply(): Nullable<Effect>;
  101596. private _disposeTextures;
  101597. /**
  101598. * Disposes the post process.
  101599. * @param camera The camera to dispose the post process on.
  101600. */
  101601. dispose(camera?: Camera): void;
  101602. }
  101603. }
  101604. declare module BABYLON {
  101605. /** @hidden */
  101606. export var kernelBlurVaryingDeclaration: {
  101607. name: string;
  101608. shader: string;
  101609. };
  101610. }
  101611. declare module BABYLON {
  101612. /** @hidden */
  101613. export var kernelBlurFragment: {
  101614. name: string;
  101615. shader: string;
  101616. };
  101617. }
  101618. declare module BABYLON {
  101619. /** @hidden */
  101620. export var kernelBlurFragment2: {
  101621. name: string;
  101622. shader: string;
  101623. };
  101624. }
  101625. declare module BABYLON {
  101626. /** @hidden */
  101627. export var kernelBlurPixelShader: {
  101628. name: string;
  101629. shader: string;
  101630. };
  101631. }
  101632. declare module BABYLON {
  101633. /** @hidden */
  101634. export var kernelBlurVertex: {
  101635. name: string;
  101636. shader: string;
  101637. };
  101638. }
  101639. declare module BABYLON {
  101640. /** @hidden */
  101641. export var kernelBlurVertexShader: {
  101642. name: string;
  101643. shader: string;
  101644. };
  101645. }
  101646. declare module BABYLON {
  101647. /**
  101648. * The Blur Post Process which blurs an image based on a kernel and direction.
  101649. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101650. */
  101651. export class BlurPostProcess extends PostProcess {
  101652. /** The direction in which to blur the image. */
  101653. direction: Vector2;
  101654. private blockCompilation;
  101655. protected _kernel: number;
  101656. protected _idealKernel: number;
  101657. protected _packedFloat: boolean;
  101658. private _staticDefines;
  101659. /**
  101660. * Sets the length in pixels of the blur sample region
  101661. */
  101662. set kernel(v: number);
  101663. /**
  101664. * Gets the length in pixels of the blur sample region
  101665. */
  101666. get kernel(): number;
  101667. /**
  101668. * Sets wether or not the blur needs to unpack/repack floats
  101669. */
  101670. set packedFloat(v: boolean);
  101671. /**
  101672. * Gets wether or not the blur is unpacking/repacking floats
  101673. */
  101674. get packedFloat(): boolean;
  101675. /**
  101676. * Creates a new instance BlurPostProcess
  101677. * @param name The name of the effect.
  101678. * @param direction The direction in which to blur the image.
  101679. * @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.
  101680. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101681. * @param camera The camera to apply the render pass to.
  101682. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101683. * @param engine The engine which the post process will be applied. (default: current engine)
  101684. * @param reusable If the post process can be reused on the same frame. (default: false)
  101685. * @param textureType Type of textures used when performing the post process. (default: 0)
  101686. * @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)
  101687. */
  101688. constructor(name: string,
  101689. /** The direction in which to blur the image. */
  101690. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101691. /**
  101692. * Updates the effect with the current post process compile time values and recompiles the shader.
  101693. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101694. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101695. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101696. * @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
  101697. * @param onCompiled Called when the shader has been compiled.
  101698. * @param onError Called if there is an error when compiling a shader.
  101699. */
  101700. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101701. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101702. /**
  101703. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101704. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101705. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101706. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101707. * The gaps between physical kernels are compensated for in the weighting of the samples
  101708. * @param idealKernel Ideal blur kernel.
  101709. * @return Nearest best kernel.
  101710. */
  101711. protected _nearestBestKernel(idealKernel: number): number;
  101712. /**
  101713. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101714. * @param x The point on the Gaussian distribution to sample.
  101715. * @return the value of the Gaussian function at x.
  101716. */
  101717. protected _gaussianWeight(x: number): number;
  101718. /**
  101719. * Generates a string that can be used as a floating point number in GLSL.
  101720. * @param x Value to print.
  101721. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101722. * @return GLSL float string.
  101723. */
  101724. protected _glslFloat(x: number, decimalFigures?: number): string;
  101725. }
  101726. }
  101727. declare module BABYLON {
  101728. /**
  101729. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101730. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101731. * You can then easily use it as a reflectionTexture on a flat surface.
  101732. * In case the surface is not a plane, please consider relying on reflection probes.
  101733. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101734. */
  101735. export class MirrorTexture extends RenderTargetTexture {
  101736. private scene;
  101737. /**
  101738. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101739. * 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.
  101740. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101741. */
  101742. mirrorPlane: Plane;
  101743. /**
  101744. * Define the blur ratio used to blur the reflection if needed.
  101745. */
  101746. set blurRatio(value: number);
  101747. get blurRatio(): number;
  101748. /**
  101749. * Define the adaptive blur kernel used to blur the reflection if needed.
  101750. * This will autocompute the closest best match for the `blurKernel`
  101751. */
  101752. set adaptiveBlurKernel(value: number);
  101753. /**
  101754. * Define the blur kernel used to blur the reflection if needed.
  101755. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101756. */
  101757. set blurKernel(value: number);
  101758. /**
  101759. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101760. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101761. */
  101762. set blurKernelX(value: number);
  101763. get blurKernelX(): number;
  101764. /**
  101765. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101767. */
  101768. set blurKernelY(value: number);
  101769. get blurKernelY(): number;
  101770. private _autoComputeBlurKernel;
  101771. protected _onRatioRescale(): void;
  101772. private _updateGammaSpace;
  101773. private _imageProcessingConfigChangeObserver;
  101774. private _transformMatrix;
  101775. private _mirrorMatrix;
  101776. private _savedViewMatrix;
  101777. private _blurX;
  101778. private _blurY;
  101779. private _adaptiveBlurKernel;
  101780. private _blurKernelX;
  101781. private _blurKernelY;
  101782. private _blurRatio;
  101783. /**
  101784. * Instantiates a Mirror Texture.
  101785. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101786. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101787. * You can then easily use it as a reflectionTexture on a flat surface.
  101788. * In case the surface is not a plane, please consider relying on reflection probes.
  101789. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101790. * @param name
  101791. * @param size
  101792. * @param scene
  101793. * @param generateMipMaps
  101794. * @param type
  101795. * @param samplingMode
  101796. * @param generateDepthBuffer
  101797. */
  101798. constructor(name: string, size: number | {
  101799. width: number;
  101800. height: number;
  101801. } | {
  101802. ratio: number;
  101803. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101804. private _preparePostProcesses;
  101805. /**
  101806. * Clone the mirror texture.
  101807. * @returns the cloned texture
  101808. */
  101809. clone(): MirrorTexture;
  101810. /**
  101811. * Serialize the texture to a JSON representation you could use in Parse later on
  101812. * @returns the serialized JSON representation
  101813. */
  101814. serialize(): any;
  101815. /**
  101816. * Dispose the texture and release its associated resources.
  101817. */
  101818. dispose(): void;
  101819. }
  101820. }
  101821. declare module BABYLON {
  101822. /**
  101823. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101824. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101825. */
  101826. export class Texture extends BaseTexture {
  101827. /**
  101828. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101829. */
  101830. static SerializeBuffers: boolean;
  101831. /** @hidden */
  101832. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101833. /** @hidden */
  101834. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101835. /** @hidden */
  101836. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101837. /** nearest is mag = nearest and min = nearest and mip = linear */
  101838. static readonly NEAREST_SAMPLINGMODE: number;
  101839. /** nearest is mag = nearest and min = nearest and mip = linear */
  101840. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101841. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101842. static readonly BILINEAR_SAMPLINGMODE: number;
  101843. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101844. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101845. /** Trilinear is mag = linear and min = linear and mip = linear */
  101846. static readonly TRILINEAR_SAMPLINGMODE: number;
  101847. /** Trilinear is mag = linear and min = linear and mip = linear */
  101848. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101849. /** mag = nearest and min = nearest and mip = nearest */
  101850. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101851. /** mag = nearest and min = linear and mip = nearest */
  101852. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101853. /** mag = nearest and min = linear and mip = linear */
  101854. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101855. /** mag = nearest and min = linear and mip = none */
  101856. static readonly NEAREST_LINEAR: number;
  101857. /** mag = nearest and min = nearest and mip = none */
  101858. static readonly NEAREST_NEAREST: number;
  101859. /** mag = linear and min = nearest and mip = nearest */
  101860. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101861. /** mag = linear and min = nearest and mip = linear */
  101862. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101863. /** mag = linear and min = linear and mip = none */
  101864. static readonly LINEAR_LINEAR: number;
  101865. /** mag = linear and min = nearest and mip = none */
  101866. static readonly LINEAR_NEAREST: number;
  101867. /** Explicit coordinates mode */
  101868. static readonly EXPLICIT_MODE: number;
  101869. /** Spherical coordinates mode */
  101870. static readonly SPHERICAL_MODE: number;
  101871. /** Planar coordinates mode */
  101872. static readonly PLANAR_MODE: number;
  101873. /** Cubic coordinates mode */
  101874. static readonly CUBIC_MODE: number;
  101875. /** Projection coordinates mode */
  101876. static readonly PROJECTION_MODE: number;
  101877. /** Inverse Cubic coordinates mode */
  101878. static readonly SKYBOX_MODE: number;
  101879. /** Inverse Cubic coordinates mode */
  101880. static readonly INVCUBIC_MODE: number;
  101881. /** Equirectangular coordinates mode */
  101882. static readonly EQUIRECTANGULAR_MODE: number;
  101883. /** Equirectangular Fixed coordinates mode */
  101884. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101885. /** Equirectangular Fixed Mirrored coordinates mode */
  101886. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101887. /** Texture is not repeating outside of 0..1 UVs */
  101888. static readonly CLAMP_ADDRESSMODE: number;
  101889. /** Texture is repeating outside of 0..1 UVs */
  101890. static readonly WRAP_ADDRESSMODE: number;
  101891. /** Texture is repeating and mirrored */
  101892. static readonly MIRROR_ADDRESSMODE: number;
  101893. /**
  101894. * 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
  101895. */
  101896. static UseSerializedUrlIfAny: boolean;
  101897. /**
  101898. * Define the url of the texture.
  101899. */
  101900. url: Nullable<string>;
  101901. /**
  101902. * Define an offset on the texture to offset the u coordinates of the UVs
  101903. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101904. */
  101905. uOffset: number;
  101906. /**
  101907. * Define an offset on the texture to offset the v coordinates of the UVs
  101908. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101909. */
  101910. vOffset: number;
  101911. /**
  101912. * Define an offset on the texture to scale the u coordinates of the UVs
  101913. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101914. */
  101915. uScale: number;
  101916. /**
  101917. * Define an offset on the texture to scale the v coordinates of the UVs
  101918. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101919. */
  101920. vScale: number;
  101921. /**
  101922. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101923. * @see https://doc.babylonjs.com/how_to/more_materials
  101924. */
  101925. uAng: number;
  101926. /**
  101927. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101928. * @see https://doc.babylonjs.com/how_to/more_materials
  101929. */
  101930. vAng: number;
  101931. /**
  101932. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101933. * @see https://doc.babylonjs.com/how_to/more_materials
  101934. */
  101935. wAng: number;
  101936. /**
  101937. * Defines the center of rotation (U)
  101938. */
  101939. uRotationCenter: number;
  101940. /**
  101941. * Defines the center of rotation (V)
  101942. */
  101943. vRotationCenter: number;
  101944. /**
  101945. * Defines the center of rotation (W)
  101946. */
  101947. wRotationCenter: number;
  101948. /**
  101949. * Are mip maps generated for this texture or not.
  101950. */
  101951. get noMipmap(): boolean;
  101952. /**
  101953. * List of inspectable custom properties (used by the Inspector)
  101954. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101955. */
  101956. inspectableCustomProperties: Nullable<IInspectable[]>;
  101957. private _noMipmap;
  101958. /** @hidden */
  101959. _invertY: boolean;
  101960. private _rowGenerationMatrix;
  101961. private _cachedTextureMatrix;
  101962. private _projectionModeMatrix;
  101963. private _t0;
  101964. private _t1;
  101965. private _t2;
  101966. private _cachedUOffset;
  101967. private _cachedVOffset;
  101968. private _cachedUScale;
  101969. private _cachedVScale;
  101970. private _cachedUAng;
  101971. private _cachedVAng;
  101972. private _cachedWAng;
  101973. private _cachedProjectionMatrixId;
  101974. private _cachedCoordinatesMode;
  101975. /** @hidden */
  101976. protected _initialSamplingMode: number;
  101977. /** @hidden */
  101978. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101979. private _deleteBuffer;
  101980. protected _format: Nullable<number>;
  101981. private _delayedOnLoad;
  101982. private _delayedOnError;
  101983. private _mimeType?;
  101984. /**
  101985. * Observable triggered once the texture has been loaded.
  101986. */
  101987. onLoadObservable: Observable<Texture>;
  101988. protected _isBlocking: boolean;
  101989. /**
  101990. * Is the texture preventing material to render while loading.
  101991. * If false, a default texture will be used instead of the loading one during the preparation step.
  101992. */
  101993. set isBlocking(value: boolean);
  101994. get isBlocking(): boolean;
  101995. /**
  101996. * Get the current sampling mode associated with the texture.
  101997. */
  101998. get samplingMode(): number;
  101999. /**
  102000. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102001. */
  102002. get invertY(): boolean;
  102003. /**
  102004. * Instantiates a new texture.
  102005. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102006. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102007. * @param url defines the url of the picture to load as a texture
  102008. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102009. * @param noMipmap defines if the texture will require mip maps or not
  102010. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102011. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102012. * @param onLoad defines a callback triggered when the texture has been loaded
  102013. * @param onError defines a callback triggered when an error occurred during the loading session
  102014. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102015. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102016. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102017. * @param mimeType defines an optional mime type information
  102018. */
  102019. 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);
  102020. /**
  102021. * Update the url (and optional buffer) of this texture if url was null during construction.
  102022. * @param url the url of the texture
  102023. * @param buffer the buffer of the texture (defaults to null)
  102024. * @param onLoad callback called when the texture is loaded (defaults to null)
  102025. */
  102026. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102027. /**
  102028. * Finish the loading sequence of a texture flagged as delayed load.
  102029. * @hidden
  102030. */
  102031. delayLoad(): void;
  102032. private _prepareRowForTextureGeneration;
  102033. /**
  102034. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102035. * @returns the transform matrix of the texture.
  102036. */
  102037. getTextureMatrix(uBase?: number): Matrix;
  102038. /**
  102039. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102040. * @returns The reflection texture transform
  102041. */
  102042. getReflectionTextureMatrix(): Matrix;
  102043. /**
  102044. * Clones the texture.
  102045. * @returns the cloned texture
  102046. */
  102047. clone(): Texture;
  102048. /**
  102049. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102050. * @returns The JSON representation of the texture
  102051. */
  102052. serialize(): any;
  102053. /**
  102054. * Get the current class name of the texture useful for serialization or dynamic coding.
  102055. * @returns "Texture"
  102056. */
  102057. getClassName(): string;
  102058. /**
  102059. * Dispose the texture and release its associated resources.
  102060. */
  102061. dispose(): void;
  102062. /**
  102063. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102064. * @param parsedTexture Define the JSON representation of the texture
  102065. * @param scene Define the scene the parsed texture should be instantiated in
  102066. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102067. * @returns The parsed texture if successful
  102068. */
  102069. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102070. /**
  102071. * Creates a texture from its base 64 representation.
  102072. * @param data Define the base64 payload without the data: prefix
  102073. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102074. * @param scene Define the scene the texture should belong to
  102075. * @param noMipmap Forces the texture to not create mip map information if true
  102076. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102077. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102078. * @param onLoad define a callback triggered when the texture has been loaded
  102079. * @param onError define a callback triggered when an error occurred during the loading session
  102080. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102081. * @returns the created texture
  102082. */
  102083. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102084. /**
  102085. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102086. * @param data Define the base64 payload without the data: prefix
  102087. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102088. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102089. * @param scene Define the scene the texture should belong to
  102090. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102091. * @param noMipmap Forces the texture to not create mip map information if true
  102092. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102093. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102094. * @param onLoad define a callback triggered when the texture has been loaded
  102095. * @param onError define a callback triggered when an error occurred during the loading session
  102096. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102097. * @returns the created texture
  102098. */
  102099. 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;
  102100. }
  102101. }
  102102. declare module BABYLON {
  102103. /**
  102104. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102105. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102106. */
  102107. export class PostProcessManager {
  102108. private _scene;
  102109. private _indexBuffer;
  102110. private _vertexBuffers;
  102111. /**
  102112. * Creates a new instance PostProcess
  102113. * @param scene The scene that the post process is associated with.
  102114. */
  102115. constructor(scene: Scene);
  102116. private _prepareBuffers;
  102117. private _buildIndexBuffer;
  102118. /**
  102119. * Rebuilds the vertex buffers of the manager.
  102120. * @hidden
  102121. */
  102122. _rebuild(): void;
  102123. /**
  102124. * Prepares a frame to be run through a post process.
  102125. * @param sourceTexture The input texture to the post procesess. (default: null)
  102126. * @param postProcesses An array of post processes to be run. (default: null)
  102127. * @returns True if the post processes were able to be run.
  102128. * @hidden
  102129. */
  102130. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102131. /**
  102132. * Manually render a set of post processes to a texture.
  102133. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102134. * @param postProcesses An array of post processes to be run.
  102135. * @param targetTexture The target texture to render to.
  102136. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102137. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102138. * @param lodLevel defines which lod of the texture to render to
  102139. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102140. */
  102141. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102142. /**
  102143. * Finalize the result of the output of the postprocesses.
  102144. * @param doNotPresent If true the result will not be displayed to the screen.
  102145. * @param targetTexture The target texture to render to.
  102146. * @param faceIndex The index of the face to bind the target texture to.
  102147. * @param postProcesses The array of post processes to render.
  102148. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102149. * @hidden
  102150. */
  102151. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102152. /**
  102153. * Disposes of the post process manager.
  102154. */
  102155. dispose(): void;
  102156. }
  102157. }
  102158. declare module BABYLON {
  102159. /**
  102160. * This Helps creating a texture that will be created from a camera in your scene.
  102161. * It is basically a dynamic texture that could be used to create special effects for instance.
  102162. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102163. */
  102164. export class RenderTargetTexture extends Texture {
  102165. isCube: boolean;
  102166. /**
  102167. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102168. */
  102169. static readonly REFRESHRATE_RENDER_ONCE: number;
  102170. /**
  102171. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102172. */
  102173. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102174. /**
  102175. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102176. * the central point of your effect and can save a lot of performances.
  102177. */
  102178. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102179. /**
  102180. * Use this predicate to dynamically define the list of mesh you want to render.
  102181. * If set, the renderList property will be overwritten.
  102182. */
  102183. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102184. private _renderList;
  102185. /**
  102186. * Use this list to define the list of mesh you want to render.
  102187. */
  102188. get renderList(): Nullable<Array<AbstractMesh>>;
  102189. set renderList(value: Nullable<Array<AbstractMesh>>);
  102190. /**
  102191. * Use this function to overload the renderList array at rendering time.
  102192. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102193. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102194. * the cube (if the RTT is a cube, else layerOrFace=0).
  102195. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102196. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102197. * hold dummy elements!
  102198. */
  102199. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102200. private _hookArray;
  102201. /**
  102202. * Define if particles should be rendered in your texture.
  102203. */
  102204. renderParticles: boolean;
  102205. /**
  102206. * Define if sprites should be rendered in your texture.
  102207. */
  102208. renderSprites: boolean;
  102209. /**
  102210. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102211. */
  102212. coordinatesMode: number;
  102213. /**
  102214. * Define the camera used to render the texture.
  102215. */
  102216. activeCamera: Nullable<Camera>;
  102217. /**
  102218. * Override the mesh isReady function with your own one.
  102219. */
  102220. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102221. /**
  102222. * Override the render function of the texture with your own one.
  102223. */
  102224. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102225. /**
  102226. * Define if camera post processes should be use while rendering the texture.
  102227. */
  102228. useCameraPostProcesses: boolean;
  102229. /**
  102230. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102231. */
  102232. ignoreCameraViewport: boolean;
  102233. private _postProcessManager;
  102234. private _postProcesses;
  102235. private _resizeObserver;
  102236. /**
  102237. * An event triggered when the texture is unbind.
  102238. */
  102239. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102240. /**
  102241. * An event triggered when the texture is unbind.
  102242. */
  102243. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102244. private _onAfterUnbindObserver;
  102245. /**
  102246. * Set a after unbind callback in the texture.
  102247. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102248. */
  102249. set onAfterUnbind(callback: () => void);
  102250. /**
  102251. * An event triggered before rendering the texture
  102252. */
  102253. onBeforeRenderObservable: Observable<number>;
  102254. private _onBeforeRenderObserver;
  102255. /**
  102256. * Set a before render callback in the texture.
  102257. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102258. */
  102259. set onBeforeRender(callback: (faceIndex: number) => void);
  102260. /**
  102261. * An event triggered after rendering the texture
  102262. */
  102263. onAfterRenderObservable: Observable<number>;
  102264. private _onAfterRenderObserver;
  102265. /**
  102266. * Set a after render callback in the texture.
  102267. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102268. */
  102269. set onAfterRender(callback: (faceIndex: number) => void);
  102270. /**
  102271. * An event triggered after the texture clear
  102272. */
  102273. onClearObservable: Observable<Engine>;
  102274. private _onClearObserver;
  102275. /**
  102276. * Set a clear callback in the texture.
  102277. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102278. */
  102279. set onClear(callback: (Engine: Engine) => void);
  102280. /**
  102281. * An event triggered when the texture is resized.
  102282. */
  102283. onResizeObservable: Observable<RenderTargetTexture>;
  102284. /**
  102285. * Define the clear color of the Render Target if it should be different from the scene.
  102286. */
  102287. clearColor: Color4;
  102288. protected _size: number | {
  102289. width: number;
  102290. height: number;
  102291. layers?: number;
  102292. };
  102293. protected _initialSizeParameter: number | {
  102294. width: number;
  102295. height: number;
  102296. } | {
  102297. ratio: number;
  102298. };
  102299. protected _sizeRatio: Nullable<number>;
  102300. /** @hidden */
  102301. _generateMipMaps: boolean;
  102302. protected _renderingManager: RenderingManager;
  102303. /** @hidden */
  102304. _waitingRenderList: string[];
  102305. protected _doNotChangeAspectRatio: boolean;
  102306. protected _currentRefreshId: number;
  102307. protected _refreshRate: number;
  102308. protected _textureMatrix: Matrix;
  102309. protected _samples: number;
  102310. protected _renderTargetOptions: RenderTargetCreationOptions;
  102311. /**
  102312. * Gets render target creation options that were used.
  102313. */
  102314. get renderTargetOptions(): RenderTargetCreationOptions;
  102315. protected _onRatioRescale(): void;
  102316. /**
  102317. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102318. * It must define where the camera used to render the texture is set
  102319. */
  102320. boundingBoxPosition: Vector3;
  102321. private _boundingBoxSize;
  102322. /**
  102323. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102324. * When defined, the cubemap will switch to local mode
  102325. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102326. * @example https://www.babylonjs-playground.com/#RNASML
  102327. */
  102328. set boundingBoxSize(value: Vector3);
  102329. get boundingBoxSize(): Vector3;
  102330. /**
  102331. * In case the RTT has been created with a depth texture, get the associated
  102332. * depth texture.
  102333. * Otherwise, return null.
  102334. */
  102335. get depthStencilTexture(): Nullable<InternalTexture>;
  102336. /**
  102337. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102338. * or used a shadow, depth texture...
  102339. * @param name The friendly name of the texture
  102340. * @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)
  102341. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102342. * @param generateMipMaps True if mip maps need to be generated after render.
  102343. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102344. * @param type The type of the buffer in the RTT (int, half float, float...)
  102345. * @param isCube True if a cube texture needs to be created
  102346. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102347. * @param generateDepthBuffer True to generate a depth buffer
  102348. * @param generateStencilBuffer True to generate a stencil buffer
  102349. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102350. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102351. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102352. */
  102353. constructor(name: string, size: number | {
  102354. width: number;
  102355. height: number;
  102356. layers?: number;
  102357. } | {
  102358. ratio: number;
  102359. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102360. /**
  102361. * Creates a depth stencil texture.
  102362. * This is only available in WebGL 2 or with the depth texture extension available.
  102363. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102364. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102365. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102366. */
  102367. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102368. private _processSizeParameter;
  102369. /**
  102370. * Define the number of samples to use in case of MSAA.
  102371. * It defaults to one meaning no MSAA has been enabled.
  102372. */
  102373. get samples(): number;
  102374. set samples(value: number);
  102375. /**
  102376. * Resets the refresh counter of the texture and start bak from scratch.
  102377. * Could be useful to regenerate the texture if it is setup to render only once.
  102378. */
  102379. resetRefreshCounter(): void;
  102380. /**
  102381. * Define the refresh rate of the texture or the rendering frequency.
  102382. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102383. */
  102384. get refreshRate(): number;
  102385. set refreshRate(value: number);
  102386. /**
  102387. * Adds a post process to the render target rendering passes.
  102388. * @param postProcess define the post process to add
  102389. */
  102390. addPostProcess(postProcess: PostProcess): void;
  102391. /**
  102392. * Clear all the post processes attached to the render target
  102393. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102394. */
  102395. clearPostProcesses(dispose?: boolean): void;
  102396. /**
  102397. * Remove one of the post process from the list of attached post processes to the texture
  102398. * @param postProcess define the post process to remove from the list
  102399. */
  102400. removePostProcess(postProcess: PostProcess): void;
  102401. /** @hidden */
  102402. _shouldRender(): boolean;
  102403. /**
  102404. * Gets the actual render size of the texture.
  102405. * @returns the width of the render size
  102406. */
  102407. getRenderSize(): number;
  102408. /**
  102409. * Gets the actual render width of the texture.
  102410. * @returns the width of the render size
  102411. */
  102412. getRenderWidth(): number;
  102413. /**
  102414. * Gets the actual render height of the texture.
  102415. * @returns the height of the render size
  102416. */
  102417. getRenderHeight(): number;
  102418. /**
  102419. * Gets the actual number of layers of the texture.
  102420. * @returns the number of layers
  102421. */
  102422. getRenderLayers(): number;
  102423. /**
  102424. * Get if the texture can be rescaled or not.
  102425. */
  102426. get canRescale(): boolean;
  102427. /**
  102428. * Resize the texture using a ratio.
  102429. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102430. */
  102431. scale(ratio: number): void;
  102432. /**
  102433. * Get the texture reflection matrix used to rotate/transform the reflection.
  102434. * @returns the reflection matrix
  102435. */
  102436. getReflectionTextureMatrix(): Matrix;
  102437. /**
  102438. * Resize the texture to a new desired size.
  102439. * Be carrefull as it will recreate all the data in the new texture.
  102440. * @param size Define the new size. It can be:
  102441. * - a number for squared texture,
  102442. * - an object containing { width: number, height: number }
  102443. * - or an object containing a ratio { ratio: number }
  102444. */
  102445. resize(size: number | {
  102446. width: number;
  102447. height: number;
  102448. } | {
  102449. ratio: number;
  102450. }): void;
  102451. private _defaultRenderListPrepared;
  102452. /**
  102453. * Renders all the objects from the render list into the texture.
  102454. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102455. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102456. */
  102457. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102458. private _bestReflectionRenderTargetDimension;
  102459. private _prepareRenderingManager;
  102460. /**
  102461. * @hidden
  102462. * @param faceIndex face index to bind to if this is a cubetexture
  102463. * @param layer defines the index of the texture to bind in the array
  102464. */
  102465. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102466. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102467. private renderToTarget;
  102468. /**
  102469. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102470. * This allowed control for front to back rendering or reversly depending of the special needs.
  102471. *
  102472. * @param renderingGroupId The rendering group id corresponding to its index
  102473. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102474. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102475. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102476. */
  102477. 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;
  102478. /**
  102479. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102480. *
  102481. * @param renderingGroupId The rendering group id corresponding to its index
  102482. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102483. */
  102484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102485. /**
  102486. * Clones the texture.
  102487. * @returns the cloned texture
  102488. */
  102489. clone(): RenderTargetTexture;
  102490. /**
  102491. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102492. * @returns The JSON representation of the texture
  102493. */
  102494. serialize(): any;
  102495. /**
  102496. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102497. */
  102498. disposeFramebufferObjects(): void;
  102499. /**
  102500. * Dispose the texture and release its associated resources.
  102501. */
  102502. dispose(): void;
  102503. /** @hidden */
  102504. _rebuild(): void;
  102505. /**
  102506. * Clear the info related to rendering groups preventing retention point in material dispose.
  102507. */
  102508. freeRenderingGroups(): void;
  102509. /**
  102510. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102511. * @returns the view count
  102512. */
  102513. getViewCount(): number;
  102514. }
  102515. }
  102516. declare module BABYLON {
  102517. /**
  102518. * Class used to manipulate GUIDs
  102519. */
  102520. export class GUID {
  102521. /**
  102522. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102523. * Be aware Math.random() could cause collisions, but:
  102524. * "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"
  102525. * @returns a pseudo random id
  102526. */
  102527. static RandomId(): string;
  102528. }
  102529. }
  102530. declare module BABYLON {
  102531. /**
  102532. * Options to be used when creating a shadow depth material
  102533. */
  102534. export interface IIOptionShadowDepthMaterial {
  102535. /** Variables in the vertex shader code that need to have their names remapped.
  102536. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102537. * "var_name" should be either: worldPos or vNormalW
  102538. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102539. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102540. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102541. */
  102542. remappedVariables?: string[];
  102543. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102544. standalone?: boolean;
  102545. }
  102546. /**
  102547. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102548. */
  102549. export class ShadowDepthWrapper {
  102550. private _scene;
  102551. private _options?;
  102552. private _baseMaterial;
  102553. private _onEffectCreatedObserver;
  102554. private _subMeshToEffect;
  102555. private _subMeshToDepthEffect;
  102556. private _meshes;
  102557. /** @hidden */
  102558. _matriceNames: any;
  102559. /** Gets the standalone status of the wrapper */
  102560. get standalone(): boolean;
  102561. /** Gets the base material the wrapper is built upon */
  102562. get baseMaterial(): Material;
  102563. /**
  102564. * Instantiate a new shadow depth wrapper.
  102565. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102566. * generate the shadow depth map. For more information, please refer to the documentation:
  102567. * https://doc.babylonjs.com/babylon101/shadows
  102568. * @param baseMaterial Material to wrap
  102569. * @param scene Define the scene the material belongs to
  102570. * @param options Options used to create the wrapper
  102571. */
  102572. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102573. /**
  102574. * Gets the effect to use to generate the depth map
  102575. * @param subMesh subMesh to get the effect for
  102576. * @param shadowGenerator shadow generator to get the effect for
  102577. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102578. */
  102579. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102580. /**
  102581. * Specifies that the submesh is ready to be used for depth rendering
  102582. * @param subMesh submesh to check
  102583. * @param defines the list of defines to take into account when checking the effect
  102584. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102585. * @param useInstances specifies that instances should be used
  102586. * @returns a boolean indicating that the submesh is ready or not
  102587. */
  102588. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102589. /**
  102590. * Disposes the resources
  102591. */
  102592. dispose(): void;
  102593. private _makeEffect;
  102594. }
  102595. }
  102596. declare module BABYLON {
  102597. interface ThinEngine {
  102598. /**
  102599. * Unbind a list of render target textures from the webGL context
  102600. * This is used only when drawBuffer extension or webGL2 are active
  102601. * @param textures defines the render target textures to unbind
  102602. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102603. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102604. */
  102605. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102606. /**
  102607. * Create a multi render target texture
  102608. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102609. * @param size defines the size of the texture
  102610. * @param options defines the creation options
  102611. * @returns the cube texture as an InternalTexture
  102612. */
  102613. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102614. /**
  102615. * Update the sample count for a given multiple render target texture
  102616. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102617. * @param textures defines the textures to update
  102618. * @param samples defines the sample count to set
  102619. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102620. */
  102621. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102622. /**
  102623. * Select a subsets of attachments to draw to.
  102624. * @param attachments gl attachments
  102625. */
  102626. bindAttachments(attachments: number[]): void;
  102627. }
  102628. }
  102629. declare module BABYLON {
  102630. /**
  102631. * Creation options of the multi render target texture.
  102632. */
  102633. export interface IMultiRenderTargetOptions {
  102634. /**
  102635. * Define if the texture needs to create mip maps after render.
  102636. */
  102637. generateMipMaps?: boolean;
  102638. /**
  102639. * Define the types of all the draw buffers we want to create
  102640. */
  102641. types?: number[];
  102642. /**
  102643. * Define the sampling modes of all the draw buffers we want to create
  102644. */
  102645. samplingModes?: number[];
  102646. /**
  102647. * Define if a depth buffer is required
  102648. */
  102649. generateDepthBuffer?: boolean;
  102650. /**
  102651. * Define if a stencil buffer is required
  102652. */
  102653. generateStencilBuffer?: boolean;
  102654. /**
  102655. * Define if a depth texture is required instead of a depth buffer
  102656. */
  102657. generateDepthTexture?: boolean;
  102658. /**
  102659. * Define the number of desired draw buffers
  102660. */
  102661. textureCount?: number;
  102662. /**
  102663. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102664. */
  102665. doNotChangeAspectRatio?: boolean;
  102666. /**
  102667. * Define the default type of the buffers we are creating
  102668. */
  102669. defaultType?: number;
  102670. }
  102671. /**
  102672. * A multi render target, like a render target provides the ability to render to a texture.
  102673. * Unlike the render target, it can render to several draw buffers in one draw.
  102674. * This is specially interesting in deferred rendering or for any effects requiring more than
  102675. * just one color from a single pass.
  102676. */
  102677. export class MultiRenderTarget extends RenderTargetTexture {
  102678. private _internalTextures;
  102679. private _textures;
  102680. private _multiRenderTargetOptions;
  102681. private _count;
  102682. /**
  102683. * Get if draw buffers are currently supported by the used hardware and browser.
  102684. */
  102685. get isSupported(): boolean;
  102686. /**
  102687. * Get the list of textures generated by the multi render target.
  102688. */
  102689. get textures(): Texture[];
  102690. /**
  102691. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102692. */
  102693. get count(): number;
  102694. /**
  102695. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102696. */
  102697. get depthTexture(): Texture;
  102698. /**
  102699. * Set the wrapping mode on U of all the textures we are rendering to.
  102700. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102701. */
  102702. set wrapU(wrap: number);
  102703. /**
  102704. * Set the wrapping mode on V of all the textures we are rendering to.
  102705. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102706. */
  102707. set wrapV(wrap: number);
  102708. /**
  102709. * Instantiate a new multi render target texture.
  102710. * A multi render target, like a render target provides the ability to render to a texture.
  102711. * Unlike the render target, it can render to several draw buffers in one draw.
  102712. * This is specially interesting in deferred rendering or for any effects requiring more than
  102713. * just one color from a single pass.
  102714. * @param name Define the name of the texture
  102715. * @param size Define the size of the buffers to render to
  102716. * @param count Define the number of target we are rendering into
  102717. * @param scene Define the scene the texture belongs to
  102718. * @param options Define the options used to create the multi render target
  102719. */
  102720. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102721. /** @hidden */
  102722. _rebuild(): void;
  102723. private _createInternalTextures;
  102724. private _createTextures;
  102725. /**
  102726. * Define the number of samples used if MSAA is enabled.
  102727. */
  102728. get samples(): number;
  102729. set samples(value: number);
  102730. /**
  102731. * Resize all the textures in the multi render target.
  102732. * Be carrefull as it will recreate all the data in the new texture.
  102733. * @param size Define the new size
  102734. */
  102735. resize(size: any): void;
  102736. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102737. /**
  102738. * Dispose the render targets and their associated resources
  102739. */
  102740. dispose(): void;
  102741. /**
  102742. * Release all the underlying texture used as draw buffers.
  102743. */
  102744. releaseInternalTextures(): void;
  102745. }
  102746. }
  102747. declare module BABYLON {
  102748. /** @hidden */
  102749. export var imageProcessingPixelShader: {
  102750. name: string;
  102751. shader: string;
  102752. };
  102753. }
  102754. declare module BABYLON {
  102755. /**
  102756. * ImageProcessingPostProcess
  102757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102758. */
  102759. export class ImageProcessingPostProcess extends PostProcess {
  102760. /**
  102761. * Default configuration related to image processing available in the PBR Material.
  102762. */
  102763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102764. /**
  102765. * Gets the image processing configuration used either in this material.
  102766. */
  102767. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102768. /**
  102769. * Sets the Default image processing configuration used either in the this material.
  102770. *
  102771. * If sets to null, the scene one is in use.
  102772. */
  102773. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102774. /**
  102775. * Keep track of the image processing observer to allow dispose and replace.
  102776. */
  102777. private _imageProcessingObserver;
  102778. /**
  102779. * Attaches a new image processing configuration to the PBR Material.
  102780. * @param configuration
  102781. */
  102782. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102783. /**
  102784. * If the post process is supported.
  102785. */
  102786. get isSupported(): boolean;
  102787. /**
  102788. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102789. */
  102790. get colorCurves(): Nullable<ColorCurves>;
  102791. /**
  102792. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102793. */
  102794. set colorCurves(value: Nullable<ColorCurves>);
  102795. /**
  102796. * Gets wether the color curves effect is enabled.
  102797. */
  102798. get colorCurvesEnabled(): boolean;
  102799. /**
  102800. * Sets wether the color curves effect is enabled.
  102801. */
  102802. set colorCurvesEnabled(value: boolean);
  102803. /**
  102804. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102805. */
  102806. get colorGradingTexture(): Nullable<BaseTexture>;
  102807. /**
  102808. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102809. */
  102810. set colorGradingTexture(value: Nullable<BaseTexture>);
  102811. /**
  102812. * Gets wether the color grading effect is enabled.
  102813. */
  102814. get colorGradingEnabled(): boolean;
  102815. /**
  102816. * Gets wether the color grading effect is enabled.
  102817. */
  102818. set colorGradingEnabled(value: boolean);
  102819. /**
  102820. * Gets exposure used in the effect.
  102821. */
  102822. get exposure(): number;
  102823. /**
  102824. * Sets exposure used in the effect.
  102825. */
  102826. set exposure(value: number);
  102827. /**
  102828. * Gets wether tonemapping is enabled or not.
  102829. */
  102830. get toneMappingEnabled(): boolean;
  102831. /**
  102832. * Sets wether tonemapping is enabled or not
  102833. */
  102834. set toneMappingEnabled(value: boolean);
  102835. /**
  102836. * Gets the type of tone mapping effect.
  102837. */
  102838. get toneMappingType(): number;
  102839. /**
  102840. * Sets the type of tone mapping effect.
  102841. */
  102842. set toneMappingType(value: number);
  102843. /**
  102844. * Gets contrast used in the effect.
  102845. */
  102846. get contrast(): number;
  102847. /**
  102848. * Sets contrast used in the effect.
  102849. */
  102850. set contrast(value: number);
  102851. /**
  102852. * Gets Vignette stretch size.
  102853. */
  102854. get vignetteStretch(): number;
  102855. /**
  102856. * Sets Vignette stretch size.
  102857. */
  102858. set vignetteStretch(value: number);
  102859. /**
  102860. * Gets Vignette centre X Offset.
  102861. */
  102862. get vignetteCentreX(): number;
  102863. /**
  102864. * Sets Vignette centre X Offset.
  102865. */
  102866. set vignetteCentreX(value: number);
  102867. /**
  102868. * Gets Vignette centre Y Offset.
  102869. */
  102870. get vignetteCentreY(): number;
  102871. /**
  102872. * Sets Vignette centre Y Offset.
  102873. */
  102874. set vignetteCentreY(value: number);
  102875. /**
  102876. * Gets Vignette weight or intensity of the vignette effect.
  102877. */
  102878. get vignetteWeight(): number;
  102879. /**
  102880. * Sets Vignette weight or intensity of the vignette effect.
  102881. */
  102882. set vignetteWeight(value: number);
  102883. /**
  102884. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102885. * if vignetteEnabled is set to true.
  102886. */
  102887. get vignetteColor(): Color4;
  102888. /**
  102889. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102890. * if vignetteEnabled is set to true.
  102891. */
  102892. set vignetteColor(value: Color4);
  102893. /**
  102894. * Gets Camera field of view used by the Vignette effect.
  102895. */
  102896. get vignetteCameraFov(): number;
  102897. /**
  102898. * Sets Camera field of view used by the Vignette effect.
  102899. */
  102900. set vignetteCameraFov(value: number);
  102901. /**
  102902. * Gets the vignette blend mode allowing different kind of effect.
  102903. */
  102904. get vignetteBlendMode(): number;
  102905. /**
  102906. * Sets the vignette blend mode allowing different kind of effect.
  102907. */
  102908. set vignetteBlendMode(value: number);
  102909. /**
  102910. * Gets wether the vignette effect is enabled.
  102911. */
  102912. get vignetteEnabled(): boolean;
  102913. /**
  102914. * Sets wether the vignette effect is enabled.
  102915. */
  102916. set vignetteEnabled(value: boolean);
  102917. private _fromLinearSpace;
  102918. /**
  102919. * Gets wether the input of the processing is in Gamma or Linear Space.
  102920. */
  102921. get fromLinearSpace(): boolean;
  102922. /**
  102923. * Sets wether the input of the processing is in Gamma or Linear Space.
  102924. */
  102925. set fromLinearSpace(value: boolean);
  102926. /**
  102927. * Defines cache preventing GC.
  102928. */
  102929. private _defines;
  102930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102931. /**
  102932. * "ImageProcessingPostProcess"
  102933. * @returns "ImageProcessingPostProcess"
  102934. */
  102935. getClassName(): string;
  102936. /**
  102937. * @hidden
  102938. */
  102939. _updateParameters(): void;
  102940. dispose(camera?: Camera): void;
  102941. }
  102942. }
  102943. declare module BABYLON {
  102944. /** @hidden */
  102945. export var fibonacci: {
  102946. name: string;
  102947. shader: string;
  102948. };
  102949. }
  102950. declare module BABYLON {
  102951. /** @hidden */
  102952. export var subSurfaceScatteringFunctions: {
  102953. name: string;
  102954. shader: string;
  102955. };
  102956. }
  102957. declare module BABYLON {
  102958. /** @hidden */
  102959. export var diffusionProfile: {
  102960. name: string;
  102961. shader: string;
  102962. };
  102963. }
  102964. declare module BABYLON {
  102965. /** @hidden */
  102966. export var subSurfaceScatteringPixelShader: {
  102967. name: string;
  102968. shader: string;
  102969. };
  102970. }
  102971. declare module BABYLON {
  102972. /**
  102973. * Sub surface scattering post process
  102974. */
  102975. export class SubSurfaceScatteringPostProcess extends PostProcess {
  102976. /** @hidden */
  102977. texelWidth: number;
  102978. /** @hidden */
  102979. texelHeight: number;
  102980. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  102981. }
  102982. }
  102983. declare module BABYLON {
  102984. /**
  102985. * Interface for defining prepass effects in the prepass post-process pipeline
  102986. */
  102987. export interface PrePassEffectConfiguration {
  102988. /**
  102989. * Post process to attach for this effect
  102990. */
  102991. postProcess: PostProcess;
  102992. /**
  102993. * Is the effect enabled
  102994. */
  102995. enabled: boolean;
  102996. /**
  102997. * Disposes the effect configuration
  102998. */
  102999. dispose(): void;
  103000. /**
  103001. * Disposes the effect configuration
  103002. */
  103003. createPostProcess: () => PostProcess;
  103004. }
  103005. }
  103006. declare module BABYLON {
  103007. /**
  103008. * Contains all parameters needed for the prepass to perform
  103009. * screen space subsurface scattering
  103010. */
  103011. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103012. private _ssDiffusionS;
  103013. private _ssFilterRadii;
  103014. private _ssDiffusionD;
  103015. /**
  103016. * Post process to attach for screen space subsurface scattering
  103017. */
  103018. postProcess: SubSurfaceScatteringPostProcess;
  103019. /**
  103020. * Diffusion profile color for subsurface scattering
  103021. */
  103022. get ssDiffusionS(): number[];
  103023. /**
  103024. * Diffusion profile max color channel value for subsurface scattering
  103025. */
  103026. get ssDiffusionD(): number[];
  103027. /**
  103028. * Diffusion profile filter radius for subsurface scattering
  103029. */
  103030. get ssFilterRadii(): number[];
  103031. /**
  103032. * Is subsurface enabled
  103033. */
  103034. enabled: boolean;
  103035. /**
  103036. * Diffusion profile colors for subsurface scattering
  103037. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103038. * See ...
  103039. * Note that you can only store up to 5 of them
  103040. */
  103041. ssDiffusionProfileColors: Color3[];
  103042. /**
  103043. * Defines the ratio real world => scene units.
  103044. * Used for subsurface scattering
  103045. */
  103046. metersPerUnit: number;
  103047. private _scene;
  103048. /**
  103049. * Builds a subsurface configuration object
  103050. * @param scene The scene
  103051. */
  103052. constructor(scene: Scene);
  103053. /**
  103054. * Adds a new diffusion profile.
  103055. * Useful for more realistic subsurface scattering on diverse materials.
  103056. * @param color The color of the diffusion profile. Should be the average color of the material.
  103057. * @return The index of the diffusion profile for the material subsurface configuration
  103058. */
  103059. addDiffusionProfile(color: Color3): number;
  103060. /**
  103061. * Creates the sss post process
  103062. * @return The created post process
  103063. */
  103064. createPostProcess(): SubSurfaceScatteringPostProcess;
  103065. /**
  103066. * Deletes all diffusion profiles.
  103067. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103068. */
  103069. clearAllDiffusionProfiles(): void;
  103070. /**
  103071. * Disposes this object
  103072. */
  103073. dispose(): void;
  103074. /**
  103075. * @hidden
  103076. * https://zero-radiance.github.io/post/sampling-diffusion/
  103077. *
  103078. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103079. * ------------------------------------------------------------------------------------
  103080. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103081. * PDF[r, phi, s] = r * R[r, phi, s]
  103082. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103083. * ------------------------------------------------------------------------------------
  103084. * We importance sample the color channel with the widest scattering distance.
  103085. */
  103086. getDiffusionProfileParameters(color: Color3): number;
  103087. /**
  103088. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103089. * 'u' is the random number (the value of the CDF): [0, 1).
  103090. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103091. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103092. */
  103093. private _sampleBurleyDiffusionProfile;
  103094. }
  103095. }
  103096. declare module BABYLON {
  103097. /**
  103098. * Renders a pre pass of the scene
  103099. * This means every mesh in the scene will be rendered to a render target texture
  103100. * And then this texture will be composited to the rendering canvas with post processes
  103101. * It is necessary for effects like subsurface scattering or deferred shading
  103102. */
  103103. export class PrePassRenderer {
  103104. /** @hidden */
  103105. static _SceneComponentInitialization: (scene: Scene) => void;
  103106. private _scene;
  103107. private _engine;
  103108. private _isDirty;
  103109. /**
  103110. * Number of textures in the multi render target texture where the scene is directly rendered
  103111. */
  103112. readonly mrtCount: number;
  103113. /**
  103114. * The render target where the scene is directly rendered
  103115. */
  103116. prePassRT: MultiRenderTarget;
  103117. private _mrtTypes;
  103118. private _multiRenderAttachments;
  103119. private _defaultAttachments;
  103120. private _clearAttachments;
  103121. private _postProcesses;
  103122. private readonly _clearColor;
  103123. /**
  103124. * Image processing post process for composition
  103125. */
  103126. imageProcessingPostProcess: ImageProcessingPostProcess;
  103127. /**
  103128. * Configuration for sub surface scattering post process
  103129. */
  103130. subSurfaceConfiguration: SubSurfaceConfiguration;
  103131. /**
  103132. * Should materials render their geometry on the MRT
  103133. */
  103134. materialsShouldRenderGeometry: boolean;
  103135. /**
  103136. * Should materials render the irradiance information on the MRT
  103137. */
  103138. materialsShouldRenderIrradiance: boolean;
  103139. private _enabled;
  103140. /**
  103141. * Indicates if the prepass is enabled
  103142. */
  103143. get enabled(): boolean;
  103144. /**
  103145. * How many samples are used for MSAA of the scene render target
  103146. */
  103147. get samples(): number;
  103148. set samples(n: number);
  103149. /**
  103150. * Instanciates a prepass renderer
  103151. * @param scene The scene
  103152. */
  103153. constructor(scene: Scene);
  103154. private _initializeAttachments;
  103155. private _createCompositionEffect;
  103156. /**
  103157. * Indicates if rendering a prepass is supported
  103158. */
  103159. get isSupported(): boolean;
  103160. /**
  103161. * Sets the proper output textures to draw in the engine.
  103162. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103163. */
  103164. bindAttachmentsForEffect(effect: Effect): void;
  103165. /**
  103166. * @hidden
  103167. */
  103168. _beforeCameraDraw(): void;
  103169. /**
  103170. * @hidden
  103171. */
  103172. _afterCameraDraw(): void;
  103173. private _checkRTSize;
  103174. private _bindFrameBuffer;
  103175. /**
  103176. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103177. */
  103178. clear(): void;
  103179. private _setState;
  103180. private _enable;
  103181. private _disable;
  103182. private _resetPostProcessChain;
  103183. private _bindPostProcessChain;
  103184. /**
  103185. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103186. */
  103187. markAsDirty(): void;
  103188. private _update;
  103189. /**
  103190. * Disposes the prepass renderer.
  103191. */
  103192. dispose(): void;
  103193. }
  103194. }
  103195. declare module BABYLON {
  103196. /**
  103197. * Options for compiling materials.
  103198. */
  103199. export interface IMaterialCompilationOptions {
  103200. /**
  103201. * Defines whether clip planes are enabled.
  103202. */
  103203. clipPlane: boolean;
  103204. /**
  103205. * Defines whether instances are enabled.
  103206. */
  103207. useInstances: boolean;
  103208. }
  103209. /**
  103210. * Options passed when calling customShaderNameResolve
  103211. */
  103212. export interface ICustomShaderNameResolveOptions {
  103213. /**
  103214. * 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
  103215. */
  103216. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103217. }
  103218. /**
  103219. * Base class for the main features of a material in Babylon.js
  103220. */
  103221. export class Material implements IAnimatable {
  103222. /**
  103223. * Returns the triangle fill mode
  103224. */
  103225. static readonly TriangleFillMode: number;
  103226. /**
  103227. * Returns the wireframe mode
  103228. */
  103229. static readonly WireFrameFillMode: number;
  103230. /**
  103231. * Returns the point fill mode
  103232. */
  103233. static readonly PointFillMode: number;
  103234. /**
  103235. * Returns the point list draw mode
  103236. */
  103237. static readonly PointListDrawMode: number;
  103238. /**
  103239. * Returns the line list draw mode
  103240. */
  103241. static readonly LineListDrawMode: number;
  103242. /**
  103243. * Returns the line loop draw mode
  103244. */
  103245. static readonly LineLoopDrawMode: number;
  103246. /**
  103247. * Returns the line strip draw mode
  103248. */
  103249. static readonly LineStripDrawMode: number;
  103250. /**
  103251. * Returns the triangle strip draw mode
  103252. */
  103253. static readonly TriangleStripDrawMode: number;
  103254. /**
  103255. * Returns the triangle fan draw mode
  103256. */
  103257. static readonly TriangleFanDrawMode: number;
  103258. /**
  103259. * Stores the clock-wise side orientation
  103260. */
  103261. static readonly ClockWiseSideOrientation: number;
  103262. /**
  103263. * Stores the counter clock-wise side orientation
  103264. */
  103265. static readonly CounterClockWiseSideOrientation: number;
  103266. /**
  103267. * The dirty texture flag value
  103268. */
  103269. static readonly TextureDirtyFlag: number;
  103270. /**
  103271. * The dirty light flag value
  103272. */
  103273. static readonly LightDirtyFlag: number;
  103274. /**
  103275. * The dirty fresnel flag value
  103276. */
  103277. static readonly FresnelDirtyFlag: number;
  103278. /**
  103279. * The dirty attribute flag value
  103280. */
  103281. static readonly AttributesDirtyFlag: number;
  103282. /**
  103283. * The dirty misc flag value
  103284. */
  103285. static readonly MiscDirtyFlag: number;
  103286. /**
  103287. * The all dirty flag value
  103288. */
  103289. static readonly AllDirtyFlag: number;
  103290. /**
  103291. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103292. */
  103293. static readonly MATERIAL_OPAQUE: number;
  103294. /**
  103295. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103296. */
  103297. static readonly MATERIAL_ALPHATEST: number;
  103298. /**
  103299. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103300. */
  103301. static readonly MATERIAL_ALPHABLEND: number;
  103302. /**
  103303. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103304. * They are also discarded below the alpha cutoff threshold to improve performances.
  103305. */
  103306. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103307. /**
  103308. * The Whiteout method is used to blend normals.
  103309. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103310. */
  103311. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103312. /**
  103313. * The Reoriented Normal Mapping method is used to blend normals.
  103314. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103315. */
  103316. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103317. /**
  103318. * Custom callback helping to override the default shader used in the material.
  103319. */
  103320. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103321. /**
  103322. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103323. */
  103324. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103325. /**
  103326. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103327. * This means that the material can keep using a previous shader while a new one is being compiled.
  103328. * This is mostly used when shader parallel compilation is supported (true by default)
  103329. */
  103330. allowShaderHotSwapping: boolean;
  103331. /**
  103332. * The ID of the material
  103333. */
  103334. id: string;
  103335. /**
  103336. * Gets or sets the unique id of the material
  103337. */
  103338. uniqueId: number;
  103339. /**
  103340. * The name of the material
  103341. */
  103342. name: string;
  103343. /**
  103344. * Gets or sets user defined metadata
  103345. */
  103346. metadata: any;
  103347. /**
  103348. * For internal use only. Please do not use.
  103349. */
  103350. reservedDataStore: any;
  103351. /**
  103352. * Specifies if the ready state should be checked on each call
  103353. */
  103354. checkReadyOnEveryCall: boolean;
  103355. /**
  103356. * Specifies if the ready state should be checked once
  103357. */
  103358. checkReadyOnlyOnce: boolean;
  103359. /**
  103360. * The state of the material
  103361. */
  103362. state: string;
  103363. /**
  103364. * If the material can be rendered to several textures with MRT extension
  103365. */
  103366. get canRenderToMRT(): boolean;
  103367. /**
  103368. * The alpha value of the material
  103369. */
  103370. protected _alpha: number;
  103371. /**
  103372. * List of inspectable custom properties (used by the Inspector)
  103373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103374. */
  103375. inspectableCustomProperties: IInspectable[];
  103376. /**
  103377. * Sets the alpha value of the material
  103378. */
  103379. set alpha(value: number);
  103380. /**
  103381. * Gets the alpha value of the material
  103382. */
  103383. get alpha(): number;
  103384. /**
  103385. * Specifies if back face culling is enabled
  103386. */
  103387. protected _backFaceCulling: boolean;
  103388. /**
  103389. * Sets the back-face culling state
  103390. */
  103391. set backFaceCulling(value: boolean);
  103392. /**
  103393. * Gets the back-face culling state
  103394. */
  103395. get backFaceCulling(): boolean;
  103396. /**
  103397. * Stores the value for side orientation
  103398. */
  103399. sideOrientation: number;
  103400. /**
  103401. * Callback triggered when the material is compiled
  103402. */
  103403. onCompiled: Nullable<(effect: Effect) => void>;
  103404. /**
  103405. * Callback triggered when an error occurs
  103406. */
  103407. onError: Nullable<(effect: Effect, errors: string) => void>;
  103408. /**
  103409. * Callback triggered to get the render target textures
  103410. */
  103411. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103412. /**
  103413. * Gets a boolean indicating that current material needs to register RTT
  103414. */
  103415. get hasRenderTargetTextures(): boolean;
  103416. /**
  103417. * Specifies if the material should be serialized
  103418. */
  103419. doNotSerialize: boolean;
  103420. /**
  103421. * @hidden
  103422. */
  103423. _storeEffectOnSubMeshes: boolean;
  103424. /**
  103425. * Stores the animations for the material
  103426. */
  103427. animations: Nullable<Array<Animation>>;
  103428. /**
  103429. * An event triggered when the material is disposed
  103430. */
  103431. onDisposeObservable: Observable<Material>;
  103432. /**
  103433. * An observer which watches for dispose events
  103434. */
  103435. private _onDisposeObserver;
  103436. private _onUnBindObservable;
  103437. /**
  103438. * Called during a dispose event
  103439. */
  103440. set onDispose(callback: () => void);
  103441. private _onBindObservable;
  103442. /**
  103443. * An event triggered when the material is bound
  103444. */
  103445. get onBindObservable(): Observable<AbstractMesh>;
  103446. /**
  103447. * An observer which watches for bind events
  103448. */
  103449. private _onBindObserver;
  103450. /**
  103451. * Called during a bind event
  103452. */
  103453. set onBind(callback: (Mesh: AbstractMesh) => void);
  103454. /**
  103455. * An event triggered when the material is unbound
  103456. */
  103457. get onUnBindObservable(): Observable<Material>;
  103458. protected _onEffectCreatedObservable: Nullable<Observable<{
  103459. effect: Effect;
  103460. subMesh: Nullable<SubMesh>;
  103461. }>>;
  103462. /**
  103463. * An event triggered when the effect is (re)created
  103464. */
  103465. get onEffectCreatedObservable(): Observable<{
  103466. effect: Effect;
  103467. subMesh: Nullable<SubMesh>;
  103468. }>;
  103469. /**
  103470. * Stores the value of the alpha mode
  103471. */
  103472. private _alphaMode;
  103473. /**
  103474. * Sets the value of the alpha mode.
  103475. *
  103476. * | Value | Type | Description |
  103477. * | --- | --- | --- |
  103478. * | 0 | ALPHA_DISABLE | |
  103479. * | 1 | ALPHA_ADD | |
  103480. * | 2 | ALPHA_COMBINE | |
  103481. * | 3 | ALPHA_SUBTRACT | |
  103482. * | 4 | ALPHA_MULTIPLY | |
  103483. * | 5 | ALPHA_MAXIMIZED | |
  103484. * | 6 | ALPHA_ONEONE | |
  103485. * | 7 | ALPHA_PREMULTIPLIED | |
  103486. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103487. * | 9 | ALPHA_INTERPOLATE | |
  103488. * | 10 | ALPHA_SCREENMODE | |
  103489. *
  103490. */
  103491. set alphaMode(value: number);
  103492. /**
  103493. * Gets the value of the alpha mode
  103494. */
  103495. get alphaMode(): number;
  103496. /**
  103497. * Stores the state of the need depth pre-pass value
  103498. */
  103499. private _needDepthPrePass;
  103500. /**
  103501. * Sets the need depth pre-pass value
  103502. */
  103503. set needDepthPrePass(value: boolean);
  103504. /**
  103505. * Gets the depth pre-pass value
  103506. */
  103507. get needDepthPrePass(): boolean;
  103508. /**
  103509. * Specifies if depth writing should be disabled
  103510. */
  103511. disableDepthWrite: boolean;
  103512. /**
  103513. * Specifies if color writing should be disabled
  103514. */
  103515. disableColorWrite: boolean;
  103516. /**
  103517. * Specifies if depth writing should be forced
  103518. */
  103519. forceDepthWrite: boolean;
  103520. /**
  103521. * Specifies the depth function that should be used. 0 means the default engine function
  103522. */
  103523. depthFunction: number;
  103524. /**
  103525. * Specifies if there should be a separate pass for culling
  103526. */
  103527. separateCullingPass: boolean;
  103528. /**
  103529. * Stores the state specifing if fog should be enabled
  103530. */
  103531. private _fogEnabled;
  103532. /**
  103533. * Sets the state for enabling fog
  103534. */
  103535. set fogEnabled(value: boolean);
  103536. /**
  103537. * Gets the value of the fog enabled state
  103538. */
  103539. get fogEnabled(): boolean;
  103540. /**
  103541. * Stores the size of points
  103542. */
  103543. pointSize: number;
  103544. /**
  103545. * Stores the z offset value
  103546. */
  103547. zOffset: number;
  103548. get wireframe(): boolean;
  103549. /**
  103550. * Sets the state of wireframe mode
  103551. */
  103552. set wireframe(value: boolean);
  103553. /**
  103554. * Gets the value specifying if point clouds are enabled
  103555. */
  103556. get pointsCloud(): boolean;
  103557. /**
  103558. * Sets the state of point cloud mode
  103559. */
  103560. set pointsCloud(value: boolean);
  103561. /**
  103562. * Gets the material fill mode
  103563. */
  103564. get fillMode(): number;
  103565. /**
  103566. * Sets the material fill mode
  103567. */
  103568. set fillMode(value: number);
  103569. /**
  103570. * @hidden
  103571. * Stores the effects for the material
  103572. */
  103573. _effect: Nullable<Effect>;
  103574. /**
  103575. * Specifies if uniform buffers should be used
  103576. */
  103577. private _useUBO;
  103578. /**
  103579. * Stores a reference to the scene
  103580. */
  103581. private _scene;
  103582. /**
  103583. * Stores the fill mode state
  103584. */
  103585. private _fillMode;
  103586. /**
  103587. * Specifies if the depth write state should be cached
  103588. */
  103589. private _cachedDepthWriteState;
  103590. /**
  103591. * Specifies if the color write state should be cached
  103592. */
  103593. private _cachedColorWriteState;
  103594. /**
  103595. * Specifies if the depth function state should be cached
  103596. */
  103597. private _cachedDepthFunctionState;
  103598. /**
  103599. * Stores the uniform buffer
  103600. */
  103601. protected _uniformBuffer: UniformBuffer;
  103602. /** @hidden */
  103603. _indexInSceneMaterialArray: number;
  103604. /** @hidden */
  103605. meshMap: Nullable<{
  103606. [id: string]: AbstractMesh | undefined;
  103607. }>;
  103608. /**
  103609. * Creates a material instance
  103610. * @param name defines the name of the material
  103611. * @param scene defines the scene to reference
  103612. * @param doNotAdd specifies if the material should be added to the scene
  103613. */
  103614. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103615. /**
  103616. * Returns a string representation of the current material
  103617. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103618. * @returns a string with material information
  103619. */
  103620. toString(fullDetails?: boolean): string;
  103621. /**
  103622. * Gets the class name of the material
  103623. * @returns a string with the class name of the material
  103624. */
  103625. getClassName(): string;
  103626. /**
  103627. * Specifies if updates for the material been locked
  103628. */
  103629. get isFrozen(): boolean;
  103630. /**
  103631. * Locks updates for the material
  103632. */
  103633. freeze(): void;
  103634. /**
  103635. * Unlocks updates for the material
  103636. */
  103637. unfreeze(): void;
  103638. /**
  103639. * Specifies if the material is ready to be used
  103640. * @param mesh defines the mesh to check
  103641. * @param useInstances specifies if instances should be used
  103642. * @returns a boolean indicating if the material is ready to be used
  103643. */
  103644. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103645. /**
  103646. * Specifies that the submesh is ready to be used
  103647. * @param mesh defines the mesh to check
  103648. * @param subMesh defines which submesh to check
  103649. * @param useInstances specifies that instances should be used
  103650. * @returns a boolean indicating that the submesh is ready or not
  103651. */
  103652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103653. /**
  103654. * Returns the material effect
  103655. * @returns the effect associated with the material
  103656. */
  103657. getEffect(): Nullable<Effect>;
  103658. /**
  103659. * Returns the current scene
  103660. * @returns a Scene
  103661. */
  103662. getScene(): Scene;
  103663. /**
  103664. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103665. */
  103666. protected _forceAlphaTest: boolean;
  103667. /**
  103668. * The transparency mode of the material.
  103669. */
  103670. protected _transparencyMode: Nullable<number>;
  103671. /**
  103672. * Gets the current transparency mode.
  103673. */
  103674. get transparencyMode(): Nullable<number>;
  103675. /**
  103676. * Sets the transparency mode of the material.
  103677. *
  103678. * | Value | Type | Description |
  103679. * | ----- | ----------------------------------- | ----------- |
  103680. * | 0 | OPAQUE | |
  103681. * | 1 | ALPHATEST | |
  103682. * | 2 | ALPHABLEND | |
  103683. * | 3 | ALPHATESTANDBLEND | |
  103684. *
  103685. */
  103686. set transparencyMode(value: Nullable<number>);
  103687. /**
  103688. * Returns true if alpha blending should be disabled.
  103689. */
  103690. protected get _disableAlphaBlending(): boolean;
  103691. /**
  103692. * Specifies whether or not this material should be rendered in alpha blend mode.
  103693. * @returns a boolean specifying if alpha blending is needed
  103694. */
  103695. needAlphaBlending(): boolean;
  103696. /**
  103697. * Specifies if the mesh will require alpha blending
  103698. * @param mesh defines the mesh to check
  103699. * @returns a boolean specifying if alpha blending is needed for the mesh
  103700. */
  103701. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103702. /**
  103703. * Specifies whether or not this material should be rendered in alpha test mode.
  103704. * @returns a boolean specifying if an alpha test is needed.
  103705. */
  103706. needAlphaTesting(): boolean;
  103707. /**
  103708. * Specifies if material alpha testing should be turned on for the mesh
  103709. * @param mesh defines the mesh to check
  103710. */
  103711. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103712. /**
  103713. * Gets the texture used for the alpha test
  103714. * @returns the texture to use for alpha testing
  103715. */
  103716. getAlphaTestTexture(): Nullable<BaseTexture>;
  103717. /**
  103718. * Marks the material to indicate that it needs to be re-calculated
  103719. */
  103720. markDirty(): void;
  103721. /** @hidden */
  103722. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103723. /**
  103724. * Binds the material to the mesh
  103725. * @param world defines the world transformation matrix
  103726. * @param mesh defines the mesh to bind the material to
  103727. */
  103728. bind(world: Matrix, mesh?: Mesh): void;
  103729. /**
  103730. * Binds the submesh to the material
  103731. * @param world defines the world transformation matrix
  103732. * @param mesh defines the mesh containing the submesh
  103733. * @param subMesh defines the submesh to bind the material to
  103734. */
  103735. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103736. /**
  103737. * Binds the world matrix to the material
  103738. * @param world defines the world transformation matrix
  103739. */
  103740. bindOnlyWorldMatrix(world: Matrix): void;
  103741. /**
  103742. * Binds the scene's uniform buffer to the effect.
  103743. * @param effect defines the effect to bind to the scene uniform buffer
  103744. * @param sceneUbo defines the uniform buffer storing scene data
  103745. */
  103746. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103747. /**
  103748. * Binds the view matrix to the effect
  103749. * @param effect defines the effect to bind the view matrix to
  103750. */
  103751. bindView(effect: Effect): void;
  103752. /**
  103753. * Binds the view projection matrix to the effect
  103754. * @param effect defines the effect to bind the view projection matrix to
  103755. */
  103756. bindViewProjection(effect: Effect): void;
  103757. /**
  103758. * Processes to execute after binding the material to a mesh
  103759. * @param mesh defines the rendered mesh
  103760. */
  103761. protected _afterBind(mesh?: Mesh): void;
  103762. /**
  103763. * Unbinds the material from the mesh
  103764. */
  103765. unbind(): void;
  103766. /**
  103767. * Gets the active textures from the material
  103768. * @returns an array of textures
  103769. */
  103770. getActiveTextures(): BaseTexture[];
  103771. /**
  103772. * Specifies if the material uses a texture
  103773. * @param texture defines the texture to check against the material
  103774. * @returns a boolean specifying if the material uses the texture
  103775. */
  103776. hasTexture(texture: BaseTexture): boolean;
  103777. /**
  103778. * Makes a duplicate of the material, and gives it a new name
  103779. * @param name defines the new name for the duplicated material
  103780. * @returns the cloned material
  103781. */
  103782. clone(name: string): Nullable<Material>;
  103783. /**
  103784. * Gets the meshes bound to the material
  103785. * @returns an array of meshes bound to the material
  103786. */
  103787. getBindedMeshes(): AbstractMesh[];
  103788. /**
  103789. * Force shader compilation
  103790. * @param mesh defines the mesh associated with this material
  103791. * @param onCompiled defines a function to execute once the material is compiled
  103792. * @param options defines the options to configure the compilation
  103793. * @param onError defines a function to execute if the material fails compiling
  103794. */
  103795. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103796. /**
  103797. * Force shader compilation
  103798. * @param mesh defines the mesh that will use this material
  103799. * @param options defines additional options for compiling the shaders
  103800. * @returns a promise that resolves when the compilation completes
  103801. */
  103802. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  103803. private static readonly _AllDirtyCallBack;
  103804. private static readonly _ImageProcessingDirtyCallBack;
  103805. private static readonly _TextureDirtyCallBack;
  103806. private static readonly _FresnelDirtyCallBack;
  103807. private static readonly _MiscDirtyCallBack;
  103808. private static readonly _LightsDirtyCallBack;
  103809. private static readonly _AttributeDirtyCallBack;
  103810. private static _FresnelAndMiscDirtyCallBack;
  103811. private static _TextureAndMiscDirtyCallBack;
  103812. private static readonly _DirtyCallbackArray;
  103813. private static readonly _RunDirtyCallBacks;
  103814. /**
  103815. * Marks a define in the material to indicate that it needs to be re-computed
  103816. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  103817. */
  103818. markAsDirty(flag: number): void;
  103819. /**
  103820. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  103821. * @param func defines a function which checks material defines against the submeshes
  103822. */
  103823. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  103824. /**
  103825. * Indicates that the scene should check if the rendering now needs a prepass
  103826. */
  103827. protected _markScenePrePassDirty(): void;
  103828. /**
  103829. * Indicates that we need to re-calculated for all submeshes
  103830. */
  103831. protected _markAllSubMeshesAsAllDirty(): void;
  103832. /**
  103833. * Indicates that image processing needs to be re-calculated for all submeshes
  103834. */
  103835. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  103836. /**
  103837. * Indicates that textures need to be re-calculated for all submeshes
  103838. */
  103839. protected _markAllSubMeshesAsTexturesDirty(): void;
  103840. /**
  103841. * Indicates that fresnel needs to be re-calculated for all submeshes
  103842. */
  103843. protected _markAllSubMeshesAsFresnelDirty(): void;
  103844. /**
  103845. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  103846. */
  103847. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  103848. /**
  103849. * Indicates that lights need to be re-calculated for all submeshes
  103850. */
  103851. protected _markAllSubMeshesAsLightsDirty(): void;
  103852. /**
  103853. * Indicates that attributes need to be re-calculated for all submeshes
  103854. */
  103855. protected _markAllSubMeshesAsAttributesDirty(): void;
  103856. /**
  103857. * Indicates that misc needs to be re-calculated for all submeshes
  103858. */
  103859. protected _markAllSubMeshesAsMiscDirty(): void;
  103860. /**
  103861. * Indicates that textures and misc need to be re-calculated for all submeshes
  103862. */
  103863. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  103864. /**
  103865. * Sets the required values to the prepass renderer.
  103866. * @param prePassRenderer defines the prepass renderer to setup.
  103867. * @returns true if the pre pass is needed.
  103868. */
  103869. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103870. /**
  103871. * Disposes the material
  103872. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103873. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103874. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103875. */
  103876. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103877. /** @hidden */
  103878. private releaseVertexArrayObject;
  103879. /**
  103880. * Serializes this material
  103881. * @returns the serialized material object
  103882. */
  103883. serialize(): any;
  103884. /**
  103885. * Creates a material from parsed material data
  103886. * @param parsedMaterial defines parsed material data
  103887. * @param scene defines the hosting scene
  103888. * @param rootUrl defines the root URL to use to load textures
  103889. * @returns a new material
  103890. */
  103891. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  103892. }
  103893. }
  103894. declare module BABYLON {
  103895. /**
  103896. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103897. * separate meshes. This can be use to improve performances.
  103898. * @see https://doc.babylonjs.com/how_to/multi_materials
  103899. */
  103900. export class MultiMaterial extends Material {
  103901. private _subMaterials;
  103902. /**
  103903. * Gets or Sets the list of Materials used within the multi material.
  103904. * They need to be ordered according to the submeshes order in the associated mesh
  103905. */
  103906. get subMaterials(): Nullable<Material>[];
  103907. set subMaterials(value: Nullable<Material>[]);
  103908. /**
  103909. * Function used to align with Node.getChildren()
  103910. * @returns the list of Materials used within the multi material
  103911. */
  103912. getChildren(): Nullable<Material>[];
  103913. /**
  103914. * Instantiates a new Multi Material
  103915. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103916. * separate meshes. This can be use to improve performances.
  103917. * @see https://doc.babylonjs.com/how_to/multi_materials
  103918. * @param name Define the name in the scene
  103919. * @param scene Define the scene the material belongs to
  103920. */
  103921. constructor(name: string, scene: Scene);
  103922. private _hookArray;
  103923. /**
  103924. * Get one of the submaterial by its index in the submaterials array
  103925. * @param index The index to look the sub material at
  103926. * @returns The Material if the index has been defined
  103927. */
  103928. getSubMaterial(index: number): Nullable<Material>;
  103929. /**
  103930. * Get the list of active textures for the whole sub materials list.
  103931. * @returns All the textures that will be used during the rendering
  103932. */
  103933. getActiveTextures(): BaseTexture[];
  103934. /**
  103935. * Gets the current class name of the material e.g. "MultiMaterial"
  103936. * Mainly use in serialization.
  103937. * @returns the class name
  103938. */
  103939. getClassName(): string;
  103940. /**
  103941. * Checks if the material is ready to render the requested sub mesh
  103942. * @param mesh Define the mesh the submesh belongs to
  103943. * @param subMesh Define the sub mesh to look readyness for
  103944. * @param useInstances Define whether or not the material is used with instances
  103945. * @returns true if ready, otherwise false
  103946. */
  103947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103948. /**
  103949. * Clones the current material and its related sub materials
  103950. * @param name Define the name of the newly cloned material
  103951. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  103952. * @returns the cloned material
  103953. */
  103954. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  103955. /**
  103956. * Serializes the materials into a JSON representation.
  103957. * @returns the JSON representation
  103958. */
  103959. serialize(): any;
  103960. /**
  103961. * Dispose the material and release its associated resources
  103962. * @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)
  103963. * @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)
  103964. * @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)
  103965. */
  103966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  103967. /**
  103968. * Creates a MultiMaterial from parsed MultiMaterial data.
  103969. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  103970. * @param scene defines the hosting scene
  103971. * @returns a new MultiMaterial
  103972. */
  103973. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  103974. }
  103975. }
  103976. declare module BABYLON {
  103977. /**
  103978. * Defines a subdivision inside a mesh
  103979. */
  103980. export class SubMesh implements ICullable {
  103981. /** the material index to use */
  103982. materialIndex: number;
  103983. /** vertex index start */
  103984. verticesStart: number;
  103985. /** vertices count */
  103986. verticesCount: number;
  103987. /** index start */
  103988. indexStart: number;
  103989. /** indices count */
  103990. indexCount: number;
  103991. /** @hidden */
  103992. _materialDefines: Nullable<MaterialDefines>;
  103993. /** @hidden */
  103994. _materialEffect: Nullable<Effect>;
  103995. /** @hidden */
  103996. _effectOverride: Nullable<Effect>;
  103997. /**
  103998. * Gets material defines used by the effect associated to the sub mesh
  103999. */
  104000. get materialDefines(): Nullable<MaterialDefines>;
  104001. /**
  104002. * Sets material defines used by the effect associated to the sub mesh
  104003. */
  104004. set materialDefines(defines: Nullable<MaterialDefines>);
  104005. /**
  104006. * Gets associated effect
  104007. */
  104008. get effect(): Nullable<Effect>;
  104009. /**
  104010. * Sets associated effect (effect used to render this submesh)
  104011. * @param effect defines the effect to associate with
  104012. * @param defines defines the set of defines used to compile this effect
  104013. */
  104014. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104015. /** @hidden */
  104016. _linesIndexCount: number;
  104017. private _mesh;
  104018. private _renderingMesh;
  104019. private _boundingInfo;
  104020. private _linesIndexBuffer;
  104021. /** @hidden */
  104022. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104023. /** @hidden */
  104024. _trianglePlanes: Plane[];
  104025. /** @hidden */
  104026. _lastColliderTransformMatrix: Nullable<Matrix>;
  104027. /** @hidden */
  104028. _renderId: number;
  104029. /** @hidden */
  104030. _alphaIndex: number;
  104031. /** @hidden */
  104032. _distanceToCamera: number;
  104033. /** @hidden */
  104034. _id: number;
  104035. private _currentMaterial;
  104036. /**
  104037. * Add a new submesh to a mesh
  104038. * @param materialIndex defines the material index to use
  104039. * @param verticesStart defines vertex index start
  104040. * @param verticesCount defines vertices count
  104041. * @param indexStart defines index start
  104042. * @param indexCount defines indices count
  104043. * @param mesh defines the parent mesh
  104044. * @param renderingMesh defines an optional rendering mesh
  104045. * @param createBoundingBox defines if bounding box should be created for this submesh
  104046. * @returns the new submesh
  104047. */
  104048. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104049. /**
  104050. * Creates a new submesh
  104051. * @param materialIndex defines the material index to use
  104052. * @param verticesStart defines vertex index start
  104053. * @param verticesCount defines vertices count
  104054. * @param indexStart defines index start
  104055. * @param indexCount defines indices count
  104056. * @param mesh defines the parent mesh
  104057. * @param renderingMesh defines an optional rendering mesh
  104058. * @param createBoundingBox defines if bounding box should be created for this submesh
  104059. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104060. */
  104061. constructor(
  104062. /** the material index to use */
  104063. materialIndex: number,
  104064. /** vertex index start */
  104065. verticesStart: number,
  104066. /** vertices count */
  104067. verticesCount: number,
  104068. /** index start */
  104069. indexStart: number,
  104070. /** indices count */
  104071. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104072. /**
  104073. * Returns true if this submesh covers the entire parent mesh
  104074. * @ignorenaming
  104075. */
  104076. get IsGlobal(): boolean;
  104077. /**
  104078. * Returns the submesh BoudingInfo object
  104079. * @returns current bounding info (or mesh's one if the submesh is global)
  104080. */
  104081. getBoundingInfo(): BoundingInfo;
  104082. /**
  104083. * Sets the submesh BoundingInfo
  104084. * @param boundingInfo defines the new bounding info to use
  104085. * @returns the SubMesh
  104086. */
  104087. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104088. /**
  104089. * Returns the mesh of the current submesh
  104090. * @return the parent mesh
  104091. */
  104092. getMesh(): AbstractMesh;
  104093. /**
  104094. * Returns the rendering mesh of the submesh
  104095. * @returns the rendering mesh (could be different from parent mesh)
  104096. */
  104097. getRenderingMesh(): Mesh;
  104098. /**
  104099. * Returns the replacement mesh of the submesh
  104100. * @returns the replacement mesh (could be different from parent mesh)
  104101. */
  104102. getReplacementMesh(): Nullable<AbstractMesh>;
  104103. /**
  104104. * Returns the effective mesh of the submesh
  104105. * @returns the effective mesh (could be different from parent mesh)
  104106. */
  104107. getEffectiveMesh(): AbstractMesh;
  104108. /**
  104109. * Returns the submesh material
  104110. * @returns null or the current material
  104111. */
  104112. getMaterial(): Nullable<Material>;
  104113. private _IsMultiMaterial;
  104114. /**
  104115. * Sets a new updated BoundingInfo object to the submesh
  104116. * @param data defines an optional position array to use to determine the bounding info
  104117. * @returns the SubMesh
  104118. */
  104119. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104120. /** @hidden */
  104121. _checkCollision(collider: Collider): boolean;
  104122. /**
  104123. * Updates the submesh BoundingInfo
  104124. * @param world defines the world matrix to use to update the bounding info
  104125. * @returns the submesh
  104126. */
  104127. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104128. /**
  104129. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104130. * @param frustumPlanes defines the frustum planes
  104131. * @returns true if the submesh is intersecting with the frustum
  104132. */
  104133. isInFrustum(frustumPlanes: Plane[]): boolean;
  104134. /**
  104135. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104136. * @param frustumPlanes defines the frustum planes
  104137. * @returns true if the submesh is inside the frustum
  104138. */
  104139. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104140. /**
  104141. * Renders the submesh
  104142. * @param enableAlphaMode defines if alpha needs to be used
  104143. * @returns the submesh
  104144. */
  104145. render(enableAlphaMode: boolean): SubMesh;
  104146. /**
  104147. * @hidden
  104148. */
  104149. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104150. /**
  104151. * Checks if the submesh intersects with a ray
  104152. * @param ray defines the ray to test
  104153. * @returns true is the passed ray intersects the submesh bounding box
  104154. */
  104155. canIntersects(ray: Ray): boolean;
  104156. /**
  104157. * Intersects current submesh with a ray
  104158. * @param ray defines the ray to test
  104159. * @param positions defines mesh's positions array
  104160. * @param indices defines mesh's indices array
  104161. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104162. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104163. * @returns intersection info or null if no intersection
  104164. */
  104165. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104166. /** @hidden */
  104167. private _intersectLines;
  104168. /** @hidden */
  104169. private _intersectUnIndexedLines;
  104170. /** @hidden */
  104171. private _intersectTriangles;
  104172. /** @hidden */
  104173. private _intersectUnIndexedTriangles;
  104174. /** @hidden */
  104175. _rebuild(): void;
  104176. /**
  104177. * Creates a new submesh from the passed mesh
  104178. * @param newMesh defines the new hosting mesh
  104179. * @param newRenderingMesh defines an optional rendering mesh
  104180. * @returns the new submesh
  104181. */
  104182. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104183. /**
  104184. * Release associated resources
  104185. */
  104186. dispose(): void;
  104187. /**
  104188. * Gets the class name
  104189. * @returns the string "SubMesh".
  104190. */
  104191. getClassName(): string;
  104192. /**
  104193. * Creates a new submesh from indices data
  104194. * @param materialIndex the index of the main mesh material
  104195. * @param startIndex the index where to start the copy in the mesh indices array
  104196. * @param indexCount the number of indices to copy then from the startIndex
  104197. * @param mesh the main mesh to create the submesh from
  104198. * @param renderingMesh the optional rendering mesh
  104199. * @returns a new submesh
  104200. */
  104201. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104202. }
  104203. }
  104204. declare module BABYLON {
  104205. /**
  104206. * Class used to represent data loading progression
  104207. */
  104208. export class SceneLoaderFlags {
  104209. private static _ForceFullSceneLoadingForIncremental;
  104210. private static _ShowLoadingScreen;
  104211. private static _CleanBoneMatrixWeights;
  104212. private static _loggingLevel;
  104213. /**
  104214. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104215. */
  104216. static get ForceFullSceneLoadingForIncremental(): boolean;
  104217. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104218. /**
  104219. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104220. */
  104221. static get ShowLoadingScreen(): boolean;
  104222. static set ShowLoadingScreen(value: boolean);
  104223. /**
  104224. * Defines the current logging level (while loading the scene)
  104225. * @ignorenaming
  104226. */
  104227. static get loggingLevel(): number;
  104228. static set loggingLevel(value: number);
  104229. /**
  104230. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104231. */
  104232. static get CleanBoneMatrixWeights(): boolean;
  104233. static set CleanBoneMatrixWeights(value: boolean);
  104234. }
  104235. }
  104236. declare module BABYLON {
  104237. /**
  104238. * Class used to store geometry data (vertex buffers + index buffer)
  104239. */
  104240. export class Geometry implements IGetSetVerticesData {
  104241. /**
  104242. * Gets or sets the ID of the geometry
  104243. */
  104244. id: string;
  104245. /**
  104246. * Gets or sets the unique ID of the geometry
  104247. */
  104248. uniqueId: number;
  104249. /**
  104250. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104251. */
  104252. delayLoadState: number;
  104253. /**
  104254. * Gets the file containing the data to load when running in delay load state
  104255. */
  104256. delayLoadingFile: Nullable<string>;
  104257. /**
  104258. * Callback called when the geometry is updated
  104259. */
  104260. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104261. private _scene;
  104262. private _engine;
  104263. private _meshes;
  104264. private _totalVertices;
  104265. /** @hidden */
  104266. _indices: IndicesArray;
  104267. /** @hidden */
  104268. _vertexBuffers: {
  104269. [key: string]: VertexBuffer;
  104270. };
  104271. private _isDisposed;
  104272. private _extend;
  104273. private _boundingBias;
  104274. /** @hidden */
  104275. _delayInfo: Array<string>;
  104276. private _indexBuffer;
  104277. private _indexBufferIsUpdatable;
  104278. /** @hidden */
  104279. _boundingInfo: Nullable<BoundingInfo>;
  104280. /** @hidden */
  104281. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104282. /** @hidden */
  104283. _softwareSkinningFrameId: number;
  104284. private _vertexArrayObjects;
  104285. private _updatable;
  104286. /** @hidden */
  104287. _positions: Nullable<Vector3[]>;
  104288. /**
  104289. * 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
  104290. */
  104291. get boundingBias(): Vector2;
  104292. /**
  104293. * 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
  104294. */
  104295. set boundingBias(value: Vector2);
  104296. /**
  104297. * Static function used to attach a new empty geometry to a mesh
  104298. * @param mesh defines the mesh to attach the geometry to
  104299. * @returns the new Geometry
  104300. */
  104301. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104302. /** Get the list of meshes using this geometry */
  104303. get meshes(): Mesh[];
  104304. /**
  104305. * 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
  104306. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104307. */
  104308. useBoundingInfoFromGeometry: boolean;
  104309. /**
  104310. * Creates a new geometry
  104311. * @param id defines the unique ID
  104312. * @param scene defines the hosting scene
  104313. * @param vertexData defines the VertexData used to get geometry data
  104314. * @param updatable defines if geometry must be updatable (false by default)
  104315. * @param mesh defines the mesh that will be associated with the geometry
  104316. */
  104317. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104318. /**
  104319. * Gets the current extend of the geometry
  104320. */
  104321. get extend(): {
  104322. minimum: Vector3;
  104323. maximum: Vector3;
  104324. };
  104325. /**
  104326. * Gets the hosting scene
  104327. * @returns the hosting Scene
  104328. */
  104329. getScene(): Scene;
  104330. /**
  104331. * Gets the hosting engine
  104332. * @returns the hosting Engine
  104333. */
  104334. getEngine(): Engine;
  104335. /**
  104336. * Defines if the geometry is ready to use
  104337. * @returns true if the geometry is ready to be used
  104338. */
  104339. isReady(): boolean;
  104340. /**
  104341. * Gets a value indicating that the geometry should not be serialized
  104342. */
  104343. get doNotSerialize(): boolean;
  104344. /** @hidden */
  104345. _rebuild(): void;
  104346. /**
  104347. * Affects all geometry data in one call
  104348. * @param vertexData defines the geometry data
  104349. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104350. */
  104351. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104352. /**
  104353. * Set specific vertex data
  104354. * @param kind defines the data kind (Position, normal, etc...)
  104355. * @param data defines the vertex data to use
  104356. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104357. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104358. */
  104359. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104360. /**
  104361. * Removes a specific vertex data
  104362. * @param kind defines the data kind (Position, normal, etc...)
  104363. */
  104364. removeVerticesData(kind: string): void;
  104365. /**
  104366. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104367. * @param buffer defines the vertex buffer to use
  104368. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104369. */
  104370. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104371. /**
  104372. * Update a specific vertex buffer
  104373. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104374. * It will do nothing if the buffer is not updatable
  104375. * @param kind defines the data kind (Position, normal, etc...)
  104376. * @param data defines the data to use
  104377. * @param offset defines the offset in the target buffer where to store the data
  104378. * @param useBytes set to true if the offset is in bytes
  104379. */
  104380. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104381. /**
  104382. * Update a specific vertex buffer
  104383. * This function will create a new buffer if the current one is not updatable
  104384. * @param kind defines the data kind (Position, normal, etc...)
  104385. * @param data defines the data to use
  104386. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104387. */
  104388. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104389. private _updateBoundingInfo;
  104390. /** @hidden */
  104391. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104392. /**
  104393. * Gets total number of vertices
  104394. * @returns the total number of vertices
  104395. */
  104396. getTotalVertices(): number;
  104397. /**
  104398. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104399. * @param kind defines the data kind (Position, normal, etc...)
  104400. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104401. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104402. * @returns a float array containing vertex data
  104403. */
  104404. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104405. /**
  104406. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104407. * @param kind defines the data kind (Position, normal, etc...)
  104408. * @returns true if the vertex buffer with the specified kind is updatable
  104409. */
  104410. isVertexBufferUpdatable(kind: string): boolean;
  104411. /**
  104412. * Gets a specific vertex buffer
  104413. * @param kind defines the data kind (Position, normal, etc...)
  104414. * @returns a VertexBuffer
  104415. */
  104416. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104417. /**
  104418. * Returns all vertex buffers
  104419. * @return an object holding all vertex buffers indexed by kind
  104420. */
  104421. getVertexBuffers(): Nullable<{
  104422. [key: string]: VertexBuffer;
  104423. }>;
  104424. /**
  104425. * Gets a boolean indicating if specific vertex buffer is present
  104426. * @param kind defines the data kind (Position, normal, etc...)
  104427. * @returns true if data is present
  104428. */
  104429. isVerticesDataPresent(kind: string): boolean;
  104430. /**
  104431. * Gets a list of all attached data kinds (Position, normal, etc...)
  104432. * @returns a list of string containing all kinds
  104433. */
  104434. getVerticesDataKinds(): string[];
  104435. /**
  104436. * Update index buffer
  104437. * @param indices defines the indices to store in the index buffer
  104438. * @param offset defines the offset in the target buffer where to store the data
  104439. * @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)
  104440. */
  104441. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104442. /**
  104443. * Creates a new index buffer
  104444. * @param indices defines the indices to store in the index buffer
  104445. * @param totalVertices defines the total number of vertices (could be null)
  104446. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104447. */
  104448. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104449. /**
  104450. * Return the total number of indices
  104451. * @returns the total number of indices
  104452. */
  104453. getTotalIndices(): number;
  104454. /**
  104455. * Gets the index buffer array
  104456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104458. * @returns the index buffer array
  104459. */
  104460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104461. /**
  104462. * Gets the index buffer
  104463. * @return the index buffer
  104464. */
  104465. getIndexBuffer(): Nullable<DataBuffer>;
  104466. /** @hidden */
  104467. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104468. /**
  104469. * Release the associated resources for a specific mesh
  104470. * @param mesh defines the source mesh
  104471. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104472. */
  104473. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104474. /**
  104475. * Apply current geometry to a given mesh
  104476. * @param mesh defines the mesh to apply geometry to
  104477. */
  104478. applyToMesh(mesh: Mesh): void;
  104479. private _updateExtend;
  104480. private _applyToMesh;
  104481. private notifyUpdate;
  104482. /**
  104483. * Load the geometry if it was flagged as delay loaded
  104484. * @param scene defines the hosting scene
  104485. * @param onLoaded defines a callback called when the geometry is loaded
  104486. */
  104487. load(scene: Scene, onLoaded?: () => void): void;
  104488. private _queueLoad;
  104489. /**
  104490. * Invert the geometry to move from a right handed system to a left handed one.
  104491. */
  104492. toLeftHanded(): void;
  104493. /** @hidden */
  104494. _resetPointsArrayCache(): void;
  104495. /** @hidden */
  104496. _generatePointsArray(): boolean;
  104497. /**
  104498. * Gets a value indicating if the geometry is disposed
  104499. * @returns true if the geometry was disposed
  104500. */
  104501. isDisposed(): boolean;
  104502. private _disposeVertexArrayObjects;
  104503. /**
  104504. * Free all associated resources
  104505. */
  104506. dispose(): void;
  104507. /**
  104508. * Clone the current geometry into a new geometry
  104509. * @param id defines the unique ID of the new geometry
  104510. * @returns a new geometry object
  104511. */
  104512. copy(id: string): Geometry;
  104513. /**
  104514. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104515. * @return a JSON representation of the current geometry data (without the vertices data)
  104516. */
  104517. serialize(): any;
  104518. private toNumberArray;
  104519. /**
  104520. * Serialize all vertices data into a JSON oject
  104521. * @returns a JSON representation of the current geometry data
  104522. */
  104523. serializeVerticeData(): any;
  104524. /**
  104525. * Extracts a clone of a mesh geometry
  104526. * @param mesh defines the source mesh
  104527. * @param id defines the unique ID of the new geometry object
  104528. * @returns the new geometry object
  104529. */
  104530. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104531. /**
  104532. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104533. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104534. * Be aware Math.random() could cause collisions, but:
  104535. * "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"
  104536. * @returns a string containing a new GUID
  104537. */
  104538. static RandomId(): string;
  104539. /** @hidden */
  104540. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104541. private static _CleanMatricesWeights;
  104542. /**
  104543. * Create a new geometry from persisted data (Using .babylon file format)
  104544. * @param parsedVertexData defines the persisted data
  104545. * @param scene defines the hosting scene
  104546. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104547. * @returns the new geometry object
  104548. */
  104549. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104550. }
  104551. }
  104552. declare module BABYLON {
  104553. /**
  104554. * Define an interface for all classes that will get and set the data on vertices
  104555. */
  104556. export interface IGetSetVerticesData {
  104557. /**
  104558. * Gets a boolean indicating if specific vertex data is present
  104559. * @param kind defines the vertex data kind to use
  104560. * @returns true is data kind is present
  104561. */
  104562. isVerticesDataPresent(kind: string): boolean;
  104563. /**
  104564. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104565. * @param kind defines the data kind (Position, normal, etc...)
  104566. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104567. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104568. * @returns a float array containing vertex data
  104569. */
  104570. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104571. /**
  104572. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104573. * @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.
  104574. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104575. * @returns the indices array or an empty array if the mesh has no geometry
  104576. */
  104577. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104578. /**
  104579. * Set specific vertex data
  104580. * @param kind defines the data kind (Position, normal, etc...)
  104581. * @param data defines the vertex data to use
  104582. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104583. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104584. */
  104585. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104586. /**
  104587. * Update a specific associated vertex buffer
  104588. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104589. * - VertexBuffer.PositionKind
  104590. * - VertexBuffer.UVKind
  104591. * - VertexBuffer.UV2Kind
  104592. * - VertexBuffer.UV3Kind
  104593. * - VertexBuffer.UV4Kind
  104594. * - VertexBuffer.UV5Kind
  104595. * - VertexBuffer.UV6Kind
  104596. * - VertexBuffer.ColorKind
  104597. * - VertexBuffer.MatricesIndicesKind
  104598. * - VertexBuffer.MatricesIndicesExtraKind
  104599. * - VertexBuffer.MatricesWeightsKind
  104600. * - VertexBuffer.MatricesWeightsExtraKind
  104601. * @param data defines the data source
  104602. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104603. * @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)
  104604. */
  104605. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104606. /**
  104607. * Creates a new index buffer
  104608. * @param indices defines the indices to store in the index buffer
  104609. * @param totalVertices defines the total number of vertices (could be null)
  104610. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104611. */
  104612. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104613. }
  104614. /**
  104615. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104616. */
  104617. export class VertexData {
  104618. /**
  104619. * Mesh side orientation : usually the external or front surface
  104620. */
  104621. static readonly FRONTSIDE: number;
  104622. /**
  104623. * Mesh side orientation : usually the internal or back surface
  104624. */
  104625. static readonly BACKSIDE: number;
  104626. /**
  104627. * Mesh side orientation : both internal and external or front and back surfaces
  104628. */
  104629. static readonly DOUBLESIDE: number;
  104630. /**
  104631. * Mesh side orientation : by default, `FRONTSIDE`
  104632. */
  104633. static readonly DEFAULTSIDE: number;
  104634. /**
  104635. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104636. */
  104637. positions: Nullable<FloatArray>;
  104638. /**
  104639. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104640. */
  104641. normals: Nullable<FloatArray>;
  104642. /**
  104643. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104644. */
  104645. tangents: Nullable<FloatArray>;
  104646. /**
  104647. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104648. */
  104649. uvs: Nullable<FloatArray>;
  104650. /**
  104651. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104652. */
  104653. uvs2: Nullable<FloatArray>;
  104654. /**
  104655. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104656. */
  104657. uvs3: Nullable<FloatArray>;
  104658. /**
  104659. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104660. */
  104661. uvs4: Nullable<FloatArray>;
  104662. /**
  104663. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104664. */
  104665. uvs5: Nullable<FloatArray>;
  104666. /**
  104667. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104668. */
  104669. uvs6: Nullable<FloatArray>;
  104670. /**
  104671. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104672. */
  104673. colors: Nullable<FloatArray>;
  104674. /**
  104675. * 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).
  104676. */
  104677. matricesIndices: Nullable<FloatArray>;
  104678. /**
  104679. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104680. */
  104681. matricesWeights: Nullable<FloatArray>;
  104682. /**
  104683. * An array extending the number of possible indices
  104684. */
  104685. matricesIndicesExtra: Nullable<FloatArray>;
  104686. /**
  104687. * An array extending the number of possible weights when the number of indices is extended
  104688. */
  104689. matricesWeightsExtra: Nullable<FloatArray>;
  104690. /**
  104691. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104692. */
  104693. indices: Nullable<IndicesArray>;
  104694. /**
  104695. * Uses the passed data array to set the set the values for the specified kind of data
  104696. * @param data a linear array of floating numbers
  104697. * @param kind the type of data that is being set, eg positions, colors etc
  104698. */
  104699. set(data: FloatArray, kind: string): void;
  104700. /**
  104701. * Associates the vertexData to the passed Mesh.
  104702. * Sets it as updatable or not (default `false`)
  104703. * @param mesh the mesh the vertexData is applied to
  104704. * @param updatable when used and having the value true allows new data to update the vertexData
  104705. * @returns the VertexData
  104706. */
  104707. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104708. /**
  104709. * Associates the vertexData to the passed Geometry.
  104710. * Sets it as updatable or not (default `false`)
  104711. * @param geometry the geometry the vertexData is applied to
  104712. * @param updatable when used and having the value true allows new data to update the vertexData
  104713. * @returns VertexData
  104714. */
  104715. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104716. /**
  104717. * Updates the associated mesh
  104718. * @param mesh the mesh to be updated
  104719. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104720. * @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
  104721. * @returns VertexData
  104722. */
  104723. updateMesh(mesh: Mesh): VertexData;
  104724. /**
  104725. * Updates the associated geometry
  104726. * @param geometry the geometry to be updated
  104727. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104728. * @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
  104729. * @returns VertexData.
  104730. */
  104731. updateGeometry(geometry: Geometry): VertexData;
  104732. private _applyTo;
  104733. private _update;
  104734. /**
  104735. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104736. * @param matrix the transforming matrix
  104737. * @returns the VertexData
  104738. */
  104739. transform(matrix: Matrix): VertexData;
  104740. /**
  104741. * Merges the passed VertexData into the current one
  104742. * @param other the VertexData to be merged into the current one
  104743. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104744. * @returns the modified VertexData
  104745. */
  104746. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104747. private _mergeElement;
  104748. private _validate;
  104749. /**
  104750. * Serializes the VertexData
  104751. * @returns a serialized object
  104752. */
  104753. serialize(): any;
  104754. /**
  104755. * Extracts the vertexData from a mesh
  104756. * @param mesh the mesh from which to extract the VertexData
  104757. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104758. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104759. * @returns the object VertexData associated to the passed mesh
  104760. */
  104761. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104762. /**
  104763. * Extracts the vertexData from the geometry
  104764. * @param geometry the geometry from which to extract the VertexData
  104765. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104766. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104767. * @returns the object VertexData associated to the passed mesh
  104768. */
  104769. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104770. private static _ExtractFrom;
  104771. /**
  104772. * Creates the VertexData for a Ribbon
  104773. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104774. * * pathArray array of paths, each of which an array of successive Vector3
  104775. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104776. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104777. * * 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
  104778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104779. * * 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)
  104780. * * 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)
  104781. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104782. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104783. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104784. * @returns the VertexData of the ribbon
  104785. */
  104786. static CreateRibbon(options: {
  104787. pathArray: Vector3[][];
  104788. closeArray?: boolean;
  104789. closePath?: boolean;
  104790. offset?: number;
  104791. sideOrientation?: number;
  104792. frontUVs?: Vector4;
  104793. backUVs?: Vector4;
  104794. invertUV?: boolean;
  104795. uvs?: Vector2[];
  104796. colors?: Color4[];
  104797. }): VertexData;
  104798. /**
  104799. * Creates the VertexData for a box
  104800. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104801. * * size sets the width, height and depth of the box to the value of size, optional default 1
  104802. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  104803. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  104804. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  104805. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104806. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104808. * * 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)
  104809. * * 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)
  104810. * @returns the VertexData of the box
  104811. */
  104812. static CreateBox(options: {
  104813. size?: number;
  104814. width?: number;
  104815. height?: number;
  104816. depth?: number;
  104817. faceUV?: Vector4[];
  104818. faceColors?: Color4[];
  104819. sideOrientation?: number;
  104820. frontUVs?: Vector4;
  104821. backUVs?: Vector4;
  104822. }): VertexData;
  104823. /**
  104824. * Creates the VertexData for a tiled box
  104825. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104826. * * faceTiles sets the pattern, tile size and number of tiles for a face
  104827. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104828. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104830. * @returns the VertexData of the box
  104831. */
  104832. static CreateTiledBox(options: {
  104833. pattern?: number;
  104834. width?: number;
  104835. height?: number;
  104836. depth?: number;
  104837. tileSize?: number;
  104838. tileWidth?: number;
  104839. tileHeight?: number;
  104840. alignHorizontal?: number;
  104841. alignVertical?: number;
  104842. faceUV?: Vector4[];
  104843. faceColors?: Color4[];
  104844. sideOrientation?: number;
  104845. }): VertexData;
  104846. /**
  104847. * Creates the VertexData for a tiled plane
  104848. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104849. * * pattern a limited pattern arrangement depending on the number
  104850. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  104851. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  104852. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  104853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104854. * * 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)
  104855. * * 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)
  104856. * @returns the VertexData of the tiled plane
  104857. */
  104858. static CreateTiledPlane(options: {
  104859. pattern?: number;
  104860. tileSize?: number;
  104861. tileWidth?: number;
  104862. tileHeight?: number;
  104863. size?: number;
  104864. width?: number;
  104865. height?: number;
  104866. alignHorizontal?: number;
  104867. alignVertical?: number;
  104868. sideOrientation?: number;
  104869. frontUVs?: Vector4;
  104870. backUVs?: Vector4;
  104871. }): VertexData;
  104872. /**
  104873. * Creates the VertexData for an ellipsoid, defaults to a sphere
  104874. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104875. * * segments sets the number of horizontal strips optional, default 32
  104876. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  104877. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  104878. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  104879. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  104880. * * 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
  104881. * * 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
  104882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104883. * * 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)
  104884. * * 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)
  104885. * @returns the VertexData of the ellipsoid
  104886. */
  104887. static CreateSphere(options: {
  104888. segments?: number;
  104889. diameter?: number;
  104890. diameterX?: number;
  104891. diameterY?: number;
  104892. diameterZ?: number;
  104893. arc?: number;
  104894. slice?: number;
  104895. sideOrientation?: number;
  104896. frontUVs?: Vector4;
  104897. backUVs?: Vector4;
  104898. }): VertexData;
  104899. /**
  104900. * Creates the VertexData for a cylinder, cone or prism
  104901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104902. * * height sets the height (y direction) of the cylinder, optional, default 2
  104903. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  104904. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  104905. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  104906. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104907. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  104908. * * 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
  104909. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104910. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  104911. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  104912. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  104913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104914. * * 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)
  104915. * * 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)
  104916. * @returns the VertexData of the cylinder, cone or prism
  104917. */
  104918. static CreateCylinder(options: {
  104919. height?: number;
  104920. diameterTop?: number;
  104921. diameterBottom?: number;
  104922. diameter?: number;
  104923. tessellation?: number;
  104924. subdivisions?: number;
  104925. arc?: number;
  104926. faceColors?: Color4[];
  104927. faceUV?: Vector4[];
  104928. hasRings?: boolean;
  104929. enclose?: boolean;
  104930. sideOrientation?: number;
  104931. frontUVs?: Vector4;
  104932. backUVs?: Vector4;
  104933. }): VertexData;
  104934. /**
  104935. * Creates the VertexData for a torus
  104936. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104937. * * diameter the diameter of the torus, optional default 1
  104938. * * thickness the diameter of the tube forming the torus, optional default 0.5
  104939. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104940. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104941. * * 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)
  104942. * * 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)
  104943. * @returns the VertexData of the torus
  104944. */
  104945. static CreateTorus(options: {
  104946. diameter?: number;
  104947. thickness?: number;
  104948. tessellation?: number;
  104949. sideOrientation?: number;
  104950. frontUVs?: Vector4;
  104951. backUVs?: Vector4;
  104952. }): VertexData;
  104953. /**
  104954. * Creates the VertexData of the LineSystem
  104955. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  104956. * - lines an array of lines, each line being an array of successive Vector3
  104957. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  104958. * @returns the VertexData of the LineSystem
  104959. */
  104960. static CreateLineSystem(options: {
  104961. lines: Vector3[][];
  104962. colors?: Nullable<Color4[][]>;
  104963. }): VertexData;
  104964. /**
  104965. * Create the VertexData for a DashedLines
  104966. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  104967. * - points an array successive Vector3
  104968. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  104969. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  104970. * - dashNb the intended total number of dashes, optional, default 200
  104971. * @returns the VertexData for the DashedLines
  104972. */
  104973. static CreateDashedLines(options: {
  104974. points: Vector3[];
  104975. dashSize?: number;
  104976. gapSize?: number;
  104977. dashNb?: number;
  104978. }): VertexData;
  104979. /**
  104980. * Creates the VertexData for a Ground
  104981. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104982. * - width the width (x direction) of the ground, optional, default 1
  104983. * - height the height (z direction) of the ground, optional, default 1
  104984. * - subdivisions the number of subdivisions per side, optional, default 1
  104985. * @returns the VertexData of the Ground
  104986. */
  104987. static CreateGround(options: {
  104988. width?: number;
  104989. height?: number;
  104990. subdivisions?: number;
  104991. subdivisionsX?: number;
  104992. subdivisionsY?: number;
  104993. }): VertexData;
  104994. /**
  104995. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  104996. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  104997. * * xmin the ground minimum X coordinate, optional, default -1
  104998. * * zmin the ground minimum Z coordinate, optional, default -1
  104999. * * xmax the ground maximum X coordinate, optional, default 1
  105000. * * zmax the ground maximum Z coordinate, optional, default 1
  105001. * * 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}
  105002. * * 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}
  105003. * @returns the VertexData of the TiledGround
  105004. */
  105005. static CreateTiledGround(options: {
  105006. xmin: number;
  105007. zmin: number;
  105008. xmax: number;
  105009. zmax: number;
  105010. subdivisions?: {
  105011. w: number;
  105012. h: number;
  105013. };
  105014. precision?: {
  105015. w: number;
  105016. h: number;
  105017. };
  105018. }): VertexData;
  105019. /**
  105020. * Creates the VertexData of the Ground designed from a heightmap
  105021. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105022. * * width the width (x direction) of the ground
  105023. * * height the height (z direction) of the ground
  105024. * * subdivisions the number of subdivisions per side
  105025. * * minHeight the minimum altitude on the ground, optional, default 0
  105026. * * maxHeight the maximum altitude on the ground, optional default 1
  105027. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105028. * * buffer the array holding the image color data
  105029. * * bufferWidth the width of image
  105030. * * bufferHeight the height of image
  105031. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105032. * @returns the VertexData of the Ground designed from a heightmap
  105033. */
  105034. static CreateGroundFromHeightMap(options: {
  105035. width: number;
  105036. height: number;
  105037. subdivisions: number;
  105038. minHeight: number;
  105039. maxHeight: number;
  105040. colorFilter: Color3;
  105041. buffer: Uint8Array;
  105042. bufferWidth: number;
  105043. bufferHeight: number;
  105044. alphaFilter: number;
  105045. }): VertexData;
  105046. /**
  105047. * Creates the VertexData for a Plane
  105048. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105049. * * size sets the width and height of the plane to the value of size, optional default 1
  105050. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105051. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105053. * * 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)
  105054. * * 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)
  105055. * @returns the VertexData of the box
  105056. */
  105057. static CreatePlane(options: {
  105058. size?: number;
  105059. width?: number;
  105060. height?: number;
  105061. sideOrientation?: number;
  105062. frontUVs?: Vector4;
  105063. backUVs?: Vector4;
  105064. }): VertexData;
  105065. /**
  105066. * Creates the VertexData of the Disc or regular Polygon
  105067. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105068. * * radius the radius of the disc, optional default 0.5
  105069. * * tessellation the number of polygon sides, optional, default 64
  105070. * * 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
  105071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105072. * * 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)
  105073. * * 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)
  105074. * @returns the VertexData of the box
  105075. */
  105076. static CreateDisc(options: {
  105077. radius?: number;
  105078. tessellation?: number;
  105079. arc?: number;
  105080. sideOrientation?: number;
  105081. frontUVs?: Vector4;
  105082. backUVs?: Vector4;
  105083. }): VertexData;
  105084. /**
  105085. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105086. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105087. * @param polygon a mesh built from polygonTriangulation.build()
  105088. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105089. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105090. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105091. * @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)
  105092. * @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)
  105093. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105094. * @returns the VertexData of the Polygon
  105095. */
  105096. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105097. /**
  105098. * Creates the VertexData of the IcoSphere
  105099. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105100. * * radius the radius of the IcoSphere, optional default 1
  105101. * * radiusX allows stretching in the x direction, optional, default radius
  105102. * * radiusY allows stretching in the y direction, optional, default radius
  105103. * * radiusZ allows stretching in the z direction, optional, default radius
  105104. * * flat when true creates a flat shaded mesh, optional, default true
  105105. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105106. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105107. * * 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)
  105108. * * 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)
  105109. * @returns the VertexData of the IcoSphere
  105110. */
  105111. static CreateIcoSphere(options: {
  105112. radius?: number;
  105113. radiusX?: number;
  105114. radiusY?: number;
  105115. radiusZ?: number;
  105116. flat?: boolean;
  105117. subdivisions?: number;
  105118. sideOrientation?: number;
  105119. frontUVs?: Vector4;
  105120. backUVs?: Vector4;
  105121. }): VertexData;
  105122. /**
  105123. * Creates the VertexData for a Polyhedron
  105124. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105125. * * type provided types are:
  105126. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105127. * * 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)
  105128. * * size the size of the IcoSphere, optional default 1
  105129. * * sizeX allows stretching in the x direction, optional, default size
  105130. * * sizeY allows stretching in the y direction, optional, default size
  105131. * * sizeZ allows stretching in the z direction, optional, default size
  105132. * * 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
  105133. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105134. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105135. * * flat when true creates a flat shaded mesh, optional, default true
  105136. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105138. * * 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)
  105139. * * 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)
  105140. * @returns the VertexData of the Polyhedron
  105141. */
  105142. static CreatePolyhedron(options: {
  105143. type?: number;
  105144. size?: number;
  105145. sizeX?: number;
  105146. sizeY?: number;
  105147. sizeZ?: number;
  105148. custom?: any;
  105149. faceUV?: Vector4[];
  105150. faceColors?: Color4[];
  105151. flat?: boolean;
  105152. sideOrientation?: number;
  105153. frontUVs?: Vector4;
  105154. backUVs?: Vector4;
  105155. }): VertexData;
  105156. /**
  105157. * Creates the VertexData for a TorusKnot
  105158. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105159. * * radius the radius of the torus knot, optional, default 2
  105160. * * tube the thickness of the tube, optional, default 0.5
  105161. * * radialSegments the number of sides on each tube segments, optional, default 32
  105162. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105163. * * p the number of windings around the z axis, optional, default 2
  105164. * * q the number of windings around the x axis, optional, default 3
  105165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105166. * * 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)
  105167. * * 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)
  105168. * @returns the VertexData of the Torus Knot
  105169. */
  105170. static CreateTorusKnot(options: {
  105171. radius?: number;
  105172. tube?: number;
  105173. radialSegments?: number;
  105174. tubularSegments?: number;
  105175. p?: number;
  105176. q?: number;
  105177. sideOrientation?: number;
  105178. frontUVs?: Vector4;
  105179. backUVs?: Vector4;
  105180. }): VertexData;
  105181. /**
  105182. * Compute normals for given positions and indices
  105183. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105184. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105185. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105186. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105187. * * facetNormals : optional array of facet normals (vector3)
  105188. * * facetPositions : optional array of facet positions (vector3)
  105189. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105190. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105191. * * bInfo : optional bounding info, required for facetPartitioning computation
  105192. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105193. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105194. * * useRightHandedSystem: optional boolean to for right handed system computation
  105195. * * depthSort : optional boolean to enable the facet depth sort computation
  105196. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105197. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105198. */
  105199. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105200. facetNormals?: any;
  105201. facetPositions?: any;
  105202. facetPartitioning?: any;
  105203. ratio?: number;
  105204. bInfo?: any;
  105205. bbSize?: Vector3;
  105206. subDiv?: any;
  105207. useRightHandedSystem?: boolean;
  105208. depthSort?: boolean;
  105209. distanceTo?: Vector3;
  105210. depthSortedFacets?: any;
  105211. }): void;
  105212. /** @hidden */
  105213. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105214. /**
  105215. * Applies VertexData created from the imported parameters to the geometry
  105216. * @param parsedVertexData the parsed data from an imported file
  105217. * @param geometry the geometry to apply the VertexData to
  105218. */
  105219. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105220. }
  105221. }
  105222. declare module BABYLON {
  105223. /**
  105224. * Defines a target to use with MorphTargetManager
  105225. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105226. */
  105227. export class MorphTarget implements IAnimatable {
  105228. /** defines the name of the target */
  105229. name: string;
  105230. /**
  105231. * Gets or sets the list of animations
  105232. */
  105233. animations: Animation[];
  105234. private _scene;
  105235. private _positions;
  105236. private _normals;
  105237. private _tangents;
  105238. private _uvs;
  105239. private _influence;
  105240. private _uniqueId;
  105241. /**
  105242. * Observable raised when the influence changes
  105243. */
  105244. onInfluenceChanged: Observable<boolean>;
  105245. /** @hidden */
  105246. _onDataLayoutChanged: Observable<void>;
  105247. /**
  105248. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105249. */
  105250. get influence(): number;
  105251. set influence(influence: number);
  105252. /**
  105253. * Gets or sets the id of the morph Target
  105254. */
  105255. id: string;
  105256. private _animationPropertiesOverride;
  105257. /**
  105258. * Gets or sets the animation properties override
  105259. */
  105260. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105261. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105262. /**
  105263. * Creates a new MorphTarget
  105264. * @param name defines the name of the target
  105265. * @param influence defines the influence to use
  105266. * @param scene defines the scene the morphtarget belongs to
  105267. */
  105268. constructor(
  105269. /** defines the name of the target */
  105270. name: string, influence?: number, scene?: Nullable<Scene>);
  105271. /**
  105272. * Gets the unique ID of this manager
  105273. */
  105274. get uniqueId(): number;
  105275. /**
  105276. * Gets a boolean defining if the target contains position data
  105277. */
  105278. get hasPositions(): boolean;
  105279. /**
  105280. * Gets a boolean defining if the target contains normal data
  105281. */
  105282. get hasNormals(): boolean;
  105283. /**
  105284. * Gets a boolean defining if the target contains tangent data
  105285. */
  105286. get hasTangents(): boolean;
  105287. /**
  105288. * Gets a boolean defining if the target contains texture coordinates data
  105289. */
  105290. get hasUVs(): boolean;
  105291. /**
  105292. * Affects position data to this target
  105293. * @param data defines the position data to use
  105294. */
  105295. setPositions(data: Nullable<FloatArray>): void;
  105296. /**
  105297. * Gets the position data stored in this target
  105298. * @returns a FloatArray containing the position data (or null if not present)
  105299. */
  105300. getPositions(): Nullable<FloatArray>;
  105301. /**
  105302. * Affects normal data to this target
  105303. * @param data defines the normal data to use
  105304. */
  105305. setNormals(data: Nullable<FloatArray>): void;
  105306. /**
  105307. * Gets the normal data stored in this target
  105308. * @returns a FloatArray containing the normal data (or null if not present)
  105309. */
  105310. getNormals(): Nullable<FloatArray>;
  105311. /**
  105312. * Affects tangent data to this target
  105313. * @param data defines the tangent data to use
  105314. */
  105315. setTangents(data: Nullable<FloatArray>): void;
  105316. /**
  105317. * Gets the tangent data stored in this target
  105318. * @returns a FloatArray containing the tangent data (or null if not present)
  105319. */
  105320. getTangents(): Nullable<FloatArray>;
  105321. /**
  105322. * Affects texture coordinates data to this target
  105323. * @param data defines the texture coordinates data to use
  105324. */
  105325. setUVs(data: Nullable<FloatArray>): void;
  105326. /**
  105327. * Gets the texture coordinates data stored in this target
  105328. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105329. */
  105330. getUVs(): Nullable<FloatArray>;
  105331. /**
  105332. * Clone the current target
  105333. * @returns a new MorphTarget
  105334. */
  105335. clone(): MorphTarget;
  105336. /**
  105337. * Serializes the current target into a Serialization object
  105338. * @returns the serialized object
  105339. */
  105340. serialize(): any;
  105341. /**
  105342. * Returns the string "MorphTarget"
  105343. * @returns "MorphTarget"
  105344. */
  105345. getClassName(): string;
  105346. /**
  105347. * Creates a new target from serialized data
  105348. * @param serializationObject defines the serialized data to use
  105349. * @returns a new MorphTarget
  105350. */
  105351. static Parse(serializationObject: any): MorphTarget;
  105352. /**
  105353. * Creates a MorphTarget from mesh data
  105354. * @param mesh defines the source mesh
  105355. * @param name defines the name to use for the new target
  105356. * @param influence defines the influence to attach to the target
  105357. * @returns a new MorphTarget
  105358. */
  105359. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105360. }
  105361. }
  105362. declare module BABYLON {
  105363. /**
  105364. * This class is used to deform meshes using morphing between different targets
  105365. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105366. */
  105367. export class MorphTargetManager {
  105368. private _targets;
  105369. private _targetInfluenceChangedObservers;
  105370. private _targetDataLayoutChangedObservers;
  105371. private _activeTargets;
  105372. private _scene;
  105373. private _influences;
  105374. private _supportsNormals;
  105375. private _supportsTangents;
  105376. private _supportsUVs;
  105377. private _vertexCount;
  105378. private _uniqueId;
  105379. private _tempInfluences;
  105380. /**
  105381. * Gets or sets a boolean indicating if normals must be morphed
  105382. */
  105383. enableNormalMorphing: boolean;
  105384. /**
  105385. * Gets or sets a boolean indicating if tangents must be morphed
  105386. */
  105387. enableTangentMorphing: boolean;
  105388. /**
  105389. * Gets or sets a boolean indicating if UV must be morphed
  105390. */
  105391. enableUVMorphing: boolean;
  105392. /**
  105393. * Creates a new MorphTargetManager
  105394. * @param scene defines the current scene
  105395. */
  105396. constructor(scene?: Nullable<Scene>);
  105397. /**
  105398. * Gets the unique ID of this manager
  105399. */
  105400. get uniqueId(): number;
  105401. /**
  105402. * Gets the number of vertices handled by this manager
  105403. */
  105404. get vertexCount(): number;
  105405. /**
  105406. * Gets a boolean indicating if this manager supports morphing of normals
  105407. */
  105408. get supportsNormals(): boolean;
  105409. /**
  105410. * Gets a boolean indicating if this manager supports morphing of tangents
  105411. */
  105412. get supportsTangents(): boolean;
  105413. /**
  105414. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105415. */
  105416. get supportsUVs(): boolean;
  105417. /**
  105418. * Gets the number of targets stored in this manager
  105419. */
  105420. get numTargets(): number;
  105421. /**
  105422. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105423. */
  105424. get numInfluencers(): number;
  105425. /**
  105426. * Gets the list of influences (one per target)
  105427. */
  105428. get influences(): Float32Array;
  105429. /**
  105430. * Gets the active target at specified index. An active target is a target with an influence > 0
  105431. * @param index defines the index to check
  105432. * @returns the requested target
  105433. */
  105434. getActiveTarget(index: number): MorphTarget;
  105435. /**
  105436. * Gets the target at specified index
  105437. * @param index defines the index to check
  105438. * @returns the requested target
  105439. */
  105440. getTarget(index: number): MorphTarget;
  105441. /**
  105442. * Add a new target to this manager
  105443. * @param target defines the target to add
  105444. */
  105445. addTarget(target: MorphTarget): void;
  105446. /**
  105447. * Removes a target from the manager
  105448. * @param target defines the target to remove
  105449. */
  105450. removeTarget(target: MorphTarget): void;
  105451. /**
  105452. * Clone the current manager
  105453. * @returns a new MorphTargetManager
  105454. */
  105455. clone(): MorphTargetManager;
  105456. /**
  105457. * Serializes the current manager into a Serialization object
  105458. * @returns the serialized object
  105459. */
  105460. serialize(): any;
  105461. private _syncActiveTargets;
  105462. /**
  105463. * Syncrhonize the targets with all the meshes using this morph target manager
  105464. */
  105465. synchronize(): void;
  105466. /**
  105467. * Creates a new MorphTargetManager from serialized data
  105468. * @param serializationObject defines the serialized data
  105469. * @param scene defines the hosting scene
  105470. * @returns the new MorphTargetManager
  105471. */
  105472. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105473. }
  105474. }
  105475. declare module BABYLON {
  105476. /**
  105477. * Class used to represent a specific level of detail of a mesh
  105478. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105479. */
  105480. export class MeshLODLevel {
  105481. /** Defines the distance where this level should start being displayed */
  105482. distance: number;
  105483. /** Defines the mesh to use to render this level */
  105484. mesh: Nullable<Mesh>;
  105485. /**
  105486. * Creates a new LOD level
  105487. * @param distance defines the distance where this level should star being displayed
  105488. * @param mesh defines the mesh to use to render this level
  105489. */
  105490. constructor(
  105491. /** Defines the distance where this level should start being displayed */
  105492. distance: number,
  105493. /** Defines the mesh to use to render this level */
  105494. mesh: Nullable<Mesh>);
  105495. }
  105496. }
  105497. declare module BABYLON {
  105498. /**
  105499. * Helper class used to generate a canvas to manipulate images
  105500. */
  105501. export class CanvasGenerator {
  105502. /**
  105503. * Create a new canvas (or offscreen canvas depending on the context)
  105504. * @param width defines the expected width
  105505. * @param height defines the expected height
  105506. * @return a new canvas or offscreen canvas
  105507. */
  105508. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105509. }
  105510. }
  105511. declare module BABYLON {
  105512. /**
  105513. * Mesh representing the gorund
  105514. */
  105515. export class GroundMesh extends Mesh {
  105516. /** If octree should be generated */
  105517. generateOctree: boolean;
  105518. private _heightQuads;
  105519. /** @hidden */
  105520. _subdivisionsX: number;
  105521. /** @hidden */
  105522. _subdivisionsY: number;
  105523. /** @hidden */
  105524. _width: number;
  105525. /** @hidden */
  105526. _height: number;
  105527. /** @hidden */
  105528. _minX: number;
  105529. /** @hidden */
  105530. _maxX: number;
  105531. /** @hidden */
  105532. _minZ: number;
  105533. /** @hidden */
  105534. _maxZ: number;
  105535. constructor(name: string, scene: Scene);
  105536. /**
  105537. * "GroundMesh"
  105538. * @returns "GroundMesh"
  105539. */
  105540. getClassName(): string;
  105541. /**
  105542. * The minimum of x and y subdivisions
  105543. */
  105544. get subdivisions(): number;
  105545. /**
  105546. * X subdivisions
  105547. */
  105548. get subdivisionsX(): number;
  105549. /**
  105550. * Y subdivisions
  105551. */
  105552. get subdivisionsY(): number;
  105553. /**
  105554. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105555. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105556. * @param chunksCount the number of subdivisions for x and y
  105557. * @param octreeBlocksSize (Default: 32)
  105558. */
  105559. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105560. /**
  105561. * Returns a height (y) value in the Worl system :
  105562. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105563. * @param x x coordinate
  105564. * @param z z coordinate
  105565. * @returns the ground y position if (x, z) are outside the ground surface.
  105566. */
  105567. getHeightAtCoordinates(x: number, z: number): number;
  105568. /**
  105569. * Returns a normalized vector (Vector3) orthogonal to the ground
  105570. * at the ground coordinates (x, z) expressed in the World system.
  105571. * @param x x coordinate
  105572. * @param z z coordinate
  105573. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105574. */
  105575. getNormalAtCoordinates(x: number, z: number): Vector3;
  105576. /**
  105577. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105578. * at the ground coordinates (x, z) expressed in the World system.
  105579. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105580. * @param x x coordinate
  105581. * @param z z coordinate
  105582. * @param ref vector to store the result
  105583. * @returns the GroundMesh.
  105584. */
  105585. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105586. /**
  105587. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105588. * if the ground has been updated.
  105589. * This can be used in the render loop.
  105590. * @returns the GroundMesh.
  105591. */
  105592. updateCoordinateHeights(): GroundMesh;
  105593. private _getFacetAt;
  105594. private _initHeightQuads;
  105595. private _computeHeightQuads;
  105596. /**
  105597. * Serializes this ground mesh
  105598. * @param serializationObject object to write serialization to
  105599. */
  105600. serialize(serializationObject: any): void;
  105601. /**
  105602. * Parses a serialized ground mesh
  105603. * @param parsedMesh the serialized mesh
  105604. * @param scene the scene to create the ground mesh in
  105605. * @returns the created ground mesh
  105606. */
  105607. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105608. }
  105609. }
  105610. declare module BABYLON {
  105611. /**
  105612. * Interface for Physics-Joint data
  105613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105614. */
  105615. export interface PhysicsJointData {
  105616. /**
  105617. * The main pivot of the joint
  105618. */
  105619. mainPivot?: Vector3;
  105620. /**
  105621. * The connected pivot of the joint
  105622. */
  105623. connectedPivot?: Vector3;
  105624. /**
  105625. * The main axis of the joint
  105626. */
  105627. mainAxis?: Vector3;
  105628. /**
  105629. * The connected axis of the joint
  105630. */
  105631. connectedAxis?: Vector3;
  105632. /**
  105633. * The collision of the joint
  105634. */
  105635. collision?: boolean;
  105636. /**
  105637. * Native Oimo/Cannon/Energy data
  105638. */
  105639. nativeParams?: any;
  105640. }
  105641. /**
  105642. * This is a holder class for the physics joint created by the physics plugin
  105643. * It holds a set of functions to control the underlying joint
  105644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105645. */
  105646. export class PhysicsJoint {
  105647. /**
  105648. * The type of the physics joint
  105649. */
  105650. type: number;
  105651. /**
  105652. * The data for the physics joint
  105653. */
  105654. jointData: PhysicsJointData;
  105655. private _physicsJoint;
  105656. protected _physicsPlugin: IPhysicsEnginePlugin;
  105657. /**
  105658. * Initializes the physics joint
  105659. * @param type The type of the physics joint
  105660. * @param jointData The data for the physics joint
  105661. */
  105662. constructor(
  105663. /**
  105664. * The type of the physics joint
  105665. */
  105666. type: number,
  105667. /**
  105668. * The data for the physics joint
  105669. */
  105670. jointData: PhysicsJointData);
  105671. /**
  105672. * Gets the physics joint
  105673. */
  105674. get physicsJoint(): any;
  105675. /**
  105676. * Sets the physics joint
  105677. */
  105678. set physicsJoint(newJoint: any);
  105679. /**
  105680. * Sets the physics plugin
  105681. */
  105682. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105683. /**
  105684. * Execute a function that is physics-plugin specific.
  105685. * @param {Function} func the function that will be executed.
  105686. * It accepts two parameters: the physics world and the physics joint
  105687. */
  105688. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105689. /**
  105690. * Distance-Joint type
  105691. */
  105692. static DistanceJoint: number;
  105693. /**
  105694. * Hinge-Joint type
  105695. */
  105696. static HingeJoint: number;
  105697. /**
  105698. * Ball-and-Socket joint type
  105699. */
  105700. static BallAndSocketJoint: number;
  105701. /**
  105702. * Wheel-Joint type
  105703. */
  105704. static WheelJoint: number;
  105705. /**
  105706. * Slider-Joint type
  105707. */
  105708. static SliderJoint: number;
  105709. /**
  105710. * Prismatic-Joint type
  105711. */
  105712. static PrismaticJoint: number;
  105713. /**
  105714. * Universal-Joint type
  105715. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105716. */
  105717. static UniversalJoint: number;
  105718. /**
  105719. * Hinge-Joint 2 type
  105720. */
  105721. static Hinge2Joint: number;
  105722. /**
  105723. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105724. */
  105725. static PointToPointJoint: number;
  105726. /**
  105727. * Spring-Joint type
  105728. */
  105729. static SpringJoint: number;
  105730. /**
  105731. * Lock-Joint type
  105732. */
  105733. static LockJoint: number;
  105734. }
  105735. /**
  105736. * A class representing a physics distance joint
  105737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105738. */
  105739. export class DistanceJoint extends PhysicsJoint {
  105740. /**
  105741. *
  105742. * @param jointData The data for the Distance-Joint
  105743. */
  105744. constructor(jointData: DistanceJointData);
  105745. /**
  105746. * Update the predefined distance.
  105747. * @param maxDistance The maximum preferred distance
  105748. * @param minDistance The minimum preferred distance
  105749. */
  105750. updateDistance(maxDistance: number, minDistance?: number): void;
  105751. }
  105752. /**
  105753. * Represents a Motor-Enabled Joint
  105754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105755. */
  105756. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105757. /**
  105758. * Initializes the Motor-Enabled Joint
  105759. * @param type The type of the joint
  105760. * @param jointData The physica joint data for the joint
  105761. */
  105762. constructor(type: number, jointData: PhysicsJointData);
  105763. /**
  105764. * Set the motor values.
  105765. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105766. * @param force the force to apply
  105767. * @param maxForce max force for this motor.
  105768. */
  105769. setMotor(force?: number, maxForce?: number): void;
  105770. /**
  105771. * Set the motor's limits.
  105772. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105773. * @param upperLimit The upper limit of the motor
  105774. * @param lowerLimit The lower limit of the motor
  105775. */
  105776. setLimit(upperLimit: number, lowerLimit?: number): void;
  105777. }
  105778. /**
  105779. * This class represents a single physics Hinge-Joint
  105780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105781. */
  105782. export class HingeJoint extends MotorEnabledJoint {
  105783. /**
  105784. * Initializes the Hinge-Joint
  105785. * @param jointData The joint data for the Hinge-Joint
  105786. */
  105787. constructor(jointData: PhysicsJointData);
  105788. /**
  105789. * Set the motor values.
  105790. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105791. * @param {number} force the force to apply
  105792. * @param {number} maxForce max force for this motor.
  105793. */
  105794. setMotor(force?: number, maxForce?: number): void;
  105795. /**
  105796. * Set the motor's limits.
  105797. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105798. * @param upperLimit The upper limit of the motor
  105799. * @param lowerLimit The lower limit of the motor
  105800. */
  105801. setLimit(upperLimit: number, lowerLimit?: number): void;
  105802. }
  105803. /**
  105804. * This class represents a dual hinge physics joint (same as wheel joint)
  105805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105806. */
  105807. export class Hinge2Joint extends MotorEnabledJoint {
  105808. /**
  105809. * Initializes the Hinge2-Joint
  105810. * @param jointData The joint data for the Hinge2-Joint
  105811. */
  105812. constructor(jointData: PhysicsJointData);
  105813. /**
  105814. * Set the motor values.
  105815. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105816. * @param {number} targetSpeed the speed the motor is to reach
  105817. * @param {number} maxForce max force for this motor.
  105818. * @param {motorIndex} the motor's index, 0 or 1.
  105819. */
  105820. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  105821. /**
  105822. * Set the motor limits.
  105823. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105824. * @param {number} upperLimit the upper limit
  105825. * @param {number} lowerLimit lower limit
  105826. * @param {motorIndex} the motor's index, 0 or 1.
  105827. */
  105828. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105829. }
  105830. /**
  105831. * Interface for a motor enabled joint
  105832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105833. */
  105834. export interface IMotorEnabledJoint {
  105835. /**
  105836. * Physics joint
  105837. */
  105838. physicsJoint: any;
  105839. /**
  105840. * Sets the motor of the motor-enabled joint
  105841. * @param force The force of the motor
  105842. * @param maxForce The maximum force of the motor
  105843. * @param motorIndex The index of the motor
  105844. */
  105845. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  105846. /**
  105847. * Sets the limit of the motor
  105848. * @param upperLimit The upper limit of the motor
  105849. * @param lowerLimit The lower limit of the motor
  105850. * @param motorIndex The index of the motor
  105851. */
  105852. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105853. }
  105854. /**
  105855. * Joint data for a Distance-Joint
  105856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105857. */
  105858. export interface DistanceJointData extends PhysicsJointData {
  105859. /**
  105860. * Max distance the 2 joint objects can be apart
  105861. */
  105862. maxDistance: number;
  105863. }
  105864. /**
  105865. * Joint data from a spring joint
  105866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105867. */
  105868. export interface SpringJointData extends PhysicsJointData {
  105869. /**
  105870. * Length of the spring
  105871. */
  105872. length: number;
  105873. /**
  105874. * Stiffness of the spring
  105875. */
  105876. stiffness: number;
  105877. /**
  105878. * Damping of the spring
  105879. */
  105880. damping: number;
  105881. /** this callback will be called when applying the force to the impostors. */
  105882. forceApplicationCallback: () => void;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /**
  105887. * Holds the data for the raycast result
  105888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105889. */
  105890. export class PhysicsRaycastResult {
  105891. private _hasHit;
  105892. private _hitDistance;
  105893. private _hitNormalWorld;
  105894. private _hitPointWorld;
  105895. private _rayFromWorld;
  105896. private _rayToWorld;
  105897. /**
  105898. * Gets if there was a hit
  105899. */
  105900. get hasHit(): boolean;
  105901. /**
  105902. * Gets the distance from the hit
  105903. */
  105904. get hitDistance(): number;
  105905. /**
  105906. * Gets the hit normal/direction in the world
  105907. */
  105908. get hitNormalWorld(): Vector3;
  105909. /**
  105910. * Gets the hit point in the world
  105911. */
  105912. get hitPointWorld(): Vector3;
  105913. /**
  105914. * Gets the ray "start point" of the ray in the world
  105915. */
  105916. get rayFromWorld(): Vector3;
  105917. /**
  105918. * Gets the ray "end point" of the ray in the world
  105919. */
  105920. get rayToWorld(): Vector3;
  105921. /**
  105922. * Sets the hit data (normal & point in world space)
  105923. * @param hitNormalWorld defines the normal in world space
  105924. * @param hitPointWorld defines the point in world space
  105925. */
  105926. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  105927. /**
  105928. * Sets the distance from the start point to the hit point
  105929. * @param distance
  105930. */
  105931. setHitDistance(distance: number): void;
  105932. /**
  105933. * Calculates the distance manually
  105934. */
  105935. calculateHitDistance(): void;
  105936. /**
  105937. * Resets all the values to default
  105938. * @param from The from point on world space
  105939. * @param to The to point on world space
  105940. */
  105941. reset(from?: Vector3, to?: Vector3): void;
  105942. }
  105943. /**
  105944. * Interface for the size containing width and height
  105945. */
  105946. interface IXYZ {
  105947. /**
  105948. * X
  105949. */
  105950. x: number;
  105951. /**
  105952. * Y
  105953. */
  105954. y: number;
  105955. /**
  105956. * Z
  105957. */
  105958. z: number;
  105959. }
  105960. }
  105961. declare module BABYLON {
  105962. /**
  105963. * Interface used to describe a physics joint
  105964. */
  105965. export interface PhysicsImpostorJoint {
  105966. /** Defines the main impostor to which the joint is linked */
  105967. mainImpostor: PhysicsImpostor;
  105968. /** Defines the impostor that is connected to the main impostor using this joint */
  105969. connectedImpostor: PhysicsImpostor;
  105970. /** Defines the joint itself */
  105971. joint: PhysicsJoint;
  105972. }
  105973. /** @hidden */
  105974. export interface IPhysicsEnginePlugin {
  105975. world: any;
  105976. name: string;
  105977. setGravity(gravity: Vector3): void;
  105978. setTimeStep(timeStep: number): void;
  105979. getTimeStep(): number;
  105980. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105981. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105982. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105983. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105984. removePhysicsBody(impostor: PhysicsImpostor): void;
  105985. generateJoint(joint: PhysicsImpostorJoint): void;
  105986. removeJoint(joint: PhysicsImpostorJoint): void;
  105987. isSupported(): boolean;
  105988. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105989. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105990. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105991. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  105992. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105993. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105994. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105995. getBodyMass(impostor: PhysicsImpostor): number;
  105996. getBodyFriction(impostor: PhysicsImpostor): number;
  105997. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105998. getBodyRestitution(impostor: PhysicsImpostor): number;
  105999. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106000. getBodyPressure?(impostor: PhysicsImpostor): number;
  106001. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106002. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106003. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106004. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106005. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106006. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106007. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106008. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106009. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106010. sleepBody(impostor: PhysicsImpostor): void;
  106011. wakeUpBody(impostor: PhysicsImpostor): void;
  106012. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106013. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106014. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106015. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106016. getRadius(impostor: PhysicsImpostor): number;
  106017. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106018. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106019. dispose(): void;
  106020. }
  106021. /**
  106022. * Interface used to define a physics engine
  106023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106024. */
  106025. export interface IPhysicsEngine {
  106026. /**
  106027. * Gets the gravity vector used by the simulation
  106028. */
  106029. gravity: Vector3;
  106030. /**
  106031. * Sets the gravity vector used by the simulation
  106032. * @param gravity defines the gravity vector to use
  106033. */
  106034. setGravity(gravity: Vector3): void;
  106035. /**
  106036. * Set the time step of the physics engine.
  106037. * Default is 1/60.
  106038. * To slow it down, enter 1/600 for example.
  106039. * To speed it up, 1/30
  106040. * @param newTimeStep the new timestep to apply to this world.
  106041. */
  106042. setTimeStep(newTimeStep: number): void;
  106043. /**
  106044. * Get the time step of the physics engine.
  106045. * @returns the current time step
  106046. */
  106047. getTimeStep(): number;
  106048. /**
  106049. * Set the sub time step of the physics engine.
  106050. * Default is 0 meaning there is no sub steps
  106051. * To increase physics resolution precision, set a small value (like 1 ms)
  106052. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106053. */
  106054. setSubTimeStep(subTimeStep: number): void;
  106055. /**
  106056. * Get the sub time step of the physics engine.
  106057. * @returns the current sub time step
  106058. */
  106059. getSubTimeStep(): number;
  106060. /**
  106061. * Release all resources
  106062. */
  106063. dispose(): void;
  106064. /**
  106065. * Gets the name of the current physics plugin
  106066. * @returns the name of the plugin
  106067. */
  106068. getPhysicsPluginName(): string;
  106069. /**
  106070. * Adding a new impostor for the impostor tracking.
  106071. * This will be done by the impostor itself.
  106072. * @param impostor the impostor to add
  106073. */
  106074. addImpostor(impostor: PhysicsImpostor): void;
  106075. /**
  106076. * Remove an impostor from the engine.
  106077. * This impostor and its mesh will not longer be updated by the physics engine.
  106078. * @param impostor the impostor to remove
  106079. */
  106080. removeImpostor(impostor: PhysicsImpostor): void;
  106081. /**
  106082. * Add a joint to the physics engine
  106083. * @param mainImpostor defines the main impostor to which the joint is added.
  106084. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106085. * @param joint defines the joint that will connect both impostors.
  106086. */
  106087. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106088. /**
  106089. * Removes a joint from the simulation
  106090. * @param mainImpostor defines the impostor used with the joint
  106091. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106092. * @param joint defines the joint to remove
  106093. */
  106094. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106095. /**
  106096. * Gets the current plugin used to run the simulation
  106097. * @returns current plugin
  106098. */
  106099. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106100. /**
  106101. * Gets the list of physic impostors
  106102. * @returns an array of PhysicsImpostor
  106103. */
  106104. getImpostors(): Array<PhysicsImpostor>;
  106105. /**
  106106. * Gets the impostor for a physics enabled object
  106107. * @param object defines the object impersonated by the impostor
  106108. * @returns the PhysicsImpostor or null if not found
  106109. */
  106110. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106111. /**
  106112. * Gets the impostor for a physics body object
  106113. * @param body defines physics body used by the impostor
  106114. * @returns the PhysicsImpostor or null if not found
  106115. */
  106116. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106117. /**
  106118. * Does a raycast in the physics world
  106119. * @param from when should the ray start?
  106120. * @param to when should the ray end?
  106121. * @returns PhysicsRaycastResult
  106122. */
  106123. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106124. /**
  106125. * Called by the scene. No need to call it.
  106126. * @param delta defines the timespam between frames
  106127. */
  106128. _step(delta: number): void;
  106129. }
  106130. }
  106131. declare module BABYLON {
  106132. /**
  106133. * The interface for the physics imposter parameters
  106134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106135. */
  106136. export interface PhysicsImpostorParameters {
  106137. /**
  106138. * The mass of the physics imposter
  106139. */
  106140. mass: number;
  106141. /**
  106142. * The friction of the physics imposter
  106143. */
  106144. friction?: number;
  106145. /**
  106146. * The coefficient of restitution of the physics imposter
  106147. */
  106148. restitution?: number;
  106149. /**
  106150. * The native options of the physics imposter
  106151. */
  106152. nativeOptions?: any;
  106153. /**
  106154. * Specifies if the parent should be ignored
  106155. */
  106156. ignoreParent?: boolean;
  106157. /**
  106158. * Specifies if bi-directional transformations should be disabled
  106159. */
  106160. disableBidirectionalTransformation?: boolean;
  106161. /**
  106162. * The pressure inside the physics imposter, soft object only
  106163. */
  106164. pressure?: number;
  106165. /**
  106166. * The stiffness the physics imposter, soft object only
  106167. */
  106168. stiffness?: number;
  106169. /**
  106170. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106171. */
  106172. velocityIterations?: number;
  106173. /**
  106174. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106175. */
  106176. positionIterations?: number;
  106177. /**
  106178. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106179. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106180. * Add to fix multiple points
  106181. */
  106182. fixedPoints?: number;
  106183. /**
  106184. * The collision margin around a soft object
  106185. */
  106186. margin?: number;
  106187. /**
  106188. * The collision margin around a soft object
  106189. */
  106190. damping?: number;
  106191. /**
  106192. * The path for a rope based on an extrusion
  106193. */
  106194. path?: any;
  106195. /**
  106196. * The shape of an extrusion used for a rope based on an extrusion
  106197. */
  106198. shape?: any;
  106199. }
  106200. /**
  106201. * Interface for a physics-enabled object
  106202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106203. */
  106204. export interface IPhysicsEnabledObject {
  106205. /**
  106206. * The position of the physics-enabled object
  106207. */
  106208. position: Vector3;
  106209. /**
  106210. * The rotation of the physics-enabled object
  106211. */
  106212. rotationQuaternion: Nullable<Quaternion>;
  106213. /**
  106214. * The scale of the physics-enabled object
  106215. */
  106216. scaling: Vector3;
  106217. /**
  106218. * The rotation of the physics-enabled object
  106219. */
  106220. rotation?: Vector3;
  106221. /**
  106222. * The parent of the physics-enabled object
  106223. */
  106224. parent?: any;
  106225. /**
  106226. * The bounding info of the physics-enabled object
  106227. * @returns The bounding info of the physics-enabled object
  106228. */
  106229. getBoundingInfo(): BoundingInfo;
  106230. /**
  106231. * Computes the world matrix
  106232. * @param force Specifies if the world matrix should be computed by force
  106233. * @returns A world matrix
  106234. */
  106235. computeWorldMatrix(force: boolean): Matrix;
  106236. /**
  106237. * Gets the world matrix
  106238. * @returns A world matrix
  106239. */
  106240. getWorldMatrix?(): Matrix;
  106241. /**
  106242. * Gets the child meshes
  106243. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106244. * @returns An array of abstract meshes
  106245. */
  106246. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106247. /**
  106248. * Gets the vertex data
  106249. * @param kind The type of vertex data
  106250. * @returns A nullable array of numbers, or a float32 array
  106251. */
  106252. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106253. /**
  106254. * Gets the indices from the mesh
  106255. * @returns A nullable array of index arrays
  106256. */
  106257. getIndices?(): Nullable<IndicesArray>;
  106258. /**
  106259. * Gets the scene from the mesh
  106260. * @returns the indices array or null
  106261. */
  106262. getScene?(): Scene;
  106263. /**
  106264. * Gets the absolute position from the mesh
  106265. * @returns the absolute position
  106266. */
  106267. getAbsolutePosition(): Vector3;
  106268. /**
  106269. * Gets the absolute pivot point from the mesh
  106270. * @returns the absolute pivot point
  106271. */
  106272. getAbsolutePivotPoint(): Vector3;
  106273. /**
  106274. * Rotates the mesh
  106275. * @param axis The axis of rotation
  106276. * @param amount The amount of rotation
  106277. * @param space The space of the rotation
  106278. * @returns The rotation transform node
  106279. */
  106280. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106281. /**
  106282. * Translates the mesh
  106283. * @param axis The axis of translation
  106284. * @param distance The distance of translation
  106285. * @param space The space of the translation
  106286. * @returns The transform node
  106287. */
  106288. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106289. /**
  106290. * Sets the absolute position of the mesh
  106291. * @param absolutePosition The absolute position of the mesh
  106292. * @returns The transform node
  106293. */
  106294. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106295. /**
  106296. * Gets the class name of the mesh
  106297. * @returns The class name
  106298. */
  106299. getClassName(): string;
  106300. }
  106301. /**
  106302. * Represents a physics imposter
  106303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106304. */
  106305. export class PhysicsImpostor {
  106306. /**
  106307. * The physics-enabled object used as the physics imposter
  106308. */
  106309. object: IPhysicsEnabledObject;
  106310. /**
  106311. * The type of the physics imposter
  106312. */
  106313. type: number;
  106314. private _options;
  106315. private _scene?;
  106316. /**
  106317. * The default object size of the imposter
  106318. */
  106319. static DEFAULT_OBJECT_SIZE: Vector3;
  106320. /**
  106321. * The identity quaternion of the imposter
  106322. */
  106323. static IDENTITY_QUATERNION: Quaternion;
  106324. /** @hidden */
  106325. _pluginData: any;
  106326. private _physicsEngine;
  106327. private _physicsBody;
  106328. private _bodyUpdateRequired;
  106329. private _onBeforePhysicsStepCallbacks;
  106330. private _onAfterPhysicsStepCallbacks;
  106331. /** @hidden */
  106332. _onPhysicsCollideCallbacks: Array<{
  106333. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106334. otherImpostors: Array<PhysicsImpostor>;
  106335. }>;
  106336. private _deltaPosition;
  106337. private _deltaRotation;
  106338. private _deltaRotationConjugated;
  106339. /** @hidden */
  106340. _isFromLine: boolean;
  106341. private _parent;
  106342. private _isDisposed;
  106343. private static _tmpVecs;
  106344. private static _tmpQuat;
  106345. /**
  106346. * Specifies if the physics imposter is disposed
  106347. */
  106348. get isDisposed(): boolean;
  106349. /**
  106350. * Gets the mass of the physics imposter
  106351. */
  106352. get mass(): number;
  106353. set mass(value: number);
  106354. /**
  106355. * Gets the coefficient of friction
  106356. */
  106357. get friction(): number;
  106358. /**
  106359. * Sets the coefficient of friction
  106360. */
  106361. set friction(value: number);
  106362. /**
  106363. * Gets the coefficient of restitution
  106364. */
  106365. get restitution(): number;
  106366. /**
  106367. * Sets the coefficient of restitution
  106368. */
  106369. set restitution(value: number);
  106370. /**
  106371. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106372. */
  106373. get pressure(): number;
  106374. /**
  106375. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106376. */
  106377. set pressure(value: number);
  106378. /**
  106379. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106380. */
  106381. get stiffness(): number;
  106382. /**
  106383. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106384. */
  106385. set stiffness(value: number);
  106386. /**
  106387. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106388. */
  106389. get velocityIterations(): number;
  106390. /**
  106391. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106392. */
  106393. set velocityIterations(value: number);
  106394. /**
  106395. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106396. */
  106397. get positionIterations(): number;
  106398. /**
  106399. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106400. */
  106401. set positionIterations(value: number);
  106402. /**
  106403. * The unique id of the physics imposter
  106404. * set by the physics engine when adding this impostor to the array
  106405. */
  106406. uniqueId: number;
  106407. /**
  106408. * @hidden
  106409. */
  106410. soft: boolean;
  106411. /**
  106412. * @hidden
  106413. */
  106414. segments: number;
  106415. private _joints;
  106416. /**
  106417. * Initializes the physics imposter
  106418. * @param object The physics-enabled object used as the physics imposter
  106419. * @param type The type of the physics imposter
  106420. * @param _options The options for the physics imposter
  106421. * @param _scene The Babylon scene
  106422. */
  106423. constructor(
  106424. /**
  106425. * The physics-enabled object used as the physics imposter
  106426. */
  106427. object: IPhysicsEnabledObject,
  106428. /**
  106429. * The type of the physics imposter
  106430. */
  106431. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106432. /**
  106433. * This function will completly initialize this impostor.
  106434. * It will create a new body - but only if this mesh has no parent.
  106435. * If it has, this impostor will not be used other than to define the impostor
  106436. * of the child mesh.
  106437. * @hidden
  106438. */
  106439. _init(): void;
  106440. private _getPhysicsParent;
  106441. /**
  106442. * Should a new body be generated.
  106443. * @returns boolean specifying if body initialization is required
  106444. */
  106445. isBodyInitRequired(): boolean;
  106446. /**
  106447. * Sets the updated scaling
  106448. * @param updated Specifies if the scaling is updated
  106449. */
  106450. setScalingUpdated(): void;
  106451. /**
  106452. * Force a regeneration of this or the parent's impostor's body.
  106453. * Use under cautious - This will remove all joints already implemented.
  106454. */
  106455. forceUpdate(): void;
  106456. /**
  106457. * Gets the body that holds this impostor. Either its own, or its parent.
  106458. */
  106459. get physicsBody(): any;
  106460. /**
  106461. * Get the parent of the physics imposter
  106462. * @returns Physics imposter or null
  106463. */
  106464. get parent(): Nullable<PhysicsImpostor>;
  106465. /**
  106466. * Sets the parent of the physics imposter
  106467. */
  106468. set parent(value: Nullable<PhysicsImpostor>);
  106469. /**
  106470. * Set the physics body. Used mainly by the physics engine/plugin
  106471. */
  106472. set physicsBody(physicsBody: any);
  106473. /**
  106474. * Resets the update flags
  106475. */
  106476. resetUpdateFlags(): void;
  106477. /**
  106478. * Gets the object extend size
  106479. * @returns the object extend size
  106480. */
  106481. getObjectExtendSize(): Vector3;
  106482. /**
  106483. * Gets the object center
  106484. * @returns The object center
  106485. */
  106486. getObjectCenter(): Vector3;
  106487. /**
  106488. * Get a specific parameter from the options parameters
  106489. * @param paramName The object parameter name
  106490. * @returns The object parameter
  106491. */
  106492. getParam(paramName: string): any;
  106493. /**
  106494. * Sets a specific parameter in the options given to the physics plugin
  106495. * @param paramName The parameter name
  106496. * @param value The value of the parameter
  106497. */
  106498. setParam(paramName: string, value: number): void;
  106499. /**
  106500. * Specifically change the body's mass option. Won't recreate the physics body object
  106501. * @param mass The mass of the physics imposter
  106502. */
  106503. setMass(mass: number): void;
  106504. /**
  106505. * Gets the linear velocity
  106506. * @returns linear velocity or null
  106507. */
  106508. getLinearVelocity(): Nullable<Vector3>;
  106509. /**
  106510. * Sets the linear velocity
  106511. * @param velocity linear velocity or null
  106512. */
  106513. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106514. /**
  106515. * Gets the angular velocity
  106516. * @returns angular velocity or null
  106517. */
  106518. getAngularVelocity(): Nullable<Vector3>;
  106519. /**
  106520. * Sets the angular velocity
  106521. * @param velocity The velocity or null
  106522. */
  106523. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106524. /**
  106525. * Execute a function with the physics plugin native code
  106526. * Provide a function the will have two variables - the world object and the physics body object
  106527. * @param func The function to execute with the physics plugin native code
  106528. */
  106529. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106530. /**
  106531. * Register a function that will be executed before the physics world is stepping forward
  106532. * @param func The function to execute before the physics world is stepped forward
  106533. */
  106534. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106535. /**
  106536. * Unregister a function that will be executed before the physics world is stepping forward
  106537. * @param func The function to execute before the physics world is stepped forward
  106538. */
  106539. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106540. /**
  106541. * Register a function that will be executed after the physics step
  106542. * @param func The function to execute after physics step
  106543. */
  106544. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106545. /**
  106546. * Unregisters a function that will be executed after the physics step
  106547. * @param func The function to execute after physics step
  106548. */
  106549. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106550. /**
  106551. * register a function that will be executed when this impostor collides against a different body
  106552. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106553. * @param func Callback that is executed on collision
  106554. */
  106555. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106556. /**
  106557. * Unregisters the physics imposter on contact
  106558. * @param collideAgainst The physics object to collide against
  106559. * @param func Callback to execute on collision
  106560. */
  106561. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106562. private _tmpQuat;
  106563. private _tmpQuat2;
  106564. /**
  106565. * Get the parent rotation
  106566. * @returns The parent rotation
  106567. */
  106568. getParentsRotation(): Quaternion;
  106569. /**
  106570. * this function is executed by the physics engine.
  106571. */
  106572. beforeStep: () => void;
  106573. /**
  106574. * this function is executed by the physics engine
  106575. */
  106576. afterStep: () => void;
  106577. /**
  106578. * Legacy collision detection event support
  106579. */
  106580. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106581. /**
  106582. * event and body object due to cannon's event-based architecture.
  106583. */
  106584. onCollide: (e: {
  106585. body: any;
  106586. }) => void;
  106587. /**
  106588. * Apply a force
  106589. * @param force The force to apply
  106590. * @param contactPoint The contact point for the force
  106591. * @returns The physics imposter
  106592. */
  106593. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106594. /**
  106595. * Apply an impulse
  106596. * @param force The impulse force
  106597. * @param contactPoint The contact point for the impulse force
  106598. * @returns The physics imposter
  106599. */
  106600. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106601. /**
  106602. * A help function to create a joint
  106603. * @param otherImpostor A physics imposter used to create a joint
  106604. * @param jointType The type of joint
  106605. * @param jointData The data for the joint
  106606. * @returns The physics imposter
  106607. */
  106608. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106609. /**
  106610. * Add a joint to this impostor with a different impostor
  106611. * @param otherImpostor A physics imposter used to add a joint
  106612. * @param joint The joint to add
  106613. * @returns The physics imposter
  106614. */
  106615. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106616. /**
  106617. * Add an anchor to a cloth impostor
  106618. * @param otherImpostor rigid impostor to anchor to
  106619. * @param width ratio across width from 0 to 1
  106620. * @param height ratio up height from 0 to 1
  106621. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106622. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106623. * @returns impostor the soft imposter
  106624. */
  106625. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106626. /**
  106627. * Add a hook to a rope impostor
  106628. * @param otherImpostor rigid impostor to anchor to
  106629. * @param length ratio across rope from 0 to 1
  106630. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106631. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106632. * @returns impostor the rope imposter
  106633. */
  106634. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106635. /**
  106636. * Will keep this body still, in a sleep mode.
  106637. * @returns the physics imposter
  106638. */
  106639. sleep(): PhysicsImpostor;
  106640. /**
  106641. * Wake the body up.
  106642. * @returns The physics imposter
  106643. */
  106644. wakeUp(): PhysicsImpostor;
  106645. /**
  106646. * Clones the physics imposter
  106647. * @param newObject The physics imposter clones to this physics-enabled object
  106648. * @returns A nullable physics imposter
  106649. */
  106650. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106651. /**
  106652. * Disposes the physics imposter
  106653. */
  106654. dispose(): void;
  106655. /**
  106656. * Sets the delta position
  106657. * @param position The delta position amount
  106658. */
  106659. setDeltaPosition(position: Vector3): void;
  106660. /**
  106661. * Sets the delta rotation
  106662. * @param rotation The delta rotation amount
  106663. */
  106664. setDeltaRotation(rotation: Quaternion): void;
  106665. /**
  106666. * Gets the box size of the physics imposter and stores the result in the input parameter
  106667. * @param result Stores the box size
  106668. * @returns The physics imposter
  106669. */
  106670. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106671. /**
  106672. * Gets the radius of the physics imposter
  106673. * @returns Radius of the physics imposter
  106674. */
  106675. getRadius(): number;
  106676. /**
  106677. * Sync a bone with this impostor
  106678. * @param bone The bone to sync to the impostor.
  106679. * @param boneMesh The mesh that the bone is influencing.
  106680. * @param jointPivot The pivot of the joint / bone in local space.
  106681. * @param distToJoint Optional distance from the impostor to the joint.
  106682. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106683. */
  106684. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106685. /**
  106686. * Sync impostor to a bone
  106687. * @param bone The bone that the impostor will be synced to.
  106688. * @param boneMesh The mesh that the bone is influencing.
  106689. * @param jointPivot The pivot of the joint / bone in local space.
  106690. * @param distToJoint Optional distance from the impostor to the joint.
  106691. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106692. * @param boneAxis Optional vector3 axis the bone is aligned with
  106693. */
  106694. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106695. /**
  106696. * No-Imposter type
  106697. */
  106698. static NoImpostor: number;
  106699. /**
  106700. * Sphere-Imposter type
  106701. */
  106702. static SphereImpostor: number;
  106703. /**
  106704. * Box-Imposter type
  106705. */
  106706. static BoxImpostor: number;
  106707. /**
  106708. * Plane-Imposter type
  106709. */
  106710. static PlaneImpostor: number;
  106711. /**
  106712. * Mesh-imposter type
  106713. */
  106714. static MeshImpostor: number;
  106715. /**
  106716. * Capsule-Impostor type (Ammo.js plugin only)
  106717. */
  106718. static CapsuleImpostor: number;
  106719. /**
  106720. * Cylinder-Imposter type
  106721. */
  106722. static CylinderImpostor: number;
  106723. /**
  106724. * Particle-Imposter type
  106725. */
  106726. static ParticleImpostor: number;
  106727. /**
  106728. * Heightmap-Imposter type
  106729. */
  106730. static HeightmapImpostor: number;
  106731. /**
  106732. * ConvexHull-Impostor type (Ammo.js plugin only)
  106733. */
  106734. static ConvexHullImpostor: number;
  106735. /**
  106736. * Custom-Imposter type (Ammo.js plugin only)
  106737. */
  106738. static CustomImpostor: number;
  106739. /**
  106740. * Rope-Imposter type
  106741. */
  106742. static RopeImpostor: number;
  106743. /**
  106744. * Cloth-Imposter type
  106745. */
  106746. static ClothImpostor: number;
  106747. /**
  106748. * Softbody-Imposter type
  106749. */
  106750. static SoftbodyImpostor: number;
  106751. }
  106752. }
  106753. declare module BABYLON {
  106754. /**
  106755. * @hidden
  106756. **/
  106757. export class _CreationDataStorage {
  106758. closePath?: boolean;
  106759. closeArray?: boolean;
  106760. idx: number[];
  106761. dashSize: number;
  106762. gapSize: number;
  106763. path3D: Path3D;
  106764. pathArray: Vector3[][];
  106765. arc: number;
  106766. radius: number;
  106767. cap: number;
  106768. tessellation: number;
  106769. }
  106770. /**
  106771. * @hidden
  106772. **/
  106773. class _InstanceDataStorage {
  106774. visibleInstances: any;
  106775. batchCache: _InstancesBatch;
  106776. instancesBufferSize: number;
  106777. instancesBuffer: Nullable<Buffer>;
  106778. instancesData: Float32Array;
  106779. overridenInstanceCount: number;
  106780. isFrozen: boolean;
  106781. previousBatch: Nullable<_InstancesBatch>;
  106782. hardwareInstancedRendering: boolean;
  106783. sideOrientation: number;
  106784. manualUpdate: boolean;
  106785. }
  106786. /**
  106787. * @hidden
  106788. **/
  106789. export class _InstancesBatch {
  106790. mustReturn: boolean;
  106791. visibleInstances: Nullable<InstancedMesh[]>[];
  106792. renderSelf: boolean[];
  106793. hardwareInstancedRendering: boolean[];
  106794. }
  106795. /**
  106796. * @hidden
  106797. **/
  106798. class _ThinInstanceDataStorage {
  106799. instancesCount: number;
  106800. matrixBuffer: Nullable<Buffer>;
  106801. matrixBufferSize: number;
  106802. matrixData: Nullable<Float32Array>;
  106803. boundingVectors: Array<Vector3>;
  106804. worldMatrices: Nullable<Matrix[]>;
  106805. }
  106806. /**
  106807. * Class used to represent renderable models
  106808. */
  106809. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  106810. /**
  106811. * Mesh side orientation : usually the external or front surface
  106812. */
  106813. static readonly FRONTSIDE: number;
  106814. /**
  106815. * Mesh side orientation : usually the internal or back surface
  106816. */
  106817. static readonly BACKSIDE: number;
  106818. /**
  106819. * Mesh side orientation : both internal and external or front and back surfaces
  106820. */
  106821. static readonly DOUBLESIDE: number;
  106822. /**
  106823. * Mesh side orientation : by default, `FRONTSIDE`
  106824. */
  106825. static readonly DEFAULTSIDE: number;
  106826. /**
  106827. * Mesh cap setting : no cap
  106828. */
  106829. static readonly NO_CAP: number;
  106830. /**
  106831. * Mesh cap setting : one cap at the beginning of the mesh
  106832. */
  106833. static readonly CAP_START: number;
  106834. /**
  106835. * Mesh cap setting : one cap at the end of the mesh
  106836. */
  106837. static readonly CAP_END: number;
  106838. /**
  106839. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  106840. */
  106841. static readonly CAP_ALL: number;
  106842. /**
  106843. * Mesh pattern setting : no flip or rotate
  106844. */
  106845. static readonly NO_FLIP: number;
  106846. /**
  106847. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  106848. */
  106849. static readonly FLIP_TILE: number;
  106850. /**
  106851. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  106852. */
  106853. static readonly ROTATE_TILE: number;
  106854. /**
  106855. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  106856. */
  106857. static readonly FLIP_ROW: number;
  106858. /**
  106859. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  106860. */
  106861. static readonly ROTATE_ROW: number;
  106862. /**
  106863. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  106864. */
  106865. static readonly FLIP_N_ROTATE_TILE: number;
  106866. /**
  106867. * Mesh pattern setting : rotate pattern and rotate
  106868. */
  106869. static readonly FLIP_N_ROTATE_ROW: number;
  106870. /**
  106871. * Mesh tile positioning : part tiles same on left/right or top/bottom
  106872. */
  106873. static readonly CENTER: number;
  106874. /**
  106875. * Mesh tile positioning : part tiles on left
  106876. */
  106877. static readonly LEFT: number;
  106878. /**
  106879. * Mesh tile positioning : part tiles on right
  106880. */
  106881. static readonly RIGHT: number;
  106882. /**
  106883. * Mesh tile positioning : part tiles on top
  106884. */
  106885. static readonly TOP: number;
  106886. /**
  106887. * Mesh tile positioning : part tiles on bottom
  106888. */
  106889. static readonly BOTTOM: number;
  106890. /**
  106891. * Gets the default side orientation.
  106892. * @param orientation the orientation to value to attempt to get
  106893. * @returns the default orientation
  106894. * @hidden
  106895. */
  106896. static _GetDefaultSideOrientation(orientation?: number): number;
  106897. private _internalMeshDataInfo;
  106898. get computeBonesUsingShaders(): boolean;
  106899. set computeBonesUsingShaders(value: boolean);
  106900. /**
  106901. * An event triggered before rendering the mesh
  106902. */
  106903. get onBeforeRenderObservable(): Observable<Mesh>;
  106904. /**
  106905. * An event triggered before binding the mesh
  106906. */
  106907. get onBeforeBindObservable(): Observable<Mesh>;
  106908. /**
  106909. * An event triggered after rendering the mesh
  106910. */
  106911. get onAfterRenderObservable(): Observable<Mesh>;
  106912. /**
  106913. * An event triggered before drawing the mesh
  106914. */
  106915. get onBeforeDrawObservable(): Observable<Mesh>;
  106916. private _onBeforeDrawObserver;
  106917. /**
  106918. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  106919. */
  106920. set onBeforeDraw(callback: () => void);
  106921. get hasInstances(): boolean;
  106922. get hasThinInstances(): boolean;
  106923. /**
  106924. * Gets the delay loading state of the mesh (when delay loading is turned on)
  106925. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  106926. */
  106927. delayLoadState: number;
  106928. /**
  106929. * Gets the list of instances created from this mesh
  106930. * it is not supposed to be modified manually.
  106931. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  106932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106933. */
  106934. instances: InstancedMesh[];
  106935. /**
  106936. * Gets the file containing delay loading data for this mesh
  106937. */
  106938. delayLoadingFile: string;
  106939. /** @hidden */
  106940. _binaryInfo: any;
  106941. /**
  106942. * User defined function used to change how LOD level selection is done
  106943. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106944. */
  106945. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  106946. /**
  106947. * Gets or sets the morph target manager
  106948. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106949. */
  106950. get morphTargetManager(): Nullable<MorphTargetManager>;
  106951. set morphTargetManager(value: Nullable<MorphTargetManager>);
  106952. /** @hidden */
  106953. _creationDataStorage: Nullable<_CreationDataStorage>;
  106954. /** @hidden */
  106955. _geometry: Nullable<Geometry>;
  106956. /** @hidden */
  106957. _delayInfo: Array<string>;
  106958. /** @hidden */
  106959. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  106960. /** @hidden */
  106961. _instanceDataStorage: _InstanceDataStorage;
  106962. /** @hidden */
  106963. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  106964. private _effectiveMaterial;
  106965. /** @hidden */
  106966. _shouldGenerateFlatShading: boolean;
  106967. /** @hidden */
  106968. _originalBuilderSideOrientation: number;
  106969. /**
  106970. * Use this property to change the original side orientation defined at construction time
  106971. */
  106972. overrideMaterialSideOrientation: Nullable<number>;
  106973. /**
  106974. * Gets the source mesh (the one used to clone this one from)
  106975. */
  106976. get source(): Nullable<Mesh>;
  106977. /**
  106978. * Gets or sets a boolean indicating that this mesh does not use index buffer
  106979. */
  106980. get isUnIndexed(): boolean;
  106981. set isUnIndexed(value: boolean);
  106982. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  106983. get worldMatrixInstancedBuffer(): Float32Array;
  106984. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  106985. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  106986. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  106987. /**
  106988. * @constructor
  106989. * @param name The value used by scene.getMeshByName() to do a lookup.
  106990. * @param scene The scene to add this mesh to.
  106991. * @param parent The parent of this mesh, if it has one
  106992. * @param source An optional Mesh from which geometry is shared, cloned.
  106993. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  106994. * When false, achieved by calling a clone(), also passing False.
  106995. * This will make creation of children, recursive.
  106996. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  106997. */
  106998. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  106999. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107000. doNotInstantiate: boolean;
  107001. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107002. /**
  107003. * Gets the class name
  107004. * @returns the string "Mesh".
  107005. */
  107006. getClassName(): string;
  107007. /** @hidden */
  107008. get _isMesh(): boolean;
  107009. /**
  107010. * Returns a description of this mesh
  107011. * @param fullDetails define if full details about this mesh must be used
  107012. * @returns a descriptive string representing this mesh
  107013. */
  107014. toString(fullDetails?: boolean): string;
  107015. /** @hidden */
  107016. _unBindEffect(): void;
  107017. /**
  107018. * Gets a boolean indicating if this mesh has LOD
  107019. */
  107020. get hasLODLevels(): boolean;
  107021. /**
  107022. * Gets the list of MeshLODLevel associated with the current mesh
  107023. * @returns an array of MeshLODLevel
  107024. */
  107025. getLODLevels(): MeshLODLevel[];
  107026. private _sortLODLevels;
  107027. /**
  107028. * Add a mesh as LOD level triggered at the given distance.
  107029. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107030. * @param distance The distance from the center of the object to show this level
  107031. * @param mesh The mesh to be added as LOD level (can be null)
  107032. * @return This mesh (for chaining)
  107033. */
  107034. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107035. /**
  107036. * Returns the LOD level mesh at the passed distance or null if not found.
  107037. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107038. * @param distance The distance from the center of the object to show this level
  107039. * @returns a Mesh or `null`
  107040. */
  107041. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107042. /**
  107043. * Remove a mesh from the LOD array
  107044. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107045. * @param mesh defines the mesh to be removed
  107046. * @return This mesh (for chaining)
  107047. */
  107048. removeLODLevel(mesh: Mesh): Mesh;
  107049. /**
  107050. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107051. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107052. * @param camera defines the camera to use to compute distance
  107053. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107054. * @return This mesh (for chaining)
  107055. */
  107056. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107057. /**
  107058. * Gets the mesh internal Geometry object
  107059. */
  107060. get geometry(): Nullable<Geometry>;
  107061. /**
  107062. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107063. * @returns the total number of vertices
  107064. */
  107065. getTotalVertices(): number;
  107066. /**
  107067. * Returns the content of an associated vertex buffer
  107068. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107069. * - VertexBuffer.PositionKind
  107070. * - VertexBuffer.UVKind
  107071. * - VertexBuffer.UV2Kind
  107072. * - VertexBuffer.UV3Kind
  107073. * - VertexBuffer.UV4Kind
  107074. * - VertexBuffer.UV5Kind
  107075. * - VertexBuffer.UV6Kind
  107076. * - VertexBuffer.ColorKind
  107077. * - VertexBuffer.MatricesIndicesKind
  107078. * - VertexBuffer.MatricesIndicesExtraKind
  107079. * - VertexBuffer.MatricesWeightsKind
  107080. * - VertexBuffer.MatricesWeightsExtraKind
  107081. * @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
  107082. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107083. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107084. */
  107085. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107086. /**
  107087. * Returns the mesh VertexBuffer object from the requested `kind`
  107088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107089. * - VertexBuffer.PositionKind
  107090. * - VertexBuffer.NormalKind
  107091. * - VertexBuffer.UVKind
  107092. * - VertexBuffer.UV2Kind
  107093. * - VertexBuffer.UV3Kind
  107094. * - VertexBuffer.UV4Kind
  107095. * - VertexBuffer.UV5Kind
  107096. * - VertexBuffer.UV6Kind
  107097. * - VertexBuffer.ColorKind
  107098. * - VertexBuffer.MatricesIndicesKind
  107099. * - VertexBuffer.MatricesIndicesExtraKind
  107100. * - VertexBuffer.MatricesWeightsKind
  107101. * - VertexBuffer.MatricesWeightsExtraKind
  107102. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107103. */
  107104. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107105. /**
  107106. * Tests if a specific vertex buffer is associated with this mesh
  107107. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107108. * - VertexBuffer.PositionKind
  107109. * - VertexBuffer.NormalKind
  107110. * - VertexBuffer.UVKind
  107111. * - VertexBuffer.UV2Kind
  107112. * - VertexBuffer.UV3Kind
  107113. * - VertexBuffer.UV4Kind
  107114. * - VertexBuffer.UV5Kind
  107115. * - VertexBuffer.UV6Kind
  107116. * - VertexBuffer.ColorKind
  107117. * - VertexBuffer.MatricesIndicesKind
  107118. * - VertexBuffer.MatricesIndicesExtraKind
  107119. * - VertexBuffer.MatricesWeightsKind
  107120. * - VertexBuffer.MatricesWeightsExtraKind
  107121. * @returns a boolean
  107122. */
  107123. isVerticesDataPresent(kind: string): boolean;
  107124. /**
  107125. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107126. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107127. * - VertexBuffer.PositionKind
  107128. * - VertexBuffer.UVKind
  107129. * - VertexBuffer.UV2Kind
  107130. * - VertexBuffer.UV3Kind
  107131. * - VertexBuffer.UV4Kind
  107132. * - VertexBuffer.UV5Kind
  107133. * - VertexBuffer.UV6Kind
  107134. * - VertexBuffer.ColorKind
  107135. * - VertexBuffer.MatricesIndicesKind
  107136. * - VertexBuffer.MatricesIndicesExtraKind
  107137. * - VertexBuffer.MatricesWeightsKind
  107138. * - VertexBuffer.MatricesWeightsExtraKind
  107139. * @returns a boolean
  107140. */
  107141. isVertexBufferUpdatable(kind: string): boolean;
  107142. /**
  107143. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107144. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107145. * - VertexBuffer.PositionKind
  107146. * - VertexBuffer.NormalKind
  107147. * - VertexBuffer.UVKind
  107148. * - VertexBuffer.UV2Kind
  107149. * - VertexBuffer.UV3Kind
  107150. * - VertexBuffer.UV4Kind
  107151. * - VertexBuffer.UV5Kind
  107152. * - VertexBuffer.UV6Kind
  107153. * - VertexBuffer.ColorKind
  107154. * - VertexBuffer.MatricesIndicesKind
  107155. * - VertexBuffer.MatricesIndicesExtraKind
  107156. * - VertexBuffer.MatricesWeightsKind
  107157. * - VertexBuffer.MatricesWeightsExtraKind
  107158. * @returns an array of strings
  107159. */
  107160. getVerticesDataKinds(): string[];
  107161. /**
  107162. * Returns a positive integer : the total number of indices in this mesh geometry.
  107163. * @returns the numner of indices or zero if the mesh has no geometry.
  107164. */
  107165. getTotalIndices(): number;
  107166. /**
  107167. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107168. * @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.
  107169. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107170. * @returns the indices array or an empty array if the mesh has no geometry
  107171. */
  107172. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107173. get isBlocked(): boolean;
  107174. /**
  107175. * Determine if the current mesh is ready to be rendered
  107176. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107177. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107178. * @returns true if all associated assets are ready (material, textures, shaders)
  107179. */
  107180. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107181. /**
  107182. * 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.
  107183. */
  107184. get areNormalsFrozen(): boolean;
  107185. /**
  107186. * 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.
  107187. * @returns the current mesh
  107188. */
  107189. freezeNormals(): Mesh;
  107190. /**
  107191. * 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
  107192. * @returns the current mesh
  107193. */
  107194. unfreezeNormals(): Mesh;
  107195. /**
  107196. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107197. */
  107198. set overridenInstanceCount(count: number);
  107199. /** @hidden */
  107200. _preActivate(): Mesh;
  107201. /** @hidden */
  107202. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107203. /** @hidden */
  107204. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107205. protected _afterComputeWorldMatrix(): void;
  107206. /** @hidden */
  107207. _postActivate(): void;
  107208. /**
  107209. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107210. * This means the mesh underlying bounding box and sphere are recomputed.
  107211. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107212. * @returns the current mesh
  107213. */
  107214. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107215. /** @hidden */
  107216. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107217. /**
  107218. * This function will subdivide the mesh into multiple submeshes
  107219. * @param count defines the expected number of submeshes
  107220. */
  107221. subdivide(count: number): void;
  107222. /**
  107223. * Copy a FloatArray into a specific associated vertex buffer
  107224. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107225. * - VertexBuffer.PositionKind
  107226. * - VertexBuffer.UVKind
  107227. * - VertexBuffer.UV2Kind
  107228. * - VertexBuffer.UV3Kind
  107229. * - VertexBuffer.UV4Kind
  107230. * - VertexBuffer.UV5Kind
  107231. * - VertexBuffer.UV6Kind
  107232. * - VertexBuffer.ColorKind
  107233. * - VertexBuffer.MatricesIndicesKind
  107234. * - VertexBuffer.MatricesIndicesExtraKind
  107235. * - VertexBuffer.MatricesWeightsKind
  107236. * - VertexBuffer.MatricesWeightsExtraKind
  107237. * @param data defines the data source
  107238. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107239. * @param stride defines the data stride size (can be null)
  107240. * @returns the current mesh
  107241. */
  107242. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107243. /**
  107244. * Delete a vertex buffer associated with this mesh
  107245. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107246. * - VertexBuffer.PositionKind
  107247. * - VertexBuffer.UVKind
  107248. * - VertexBuffer.UV2Kind
  107249. * - VertexBuffer.UV3Kind
  107250. * - VertexBuffer.UV4Kind
  107251. * - VertexBuffer.UV5Kind
  107252. * - VertexBuffer.UV6Kind
  107253. * - VertexBuffer.ColorKind
  107254. * - VertexBuffer.MatricesIndicesKind
  107255. * - VertexBuffer.MatricesIndicesExtraKind
  107256. * - VertexBuffer.MatricesWeightsKind
  107257. * - VertexBuffer.MatricesWeightsExtraKind
  107258. */
  107259. removeVerticesData(kind: string): void;
  107260. /**
  107261. * Flags an associated vertex buffer as updatable
  107262. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107263. * - VertexBuffer.PositionKind
  107264. * - VertexBuffer.UVKind
  107265. * - VertexBuffer.UV2Kind
  107266. * - VertexBuffer.UV3Kind
  107267. * - VertexBuffer.UV4Kind
  107268. * - VertexBuffer.UV5Kind
  107269. * - VertexBuffer.UV6Kind
  107270. * - VertexBuffer.ColorKind
  107271. * - VertexBuffer.MatricesIndicesKind
  107272. * - VertexBuffer.MatricesIndicesExtraKind
  107273. * - VertexBuffer.MatricesWeightsKind
  107274. * - VertexBuffer.MatricesWeightsExtraKind
  107275. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107276. */
  107277. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107278. /**
  107279. * Sets the mesh global Vertex Buffer
  107280. * @param buffer defines the buffer to use
  107281. * @returns the current mesh
  107282. */
  107283. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107284. /**
  107285. * Update a specific associated vertex buffer
  107286. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107287. * - VertexBuffer.PositionKind
  107288. * - VertexBuffer.UVKind
  107289. * - VertexBuffer.UV2Kind
  107290. * - VertexBuffer.UV3Kind
  107291. * - VertexBuffer.UV4Kind
  107292. * - VertexBuffer.UV5Kind
  107293. * - VertexBuffer.UV6Kind
  107294. * - VertexBuffer.ColorKind
  107295. * - VertexBuffer.MatricesIndicesKind
  107296. * - VertexBuffer.MatricesIndicesExtraKind
  107297. * - VertexBuffer.MatricesWeightsKind
  107298. * - VertexBuffer.MatricesWeightsExtraKind
  107299. * @param data defines the data source
  107300. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107301. * @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)
  107302. * @returns the current mesh
  107303. */
  107304. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107305. /**
  107306. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107307. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107308. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107309. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107310. * @returns the current mesh
  107311. */
  107312. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107313. /**
  107314. * Creates a un-shared specific occurence of the geometry for the mesh.
  107315. * @returns the current mesh
  107316. */
  107317. makeGeometryUnique(): Mesh;
  107318. /**
  107319. * Set the index buffer of this mesh
  107320. * @param indices defines the source data
  107321. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107322. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107323. * @returns the current mesh
  107324. */
  107325. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107326. /**
  107327. * Update the current index buffer
  107328. * @param indices defines the source data
  107329. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107330. * @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)
  107331. * @returns the current mesh
  107332. */
  107333. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107334. /**
  107335. * Invert the geometry to move from a right handed system to a left handed one.
  107336. * @returns the current mesh
  107337. */
  107338. toLeftHanded(): Mesh;
  107339. /** @hidden */
  107340. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107341. /** @hidden */
  107342. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107343. /**
  107344. * Registers for this mesh a javascript function called just before the rendering process
  107345. * @param func defines the function to call before rendering this mesh
  107346. * @returns the current mesh
  107347. */
  107348. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107349. /**
  107350. * Disposes a previously registered javascript function called before the rendering
  107351. * @param func defines the function to remove
  107352. * @returns the current mesh
  107353. */
  107354. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107355. /**
  107356. * Registers for this mesh a javascript function called just after the rendering is complete
  107357. * @param func defines the function to call after rendering this mesh
  107358. * @returns the current mesh
  107359. */
  107360. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107361. /**
  107362. * Disposes a previously registered javascript function called after the rendering.
  107363. * @param func defines the function to remove
  107364. * @returns the current mesh
  107365. */
  107366. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107367. /** @hidden */
  107368. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107369. /** @hidden */
  107370. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107371. /** @hidden */
  107372. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107373. /** @hidden */
  107374. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107375. /** @hidden */
  107376. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107377. /** @hidden */
  107378. _rebuild(): void;
  107379. /** @hidden */
  107380. _freeze(): void;
  107381. /** @hidden */
  107382. _unFreeze(): void;
  107383. /**
  107384. * 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
  107385. * @param subMesh defines the subMesh to render
  107386. * @param enableAlphaMode defines if alpha mode can be changed
  107387. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107388. * @returns the current mesh
  107389. */
  107390. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107391. private _onBeforeDraw;
  107392. /**
  107393. * Renormalize the mesh and patch it up if there are no weights
  107394. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107395. * However in the case of zero weights then we set just a single influence to 1.
  107396. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107397. */
  107398. cleanMatrixWeights(): void;
  107399. private normalizeSkinFourWeights;
  107400. private normalizeSkinWeightsAndExtra;
  107401. /**
  107402. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107403. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107404. * the user know there was an issue with importing the mesh
  107405. * @returns a validation object with skinned, valid and report string
  107406. */
  107407. validateSkinning(): {
  107408. skinned: boolean;
  107409. valid: boolean;
  107410. report: string;
  107411. };
  107412. /** @hidden */
  107413. _checkDelayState(): Mesh;
  107414. private _queueLoad;
  107415. /**
  107416. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107417. * A mesh is in the frustum if its bounding box intersects the frustum
  107418. * @param frustumPlanes defines the frustum to test
  107419. * @returns true if the mesh is in the frustum planes
  107420. */
  107421. isInFrustum(frustumPlanes: Plane[]): boolean;
  107422. /**
  107423. * Sets the mesh material by the material or multiMaterial `id` property
  107424. * @param id is a string identifying the material or the multiMaterial
  107425. * @returns the current mesh
  107426. */
  107427. setMaterialByID(id: string): Mesh;
  107428. /**
  107429. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107430. * @returns an array of IAnimatable
  107431. */
  107432. getAnimatables(): IAnimatable[];
  107433. /**
  107434. * Modifies the mesh geometry according to the passed transformation matrix.
  107435. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107436. * The mesh normals are modified using the same transformation.
  107437. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107438. * @param transform defines the transform matrix to use
  107439. * @see https://doc.babylonjs.com/resources/baking_transformations
  107440. * @returns the current mesh
  107441. */
  107442. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107443. /**
  107444. * Modifies the mesh geometry according to its own current World Matrix.
  107445. * The mesh World Matrix is then reset.
  107446. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107447. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107448. * @see https://doc.babylonjs.com/resources/baking_transformations
  107449. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107450. * @returns the current mesh
  107451. */
  107452. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107453. /** @hidden */
  107454. get _positions(): Nullable<Vector3[]>;
  107455. /** @hidden */
  107456. _resetPointsArrayCache(): Mesh;
  107457. /** @hidden */
  107458. _generatePointsArray(): boolean;
  107459. /**
  107460. * Returns a new Mesh object generated from the current mesh properties.
  107461. * This method must not get confused with createInstance()
  107462. * @param name is a string, the name given to the new mesh
  107463. * @param newParent can be any Node object (default `null`)
  107464. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107465. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107466. * @returns a new mesh
  107467. */
  107468. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107469. /**
  107470. * Releases resources associated with this mesh.
  107471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107473. */
  107474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107475. /** @hidden */
  107476. _disposeInstanceSpecificData(): void;
  107477. /** @hidden */
  107478. _disposeThinInstanceSpecificData(): void;
  107479. /**
  107480. * Modifies the mesh geometry according to a displacement map.
  107481. * 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.
  107482. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107483. * @param url is a string, the URL from the image file is to be downloaded.
  107484. * @param minHeight is the lower limit of the displacement.
  107485. * @param maxHeight is the upper limit of the displacement.
  107486. * @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.
  107487. * @param uvOffset is an optional vector2 used to offset UV.
  107488. * @param uvScale is an optional vector2 used to scale UV.
  107489. * @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.
  107490. * @returns the Mesh.
  107491. */
  107492. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107493. /**
  107494. * Modifies the mesh geometry according to a displacementMap buffer.
  107495. * 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.
  107496. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107497. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107498. * @param heightMapWidth is the width of the buffer image.
  107499. * @param heightMapHeight is the height of the buffer image.
  107500. * @param minHeight is the lower limit of the displacement.
  107501. * @param maxHeight is the upper limit of the displacement.
  107502. * @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.
  107503. * @param uvOffset is an optional vector2 used to offset UV.
  107504. * @param uvScale is an optional vector2 used to scale UV.
  107505. * @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.
  107506. * @returns the Mesh.
  107507. */
  107508. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107509. /**
  107510. * Modify the mesh to get a flat shading rendering.
  107511. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107512. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107513. * @returns current mesh
  107514. */
  107515. convertToFlatShadedMesh(): Mesh;
  107516. /**
  107517. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107518. * In other words, more vertices, no more indices and a single bigger VBO.
  107519. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107520. * @returns current mesh
  107521. */
  107522. convertToUnIndexedMesh(): Mesh;
  107523. /**
  107524. * Inverses facet orientations.
  107525. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107526. * @param flipNormals will also inverts the normals
  107527. * @returns current mesh
  107528. */
  107529. flipFaces(flipNormals?: boolean): Mesh;
  107530. /**
  107531. * Increase the number of facets and hence vertices in a mesh
  107532. * Vertex normals are interpolated from existing vertex normals
  107533. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107534. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107535. */
  107536. increaseVertices(numberPerEdge: number): void;
  107537. /**
  107538. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107539. * This will undo any application of covertToFlatShadedMesh
  107540. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107541. */
  107542. forceSharedVertices(): void;
  107543. /** @hidden */
  107544. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107545. /** @hidden */
  107546. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107547. /**
  107548. * Creates a new InstancedMesh object from the mesh model.
  107549. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107550. * @param name defines the name of the new instance
  107551. * @returns a new InstancedMesh
  107552. */
  107553. createInstance(name: string): InstancedMesh;
  107554. /**
  107555. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107556. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107557. * @returns the current mesh
  107558. */
  107559. synchronizeInstances(): Mesh;
  107560. /**
  107561. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107562. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107563. * This should be used together with the simplification to avoid disappearing triangles.
  107564. * @param successCallback an optional success callback to be called after the optimization finished.
  107565. * @returns the current mesh
  107566. */
  107567. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107568. /**
  107569. * Serialize current mesh
  107570. * @param serializationObject defines the object which will receive the serialization data
  107571. */
  107572. serialize(serializationObject: any): void;
  107573. /** @hidden */
  107574. _syncGeometryWithMorphTargetManager(): void;
  107575. /** @hidden */
  107576. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107577. /**
  107578. * Returns a new Mesh object parsed from the source provided.
  107579. * @param parsedMesh is the source
  107580. * @param scene defines the hosting scene
  107581. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107582. * @returns a new Mesh
  107583. */
  107584. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107585. /**
  107586. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107588. * @param name defines the name of the mesh to create
  107589. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107590. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107591. * @param closePath creates a seam between the first and the last points of each path of the path array
  107592. * @param offset is taken in account only if the `pathArray` is containing a single path
  107593. * @param scene defines the hosting scene
  107594. * @param updatable defines if the mesh must be flagged as updatable
  107595. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107596. * @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)
  107597. * @returns a new Mesh
  107598. */
  107599. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107600. /**
  107601. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107602. * @param name defines the name of the mesh to create
  107603. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107604. * @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
  107605. * @param scene defines the hosting scene
  107606. * @param updatable defines if the mesh must be flagged as updatable
  107607. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107608. * @returns a new Mesh
  107609. */
  107610. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107611. /**
  107612. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107613. * @param name defines the name of the mesh to create
  107614. * @param size sets the size (float) of each box side (default 1)
  107615. * @param scene defines the hosting scene
  107616. * @param updatable defines if the mesh must be flagged as updatable
  107617. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107618. * @returns a new Mesh
  107619. */
  107620. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107621. /**
  107622. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107623. * @param name defines the name of the mesh to create
  107624. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107625. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107626. * @param scene defines the hosting scene
  107627. * @param updatable defines if the mesh must be flagged as updatable
  107628. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107629. * @returns a new Mesh
  107630. */
  107631. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107632. /**
  107633. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107634. * @param name defines the name of the mesh to create
  107635. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107636. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107637. * @param scene defines the hosting scene
  107638. * @returns a new Mesh
  107639. */
  107640. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107641. /**
  107642. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107643. * @param name defines the name of the mesh to create
  107644. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107645. * @param diameterTop set the top cap diameter (floats, default 1)
  107646. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107647. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107648. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107649. * @param scene defines the hosting scene
  107650. * @param updatable defines if the mesh must be flagged as updatable
  107651. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107652. * @returns a new Mesh
  107653. */
  107654. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107655. /**
  107656. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107657. * @param name defines the name of the mesh to create
  107658. * @param diameter sets the diameter size (float) of the torus (default 1)
  107659. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107660. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107661. * @param scene defines the hosting scene
  107662. * @param updatable defines if the mesh must be flagged as updatable
  107663. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107664. * @returns a new Mesh
  107665. */
  107666. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107667. /**
  107668. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107669. * @param name defines the name of the mesh to create
  107670. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107671. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107672. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107673. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107674. * @param p the number of windings on X axis (positive integers, default 2)
  107675. * @param q the number of windings on Y axis (positive integers, default 3)
  107676. * @param scene defines the hosting scene
  107677. * @param updatable defines if the mesh must be flagged as updatable
  107678. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107679. * @returns a new Mesh
  107680. */
  107681. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107682. /**
  107683. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107684. * @param name defines the name of the mesh to create
  107685. * @param points is an array successive Vector3
  107686. * @param scene defines the hosting scene
  107687. * @param updatable defines if the mesh must be flagged as updatable
  107688. * @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).
  107689. * @returns a new Mesh
  107690. */
  107691. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107692. /**
  107693. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107694. * @param name defines the name of the mesh to create
  107695. * @param points is an array successive Vector3
  107696. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107697. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107698. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107699. * @param scene defines the hosting scene
  107700. * @param updatable defines if the mesh must be flagged as updatable
  107701. * @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)
  107702. * @returns a new Mesh
  107703. */
  107704. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107705. /**
  107706. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107707. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107708. * 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.
  107709. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107710. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107711. * Remember you can only change the shape positions, not their number when updating a polygon.
  107712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107713. * @param name defines the name of the mesh to create
  107714. * @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
  107715. * @param scene defines the hosting scene
  107716. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107717. * @param updatable defines if the mesh must be flagged as updatable
  107718. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107719. * @param earcutInjection can be used to inject your own earcut reference
  107720. * @returns a new Mesh
  107721. */
  107722. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107723. /**
  107724. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107726. * @param name defines the name of the mesh to create
  107727. * @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
  107728. * @param depth defines the height of extrusion
  107729. * @param scene defines the hosting scene
  107730. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107731. * @param updatable defines if the mesh must be flagged as updatable
  107732. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107733. * @param earcutInjection can be used to inject your own earcut reference
  107734. * @returns a new Mesh
  107735. */
  107736. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107737. /**
  107738. * Creates an extruded shape mesh.
  107739. * 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
  107740. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107742. * @param name defines the name of the mesh to create
  107743. * @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
  107744. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107745. * @param scale is the value to scale the shape
  107746. * @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
  107747. * @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
  107748. * @param scene defines the hosting scene
  107749. * @param updatable defines if the mesh must be flagged as updatable
  107750. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107751. * @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)
  107752. * @returns a new Mesh
  107753. */
  107754. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107755. /**
  107756. * Creates an custom extruded shape mesh.
  107757. * The custom extrusion is a parametric shape.
  107758. * It has no predefined shape. Its final shape will depend on the input parameters.
  107759. * Please consider using the same method from the MeshBuilder class instead
  107760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107761. * @param name defines the name of the mesh to create
  107762. * @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
  107763. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107764. * @param scaleFunction is a custom Javascript function called on each path point
  107765. * @param rotationFunction is a custom Javascript function called on each path point
  107766. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107767. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107768. * @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
  107769. * @param scene defines the hosting scene
  107770. * @param updatable defines if the mesh must be flagged as updatable
  107771. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107772. * @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)
  107773. * @returns a new Mesh
  107774. */
  107775. 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;
  107776. /**
  107777. * Creates lathe mesh.
  107778. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107779. * Please consider using the same method from the MeshBuilder class instead
  107780. * @param name defines the name of the mesh to create
  107781. * @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
  107782. * @param radius is the radius value of the lathe
  107783. * @param tessellation is the side number of the lathe.
  107784. * @param scene defines the hosting scene
  107785. * @param updatable defines if the mesh must be flagged as updatable
  107786. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107787. * @returns a new Mesh
  107788. */
  107789. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107790. /**
  107791. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107792. * @param name defines the name of the mesh to create
  107793. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107794. * @param scene defines the hosting scene
  107795. * @param updatable defines if the mesh must be flagged as updatable
  107796. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107797. * @returns a new Mesh
  107798. */
  107799. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107800. /**
  107801. * Creates a ground mesh.
  107802. * Please consider using the same method from the MeshBuilder class instead
  107803. * @param name defines the name of the mesh to create
  107804. * @param width set the width of the ground
  107805. * @param height set the height of the ground
  107806. * @param subdivisions sets the number of subdivisions per side
  107807. * @param scene defines the hosting scene
  107808. * @param updatable defines if the mesh must be flagged as updatable
  107809. * @returns a new Mesh
  107810. */
  107811. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  107812. /**
  107813. * Creates a tiled ground mesh.
  107814. * Please consider using the same method from the MeshBuilder class instead
  107815. * @param name defines the name of the mesh to create
  107816. * @param xmin set the ground minimum X coordinate
  107817. * @param zmin set the ground minimum Y coordinate
  107818. * @param xmax set the ground maximum X coordinate
  107819. * @param zmax set the ground maximum Z coordinate
  107820. * @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
  107821. * @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
  107822. * @param scene defines the hosting scene
  107823. * @param updatable defines if the mesh must be flagged as updatable
  107824. * @returns a new Mesh
  107825. */
  107826. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  107827. w: number;
  107828. h: number;
  107829. }, precision: {
  107830. w: number;
  107831. h: number;
  107832. }, scene: Scene, updatable?: boolean): Mesh;
  107833. /**
  107834. * Creates a ground mesh from a height map.
  107835. * Please consider using the same method from the MeshBuilder class instead
  107836. * @see https://doc.babylonjs.com/babylon101/height_map
  107837. * @param name defines the name of the mesh to create
  107838. * @param url sets the URL of the height map image resource
  107839. * @param width set the ground width size
  107840. * @param height set the ground height size
  107841. * @param subdivisions sets the number of subdivision per side
  107842. * @param minHeight is the minimum altitude on the ground
  107843. * @param maxHeight is the maximum altitude on the ground
  107844. * @param scene defines the hosting scene
  107845. * @param updatable defines if the mesh must be flagged as updatable
  107846. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  107847. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107848. * @returns a new Mesh
  107849. */
  107850. 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;
  107851. /**
  107852. * Creates a tube mesh.
  107853. * The tube is a parametric shape.
  107854. * It has no predefined shape. Its final shape will depend on the input parameters.
  107855. * Please consider using the same method from the MeshBuilder class instead
  107856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107857. * @param name defines the name of the mesh to create
  107858. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  107859. * @param radius sets the tube radius size
  107860. * @param tessellation is the number of sides on the tubular surface
  107861. * @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
  107862. * @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
  107863. * @param scene defines the hosting scene
  107864. * @param updatable defines if the mesh must be flagged as updatable
  107865. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107866. * @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)
  107867. * @returns a new Mesh
  107868. */
  107869. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  107870. (i: number, distance: number): number;
  107871. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107872. /**
  107873. * Creates a polyhedron mesh.
  107874. * Please consider using the same method from the MeshBuilder class instead.
  107875. * * 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
  107876. * * The parameter `size` (positive float, default 1) sets the polygon size
  107877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107878. * * 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`
  107879. * * 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
  107880. * * 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)`)
  107881. * * 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
  107882. * * 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
  107883. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107886. * @param name defines the name of the mesh to create
  107887. * @param options defines the options used to create the mesh
  107888. * @param scene defines the hosting scene
  107889. * @returns a new Mesh
  107890. */
  107891. static CreatePolyhedron(name: string, options: {
  107892. type?: number;
  107893. size?: number;
  107894. sizeX?: number;
  107895. sizeY?: number;
  107896. sizeZ?: number;
  107897. custom?: any;
  107898. faceUV?: Vector4[];
  107899. faceColors?: Color4[];
  107900. updatable?: boolean;
  107901. sideOrientation?: number;
  107902. }, scene: Scene): Mesh;
  107903. /**
  107904. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107905. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107906. * * 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`)
  107907. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107908. * * 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
  107909. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107912. * @param name defines the name of the mesh
  107913. * @param options defines the options used to create the mesh
  107914. * @param scene defines the hosting scene
  107915. * @returns a new Mesh
  107916. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107917. */
  107918. static CreateIcoSphere(name: string, options: {
  107919. radius?: number;
  107920. flat?: boolean;
  107921. subdivisions?: number;
  107922. sideOrientation?: number;
  107923. updatable?: boolean;
  107924. }, scene: Scene): Mesh;
  107925. /**
  107926. * Creates a decal mesh.
  107927. * Please consider using the same method from the MeshBuilder class instead.
  107928. * A decal is a mesh usually applied as a model onto the surface of another mesh
  107929. * @param name defines the name of the mesh
  107930. * @param sourceMesh defines the mesh receiving the decal
  107931. * @param position sets the position of the decal in world coordinates
  107932. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  107933. * @param size sets the decal scaling
  107934. * @param angle sets the angle to rotate the decal
  107935. * @returns a new Mesh
  107936. */
  107937. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  107938. /**
  107939. * Prepare internal position array for software CPU skinning
  107940. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  107941. */
  107942. setPositionsForCPUSkinning(): Float32Array;
  107943. /**
  107944. * Prepare internal normal array for software CPU skinning
  107945. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  107946. */
  107947. setNormalsForCPUSkinning(): Float32Array;
  107948. /**
  107949. * Updates the vertex buffer by applying transformation from the bones
  107950. * @param skeleton defines the skeleton to apply to current mesh
  107951. * @returns the current mesh
  107952. */
  107953. applySkeleton(skeleton: Skeleton): Mesh;
  107954. /**
  107955. * 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
  107956. * @param meshes defines the list of meshes to scan
  107957. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  107958. */
  107959. static MinMax(meshes: AbstractMesh[]): {
  107960. min: Vector3;
  107961. max: Vector3;
  107962. };
  107963. /**
  107964. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  107965. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  107966. * @returns a vector3
  107967. */
  107968. static Center(meshesOrMinMaxVector: {
  107969. min: Vector3;
  107970. max: Vector3;
  107971. } | AbstractMesh[]): Vector3;
  107972. /**
  107973. * Merge the array of meshes into a single mesh for performance reasons.
  107974. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  107975. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  107976. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  107977. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  107978. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  107979. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  107980. * @returns a new mesh
  107981. */
  107982. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  107983. /** @hidden */
  107984. addInstance(instance: InstancedMesh): void;
  107985. /** @hidden */
  107986. removeInstance(instance: InstancedMesh): void;
  107987. }
  107988. }
  107989. declare module BABYLON {
  107990. /**
  107991. * This is the base class of all the camera used in the application.
  107992. * @see https://doc.babylonjs.com/features/cameras
  107993. */
  107994. export class Camera extends Node {
  107995. /** @hidden */
  107996. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  107997. /**
  107998. * This is the default projection mode used by the cameras.
  107999. * It helps recreating a feeling of perspective and better appreciate depth.
  108000. * This is the best way to simulate real life cameras.
  108001. */
  108002. static readonly PERSPECTIVE_CAMERA: number;
  108003. /**
  108004. * This helps creating camera with an orthographic mode.
  108005. * 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.
  108006. */
  108007. static readonly ORTHOGRAPHIC_CAMERA: number;
  108008. /**
  108009. * This is the default FOV mode for perspective cameras.
  108010. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108011. */
  108012. static readonly FOVMODE_VERTICAL_FIXED: number;
  108013. /**
  108014. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108015. */
  108016. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108017. /**
  108018. * This specifies ther is no need for a camera rig.
  108019. * Basically only one eye is rendered corresponding to the camera.
  108020. */
  108021. static readonly RIG_MODE_NONE: number;
  108022. /**
  108023. * Simulates a camera Rig with one blue eye and one red eye.
  108024. * This can be use with 3d blue and red glasses.
  108025. */
  108026. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108027. /**
  108028. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108029. */
  108030. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108031. /**
  108032. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108033. */
  108034. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108035. /**
  108036. * Defines that both eyes of the camera will be rendered over under each other.
  108037. */
  108038. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108039. /**
  108040. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108041. */
  108042. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108043. /**
  108044. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108045. */
  108046. static readonly RIG_MODE_VR: number;
  108047. /**
  108048. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108049. */
  108050. static readonly RIG_MODE_WEBVR: number;
  108051. /**
  108052. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108053. */
  108054. static readonly RIG_MODE_CUSTOM: number;
  108055. /**
  108056. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108057. */
  108058. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108059. /**
  108060. * Define the input manager associated with the camera.
  108061. */
  108062. inputs: CameraInputsManager<Camera>;
  108063. /** @hidden */
  108064. _position: Vector3;
  108065. /**
  108066. * Define the current local position of the camera in the scene
  108067. */
  108068. get position(): Vector3;
  108069. set position(newPosition: Vector3);
  108070. /**
  108071. * The vector the camera should consider as up.
  108072. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108073. */
  108074. upVector: Vector3;
  108075. /**
  108076. * Define the current limit on the left side for an orthographic camera
  108077. * In scene unit
  108078. */
  108079. orthoLeft: Nullable<number>;
  108080. /**
  108081. * Define the current limit on the right side for an orthographic camera
  108082. * In scene unit
  108083. */
  108084. orthoRight: Nullable<number>;
  108085. /**
  108086. * Define the current limit on the bottom side for an orthographic camera
  108087. * In scene unit
  108088. */
  108089. orthoBottom: Nullable<number>;
  108090. /**
  108091. * Define the current limit on the top side for an orthographic camera
  108092. * In scene unit
  108093. */
  108094. orthoTop: Nullable<number>;
  108095. /**
  108096. * Field Of View is set in Radians. (default is 0.8)
  108097. */
  108098. fov: number;
  108099. /**
  108100. * Define the minimum distance the camera can see from.
  108101. * This is important to note that the depth buffer are not infinite and the closer it starts
  108102. * the more your scene might encounter depth fighting issue.
  108103. */
  108104. minZ: number;
  108105. /**
  108106. * Define the maximum distance the camera can see to.
  108107. * This is important to note that the depth buffer are not infinite and the further it end
  108108. * the more your scene might encounter depth fighting issue.
  108109. */
  108110. maxZ: number;
  108111. /**
  108112. * Define the default inertia of the camera.
  108113. * This helps giving a smooth feeling to the camera movement.
  108114. */
  108115. inertia: number;
  108116. /**
  108117. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108118. */
  108119. mode: number;
  108120. /**
  108121. * Define whether the camera is intermediate.
  108122. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108123. */
  108124. isIntermediate: boolean;
  108125. /**
  108126. * Define the viewport of the camera.
  108127. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108128. */
  108129. viewport: Viewport;
  108130. /**
  108131. * Restricts the camera to viewing objects with the same layerMask.
  108132. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108133. */
  108134. layerMask: number;
  108135. /**
  108136. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108137. */
  108138. fovMode: number;
  108139. /**
  108140. * Rig mode of the camera.
  108141. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108142. * This is normally controlled byt the camera themselves as internal use.
  108143. */
  108144. cameraRigMode: number;
  108145. /**
  108146. * Defines the distance between both "eyes" in case of a RIG
  108147. */
  108148. interaxialDistance: number;
  108149. /**
  108150. * Defines if stereoscopic rendering is done side by side or over under.
  108151. */
  108152. isStereoscopicSideBySide: boolean;
  108153. /**
  108154. * 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
  108155. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108156. * else in the scene. (Eg. security camera)
  108157. *
  108158. * 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)
  108159. */
  108160. customRenderTargets: RenderTargetTexture[];
  108161. /**
  108162. * When set, the camera will render to this render target instead of the default canvas
  108163. *
  108164. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108165. */
  108166. outputRenderTarget: Nullable<RenderTargetTexture>;
  108167. /**
  108168. * Observable triggered when the camera view matrix has changed.
  108169. */
  108170. onViewMatrixChangedObservable: Observable<Camera>;
  108171. /**
  108172. * Observable triggered when the camera Projection matrix has changed.
  108173. */
  108174. onProjectionMatrixChangedObservable: Observable<Camera>;
  108175. /**
  108176. * Observable triggered when the inputs have been processed.
  108177. */
  108178. onAfterCheckInputsObservable: Observable<Camera>;
  108179. /**
  108180. * Observable triggered when reset has been called and applied to the camera.
  108181. */
  108182. onRestoreStateObservable: Observable<Camera>;
  108183. /**
  108184. * Is this camera a part of a rig system?
  108185. */
  108186. isRigCamera: boolean;
  108187. /**
  108188. * If isRigCamera set to true this will be set with the parent camera.
  108189. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108190. */
  108191. rigParent?: Camera;
  108192. /** @hidden */
  108193. _cameraRigParams: any;
  108194. /** @hidden */
  108195. _rigCameras: Camera[];
  108196. /** @hidden */
  108197. _rigPostProcess: Nullable<PostProcess>;
  108198. protected _webvrViewMatrix: Matrix;
  108199. /** @hidden */
  108200. _skipRendering: boolean;
  108201. /** @hidden */
  108202. _projectionMatrix: Matrix;
  108203. /** @hidden */
  108204. _postProcesses: Nullable<PostProcess>[];
  108205. /** @hidden */
  108206. _activeMeshes: SmartArray<AbstractMesh>;
  108207. protected _globalPosition: Vector3;
  108208. /** @hidden */
  108209. _computedViewMatrix: Matrix;
  108210. private _doNotComputeProjectionMatrix;
  108211. private _transformMatrix;
  108212. private _frustumPlanes;
  108213. private _refreshFrustumPlanes;
  108214. private _storedFov;
  108215. private _stateStored;
  108216. /**
  108217. * Instantiates a new camera object.
  108218. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108219. * @see https://doc.babylonjs.com/features/cameras
  108220. * @param name Defines the name of the camera in the scene
  108221. * @param position Defines the position of the camera
  108222. * @param scene Defines the scene the camera belongs too
  108223. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108224. */
  108225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108226. /**
  108227. * Store current camera state (fov, position, etc..)
  108228. * @returns the camera
  108229. */
  108230. storeState(): Camera;
  108231. /**
  108232. * Restores the camera state values if it has been stored. You must call storeState() first
  108233. */
  108234. protected _restoreStateValues(): boolean;
  108235. /**
  108236. * Restored camera state. You must call storeState() first.
  108237. * @returns true if restored and false otherwise
  108238. */
  108239. restoreState(): boolean;
  108240. /**
  108241. * Gets the class name of the camera.
  108242. * @returns the class name
  108243. */
  108244. getClassName(): string;
  108245. /** @hidden */
  108246. readonly _isCamera: boolean;
  108247. /**
  108248. * Gets a string representation of the camera useful for debug purpose.
  108249. * @param fullDetails Defines that a more verboe level of logging is required
  108250. * @returns the string representation
  108251. */
  108252. toString(fullDetails?: boolean): string;
  108253. /**
  108254. * Gets the current world space position of the camera.
  108255. */
  108256. get globalPosition(): Vector3;
  108257. /**
  108258. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108259. * @returns the active meshe list
  108260. */
  108261. getActiveMeshes(): SmartArray<AbstractMesh>;
  108262. /**
  108263. * Check whether a mesh is part of the current active mesh list of the camera
  108264. * @param mesh Defines the mesh to check
  108265. * @returns true if active, false otherwise
  108266. */
  108267. isActiveMesh(mesh: Mesh): boolean;
  108268. /**
  108269. * Is this camera ready to be used/rendered
  108270. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108271. * @return true if the camera is ready
  108272. */
  108273. isReady(completeCheck?: boolean): boolean;
  108274. /** @hidden */
  108275. _initCache(): void;
  108276. /** @hidden */
  108277. _updateCache(ignoreParentClass?: boolean): void;
  108278. /** @hidden */
  108279. _isSynchronized(): boolean;
  108280. /** @hidden */
  108281. _isSynchronizedViewMatrix(): boolean;
  108282. /** @hidden */
  108283. _isSynchronizedProjectionMatrix(): boolean;
  108284. /**
  108285. * Attach the input controls to a specific dom element to get the input from.
  108286. * @param element Defines the element the controls should be listened from
  108287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108288. */
  108289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108290. /**
  108291. * Detach the current controls from the specified dom element.
  108292. * @param element Defines the element to stop listening the inputs from
  108293. */
  108294. detachControl(element: HTMLElement): void;
  108295. /**
  108296. * Update the camera state according to the different inputs gathered during the frame.
  108297. */
  108298. update(): void;
  108299. /** @hidden */
  108300. _checkInputs(): void;
  108301. /** @hidden */
  108302. get rigCameras(): Camera[];
  108303. /**
  108304. * Gets the post process used by the rig cameras
  108305. */
  108306. get rigPostProcess(): Nullable<PostProcess>;
  108307. /**
  108308. * Internal, gets the first post proces.
  108309. * @returns the first post process to be run on this camera.
  108310. */
  108311. _getFirstPostProcess(): Nullable<PostProcess>;
  108312. private _cascadePostProcessesToRigCams;
  108313. /**
  108314. * Attach a post process to the camera.
  108315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108316. * @param postProcess The post process to attach to the camera
  108317. * @param insertAt The position of the post process in case several of them are in use in the scene
  108318. * @returns the position the post process has been inserted at
  108319. */
  108320. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108321. /**
  108322. * Detach a post process to the camera.
  108323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108324. * @param postProcess The post process to detach from the camera
  108325. */
  108326. detachPostProcess(postProcess: PostProcess): void;
  108327. /**
  108328. * Gets the current world matrix of the camera
  108329. */
  108330. getWorldMatrix(): Matrix;
  108331. /** @hidden */
  108332. _getViewMatrix(): Matrix;
  108333. /**
  108334. * Gets the current view matrix of the camera.
  108335. * @param force forces the camera to recompute the matrix without looking at the cached state
  108336. * @returns the view matrix
  108337. */
  108338. getViewMatrix(force?: boolean): Matrix;
  108339. /**
  108340. * Freeze the projection matrix.
  108341. * It will prevent the cache check of the camera projection compute and can speed up perf
  108342. * if no parameter of the camera are meant to change
  108343. * @param projection Defines manually a projection if necessary
  108344. */
  108345. freezeProjectionMatrix(projection?: Matrix): void;
  108346. /**
  108347. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108348. */
  108349. unfreezeProjectionMatrix(): void;
  108350. /**
  108351. * Gets the current projection matrix of the camera.
  108352. * @param force forces the camera to recompute the matrix without looking at the cached state
  108353. * @returns the projection matrix
  108354. */
  108355. getProjectionMatrix(force?: boolean): Matrix;
  108356. /**
  108357. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108358. * @returns a Matrix
  108359. */
  108360. getTransformationMatrix(): Matrix;
  108361. private _updateFrustumPlanes;
  108362. /**
  108363. * Checks if a cullable object (mesh...) is in the camera frustum
  108364. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108365. * @param target The object to check
  108366. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108367. * @returns true if the object is in frustum otherwise false
  108368. */
  108369. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108370. /**
  108371. * Checks if a cullable object (mesh...) is in the camera frustum
  108372. * Unlike isInFrustum this cheks the full bounding box
  108373. * @param target The object to check
  108374. * @returns true if the object is in frustum otherwise false
  108375. */
  108376. isCompletelyInFrustum(target: ICullable): boolean;
  108377. /**
  108378. * Gets a ray in the forward direction from the camera.
  108379. * @param length Defines the length of the ray to create
  108380. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108381. * @param origin Defines the start point of the ray which defaults to the camera position
  108382. * @returns the forward ray
  108383. */
  108384. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108385. /**
  108386. * Gets a ray in the forward direction from the camera.
  108387. * @param refRay the ray to (re)use when setting the values
  108388. * @param length Defines the length of the ray to create
  108389. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108390. * @param origin Defines the start point of the ray which defaults to the camera position
  108391. * @returns the forward ray
  108392. */
  108393. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108394. /**
  108395. * Releases resources associated with this node.
  108396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108398. */
  108399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108400. /** @hidden */
  108401. _isLeftCamera: boolean;
  108402. /**
  108403. * Gets the left camera of a rig setup in case of Rigged Camera
  108404. */
  108405. get isLeftCamera(): boolean;
  108406. /** @hidden */
  108407. _isRightCamera: boolean;
  108408. /**
  108409. * Gets the right camera of a rig setup in case of Rigged Camera
  108410. */
  108411. get isRightCamera(): boolean;
  108412. /**
  108413. * Gets the left camera of a rig setup in case of Rigged Camera
  108414. */
  108415. get leftCamera(): Nullable<FreeCamera>;
  108416. /**
  108417. * Gets the right camera of a rig setup in case of Rigged Camera
  108418. */
  108419. get rightCamera(): Nullable<FreeCamera>;
  108420. /**
  108421. * Gets the left camera target of a rig setup in case of Rigged Camera
  108422. * @returns the target position
  108423. */
  108424. getLeftTarget(): Nullable<Vector3>;
  108425. /**
  108426. * Gets the right camera target of a rig setup in case of Rigged Camera
  108427. * @returns the target position
  108428. */
  108429. getRightTarget(): Nullable<Vector3>;
  108430. /**
  108431. * @hidden
  108432. */
  108433. setCameraRigMode(mode: number, rigParams: any): void;
  108434. /** @hidden */
  108435. static _setStereoscopicRigMode(camera: Camera): void;
  108436. /** @hidden */
  108437. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108438. /** @hidden */
  108439. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108440. /** @hidden */
  108441. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108442. /** @hidden */
  108443. _getVRProjectionMatrix(): Matrix;
  108444. protected _updateCameraRotationMatrix(): void;
  108445. protected _updateWebVRCameraRotationMatrix(): void;
  108446. /**
  108447. * This function MUST be overwritten by the different WebVR cameras available.
  108448. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108449. * @hidden
  108450. */
  108451. _getWebVRProjectionMatrix(): Matrix;
  108452. /**
  108453. * This function MUST be overwritten by the different WebVR cameras available.
  108454. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108455. * @hidden
  108456. */
  108457. _getWebVRViewMatrix(): Matrix;
  108458. /** @hidden */
  108459. setCameraRigParameter(name: string, value: any): void;
  108460. /**
  108461. * needs to be overridden by children so sub has required properties to be copied
  108462. * @hidden
  108463. */
  108464. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108465. /**
  108466. * May need to be overridden by children
  108467. * @hidden
  108468. */
  108469. _updateRigCameras(): void;
  108470. /** @hidden */
  108471. _setupInputs(): void;
  108472. /**
  108473. * Serialiaze the camera setup to a json represention
  108474. * @returns the JSON representation
  108475. */
  108476. serialize(): any;
  108477. /**
  108478. * Clones the current camera.
  108479. * @param name The cloned camera name
  108480. * @returns the cloned camera
  108481. */
  108482. clone(name: string): Camera;
  108483. /**
  108484. * Gets the direction of the camera relative to a given local axis.
  108485. * @param localAxis Defines the reference axis to provide a relative direction.
  108486. * @return the direction
  108487. */
  108488. getDirection(localAxis: Vector3): Vector3;
  108489. /**
  108490. * Returns the current camera absolute rotation
  108491. */
  108492. get absoluteRotation(): Quaternion;
  108493. /**
  108494. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108495. * @param localAxis Defines the reference axis to provide a relative direction.
  108496. * @param result Defines the vector to store the result in
  108497. */
  108498. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108499. /**
  108500. * Gets a camera constructor for a given camera type
  108501. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108502. * @param name The name of the camera the result will be able to instantiate
  108503. * @param scene The scene the result will construct the camera in
  108504. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108505. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108506. * @returns a factory method to construc the camera
  108507. */
  108508. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108509. /**
  108510. * Compute the world matrix of the camera.
  108511. * @returns the camera world matrix
  108512. */
  108513. computeWorldMatrix(): Matrix;
  108514. /**
  108515. * Parse a JSON and creates the camera from the parsed information
  108516. * @param parsedCamera The JSON to parse
  108517. * @param scene The scene to instantiate the camera in
  108518. * @returns the newly constructed camera
  108519. */
  108520. static Parse(parsedCamera: any, scene: Scene): Camera;
  108521. }
  108522. }
  108523. declare module BABYLON {
  108524. /**
  108525. * Class containing static functions to help procedurally build meshes
  108526. */
  108527. export class DiscBuilder {
  108528. /**
  108529. * Creates a plane polygonal mesh. By default, this is a disc
  108530. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108531. * * 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
  108532. * * 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
  108533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108536. * @param name defines the name of the mesh
  108537. * @param options defines the options used to create the mesh
  108538. * @param scene defines the hosting scene
  108539. * @returns the plane polygonal mesh
  108540. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108541. */
  108542. static CreateDisc(name: string, options: {
  108543. radius?: number;
  108544. tessellation?: number;
  108545. arc?: number;
  108546. updatable?: boolean;
  108547. sideOrientation?: number;
  108548. frontUVs?: Vector4;
  108549. backUVs?: Vector4;
  108550. }, scene?: Nullable<Scene>): Mesh;
  108551. }
  108552. }
  108553. declare module BABYLON {
  108554. /**
  108555. * Options to be used when creating a FresnelParameters.
  108556. */
  108557. export type IFresnelParametersCreationOptions = {
  108558. /**
  108559. * Define the color used on edges (grazing angle)
  108560. */
  108561. leftColor?: Color3;
  108562. /**
  108563. * Define the color used on center
  108564. */
  108565. rightColor?: Color3;
  108566. /**
  108567. * Define bias applied to computed fresnel term
  108568. */
  108569. bias?: number;
  108570. /**
  108571. * Defined the power exponent applied to fresnel term
  108572. */
  108573. power?: number;
  108574. /**
  108575. * Define if the fresnel effect is enable or not.
  108576. */
  108577. isEnabled?: boolean;
  108578. };
  108579. /**
  108580. * Serialized format for FresnelParameters.
  108581. */
  108582. export type IFresnelParametersSerialized = {
  108583. /**
  108584. * Define the color used on edges (grazing angle) [as an array]
  108585. */
  108586. leftColor: number[];
  108587. /**
  108588. * Define the color used on center [as an array]
  108589. */
  108590. rightColor: number[];
  108591. /**
  108592. * Define bias applied to computed fresnel term
  108593. */
  108594. bias: number;
  108595. /**
  108596. * Defined the power exponent applied to fresnel term
  108597. */
  108598. power?: number;
  108599. /**
  108600. * Define if the fresnel effect is enable or not.
  108601. */
  108602. isEnabled: boolean;
  108603. };
  108604. /**
  108605. * This represents all the required information to add a fresnel effect on a material:
  108606. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108607. */
  108608. export class FresnelParameters {
  108609. private _isEnabled;
  108610. /**
  108611. * Define if the fresnel effect is enable or not.
  108612. */
  108613. get isEnabled(): boolean;
  108614. set isEnabled(value: boolean);
  108615. /**
  108616. * Define the color used on edges (grazing angle)
  108617. */
  108618. leftColor: Color3;
  108619. /**
  108620. * Define the color used on center
  108621. */
  108622. rightColor: Color3;
  108623. /**
  108624. * Define bias applied to computed fresnel term
  108625. */
  108626. bias: number;
  108627. /**
  108628. * Defined the power exponent applied to fresnel term
  108629. */
  108630. power: number;
  108631. /**
  108632. * Creates a new FresnelParameters object.
  108633. *
  108634. * @param options provide your own settings to optionally to override defaults
  108635. */
  108636. constructor(options?: IFresnelParametersCreationOptions);
  108637. /**
  108638. * Clones the current fresnel and its valuues
  108639. * @returns a clone fresnel configuration
  108640. */
  108641. clone(): FresnelParameters;
  108642. /**
  108643. * Determines equality between FresnelParameters objects
  108644. * @param otherFresnelParameters defines the second operand
  108645. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108646. */
  108647. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108648. /**
  108649. * Serializes the current fresnel parameters to a JSON representation.
  108650. * @return the JSON serialization
  108651. */
  108652. serialize(): IFresnelParametersSerialized;
  108653. /**
  108654. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108655. * @param parsedFresnelParameters Define the JSON representation
  108656. * @returns the parsed parameters
  108657. */
  108658. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108659. }
  108660. }
  108661. declare module BABYLON {
  108662. /**
  108663. * This groups all the flags used to control the materials channel.
  108664. */
  108665. export class MaterialFlags {
  108666. private static _DiffuseTextureEnabled;
  108667. /**
  108668. * Are diffuse textures enabled in the application.
  108669. */
  108670. static get DiffuseTextureEnabled(): boolean;
  108671. static set DiffuseTextureEnabled(value: boolean);
  108672. private static _DetailTextureEnabled;
  108673. /**
  108674. * Are detail textures enabled in the application.
  108675. */
  108676. static get DetailTextureEnabled(): boolean;
  108677. static set DetailTextureEnabled(value: boolean);
  108678. private static _AmbientTextureEnabled;
  108679. /**
  108680. * Are ambient textures enabled in the application.
  108681. */
  108682. static get AmbientTextureEnabled(): boolean;
  108683. static set AmbientTextureEnabled(value: boolean);
  108684. private static _OpacityTextureEnabled;
  108685. /**
  108686. * Are opacity textures enabled in the application.
  108687. */
  108688. static get OpacityTextureEnabled(): boolean;
  108689. static set OpacityTextureEnabled(value: boolean);
  108690. private static _ReflectionTextureEnabled;
  108691. /**
  108692. * Are reflection textures enabled in the application.
  108693. */
  108694. static get ReflectionTextureEnabled(): boolean;
  108695. static set ReflectionTextureEnabled(value: boolean);
  108696. private static _EmissiveTextureEnabled;
  108697. /**
  108698. * Are emissive textures enabled in the application.
  108699. */
  108700. static get EmissiveTextureEnabled(): boolean;
  108701. static set EmissiveTextureEnabled(value: boolean);
  108702. private static _SpecularTextureEnabled;
  108703. /**
  108704. * Are specular textures enabled in the application.
  108705. */
  108706. static get SpecularTextureEnabled(): boolean;
  108707. static set SpecularTextureEnabled(value: boolean);
  108708. private static _BumpTextureEnabled;
  108709. /**
  108710. * Are bump textures enabled in the application.
  108711. */
  108712. static get BumpTextureEnabled(): boolean;
  108713. static set BumpTextureEnabled(value: boolean);
  108714. private static _LightmapTextureEnabled;
  108715. /**
  108716. * Are lightmap textures enabled in the application.
  108717. */
  108718. static get LightmapTextureEnabled(): boolean;
  108719. static set LightmapTextureEnabled(value: boolean);
  108720. private static _RefractionTextureEnabled;
  108721. /**
  108722. * Are refraction textures enabled in the application.
  108723. */
  108724. static get RefractionTextureEnabled(): boolean;
  108725. static set RefractionTextureEnabled(value: boolean);
  108726. private static _ColorGradingTextureEnabled;
  108727. /**
  108728. * Are color grading textures enabled in the application.
  108729. */
  108730. static get ColorGradingTextureEnabled(): boolean;
  108731. static set ColorGradingTextureEnabled(value: boolean);
  108732. private static _FresnelEnabled;
  108733. /**
  108734. * Are fresnels enabled in the application.
  108735. */
  108736. static get FresnelEnabled(): boolean;
  108737. static set FresnelEnabled(value: boolean);
  108738. private static _ClearCoatTextureEnabled;
  108739. /**
  108740. * Are clear coat textures enabled in the application.
  108741. */
  108742. static get ClearCoatTextureEnabled(): boolean;
  108743. static set ClearCoatTextureEnabled(value: boolean);
  108744. private static _ClearCoatBumpTextureEnabled;
  108745. /**
  108746. * Are clear coat bump textures enabled in the application.
  108747. */
  108748. static get ClearCoatBumpTextureEnabled(): boolean;
  108749. static set ClearCoatBumpTextureEnabled(value: boolean);
  108750. private static _ClearCoatTintTextureEnabled;
  108751. /**
  108752. * Are clear coat tint textures enabled in the application.
  108753. */
  108754. static get ClearCoatTintTextureEnabled(): boolean;
  108755. static set ClearCoatTintTextureEnabled(value: boolean);
  108756. private static _SheenTextureEnabled;
  108757. /**
  108758. * Are sheen textures enabled in the application.
  108759. */
  108760. static get SheenTextureEnabled(): boolean;
  108761. static set SheenTextureEnabled(value: boolean);
  108762. private static _AnisotropicTextureEnabled;
  108763. /**
  108764. * Are anisotropic textures enabled in the application.
  108765. */
  108766. static get AnisotropicTextureEnabled(): boolean;
  108767. static set AnisotropicTextureEnabled(value: boolean);
  108768. private static _ThicknessTextureEnabled;
  108769. /**
  108770. * Are thickness textures enabled in the application.
  108771. */
  108772. static get ThicknessTextureEnabled(): boolean;
  108773. static set ThicknessTextureEnabled(value: boolean);
  108774. }
  108775. }
  108776. declare module BABYLON {
  108777. /** @hidden */
  108778. export var defaultFragmentDeclaration: {
  108779. name: string;
  108780. shader: string;
  108781. };
  108782. }
  108783. declare module BABYLON {
  108784. /** @hidden */
  108785. export var defaultUboDeclaration: {
  108786. name: string;
  108787. shader: string;
  108788. };
  108789. }
  108790. declare module BABYLON {
  108791. /** @hidden */
  108792. export var prePassDeclaration: {
  108793. name: string;
  108794. shader: string;
  108795. };
  108796. }
  108797. declare module BABYLON {
  108798. /** @hidden */
  108799. export var lightFragmentDeclaration: {
  108800. name: string;
  108801. shader: string;
  108802. };
  108803. }
  108804. declare module BABYLON {
  108805. /** @hidden */
  108806. export var lightUboDeclaration: {
  108807. name: string;
  108808. shader: string;
  108809. };
  108810. }
  108811. declare module BABYLON {
  108812. /** @hidden */
  108813. export var lightsFragmentFunctions: {
  108814. name: string;
  108815. shader: string;
  108816. };
  108817. }
  108818. declare module BABYLON {
  108819. /** @hidden */
  108820. export var shadowsFragmentFunctions: {
  108821. name: string;
  108822. shader: string;
  108823. };
  108824. }
  108825. declare module BABYLON {
  108826. /** @hidden */
  108827. export var fresnelFunction: {
  108828. name: string;
  108829. shader: string;
  108830. };
  108831. }
  108832. declare module BABYLON {
  108833. /** @hidden */
  108834. export var bumpFragmentMainFunctions: {
  108835. name: string;
  108836. shader: string;
  108837. };
  108838. }
  108839. declare module BABYLON {
  108840. /** @hidden */
  108841. export var bumpFragmentFunctions: {
  108842. name: string;
  108843. shader: string;
  108844. };
  108845. }
  108846. declare module BABYLON {
  108847. /** @hidden */
  108848. export var logDepthDeclaration: {
  108849. name: string;
  108850. shader: string;
  108851. };
  108852. }
  108853. declare module BABYLON {
  108854. /** @hidden */
  108855. export var bumpFragment: {
  108856. name: string;
  108857. shader: string;
  108858. };
  108859. }
  108860. declare module BABYLON {
  108861. /** @hidden */
  108862. export var depthPrePass: {
  108863. name: string;
  108864. shader: string;
  108865. };
  108866. }
  108867. declare module BABYLON {
  108868. /** @hidden */
  108869. export var lightFragment: {
  108870. name: string;
  108871. shader: string;
  108872. };
  108873. }
  108874. declare module BABYLON {
  108875. /** @hidden */
  108876. export var logDepthFragment: {
  108877. name: string;
  108878. shader: string;
  108879. };
  108880. }
  108881. declare module BABYLON {
  108882. /** @hidden */
  108883. export var defaultPixelShader: {
  108884. name: string;
  108885. shader: string;
  108886. };
  108887. }
  108888. declare module BABYLON {
  108889. /** @hidden */
  108890. export var defaultVertexDeclaration: {
  108891. name: string;
  108892. shader: string;
  108893. };
  108894. }
  108895. declare module BABYLON {
  108896. /** @hidden */
  108897. export var bumpVertexDeclaration: {
  108898. name: string;
  108899. shader: string;
  108900. };
  108901. }
  108902. declare module BABYLON {
  108903. /** @hidden */
  108904. export var bumpVertex: {
  108905. name: string;
  108906. shader: string;
  108907. };
  108908. }
  108909. declare module BABYLON {
  108910. /** @hidden */
  108911. export var fogVertex: {
  108912. name: string;
  108913. shader: string;
  108914. };
  108915. }
  108916. declare module BABYLON {
  108917. /** @hidden */
  108918. export var shadowsVertex: {
  108919. name: string;
  108920. shader: string;
  108921. };
  108922. }
  108923. declare module BABYLON {
  108924. /** @hidden */
  108925. export var pointCloudVertex: {
  108926. name: string;
  108927. shader: string;
  108928. };
  108929. }
  108930. declare module BABYLON {
  108931. /** @hidden */
  108932. export var logDepthVertex: {
  108933. name: string;
  108934. shader: string;
  108935. };
  108936. }
  108937. declare module BABYLON {
  108938. /** @hidden */
  108939. export var defaultVertexShader: {
  108940. name: string;
  108941. shader: string;
  108942. };
  108943. }
  108944. declare module BABYLON {
  108945. /**
  108946. * @hidden
  108947. */
  108948. export interface IMaterialDetailMapDefines {
  108949. DETAIL: boolean;
  108950. DETAILDIRECTUV: number;
  108951. DETAIL_NORMALBLENDMETHOD: number;
  108952. /** @hidden */
  108953. _areTexturesDirty: boolean;
  108954. }
  108955. /**
  108956. * Define the code related to the detail map parameters of a material
  108957. *
  108958. * Inspired from:
  108959. * 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
  108960. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  108961. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  108962. */
  108963. export class DetailMapConfiguration {
  108964. private _texture;
  108965. /**
  108966. * The detail texture of the material.
  108967. */
  108968. texture: Nullable<BaseTexture>;
  108969. /**
  108970. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  108971. * Bigger values mean stronger blending
  108972. */
  108973. diffuseBlendLevel: number;
  108974. /**
  108975. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  108976. * Bigger values mean stronger blending. Only used with PBR materials
  108977. */
  108978. roughnessBlendLevel: number;
  108979. /**
  108980. * Defines how strong the bump effect from the detail map is
  108981. * Bigger values mean stronger effect
  108982. */
  108983. bumpLevel: number;
  108984. private _normalBlendMethod;
  108985. /**
  108986. * The method used to blend the bump and detail normals together
  108987. */
  108988. normalBlendMethod: number;
  108989. private _isEnabled;
  108990. /**
  108991. * Enable or disable the detail map on this material
  108992. */
  108993. isEnabled: boolean;
  108994. /** @hidden */
  108995. private _internalMarkAllSubMeshesAsTexturesDirty;
  108996. /** @hidden */
  108997. _markAllSubMeshesAsTexturesDirty(): void;
  108998. /**
  108999. * Instantiate a new detail map
  109000. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109001. */
  109002. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109003. /**
  109004. * Gets whether the submesh is ready to be used or not.
  109005. * @param defines the list of "defines" to update.
  109006. * @param scene defines the scene the material belongs to.
  109007. * @returns - boolean indicating that the submesh is ready or not.
  109008. */
  109009. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109010. /**
  109011. * Update the defines for detail map usage
  109012. * @param defines the list of "defines" to update.
  109013. * @param scene defines the scene the material belongs to.
  109014. */
  109015. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109016. /**
  109017. * Binds the material data.
  109018. * @param uniformBuffer defines the Uniform buffer to fill in.
  109019. * @param scene defines the scene the material belongs to.
  109020. * @param isFrozen defines whether the material is frozen or not.
  109021. */
  109022. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109023. /**
  109024. * Checks to see if a texture is used in the material.
  109025. * @param texture - Base texture to use.
  109026. * @returns - Boolean specifying if a texture is used in the material.
  109027. */
  109028. hasTexture(texture: BaseTexture): boolean;
  109029. /**
  109030. * Returns an array of the actively used textures.
  109031. * @param activeTextures Array of BaseTextures
  109032. */
  109033. getActiveTextures(activeTextures: BaseTexture[]): void;
  109034. /**
  109035. * Returns the animatable textures.
  109036. * @param animatables Array of animatable textures.
  109037. */
  109038. getAnimatables(animatables: IAnimatable[]): void;
  109039. /**
  109040. * Disposes the resources of the material.
  109041. * @param forceDisposeTextures - Forces the disposal of all textures.
  109042. */
  109043. dispose(forceDisposeTextures?: boolean): void;
  109044. /**
  109045. * Get the current class name useful for serialization or dynamic coding.
  109046. * @returns "DetailMap"
  109047. */
  109048. getClassName(): string;
  109049. /**
  109050. * Add the required uniforms to the current list.
  109051. * @param uniforms defines the current uniform list.
  109052. */
  109053. static AddUniforms(uniforms: string[]): void;
  109054. /**
  109055. * Add the required samplers to the current list.
  109056. * @param samplers defines the current sampler list.
  109057. */
  109058. static AddSamplers(samplers: string[]): void;
  109059. /**
  109060. * Add the required uniforms to the current buffer.
  109061. * @param uniformBuffer defines the current uniform buffer.
  109062. */
  109063. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109064. /**
  109065. * Makes a duplicate of the current instance into another one.
  109066. * @param detailMap define the instance where to copy the info
  109067. */
  109068. copyTo(detailMap: DetailMapConfiguration): void;
  109069. /**
  109070. * Serializes this detail map instance
  109071. * @returns - An object with the serialized instance.
  109072. */
  109073. serialize(): any;
  109074. /**
  109075. * Parses a detail map setting from a serialized object.
  109076. * @param source - Serialized object.
  109077. * @param scene Defines the scene we are parsing for
  109078. * @param rootUrl Defines the rootUrl to load from
  109079. */
  109080. parse(source: any, scene: Scene, rootUrl: string): void;
  109081. }
  109082. }
  109083. declare module BABYLON {
  109084. /** @hidden */
  109085. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109086. MAINUV1: boolean;
  109087. MAINUV2: boolean;
  109088. DIFFUSE: boolean;
  109089. DIFFUSEDIRECTUV: number;
  109090. DETAIL: boolean;
  109091. DETAILDIRECTUV: number;
  109092. DETAIL_NORMALBLENDMETHOD: number;
  109093. AMBIENT: boolean;
  109094. AMBIENTDIRECTUV: number;
  109095. OPACITY: boolean;
  109096. OPACITYDIRECTUV: number;
  109097. OPACITYRGB: boolean;
  109098. REFLECTION: boolean;
  109099. EMISSIVE: boolean;
  109100. EMISSIVEDIRECTUV: number;
  109101. SPECULAR: boolean;
  109102. SPECULARDIRECTUV: number;
  109103. BUMP: boolean;
  109104. BUMPDIRECTUV: number;
  109105. PARALLAX: boolean;
  109106. PARALLAXOCCLUSION: boolean;
  109107. SPECULAROVERALPHA: boolean;
  109108. CLIPPLANE: boolean;
  109109. CLIPPLANE2: boolean;
  109110. CLIPPLANE3: boolean;
  109111. CLIPPLANE4: boolean;
  109112. CLIPPLANE5: boolean;
  109113. CLIPPLANE6: boolean;
  109114. ALPHATEST: boolean;
  109115. DEPTHPREPASS: boolean;
  109116. ALPHAFROMDIFFUSE: boolean;
  109117. POINTSIZE: boolean;
  109118. FOG: boolean;
  109119. SPECULARTERM: boolean;
  109120. DIFFUSEFRESNEL: boolean;
  109121. OPACITYFRESNEL: boolean;
  109122. REFLECTIONFRESNEL: boolean;
  109123. REFRACTIONFRESNEL: boolean;
  109124. EMISSIVEFRESNEL: boolean;
  109125. FRESNEL: boolean;
  109126. NORMAL: boolean;
  109127. UV1: boolean;
  109128. UV2: boolean;
  109129. VERTEXCOLOR: boolean;
  109130. VERTEXALPHA: boolean;
  109131. NUM_BONE_INFLUENCERS: number;
  109132. BonesPerMesh: number;
  109133. BONETEXTURE: boolean;
  109134. INSTANCES: boolean;
  109135. THIN_INSTANCES: boolean;
  109136. GLOSSINESS: boolean;
  109137. ROUGHNESS: boolean;
  109138. EMISSIVEASILLUMINATION: boolean;
  109139. LINKEMISSIVEWITHDIFFUSE: boolean;
  109140. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109141. LIGHTMAP: boolean;
  109142. LIGHTMAPDIRECTUV: number;
  109143. OBJECTSPACE_NORMALMAP: boolean;
  109144. USELIGHTMAPASSHADOWMAP: boolean;
  109145. REFLECTIONMAP_3D: boolean;
  109146. REFLECTIONMAP_SPHERICAL: boolean;
  109147. REFLECTIONMAP_PLANAR: boolean;
  109148. REFLECTIONMAP_CUBIC: boolean;
  109149. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109150. REFLECTIONMAP_PROJECTION: boolean;
  109151. REFLECTIONMAP_SKYBOX: boolean;
  109152. REFLECTIONMAP_EXPLICIT: boolean;
  109153. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109154. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109155. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109156. INVERTCUBICMAP: boolean;
  109157. LOGARITHMICDEPTH: boolean;
  109158. REFRACTION: boolean;
  109159. REFRACTIONMAP_3D: boolean;
  109160. REFLECTIONOVERALPHA: boolean;
  109161. TWOSIDEDLIGHTING: boolean;
  109162. SHADOWFLOAT: boolean;
  109163. MORPHTARGETS: boolean;
  109164. MORPHTARGETS_NORMAL: boolean;
  109165. MORPHTARGETS_TANGENT: boolean;
  109166. MORPHTARGETS_UV: boolean;
  109167. NUM_MORPH_INFLUENCERS: number;
  109168. NONUNIFORMSCALING: boolean;
  109169. PREMULTIPLYALPHA: boolean;
  109170. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109171. ALPHABLEND: boolean;
  109172. PREPASS: boolean;
  109173. SCENE_MRT_COUNT: number;
  109174. RGBDLIGHTMAP: boolean;
  109175. RGBDREFLECTION: boolean;
  109176. RGBDREFRACTION: boolean;
  109177. IMAGEPROCESSING: boolean;
  109178. VIGNETTE: boolean;
  109179. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109180. VIGNETTEBLENDMODEOPAQUE: boolean;
  109181. TONEMAPPING: boolean;
  109182. TONEMAPPING_ACES: boolean;
  109183. CONTRAST: boolean;
  109184. COLORCURVES: boolean;
  109185. COLORGRADING: boolean;
  109186. COLORGRADING3D: boolean;
  109187. SAMPLER3DGREENDEPTH: boolean;
  109188. SAMPLER3DBGRMAP: boolean;
  109189. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109190. MULTIVIEW: boolean;
  109191. /**
  109192. * If the reflection texture on this material is in linear color space
  109193. * @hidden
  109194. */
  109195. IS_REFLECTION_LINEAR: boolean;
  109196. /**
  109197. * If the refraction texture on this material is in linear color space
  109198. * @hidden
  109199. */
  109200. IS_REFRACTION_LINEAR: boolean;
  109201. EXPOSURE: boolean;
  109202. constructor();
  109203. setReflectionMode(modeToEnable: string): void;
  109204. }
  109205. /**
  109206. * This is the default material used in Babylon. It is the best trade off between quality
  109207. * and performances.
  109208. * @see https://doc.babylonjs.com/babylon101/materials
  109209. */
  109210. export class StandardMaterial extends PushMaterial {
  109211. private _diffuseTexture;
  109212. /**
  109213. * The basic texture of the material as viewed under a light.
  109214. */
  109215. diffuseTexture: Nullable<BaseTexture>;
  109216. private _ambientTexture;
  109217. /**
  109218. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109219. */
  109220. ambientTexture: Nullable<BaseTexture>;
  109221. private _opacityTexture;
  109222. /**
  109223. * Define the transparency of the material from a texture.
  109224. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109225. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109226. */
  109227. opacityTexture: Nullable<BaseTexture>;
  109228. private _reflectionTexture;
  109229. /**
  109230. * Define the texture used to display the reflection.
  109231. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109232. */
  109233. reflectionTexture: Nullable<BaseTexture>;
  109234. private _emissiveTexture;
  109235. /**
  109236. * Define texture of the material as if self lit.
  109237. * This will be mixed in the final result even in the absence of light.
  109238. */
  109239. emissiveTexture: Nullable<BaseTexture>;
  109240. private _specularTexture;
  109241. /**
  109242. * Define how the color and intensity of the highlight given by the light in the material.
  109243. */
  109244. specularTexture: Nullable<BaseTexture>;
  109245. private _bumpTexture;
  109246. /**
  109247. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109248. * 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.
  109249. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109250. */
  109251. bumpTexture: Nullable<BaseTexture>;
  109252. private _lightmapTexture;
  109253. /**
  109254. * Complex lighting can be computationally expensive to compute at runtime.
  109255. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109256. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109257. */
  109258. lightmapTexture: Nullable<BaseTexture>;
  109259. private _refractionTexture;
  109260. /**
  109261. * Define the texture used to display the refraction.
  109262. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109263. */
  109264. refractionTexture: Nullable<BaseTexture>;
  109265. /**
  109266. * The color of the material lit by the environmental background lighting.
  109267. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109268. */
  109269. ambientColor: Color3;
  109270. /**
  109271. * The basic color of the material as viewed under a light.
  109272. */
  109273. diffuseColor: Color3;
  109274. /**
  109275. * Define how the color and intensity of the highlight given by the light in the material.
  109276. */
  109277. specularColor: Color3;
  109278. /**
  109279. * Define the color of the material as if self lit.
  109280. * This will be mixed in the final result even in the absence of light.
  109281. */
  109282. emissiveColor: Color3;
  109283. /**
  109284. * Defines how sharp are the highlights in the material.
  109285. * The bigger the value the sharper giving a more glossy feeling to the result.
  109286. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109287. */
  109288. specularPower: number;
  109289. private _useAlphaFromDiffuseTexture;
  109290. /**
  109291. * Does the transparency come from the diffuse texture alpha channel.
  109292. */
  109293. useAlphaFromDiffuseTexture: boolean;
  109294. private _useEmissiveAsIllumination;
  109295. /**
  109296. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109297. */
  109298. useEmissiveAsIllumination: boolean;
  109299. private _linkEmissiveWithDiffuse;
  109300. /**
  109301. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109302. * the emissive level when the final color is close to one.
  109303. */
  109304. linkEmissiveWithDiffuse: boolean;
  109305. private _useSpecularOverAlpha;
  109306. /**
  109307. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109308. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109309. */
  109310. useSpecularOverAlpha: boolean;
  109311. private _useReflectionOverAlpha;
  109312. /**
  109313. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109314. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109315. */
  109316. useReflectionOverAlpha: boolean;
  109317. private _disableLighting;
  109318. /**
  109319. * Does lights from the scene impacts this material.
  109320. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109321. */
  109322. disableLighting: boolean;
  109323. private _useObjectSpaceNormalMap;
  109324. /**
  109325. * Allows using an object space normal map (instead of tangent space).
  109326. */
  109327. useObjectSpaceNormalMap: boolean;
  109328. private _useParallax;
  109329. /**
  109330. * Is parallax enabled or not.
  109331. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109332. */
  109333. useParallax: boolean;
  109334. private _useParallaxOcclusion;
  109335. /**
  109336. * Is parallax occlusion enabled or not.
  109337. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109338. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109339. */
  109340. useParallaxOcclusion: boolean;
  109341. /**
  109342. * 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.
  109343. */
  109344. parallaxScaleBias: number;
  109345. private _roughness;
  109346. /**
  109347. * Helps to define how blurry the reflections should appears in the material.
  109348. */
  109349. roughness: number;
  109350. /**
  109351. * In case of refraction, define the value of the index of refraction.
  109352. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109353. */
  109354. indexOfRefraction: number;
  109355. /**
  109356. * Invert the refraction texture alongside the y axis.
  109357. * It can be useful with procedural textures or probe for instance.
  109358. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109359. */
  109360. invertRefractionY: boolean;
  109361. /**
  109362. * Defines the alpha limits in alpha test mode.
  109363. */
  109364. alphaCutOff: number;
  109365. private _useLightmapAsShadowmap;
  109366. /**
  109367. * In case of light mapping, define whether the map contains light or shadow informations.
  109368. */
  109369. useLightmapAsShadowmap: boolean;
  109370. private _diffuseFresnelParameters;
  109371. /**
  109372. * Define the diffuse fresnel parameters of the material.
  109373. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109374. */
  109375. diffuseFresnelParameters: FresnelParameters;
  109376. private _opacityFresnelParameters;
  109377. /**
  109378. * Define the opacity fresnel parameters of the material.
  109379. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109380. */
  109381. opacityFresnelParameters: FresnelParameters;
  109382. private _reflectionFresnelParameters;
  109383. /**
  109384. * Define the reflection fresnel parameters of the material.
  109385. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109386. */
  109387. reflectionFresnelParameters: FresnelParameters;
  109388. private _refractionFresnelParameters;
  109389. /**
  109390. * Define the refraction fresnel parameters of the material.
  109391. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109392. */
  109393. refractionFresnelParameters: FresnelParameters;
  109394. private _emissiveFresnelParameters;
  109395. /**
  109396. * Define the emissive fresnel parameters of the material.
  109397. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109398. */
  109399. emissiveFresnelParameters: FresnelParameters;
  109400. private _useReflectionFresnelFromSpecular;
  109401. /**
  109402. * If true automatically deducts the fresnels values from the material specularity.
  109403. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109404. */
  109405. useReflectionFresnelFromSpecular: boolean;
  109406. private _useGlossinessFromSpecularMapAlpha;
  109407. /**
  109408. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109409. */
  109410. useGlossinessFromSpecularMapAlpha: boolean;
  109411. private _maxSimultaneousLights;
  109412. /**
  109413. * Defines the maximum number of lights that can be used in the material
  109414. */
  109415. maxSimultaneousLights: number;
  109416. private _invertNormalMapX;
  109417. /**
  109418. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109419. */
  109420. invertNormalMapX: boolean;
  109421. private _invertNormalMapY;
  109422. /**
  109423. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109424. */
  109425. invertNormalMapY: boolean;
  109426. private _twoSidedLighting;
  109427. /**
  109428. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109429. */
  109430. twoSidedLighting: boolean;
  109431. /**
  109432. * Default configuration related to image processing available in the standard Material.
  109433. */
  109434. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109435. /**
  109436. * Gets the image processing configuration used either in this material.
  109437. */
  109438. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109439. /**
  109440. * Sets the Default image processing configuration used either in the this material.
  109441. *
  109442. * If sets to null, the scene one is in use.
  109443. */
  109444. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109445. /**
  109446. * Keep track of the image processing observer to allow dispose and replace.
  109447. */
  109448. private _imageProcessingObserver;
  109449. /**
  109450. * Attaches a new image processing configuration to the Standard Material.
  109451. * @param configuration
  109452. */
  109453. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109454. /**
  109455. * Gets wether the color curves effect is enabled.
  109456. */
  109457. get cameraColorCurvesEnabled(): boolean;
  109458. /**
  109459. * Sets wether the color curves effect is enabled.
  109460. */
  109461. set cameraColorCurvesEnabled(value: boolean);
  109462. /**
  109463. * Gets wether the color grading effect is enabled.
  109464. */
  109465. get cameraColorGradingEnabled(): boolean;
  109466. /**
  109467. * Gets wether the color grading effect is enabled.
  109468. */
  109469. set cameraColorGradingEnabled(value: boolean);
  109470. /**
  109471. * Gets wether tonemapping is enabled or not.
  109472. */
  109473. get cameraToneMappingEnabled(): boolean;
  109474. /**
  109475. * Sets wether tonemapping is enabled or not
  109476. */
  109477. set cameraToneMappingEnabled(value: boolean);
  109478. /**
  109479. * The camera exposure used on this material.
  109480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109481. * This corresponds to a photographic exposure.
  109482. */
  109483. get cameraExposure(): number;
  109484. /**
  109485. * The camera exposure used on this material.
  109486. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109487. * This corresponds to a photographic exposure.
  109488. */
  109489. set cameraExposure(value: number);
  109490. /**
  109491. * Gets The camera contrast used on this material.
  109492. */
  109493. get cameraContrast(): number;
  109494. /**
  109495. * Sets The camera contrast used on this material.
  109496. */
  109497. set cameraContrast(value: number);
  109498. /**
  109499. * Gets the Color Grading 2D Lookup Texture.
  109500. */
  109501. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109502. /**
  109503. * Sets the Color Grading 2D Lookup Texture.
  109504. */
  109505. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109506. /**
  109507. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109508. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109509. * 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;
  109510. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109511. */
  109512. get cameraColorCurves(): Nullable<ColorCurves>;
  109513. /**
  109514. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109515. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109516. * 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;
  109517. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109518. */
  109519. set cameraColorCurves(value: Nullable<ColorCurves>);
  109520. /**
  109521. * Can this material render to several textures at once
  109522. */
  109523. get canRenderToMRT(): boolean;
  109524. /**
  109525. * Defines the detail map parameters for the material.
  109526. */
  109527. readonly detailMap: DetailMapConfiguration;
  109528. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109529. protected _worldViewProjectionMatrix: Matrix;
  109530. protected _globalAmbientColor: Color3;
  109531. protected _useLogarithmicDepth: boolean;
  109532. protected _rebuildInParallel: boolean;
  109533. /**
  109534. * Instantiates a new standard material.
  109535. * This is the default material used in Babylon. It is the best trade off between quality
  109536. * and performances.
  109537. * @see https://doc.babylonjs.com/babylon101/materials
  109538. * @param name Define the name of the material in the scene
  109539. * @param scene Define the scene the material belong to
  109540. */
  109541. constructor(name: string, scene: Scene);
  109542. /**
  109543. * Gets a boolean indicating that current material needs to register RTT
  109544. */
  109545. get hasRenderTargetTextures(): boolean;
  109546. /**
  109547. * Gets the current class name of the material e.g. "StandardMaterial"
  109548. * Mainly use in serialization.
  109549. * @returns the class name
  109550. */
  109551. getClassName(): string;
  109552. /**
  109553. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109554. * You can try switching to logarithmic depth.
  109555. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109556. */
  109557. get useLogarithmicDepth(): boolean;
  109558. set useLogarithmicDepth(value: boolean);
  109559. /**
  109560. * Specifies if the material will require alpha blending
  109561. * @returns a boolean specifying if alpha blending is needed
  109562. */
  109563. needAlphaBlending(): boolean;
  109564. /**
  109565. * Specifies if this material should be rendered in alpha test mode
  109566. * @returns a boolean specifying if an alpha test is needed.
  109567. */
  109568. needAlphaTesting(): boolean;
  109569. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109570. /**
  109571. * Get the texture used for alpha test purpose.
  109572. * @returns the diffuse texture in case of the standard material.
  109573. */
  109574. getAlphaTestTexture(): Nullable<BaseTexture>;
  109575. /**
  109576. * Get if the submesh is ready to be used and all its information available.
  109577. * Child classes can use it to update shaders
  109578. * @param mesh defines the mesh to check
  109579. * @param subMesh defines which submesh to check
  109580. * @param useInstances specifies that instances should be used
  109581. * @returns a boolean indicating that the submesh is ready or not
  109582. */
  109583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109584. /**
  109585. * Builds the material UBO layouts.
  109586. * Used internally during the effect preparation.
  109587. */
  109588. buildUniformLayout(): void;
  109589. /**
  109590. * Unbinds the material from the mesh
  109591. */
  109592. unbind(): void;
  109593. /**
  109594. * Binds the submesh to this material by preparing the effect and shader to draw
  109595. * @param world defines the world transformation matrix
  109596. * @param mesh defines the mesh containing the submesh
  109597. * @param subMesh defines the submesh to bind the material to
  109598. */
  109599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109600. /**
  109601. * Get the list of animatables in the material.
  109602. * @returns the list of animatables object used in the material
  109603. */
  109604. getAnimatables(): IAnimatable[];
  109605. /**
  109606. * Gets the active textures from the material
  109607. * @returns an array of textures
  109608. */
  109609. getActiveTextures(): BaseTexture[];
  109610. /**
  109611. * Specifies if the material uses a texture
  109612. * @param texture defines the texture to check against the material
  109613. * @returns a boolean specifying if the material uses the texture
  109614. */
  109615. hasTexture(texture: BaseTexture): boolean;
  109616. /**
  109617. * Disposes the material
  109618. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109619. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109620. */
  109621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109622. /**
  109623. * Makes a duplicate of the material, and gives it a new name
  109624. * @param name defines the new name for the duplicated material
  109625. * @returns the cloned material
  109626. */
  109627. clone(name: string): StandardMaterial;
  109628. /**
  109629. * Serializes this material in a JSON representation
  109630. * @returns the serialized material object
  109631. */
  109632. serialize(): any;
  109633. /**
  109634. * Creates a standard material from parsed material data
  109635. * @param source defines the JSON representation of the material
  109636. * @param scene defines the hosting scene
  109637. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109638. * @returns a new standard material
  109639. */
  109640. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109641. /**
  109642. * Are diffuse textures enabled in the application.
  109643. */
  109644. static get DiffuseTextureEnabled(): boolean;
  109645. static set DiffuseTextureEnabled(value: boolean);
  109646. /**
  109647. * Are detail textures enabled in the application.
  109648. */
  109649. static get DetailTextureEnabled(): boolean;
  109650. static set DetailTextureEnabled(value: boolean);
  109651. /**
  109652. * Are ambient textures enabled in the application.
  109653. */
  109654. static get AmbientTextureEnabled(): boolean;
  109655. static set AmbientTextureEnabled(value: boolean);
  109656. /**
  109657. * Are opacity textures enabled in the application.
  109658. */
  109659. static get OpacityTextureEnabled(): boolean;
  109660. static set OpacityTextureEnabled(value: boolean);
  109661. /**
  109662. * Are reflection textures enabled in the application.
  109663. */
  109664. static get ReflectionTextureEnabled(): boolean;
  109665. static set ReflectionTextureEnabled(value: boolean);
  109666. /**
  109667. * Are emissive textures enabled in the application.
  109668. */
  109669. static get EmissiveTextureEnabled(): boolean;
  109670. static set EmissiveTextureEnabled(value: boolean);
  109671. /**
  109672. * Are specular textures enabled in the application.
  109673. */
  109674. static get SpecularTextureEnabled(): boolean;
  109675. static set SpecularTextureEnabled(value: boolean);
  109676. /**
  109677. * Are bump textures enabled in the application.
  109678. */
  109679. static get BumpTextureEnabled(): boolean;
  109680. static set BumpTextureEnabled(value: boolean);
  109681. /**
  109682. * Are lightmap textures enabled in the application.
  109683. */
  109684. static get LightmapTextureEnabled(): boolean;
  109685. static set LightmapTextureEnabled(value: boolean);
  109686. /**
  109687. * Are refraction textures enabled in the application.
  109688. */
  109689. static get RefractionTextureEnabled(): boolean;
  109690. static set RefractionTextureEnabled(value: boolean);
  109691. /**
  109692. * Are color grading textures enabled in the application.
  109693. */
  109694. static get ColorGradingTextureEnabled(): boolean;
  109695. static set ColorGradingTextureEnabled(value: boolean);
  109696. /**
  109697. * Are fresnels enabled in the application.
  109698. */
  109699. static get FresnelEnabled(): boolean;
  109700. static set FresnelEnabled(value: boolean);
  109701. }
  109702. }
  109703. declare module BABYLON {
  109704. /**
  109705. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109706. *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.
  109707. * The SPS is also a particle system. It provides some methods to manage the particles.
  109708. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109709. *
  109710. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109711. */
  109712. export class SolidParticleSystem implements IDisposable {
  109713. /**
  109714. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109715. * Example : var p = SPS.particles[i];
  109716. */
  109717. particles: SolidParticle[];
  109718. /**
  109719. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109720. */
  109721. nbParticles: number;
  109722. /**
  109723. * If the particles must ever face the camera (default false). Useful for planar particles.
  109724. */
  109725. billboard: boolean;
  109726. /**
  109727. * Recompute normals when adding a shape
  109728. */
  109729. recomputeNormals: boolean;
  109730. /**
  109731. * This a counter ofr your own usage. It's not set by any SPS functions.
  109732. */
  109733. counter: number;
  109734. /**
  109735. * The SPS name. This name is also given to the underlying mesh.
  109736. */
  109737. name: string;
  109738. /**
  109739. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109740. */
  109741. mesh: Mesh;
  109742. /**
  109743. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109744. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109745. */
  109746. vars: any;
  109747. /**
  109748. * This array is populated when the SPS is set as 'pickable'.
  109749. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109750. * Each element of this array is an object `{idx: int, faceId: int}`.
  109751. * `idx` is the picked particle index in the `SPS.particles` array
  109752. * `faceId` is the picked face index counted within this particle.
  109753. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109754. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109755. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109756. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109757. */
  109758. pickedParticles: {
  109759. idx: number;
  109760. faceId: number;
  109761. }[];
  109762. /**
  109763. * This array is populated when the SPS is set as 'pickable'
  109764. * Each key of this array is a submesh index.
  109765. * Each element of this array is a second array defined like this :
  109766. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109767. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109768. * `idx` is the picked particle index in the `SPS.particles` array
  109769. * `faceId` is the picked face index counted within this particle.
  109770. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109771. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109772. */
  109773. pickedBySubMesh: {
  109774. idx: number;
  109775. faceId: number;
  109776. }[][];
  109777. /**
  109778. * This array is populated when `enableDepthSort` is set to true.
  109779. * Each element of this array is an instance of the class DepthSortedParticle.
  109780. */
  109781. depthSortedParticles: DepthSortedParticle[];
  109782. /**
  109783. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109784. * @hidden
  109785. */
  109786. _bSphereOnly: boolean;
  109787. /**
  109788. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109789. * @hidden
  109790. */
  109791. _bSphereRadiusFactor: number;
  109792. private _scene;
  109793. private _positions;
  109794. private _indices;
  109795. private _normals;
  109796. private _colors;
  109797. private _uvs;
  109798. private _indices32;
  109799. private _positions32;
  109800. private _normals32;
  109801. private _fixedNormal32;
  109802. private _colors32;
  109803. private _uvs32;
  109804. private _index;
  109805. private _updatable;
  109806. private _pickable;
  109807. private _isVisibilityBoxLocked;
  109808. private _alwaysVisible;
  109809. private _depthSort;
  109810. private _expandable;
  109811. private _shapeCounter;
  109812. private _copy;
  109813. private _color;
  109814. private _computeParticleColor;
  109815. private _computeParticleTexture;
  109816. private _computeParticleRotation;
  109817. private _computeParticleVertex;
  109818. private _computeBoundingBox;
  109819. private _depthSortParticles;
  109820. private _camera;
  109821. private _mustUnrotateFixedNormals;
  109822. private _particlesIntersect;
  109823. private _needs32Bits;
  109824. private _isNotBuilt;
  109825. private _lastParticleId;
  109826. private _idxOfId;
  109827. private _multimaterialEnabled;
  109828. private _useModelMaterial;
  109829. private _indicesByMaterial;
  109830. private _materialIndexes;
  109831. private _depthSortFunction;
  109832. private _materialSortFunction;
  109833. private _materials;
  109834. private _multimaterial;
  109835. private _materialIndexesById;
  109836. private _defaultMaterial;
  109837. private _autoUpdateSubMeshes;
  109838. private _tmpVertex;
  109839. /**
  109840. * Creates a SPS (Solid Particle System) object.
  109841. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109842. * @param scene (Scene) is the scene in which the SPS is added.
  109843. * @param options defines the options of the sps e.g.
  109844. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109845. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109846. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109847. * * 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.
  109848. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  109849. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  109850. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109851. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109852. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109853. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109854. */
  109855. constructor(name: string, scene: Scene, options?: {
  109856. updatable?: boolean;
  109857. isPickable?: boolean;
  109858. enableDepthSort?: boolean;
  109859. particleIntersection?: boolean;
  109860. boundingSphereOnly?: boolean;
  109861. bSphereRadiusFactor?: number;
  109862. expandable?: boolean;
  109863. useModelMaterial?: boolean;
  109864. enableMultiMaterial?: boolean;
  109865. });
  109866. /**
  109867. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109868. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109869. * @returns the created mesh
  109870. */
  109871. buildMesh(): Mesh;
  109872. /**
  109873. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109874. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109875. * Thus the particles generated from `digest()` have their property `position` set yet.
  109876. * @param mesh ( Mesh ) is the mesh to be digested
  109877. * @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
  109878. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109879. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109880. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109881. * @returns the current SPS
  109882. */
  109883. digest(mesh: Mesh, options?: {
  109884. facetNb?: number;
  109885. number?: number;
  109886. delta?: number;
  109887. storage?: [];
  109888. }): SolidParticleSystem;
  109889. /**
  109890. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109891. * @hidden
  109892. */
  109893. private _unrotateFixedNormals;
  109894. /**
  109895. * Resets the temporary working copy particle
  109896. * @hidden
  109897. */
  109898. private _resetCopy;
  109899. /**
  109900. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  109901. * @param p the current index in the positions array to be updated
  109902. * @param ind the current index in the indices array
  109903. * @param shape a Vector3 array, the shape geometry
  109904. * @param positions the positions array to be updated
  109905. * @param meshInd the shape indices array
  109906. * @param indices the indices array to be updated
  109907. * @param meshUV the shape uv array
  109908. * @param uvs the uv array to be updated
  109909. * @param meshCol the shape color array
  109910. * @param colors the color array to be updated
  109911. * @param meshNor the shape normals array
  109912. * @param normals the normals array to be updated
  109913. * @param idx the particle index
  109914. * @param idxInShape the particle index in its shape
  109915. * @param options the addShape() method passed options
  109916. * @model the particle model
  109917. * @hidden
  109918. */
  109919. private _meshBuilder;
  109920. /**
  109921. * Returns a shape Vector3 array from positions float array
  109922. * @param positions float array
  109923. * @returns a vector3 array
  109924. * @hidden
  109925. */
  109926. private _posToShape;
  109927. /**
  109928. * Returns a shapeUV array from a float uvs (array deep copy)
  109929. * @param uvs as a float array
  109930. * @returns a shapeUV array
  109931. * @hidden
  109932. */
  109933. private _uvsToShapeUV;
  109934. /**
  109935. * Adds a new particle object in the particles array
  109936. * @param idx particle index in particles array
  109937. * @param id particle id
  109938. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  109939. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  109940. * @param model particle ModelShape object
  109941. * @param shapeId model shape identifier
  109942. * @param idxInShape index of the particle in the current model
  109943. * @param bInfo model bounding info object
  109944. * @param storage target storage array, if any
  109945. * @hidden
  109946. */
  109947. private _addParticle;
  109948. /**
  109949. * Adds some particles to the SPS from the model shape. Returns the shape id.
  109950. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  109951. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  109952. * @param nb (positive integer) the number of particles to be created from this model
  109953. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  109954. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  109955. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109956. * @returns the number of shapes in the system
  109957. */
  109958. addShape(mesh: Mesh, nb: number, options?: {
  109959. positionFunction?: any;
  109960. vertexFunction?: any;
  109961. storage?: [];
  109962. }): number;
  109963. /**
  109964. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  109965. * @hidden
  109966. */
  109967. private _rebuildParticle;
  109968. /**
  109969. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109970. * @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.
  109971. * @returns the SPS.
  109972. */
  109973. rebuildMesh(reset?: boolean): SolidParticleSystem;
  109974. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  109975. * Returns an array with the removed particles.
  109976. * 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.
  109977. * The SPS can't be empty so at least one particle needs to remain in place.
  109978. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  109979. * @param start index of the first particle to remove
  109980. * @param end index of the last particle to remove (included)
  109981. * @returns an array populated with the removed particles
  109982. */
  109983. removeParticles(start: number, end: number): SolidParticle[];
  109984. /**
  109985. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  109986. * @param solidParticleArray an array populated with Solid Particles objects
  109987. * @returns the SPS
  109988. */
  109989. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  109990. /**
  109991. * Creates a new particle and modifies the SPS mesh geometry :
  109992. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  109993. * - calls _addParticle() to populate the particle array
  109994. * factorized code from addShape() and insertParticlesFromArray()
  109995. * @param idx particle index in the particles array
  109996. * @param i particle index in its shape
  109997. * @param modelShape particle ModelShape object
  109998. * @param shape shape vertex array
  109999. * @param meshInd shape indices array
  110000. * @param meshUV shape uv array
  110001. * @param meshCol shape color array
  110002. * @param meshNor shape normals array
  110003. * @param bbInfo shape bounding info
  110004. * @param storage target particle storage
  110005. * @options addShape() passed options
  110006. * @hidden
  110007. */
  110008. private _insertNewParticle;
  110009. /**
  110010. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110011. * This method calls `updateParticle()` for each particle of the SPS.
  110012. * For an animated SPS, it is usually called within the render loop.
  110013. * 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.
  110014. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110015. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110016. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110017. * @returns the SPS.
  110018. */
  110019. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110020. /**
  110021. * Disposes the SPS.
  110022. */
  110023. dispose(): void;
  110024. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110025. * idx is the particle index in the SPS
  110026. * faceId is the picked face index counted within this particle.
  110027. * Returns null if the pickInfo can't identify a picked particle.
  110028. * @param pickingInfo (PickingInfo object)
  110029. * @returns {idx: number, faceId: number} or null
  110030. */
  110031. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110032. idx: number;
  110033. faceId: number;
  110034. }>;
  110035. /**
  110036. * Returns a SolidParticle object from its identifier : particle.id
  110037. * @param id (integer) the particle Id
  110038. * @returns the searched particle or null if not found in the SPS.
  110039. */
  110040. getParticleById(id: number): Nullable<SolidParticle>;
  110041. /**
  110042. * Returns a new array populated with the particles having the passed shapeId.
  110043. * @param shapeId (integer) the shape identifier
  110044. * @returns a new solid particle array
  110045. */
  110046. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110047. /**
  110048. * Populates the passed array "ref" with the particles having the passed shapeId.
  110049. * @param shapeId the shape identifier
  110050. * @returns the SPS
  110051. * @param ref
  110052. */
  110053. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110054. /**
  110055. * Computes the required SubMeshes according the materials assigned to the particles.
  110056. * @returns the solid particle system.
  110057. * Does nothing if called before the SPS mesh is built.
  110058. */
  110059. computeSubMeshes(): SolidParticleSystem;
  110060. /**
  110061. * Sorts the solid particles by material when MultiMaterial is enabled.
  110062. * Updates the indices32 array.
  110063. * Updates the indicesByMaterial array.
  110064. * Updates the mesh indices array.
  110065. * @returns the SPS
  110066. * @hidden
  110067. */
  110068. private _sortParticlesByMaterial;
  110069. /**
  110070. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110071. * @hidden
  110072. */
  110073. private _setMaterialIndexesById;
  110074. /**
  110075. * Returns an array with unique values of Materials from the passed array
  110076. * @param array the material array to be checked and filtered
  110077. * @hidden
  110078. */
  110079. private _filterUniqueMaterialId;
  110080. /**
  110081. * Sets a new Standard Material as _defaultMaterial if not already set.
  110082. * @hidden
  110083. */
  110084. private _setDefaultMaterial;
  110085. /**
  110086. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110087. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110088. * @returns the SPS.
  110089. */
  110090. refreshVisibleSize(): SolidParticleSystem;
  110091. /**
  110092. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110093. * @param size the size (float) of the visibility box
  110094. * note : this doesn't lock the SPS mesh bounding box.
  110095. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110096. */
  110097. setVisibilityBox(size: number): void;
  110098. /**
  110099. * Gets whether the SPS as always visible or not
  110100. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110101. */
  110102. get isAlwaysVisible(): boolean;
  110103. /**
  110104. * Sets the SPS as always visible or not
  110105. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110106. */
  110107. set isAlwaysVisible(val: boolean);
  110108. /**
  110109. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110110. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110111. */
  110112. set isVisibilityBoxLocked(val: boolean);
  110113. /**
  110114. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110115. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110116. */
  110117. get isVisibilityBoxLocked(): boolean;
  110118. /**
  110119. * Tells to `setParticles()` to compute the particle rotations or not.
  110120. * Default value : true. The SPS is faster when it's set to false.
  110121. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110122. */
  110123. set computeParticleRotation(val: boolean);
  110124. /**
  110125. * Tells to `setParticles()` to compute the particle colors or not.
  110126. * Default value : true. The SPS is faster when it's set to false.
  110127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110128. */
  110129. set computeParticleColor(val: boolean);
  110130. set computeParticleTexture(val: boolean);
  110131. /**
  110132. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110133. * Default value : false. The SPS is faster when it's set to false.
  110134. * Note : the particle custom vertex positions aren't stored values.
  110135. */
  110136. set computeParticleVertex(val: boolean);
  110137. /**
  110138. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110139. */
  110140. set computeBoundingBox(val: boolean);
  110141. /**
  110142. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110143. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110144. * Default : `true`
  110145. */
  110146. set depthSortParticles(val: boolean);
  110147. /**
  110148. * Gets if `setParticles()` computes the particle rotations or not.
  110149. * Default value : true. The SPS is faster when it's set to false.
  110150. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110151. */
  110152. get computeParticleRotation(): boolean;
  110153. /**
  110154. * Gets if `setParticles()` computes the particle colors or not.
  110155. * Default value : true. The SPS is faster when it's set to false.
  110156. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110157. */
  110158. get computeParticleColor(): boolean;
  110159. /**
  110160. * Gets if `setParticles()` computes the particle textures or not.
  110161. * Default value : true. The SPS is faster when it's set to false.
  110162. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110163. */
  110164. get computeParticleTexture(): boolean;
  110165. /**
  110166. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110167. * Default value : false. The SPS is faster when it's set to false.
  110168. * Note : the particle custom vertex positions aren't stored values.
  110169. */
  110170. get computeParticleVertex(): boolean;
  110171. /**
  110172. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110173. */
  110174. get computeBoundingBox(): boolean;
  110175. /**
  110176. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110177. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110178. * Default : `true`
  110179. */
  110180. get depthSortParticles(): boolean;
  110181. /**
  110182. * Gets if the SPS is created as expandable at construction time.
  110183. * Default : `false`
  110184. */
  110185. get expandable(): boolean;
  110186. /**
  110187. * Gets if the SPS supports the Multi Materials
  110188. */
  110189. get multimaterialEnabled(): boolean;
  110190. /**
  110191. * Gets if the SPS uses the model materials for its own multimaterial.
  110192. */
  110193. get useModelMaterial(): boolean;
  110194. /**
  110195. * The SPS used material array.
  110196. */
  110197. get materials(): Material[];
  110198. /**
  110199. * Sets the SPS MultiMaterial from the passed materials.
  110200. * Note : the passed array is internally copied and not used then by reference.
  110201. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110202. */
  110203. setMultiMaterial(materials: Material[]): void;
  110204. /**
  110205. * The SPS computed multimaterial object
  110206. */
  110207. get multimaterial(): MultiMaterial;
  110208. set multimaterial(mm: MultiMaterial);
  110209. /**
  110210. * If the subMeshes must be updated on the next call to setParticles()
  110211. */
  110212. get autoUpdateSubMeshes(): boolean;
  110213. set autoUpdateSubMeshes(val: boolean);
  110214. /**
  110215. * This function does nothing. It may be overwritten to set all the particle first values.
  110216. * The SPS doesn't call this function, you may have to call it by your own.
  110217. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110218. */
  110219. initParticles(): void;
  110220. /**
  110221. * This function does nothing. It may be overwritten to recycle a particle.
  110222. * The SPS doesn't call this function, you may have to call it by your own.
  110223. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110224. * @param particle The particle to recycle
  110225. * @returns the recycled particle
  110226. */
  110227. recycleParticle(particle: SolidParticle): SolidParticle;
  110228. /**
  110229. * Updates a particle : this function should be overwritten by the user.
  110230. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110231. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110232. * @example : just set a particle position or velocity and recycle conditions
  110233. * @param particle The particle to update
  110234. * @returns the updated particle
  110235. */
  110236. updateParticle(particle: SolidParticle): SolidParticle;
  110237. /**
  110238. * Updates a vertex of a particle : it can be overwritten by the user.
  110239. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110240. * @param particle the current particle
  110241. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110242. * @param pt the index of the current vertex in the particle shape
  110243. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110244. * @example : just set a vertex particle position or color
  110245. * @returns the sps
  110246. */
  110247. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110248. /**
  110249. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110250. * This does nothing and may be overwritten by the user.
  110251. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110252. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110253. * @param update the boolean update value actually passed to setParticles()
  110254. */
  110255. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110256. /**
  110257. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110258. * This will be passed three parameters.
  110259. * This does nothing and may be overwritten by the user.
  110260. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110261. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110262. * @param update the boolean update value actually passed to setParticles()
  110263. */
  110264. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110265. }
  110266. }
  110267. declare module BABYLON {
  110268. /**
  110269. * Represents one particle of a solid particle system.
  110270. */
  110271. export class SolidParticle {
  110272. /**
  110273. * particle global index
  110274. */
  110275. idx: number;
  110276. /**
  110277. * particle identifier
  110278. */
  110279. id: number;
  110280. /**
  110281. * The color of the particle
  110282. */
  110283. color: Nullable<Color4>;
  110284. /**
  110285. * The world space position of the particle.
  110286. */
  110287. position: Vector3;
  110288. /**
  110289. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110290. */
  110291. rotation: Vector3;
  110292. /**
  110293. * The world space rotation quaternion of the particle.
  110294. */
  110295. rotationQuaternion: Nullable<Quaternion>;
  110296. /**
  110297. * The scaling of the particle.
  110298. */
  110299. scaling: Vector3;
  110300. /**
  110301. * The uvs of the particle.
  110302. */
  110303. uvs: Vector4;
  110304. /**
  110305. * The current speed of the particle.
  110306. */
  110307. velocity: Vector3;
  110308. /**
  110309. * The pivot point in the particle local space.
  110310. */
  110311. pivot: Vector3;
  110312. /**
  110313. * Must the particle be translated from its pivot point in its local space ?
  110314. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110315. * Default : false
  110316. */
  110317. translateFromPivot: boolean;
  110318. /**
  110319. * Is the particle active or not ?
  110320. */
  110321. alive: boolean;
  110322. /**
  110323. * Is the particle visible or not ?
  110324. */
  110325. isVisible: boolean;
  110326. /**
  110327. * Index of this particle in the global "positions" array (Internal use)
  110328. * @hidden
  110329. */
  110330. _pos: number;
  110331. /**
  110332. * @hidden Index of this particle in the global "indices" array (Internal use)
  110333. */
  110334. _ind: number;
  110335. /**
  110336. * @hidden ModelShape of this particle (Internal use)
  110337. */
  110338. _model: ModelShape;
  110339. /**
  110340. * ModelShape id of this particle
  110341. */
  110342. shapeId: number;
  110343. /**
  110344. * Index of the particle in its shape id
  110345. */
  110346. idxInShape: number;
  110347. /**
  110348. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110349. */
  110350. _modelBoundingInfo: BoundingInfo;
  110351. /**
  110352. * @hidden Particle BoundingInfo object (Internal use)
  110353. */
  110354. _boundingInfo: BoundingInfo;
  110355. /**
  110356. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110357. */
  110358. _sps: SolidParticleSystem;
  110359. /**
  110360. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110361. */
  110362. _stillInvisible: boolean;
  110363. /**
  110364. * @hidden Last computed particle rotation matrix
  110365. */
  110366. _rotationMatrix: number[];
  110367. /**
  110368. * Parent particle Id, if any.
  110369. * Default null.
  110370. */
  110371. parentId: Nullable<number>;
  110372. /**
  110373. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110374. */
  110375. materialIndex: Nullable<number>;
  110376. /**
  110377. * Custom object or properties.
  110378. */
  110379. props: Nullable<any>;
  110380. /**
  110381. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110382. * The possible values are :
  110383. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110384. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110385. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110386. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110387. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110388. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110389. * */
  110390. cullingStrategy: number;
  110391. /**
  110392. * @hidden Internal global position in the SPS.
  110393. */
  110394. _globalPosition: Vector3;
  110395. /**
  110396. * Creates a Solid Particle object.
  110397. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110398. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110399. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110400. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110401. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110402. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110403. * @param shapeId (integer) is the model shape identifier in the SPS.
  110404. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110405. * @param sps defines the sps it is associated to
  110406. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110407. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110408. */
  110409. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110410. /**
  110411. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110412. * @param target the particle target
  110413. * @returns the current particle
  110414. */
  110415. copyToRef(target: SolidParticle): SolidParticle;
  110416. /**
  110417. * Legacy support, changed scale to scaling
  110418. */
  110419. get scale(): Vector3;
  110420. /**
  110421. * Legacy support, changed scale to scaling
  110422. */
  110423. set scale(scale: Vector3);
  110424. /**
  110425. * Legacy support, changed quaternion to rotationQuaternion
  110426. */
  110427. get quaternion(): Nullable<Quaternion>;
  110428. /**
  110429. * Legacy support, changed quaternion to rotationQuaternion
  110430. */
  110431. set quaternion(q: Nullable<Quaternion>);
  110432. /**
  110433. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110434. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110435. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110436. * @returns true if it intersects
  110437. */
  110438. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110439. /**
  110440. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110441. * A particle is in the frustum if its bounding box intersects the frustum
  110442. * @param frustumPlanes defines the frustum to test
  110443. * @returns true if the particle is in the frustum planes
  110444. */
  110445. isInFrustum(frustumPlanes: Plane[]): boolean;
  110446. /**
  110447. * get the rotation matrix of the particle
  110448. * @hidden
  110449. */
  110450. getRotationMatrix(m: Matrix): void;
  110451. }
  110452. /**
  110453. * Represents the shape of the model used by one particle of a solid particle system.
  110454. * SPS internal tool, don't use it manually.
  110455. */
  110456. export class ModelShape {
  110457. /**
  110458. * The shape id
  110459. * @hidden
  110460. */
  110461. shapeID: number;
  110462. /**
  110463. * flat array of model positions (internal use)
  110464. * @hidden
  110465. */
  110466. _shape: Vector3[];
  110467. /**
  110468. * flat array of model UVs (internal use)
  110469. * @hidden
  110470. */
  110471. _shapeUV: number[];
  110472. /**
  110473. * color array of the model
  110474. * @hidden
  110475. */
  110476. _shapeColors: number[];
  110477. /**
  110478. * indices array of the model
  110479. * @hidden
  110480. */
  110481. _indices: number[];
  110482. /**
  110483. * normals array of the model
  110484. * @hidden
  110485. */
  110486. _normals: number[];
  110487. /**
  110488. * length of the shape in the model indices array (internal use)
  110489. * @hidden
  110490. */
  110491. _indicesLength: number;
  110492. /**
  110493. * Custom position function (internal use)
  110494. * @hidden
  110495. */
  110496. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110497. /**
  110498. * Custom vertex function (internal use)
  110499. * @hidden
  110500. */
  110501. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110502. /**
  110503. * Model material (internal use)
  110504. * @hidden
  110505. */
  110506. _material: Nullable<Material>;
  110507. /**
  110508. * 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.
  110509. * SPS internal tool, don't use it manually.
  110510. * @hidden
  110511. */
  110512. 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>);
  110513. }
  110514. /**
  110515. * Represents a Depth Sorted Particle in the solid particle system.
  110516. * @hidden
  110517. */
  110518. export class DepthSortedParticle {
  110519. /**
  110520. * Particle index
  110521. */
  110522. idx: number;
  110523. /**
  110524. * Index of the particle in the "indices" array
  110525. */
  110526. ind: number;
  110527. /**
  110528. * Length of the particle shape in the "indices" array
  110529. */
  110530. indicesLength: number;
  110531. /**
  110532. * Squared distance from the particle to the camera
  110533. */
  110534. sqDistance: number;
  110535. /**
  110536. * Material index when used with MultiMaterials
  110537. */
  110538. materialIndex: number;
  110539. /**
  110540. * Creates a new sorted particle
  110541. * @param materialIndex
  110542. */
  110543. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110544. }
  110545. /**
  110546. * Represents a solid particle vertex
  110547. */
  110548. export class SolidParticleVertex {
  110549. /**
  110550. * Vertex position
  110551. */
  110552. position: Vector3;
  110553. /**
  110554. * Vertex color
  110555. */
  110556. color: Color4;
  110557. /**
  110558. * Vertex UV
  110559. */
  110560. uv: Vector2;
  110561. /**
  110562. * Creates a new solid particle vertex
  110563. */
  110564. constructor();
  110565. /** Vertex x coordinate */
  110566. get x(): number;
  110567. set x(val: number);
  110568. /** Vertex y coordinate */
  110569. get y(): number;
  110570. set y(val: number);
  110571. /** Vertex z coordinate */
  110572. get z(): number;
  110573. set z(val: number);
  110574. }
  110575. }
  110576. declare module BABYLON {
  110577. /**
  110578. * @hidden
  110579. */
  110580. export class _MeshCollisionData {
  110581. _checkCollisions: boolean;
  110582. _collisionMask: number;
  110583. _collisionGroup: number;
  110584. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110585. _collider: Nullable<Collider>;
  110586. _oldPositionForCollisions: Vector3;
  110587. _diffPositionForCollisions: Vector3;
  110588. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110589. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110590. }
  110591. }
  110592. declare module BABYLON {
  110593. /** @hidden */
  110594. class _FacetDataStorage {
  110595. facetPositions: Vector3[];
  110596. facetNormals: Vector3[];
  110597. facetPartitioning: number[][];
  110598. facetNb: number;
  110599. partitioningSubdivisions: number;
  110600. partitioningBBoxRatio: number;
  110601. facetDataEnabled: boolean;
  110602. facetParameters: any;
  110603. bbSize: Vector3;
  110604. subDiv: {
  110605. max: number;
  110606. X: number;
  110607. Y: number;
  110608. Z: number;
  110609. };
  110610. facetDepthSort: boolean;
  110611. facetDepthSortEnabled: boolean;
  110612. depthSortedIndices: IndicesArray;
  110613. depthSortedFacets: {
  110614. ind: number;
  110615. sqDistance: number;
  110616. }[];
  110617. facetDepthSortFunction: (f1: {
  110618. ind: number;
  110619. sqDistance: number;
  110620. }, f2: {
  110621. ind: number;
  110622. sqDistance: number;
  110623. }) => number;
  110624. facetDepthSortFrom: Vector3;
  110625. facetDepthSortOrigin: Vector3;
  110626. invertedMatrix: Matrix;
  110627. }
  110628. /**
  110629. * @hidden
  110630. **/
  110631. class _InternalAbstractMeshDataInfo {
  110632. _hasVertexAlpha: boolean;
  110633. _useVertexColors: boolean;
  110634. _numBoneInfluencers: number;
  110635. _applyFog: boolean;
  110636. _receiveShadows: boolean;
  110637. _facetData: _FacetDataStorage;
  110638. _visibility: number;
  110639. _skeleton: Nullable<Skeleton>;
  110640. _layerMask: number;
  110641. _computeBonesUsingShaders: boolean;
  110642. _isActive: boolean;
  110643. _onlyForInstances: boolean;
  110644. _isActiveIntermediate: boolean;
  110645. _onlyForInstancesIntermediate: boolean;
  110646. _actAsRegularMesh: boolean;
  110647. }
  110648. /**
  110649. * Class used to store all common mesh properties
  110650. */
  110651. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110652. /** No occlusion */
  110653. static OCCLUSION_TYPE_NONE: number;
  110654. /** Occlusion set to optimisitic */
  110655. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110656. /** Occlusion set to strict */
  110657. static OCCLUSION_TYPE_STRICT: number;
  110658. /** Use an accurante occlusion algorithm */
  110659. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110660. /** Use a conservative occlusion algorithm */
  110661. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110662. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110663. * Test order :
  110664. * Is the bounding sphere outside the frustum ?
  110665. * If not, are the bounding box vertices outside the frustum ?
  110666. * It not, then the cullable object is in the frustum.
  110667. */
  110668. static readonly CULLINGSTRATEGY_STANDARD: number;
  110669. /** Culling strategy : Bounding Sphere Only.
  110670. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110671. * It's also less accurate than the standard because some not visible objects can still be selected.
  110672. * Test : is the bounding sphere outside the frustum ?
  110673. * If not, then the cullable object is in the frustum.
  110674. */
  110675. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110676. /** Culling strategy : Optimistic Inclusion.
  110677. * This in an inclusion test first, then the standard exclusion test.
  110678. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110679. * 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.
  110680. * Anyway, it's as accurate as the standard strategy.
  110681. * Test :
  110682. * Is the cullable object bounding sphere center in the frustum ?
  110683. * If not, apply the default culling strategy.
  110684. */
  110685. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110686. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110687. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110688. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110689. * 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.
  110690. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110691. * Test :
  110692. * Is the cullable object bounding sphere center in the frustum ?
  110693. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110694. */
  110695. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110696. /**
  110697. * No billboard
  110698. */
  110699. static get BILLBOARDMODE_NONE(): number;
  110700. /** Billboard on X axis */
  110701. static get BILLBOARDMODE_X(): number;
  110702. /** Billboard on Y axis */
  110703. static get BILLBOARDMODE_Y(): number;
  110704. /** Billboard on Z axis */
  110705. static get BILLBOARDMODE_Z(): number;
  110706. /** Billboard on all axes */
  110707. static get BILLBOARDMODE_ALL(): number;
  110708. /** Billboard on using position instead of orientation */
  110709. static get BILLBOARDMODE_USE_POSITION(): number;
  110710. /** @hidden */
  110711. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110712. /**
  110713. * The culling strategy to use to check whether the mesh must be rendered or not.
  110714. * This value can be changed at any time and will be used on the next render mesh selection.
  110715. * The possible values are :
  110716. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110717. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110718. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110719. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110720. * Please read each static variable documentation to get details about the culling process.
  110721. * */
  110722. cullingStrategy: number;
  110723. /**
  110724. * Gets the number of facets in the mesh
  110725. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110726. */
  110727. get facetNb(): number;
  110728. /**
  110729. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110731. */
  110732. get partitioningSubdivisions(): number;
  110733. set partitioningSubdivisions(nb: number);
  110734. /**
  110735. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110736. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110737. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110738. */
  110739. get partitioningBBoxRatio(): number;
  110740. set partitioningBBoxRatio(ratio: number);
  110741. /**
  110742. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110743. * Works only for updatable meshes.
  110744. * Doesn't work with multi-materials
  110745. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110746. */
  110747. get mustDepthSortFacets(): boolean;
  110748. set mustDepthSortFacets(sort: boolean);
  110749. /**
  110750. * The location (Vector3) where the facet depth sort must be computed from.
  110751. * By default, the active camera position.
  110752. * Used only when facet depth sort is enabled
  110753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110754. */
  110755. get facetDepthSortFrom(): Vector3;
  110756. set facetDepthSortFrom(location: Vector3);
  110757. /**
  110758. * gets a boolean indicating if facetData is enabled
  110759. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110760. */
  110761. get isFacetDataEnabled(): boolean;
  110762. /** @hidden */
  110763. _updateNonUniformScalingState(value: boolean): boolean;
  110764. /**
  110765. * An event triggered when this mesh collides with another one
  110766. */
  110767. onCollideObservable: Observable<AbstractMesh>;
  110768. /** Set a function to call when this mesh collides with another one */
  110769. set onCollide(callback: () => void);
  110770. /**
  110771. * An event triggered when the collision's position changes
  110772. */
  110773. onCollisionPositionChangeObservable: Observable<Vector3>;
  110774. /** Set a function to call when the collision's position changes */
  110775. set onCollisionPositionChange(callback: () => void);
  110776. /**
  110777. * An event triggered when material is changed
  110778. */
  110779. onMaterialChangedObservable: Observable<AbstractMesh>;
  110780. /**
  110781. * Gets or sets the orientation for POV movement & rotation
  110782. */
  110783. definedFacingForward: boolean;
  110784. /** @hidden */
  110785. _occlusionQuery: Nullable<WebGLQuery>;
  110786. /** @hidden */
  110787. _renderingGroup: Nullable<RenderingGroup>;
  110788. /**
  110789. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110790. */
  110791. get visibility(): number;
  110792. /**
  110793. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110794. */
  110795. set visibility(value: number);
  110796. /** Gets or sets the alpha index used to sort transparent meshes
  110797. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110798. */
  110799. alphaIndex: number;
  110800. /**
  110801. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  110802. */
  110803. isVisible: boolean;
  110804. /**
  110805. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  110806. */
  110807. isPickable: boolean;
  110808. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  110809. showSubMeshesBoundingBox: boolean;
  110810. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  110811. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110812. */
  110813. isBlocker: boolean;
  110814. /**
  110815. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  110816. */
  110817. enablePointerMoveEvents: boolean;
  110818. /**
  110819. * Specifies the rendering group id for this mesh (0 by default)
  110820. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  110821. */
  110822. renderingGroupId: number;
  110823. private _material;
  110824. /** Gets or sets current material */
  110825. get material(): Nullable<Material>;
  110826. set material(value: Nullable<Material>);
  110827. /**
  110828. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  110829. * @see https://doc.babylonjs.com/babylon101/shadows
  110830. */
  110831. get receiveShadows(): boolean;
  110832. set receiveShadows(value: boolean);
  110833. /** Defines color to use when rendering outline */
  110834. outlineColor: Color3;
  110835. /** Define width to use when rendering outline */
  110836. outlineWidth: number;
  110837. /** Defines color to use when rendering overlay */
  110838. overlayColor: Color3;
  110839. /** Defines alpha to use when rendering overlay */
  110840. overlayAlpha: number;
  110841. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  110842. get hasVertexAlpha(): boolean;
  110843. set hasVertexAlpha(value: boolean);
  110844. /** 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) */
  110845. get useVertexColors(): boolean;
  110846. set useVertexColors(value: boolean);
  110847. /**
  110848. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  110849. */
  110850. get computeBonesUsingShaders(): boolean;
  110851. set computeBonesUsingShaders(value: boolean);
  110852. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  110853. get numBoneInfluencers(): number;
  110854. set numBoneInfluencers(value: number);
  110855. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  110856. get applyFog(): boolean;
  110857. set applyFog(value: boolean);
  110858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  110859. useOctreeForRenderingSelection: boolean;
  110860. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  110861. useOctreeForPicking: boolean;
  110862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  110863. useOctreeForCollisions: boolean;
  110864. /**
  110865. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  110866. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  110867. */
  110868. get layerMask(): number;
  110869. set layerMask(value: number);
  110870. /**
  110871. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  110872. */
  110873. alwaysSelectAsActiveMesh: boolean;
  110874. /**
  110875. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  110876. */
  110877. doNotSyncBoundingInfo: boolean;
  110878. /**
  110879. * Gets or sets the current action manager
  110880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110881. */
  110882. actionManager: Nullable<AbstractActionManager>;
  110883. private _meshCollisionData;
  110884. /**
  110885. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  110886. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110887. */
  110888. ellipsoid: Vector3;
  110889. /**
  110890. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  110891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110892. */
  110893. ellipsoidOffset: Vector3;
  110894. /**
  110895. * Gets or sets a collision mask used to mask collisions (default is -1).
  110896. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110897. */
  110898. get collisionMask(): number;
  110899. set collisionMask(mask: number);
  110900. /**
  110901. * Gets or sets the current collision group mask (-1 by default).
  110902. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110903. */
  110904. get collisionGroup(): number;
  110905. set collisionGroup(mask: number);
  110906. /**
  110907. * Gets or sets current surrounding meshes (null by default).
  110908. *
  110909. * By default collision detection is tested against every mesh in the scene.
  110910. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  110911. * meshes will be tested for the collision.
  110912. *
  110913. * Note: if set to an empty array no collision will happen when this mesh is moved.
  110914. */
  110915. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  110916. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  110917. /**
  110918. * Defines edge width used when edgesRenderer is enabled
  110919. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110920. */
  110921. edgesWidth: number;
  110922. /**
  110923. * Defines edge color used when edgesRenderer is enabled
  110924. * @see https://www.babylonjs-playground.com/#10OJSG#13
  110925. */
  110926. edgesColor: Color4;
  110927. /** @hidden */
  110928. _edgesRenderer: Nullable<IEdgesRenderer>;
  110929. /** @hidden */
  110930. _masterMesh: Nullable<AbstractMesh>;
  110931. /** @hidden */
  110932. _boundingInfo: Nullable<BoundingInfo>;
  110933. /** @hidden */
  110934. _renderId: number;
  110935. /**
  110936. * Gets or sets the list of subMeshes
  110937. * @see https://doc.babylonjs.com/how_to/multi_materials
  110938. */
  110939. subMeshes: SubMesh[];
  110940. /** @hidden */
  110941. _intersectionsInProgress: AbstractMesh[];
  110942. /** @hidden */
  110943. _unIndexed: boolean;
  110944. /** @hidden */
  110945. _lightSources: Light[];
  110946. /** Gets the list of lights affecting that mesh */
  110947. get lightSources(): Light[];
  110948. /** @hidden */
  110949. get _positions(): Nullable<Vector3[]>;
  110950. /** @hidden */
  110951. _waitingData: {
  110952. lods: Nullable<any>;
  110953. actions: Nullable<any>;
  110954. freezeWorldMatrix: Nullable<boolean>;
  110955. };
  110956. /** @hidden */
  110957. _bonesTransformMatrices: Nullable<Float32Array>;
  110958. /** @hidden */
  110959. _transformMatrixTexture: Nullable<RawTexture>;
  110960. /**
  110961. * Gets or sets a skeleton to apply skining transformations
  110962. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110963. */
  110964. set skeleton(value: Nullable<Skeleton>);
  110965. get skeleton(): Nullable<Skeleton>;
  110966. /**
  110967. * An event triggered when the mesh is rebuilt.
  110968. */
  110969. onRebuildObservable: Observable<AbstractMesh>;
  110970. /**
  110971. * Creates a new AbstractMesh
  110972. * @param name defines the name of the mesh
  110973. * @param scene defines the hosting scene
  110974. */
  110975. constructor(name: string, scene?: Nullable<Scene>);
  110976. /**
  110977. * Returns the string "AbstractMesh"
  110978. * @returns "AbstractMesh"
  110979. */
  110980. getClassName(): string;
  110981. /**
  110982. * Gets a string representation of the current mesh
  110983. * @param fullDetails defines a boolean indicating if full details must be included
  110984. * @returns a string representation of the current mesh
  110985. */
  110986. toString(fullDetails?: boolean): string;
  110987. /**
  110988. * @hidden
  110989. */
  110990. protected _getEffectiveParent(): Nullable<Node>;
  110991. /** @hidden */
  110992. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110993. /** @hidden */
  110994. _rebuild(): void;
  110995. /** @hidden */
  110996. _resyncLightSources(): void;
  110997. /** @hidden */
  110998. _resyncLightSource(light: Light): void;
  110999. /** @hidden */
  111000. _unBindEffect(): void;
  111001. /** @hidden */
  111002. _removeLightSource(light: Light, dispose: boolean): void;
  111003. private _markSubMeshesAsDirty;
  111004. /** @hidden */
  111005. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111006. /** @hidden */
  111007. _markSubMeshesAsAttributesDirty(): void;
  111008. /** @hidden */
  111009. _markSubMeshesAsMiscDirty(): void;
  111010. /**
  111011. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111012. */
  111013. get scaling(): Vector3;
  111014. set scaling(newScaling: Vector3);
  111015. /**
  111016. * Returns true if the mesh is blocked. Implemented by child classes
  111017. */
  111018. get isBlocked(): boolean;
  111019. /**
  111020. * Returns the mesh itself by default. Implemented by child classes
  111021. * @param camera defines the camera to use to pick the right LOD level
  111022. * @returns the currentAbstractMesh
  111023. */
  111024. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111025. /**
  111026. * Returns 0 by default. Implemented by child classes
  111027. * @returns an integer
  111028. */
  111029. getTotalVertices(): number;
  111030. /**
  111031. * Returns a positive integer : the total number of indices in this mesh geometry.
  111032. * @returns the numner of indices or zero if the mesh has no geometry.
  111033. */
  111034. getTotalIndices(): number;
  111035. /**
  111036. * Returns null by default. Implemented by child classes
  111037. * @returns null
  111038. */
  111039. getIndices(): Nullable<IndicesArray>;
  111040. /**
  111041. * Returns the array of the requested vertex data kind. Implemented by child classes
  111042. * @param kind defines the vertex data kind to use
  111043. * @returns null
  111044. */
  111045. getVerticesData(kind: string): Nullable<FloatArray>;
  111046. /**
  111047. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111048. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111049. * Note that a new underlying VertexBuffer object is created each call.
  111050. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111051. * @param kind defines vertex data kind:
  111052. * * VertexBuffer.PositionKind
  111053. * * VertexBuffer.UVKind
  111054. * * VertexBuffer.UV2Kind
  111055. * * VertexBuffer.UV3Kind
  111056. * * VertexBuffer.UV4Kind
  111057. * * VertexBuffer.UV5Kind
  111058. * * VertexBuffer.UV6Kind
  111059. * * VertexBuffer.ColorKind
  111060. * * VertexBuffer.MatricesIndicesKind
  111061. * * VertexBuffer.MatricesIndicesExtraKind
  111062. * * VertexBuffer.MatricesWeightsKind
  111063. * * VertexBuffer.MatricesWeightsExtraKind
  111064. * @param data defines the data source
  111065. * @param updatable defines if the data must be flagged as updatable (or static)
  111066. * @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
  111067. * @returns the current mesh
  111068. */
  111069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111070. /**
  111071. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111072. * If the mesh has no geometry, it is simply returned as it is.
  111073. * @param kind defines vertex data kind:
  111074. * * VertexBuffer.PositionKind
  111075. * * VertexBuffer.UVKind
  111076. * * VertexBuffer.UV2Kind
  111077. * * VertexBuffer.UV3Kind
  111078. * * VertexBuffer.UV4Kind
  111079. * * VertexBuffer.UV5Kind
  111080. * * VertexBuffer.UV6Kind
  111081. * * VertexBuffer.ColorKind
  111082. * * VertexBuffer.MatricesIndicesKind
  111083. * * VertexBuffer.MatricesIndicesExtraKind
  111084. * * VertexBuffer.MatricesWeightsKind
  111085. * * VertexBuffer.MatricesWeightsExtraKind
  111086. * @param data defines the data source
  111087. * @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
  111088. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111089. * @returns the current mesh
  111090. */
  111091. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111092. /**
  111093. * Sets the mesh indices,
  111094. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111095. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111096. * @param totalVertices Defines the total number of vertices
  111097. * @returns the current mesh
  111098. */
  111099. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111100. /**
  111101. * Gets a boolean indicating if specific vertex data is present
  111102. * @param kind defines the vertex data kind to use
  111103. * @returns true is data kind is present
  111104. */
  111105. isVerticesDataPresent(kind: string): boolean;
  111106. /**
  111107. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111108. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111109. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111110. * @returns a BoundingInfo
  111111. */
  111112. getBoundingInfo(): BoundingInfo;
  111113. /**
  111114. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111115. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111116. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111117. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111118. * @returns the current mesh
  111119. */
  111120. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111121. /**
  111122. * Overwrite the current bounding info
  111123. * @param boundingInfo defines the new bounding info
  111124. * @returns the current mesh
  111125. */
  111126. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111127. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111128. get useBones(): boolean;
  111129. /** @hidden */
  111130. _preActivate(): void;
  111131. /** @hidden */
  111132. _preActivateForIntermediateRendering(renderId: number): void;
  111133. /** @hidden */
  111134. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111135. /** @hidden */
  111136. _postActivate(): void;
  111137. /** @hidden */
  111138. _freeze(): void;
  111139. /** @hidden */
  111140. _unFreeze(): void;
  111141. /**
  111142. * Gets the current world matrix
  111143. * @returns a Matrix
  111144. */
  111145. getWorldMatrix(): Matrix;
  111146. /** @hidden */
  111147. _getWorldMatrixDeterminant(): number;
  111148. /**
  111149. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111150. */
  111151. get isAnInstance(): boolean;
  111152. /**
  111153. * Gets a boolean indicating if this mesh has instances
  111154. */
  111155. get hasInstances(): boolean;
  111156. /**
  111157. * Gets a boolean indicating if this mesh has thin instances
  111158. */
  111159. get hasThinInstances(): boolean;
  111160. /**
  111161. * Perform relative position change from the point of view of behind the front of the mesh.
  111162. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111163. * Supports definition of mesh facing forward or backward
  111164. * @param amountRight defines the distance on the right axis
  111165. * @param amountUp defines the distance on the up axis
  111166. * @param amountForward defines the distance on the forward axis
  111167. * @returns the current mesh
  111168. */
  111169. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111170. /**
  111171. * Calculate relative position change from the point of view of behind the front of the mesh.
  111172. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111173. * Supports definition of mesh facing forward or backward
  111174. * @param amountRight defines the distance on the right axis
  111175. * @param amountUp defines the distance on the up axis
  111176. * @param amountForward defines the distance on the forward axis
  111177. * @returns the new displacement vector
  111178. */
  111179. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111180. /**
  111181. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111182. * Supports definition of mesh facing forward or backward
  111183. * @param flipBack defines the flip
  111184. * @param twirlClockwise defines the twirl
  111185. * @param tiltRight defines the tilt
  111186. * @returns the current mesh
  111187. */
  111188. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111189. /**
  111190. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111191. * Supports definition of mesh facing forward or backward.
  111192. * @param flipBack defines the flip
  111193. * @param twirlClockwise defines the twirl
  111194. * @param tiltRight defines the tilt
  111195. * @returns the new rotation vector
  111196. */
  111197. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111198. /**
  111199. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111200. * This means the mesh underlying bounding box and sphere are recomputed.
  111201. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111202. * @returns the current mesh
  111203. */
  111204. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111205. /** @hidden */
  111206. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111207. /** @hidden */
  111208. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111209. /** @hidden */
  111210. _updateBoundingInfo(): AbstractMesh;
  111211. /** @hidden */
  111212. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111213. /** @hidden */
  111214. protected _afterComputeWorldMatrix(): void;
  111215. /** @hidden */
  111216. get _effectiveMesh(): AbstractMesh;
  111217. /**
  111218. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111219. * A mesh is in the frustum if its bounding box intersects the frustum
  111220. * @param frustumPlanes defines the frustum to test
  111221. * @returns true if the mesh is in the frustum planes
  111222. */
  111223. isInFrustum(frustumPlanes: Plane[]): boolean;
  111224. /**
  111225. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111226. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111227. * @param frustumPlanes defines the frustum to test
  111228. * @returns true if the mesh is completely in the frustum planes
  111229. */
  111230. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111231. /**
  111232. * True if the mesh intersects another mesh or a SolidParticle object
  111233. * @param mesh defines a target mesh or SolidParticle to test
  111234. * @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)
  111235. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111236. * @returns true if there is an intersection
  111237. */
  111238. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111239. /**
  111240. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111241. * @param point defines the point to test
  111242. * @returns true if there is an intersection
  111243. */
  111244. intersectsPoint(point: Vector3): boolean;
  111245. /**
  111246. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111247. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111248. */
  111249. get checkCollisions(): boolean;
  111250. set checkCollisions(collisionEnabled: boolean);
  111251. /**
  111252. * Gets Collider object used to compute collisions (not physics)
  111253. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111254. */
  111255. get collider(): Nullable<Collider>;
  111256. /**
  111257. * Move the mesh using collision engine
  111258. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111259. * @param displacement defines the requested displacement vector
  111260. * @returns the current mesh
  111261. */
  111262. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111263. private _onCollisionPositionChange;
  111264. /** @hidden */
  111265. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111266. /** @hidden */
  111267. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111268. /** @hidden */
  111269. _checkCollision(collider: Collider): AbstractMesh;
  111270. /** @hidden */
  111271. _generatePointsArray(): boolean;
  111272. /**
  111273. * Checks if the passed Ray intersects with the mesh
  111274. * @param ray defines the ray to use
  111275. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111276. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111277. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111278. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111279. * @returns the picking info
  111280. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111281. */
  111282. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111283. /**
  111284. * Clones the current mesh
  111285. * @param name defines the mesh name
  111286. * @param newParent defines the new mesh parent
  111287. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111288. * @returns the new mesh
  111289. */
  111290. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111291. /**
  111292. * Disposes all the submeshes of the current meshnp
  111293. * @returns the current mesh
  111294. */
  111295. releaseSubMeshes(): AbstractMesh;
  111296. /**
  111297. * Releases resources associated with this abstract mesh.
  111298. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111299. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111300. */
  111301. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111302. /**
  111303. * Adds the passed mesh as a child to the current mesh
  111304. * @param mesh defines the child mesh
  111305. * @returns the current mesh
  111306. */
  111307. addChild(mesh: AbstractMesh): AbstractMesh;
  111308. /**
  111309. * Removes the passed mesh from the current mesh children list
  111310. * @param mesh defines the child mesh
  111311. * @returns the current mesh
  111312. */
  111313. removeChild(mesh: AbstractMesh): AbstractMesh;
  111314. /** @hidden */
  111315. private _initFacetData;
  111316. /**
  111317. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111318. * This method can be called within the render loop.
  111319. * 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
  111320. * @returns the current mesh
  111321. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111322. */
  111323. updateFacetData(): AbstractMesh;
  111324. /**
  111325. * Returns the facetLocalNormals array.
  111326. * The normals are expressed in the mesh local spac
  111327. * @returns an array of Vector3
  111328. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111329. */
  111330. getFacetLocalNormals(): Vector3[];
  111331. /**
  111332. * Returns the facetLocalPositions array.
  111333. * The facet positions are expressed in the mesh local space
  111334. * @returns an array of Vector3
  111335. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111336. */
  111337. getFacetLocalPositions(): Vector3[];
  111338. /**
  111339. * Returns the facetLocalPartioning array
  111340. * @returns an array of array of numbers
  111341. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111342. */
  111343. getFacetLocalPartitioning(): number[][];
  111344. /**
  111345. * Returns the i-th facet position in the world system.
  111346. * This method allocates a new Vector3 per call
  111347. * @param i defines the facet index
  111348. * @returns a new Vector3
  111349. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111350. */
  111351. getFacetPosition(i: number): Vector3;
  111352. /**
  111353. * Sets the reference Vector3 with the i-th facet position in the world system
  111354. * @param i defines the facet index
  111355. * @param ref defines the target vector
  111356. * @returns the current mesh
  111357. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111358. */
  111359. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111360. /**
  111361. * Returns the i-th facet normal in the world system.
  111362. * This method allocates a new Vector3 per call
  111363. * @param i defines the facet index
  111364. * @returns a new Vector3
  111365. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111366. */
  111367. getFacetNormal(i: number): Vector3;
  111368. /**
  111369. * Sets the reference Vector3 with the i-th facet normal in the world system
  111370. * @param i defines the facet index
  111371. * @param ref defines the target vector
  111372. * @returns the current mesh
  111373. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111374. */
  111375. getFacetNormalToRef(i: number, ref: Vector3): this;
  111376. /**
  111377. * 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)
  111378. * @param x defines x coordinate
  111379. * @param y defines y coordinate
  111380. * @param z defines z coordinate
  111381. * @returns the array of facet indexes
  111382. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111383. */
  111384. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111385. /**
  111386. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111387. * @param projected sets as the (x,y,z) world projection on the facet
  111388. * @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
  111389. * @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
  111390. * @param x defines x coordinate
  111391. * @param y defines y coordinate
  111392. * @param z defines z coordinate
  111393. * @returns the face index if found (or null instead)
  111394. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111395. */
  111396. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111397. /**
  111398. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111399. * @param projected sets as the (x,y,z) local projection on the facet
  111400. * @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
  111401. * @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
  111402. * @param x defines x coordinate
  111403. * @param y defines y coordinate
  111404. * @param z defines z coordinate
  111405. * @returns the face index if found (or null instead)
  111406. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111407. */
  111408. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111409. /**
  111410. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111411. * @returns the parameters
  111412. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111413. */
  111414. getFacetDataParameters(): any;
  111415. /**
  111416. * Disables the feature FacetData and frees the related memory
  111417. * @returns the current mesh
  111418. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111419. */
  111420. disableFacetData(): AbstractMesh;
  111421. /**
  111422. * Updates the AbstractMesh indices array
  111423. * @param indices defines the data source
  111424. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111425. * @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)
  111426. * @returns the current mesh
  111427. */
  111428. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111429. /**
  111430. * Creates new normals data for the mesh
  111431. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111432. * @returns the current mesh
  111433. */
  111434. createNormals(updatable: boolean): AbstractMesh;
  111435. /**
  111436. * Align the mesh with a normal
  111437. * @param normal defines the normal to use
  111438. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111439. * @returns the current mesh
  111440. */
  111441. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111442. /** @hidden */
  111443. _checkOcclusionQuery(): boolean;
  111444. /**
  111445. * Disables the mesh edge rendering mode
  111446. * @returns the currentAbstractMesh
  111447. */
  111448. disableEdgesRendering(): AbstractMesh;
  111449. /**
  111450. * Enables the edge rendering mode on the mesh.
  111451. * This mode makes the mesh edges visible
  111452. * @param epsilon defines the maximal distance between two angles to detect a face
  111453. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111454. * @returns the currentAbstractMesh
  111455. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111456. */
  111457. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111458. /**
  111459. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111460. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111461. */
  111462. getConnectedParticleSystems(): IParticleSystem[];
  111463. }
  111464. }
  111465. declare module BABYLON {
  111466. /**
  111467. * Interface used to define ActionEvent
  111468. */
  111469. export interface IActionEvent {
  111470. /** The mesh or sprite that triggered the action */
  111471. source: any;
  111472. /** The X mouse cursor position at the time of the event */
  111473. pointerX: number;
  111474. /** The Y mouse cursor position at the time of the event */
  111475. pointerY: number;
  111476. /** The mesh that is currently pointed at (can be null) */
  111477. meshUnderPointer: Nullable<AbstractMesh>;
  111478. /** the original (browser) event that triggered the ActionEvent */
  111479. sourceEvent?: any;
  111480. /** additional data for the event */
  111481. additionalData?: any;
  111482. }
  111483. /**
  111484. * ActionEvent is the event being sent when an action is triggered.
  111485. */
  111486. export class ActionEvent implements IActionEvent {
  111487. /** The mesh or sprite that triggered the action */
  111488. source: any;
  111489. /** The X mouse cursor position at the time of the event */
  111490. pointerX: number;
  111491. /** The Y mouse cursor position at the time of the event */
  111492. pointerY: number;
  111493. /** The mesh that is currently pointed at (can be null) */
  111494. meshUnderPointer: Nullable<AbstractMesh>;
  111495. /** the original (browser) event that triggered the ActionEvent */
  111496. sourceEvent?: any;
  111497. /** additional data for the event */
  111498. additionalData?: any;
  111499. /**
  111500. * Creates a new ActionEvent
  111501. * @param source The mesh or sprite that triggered the action
  111502. * @param pointerX The X mouse cursor position at the time of the event
  111503. * @param pointerY The Y mouse cursor position at the time of the event
  111504. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111505. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111506. * @param additionalData additional data for the event
  111507. */
  111508. constructor(
  111509. /** The mesh or sprite that triggered the action */
  111510. source: any,
  111511. /** The X mouse cursor position at the time of the event */
  111512. pointerX: number,
  111513. /** The Y mouse cursor position at the time of the event */
  111514. pointerY: number,
  111515. /** The mesh that is currently pointed at (can be null) */
  111516. meshUnderPointer: Nullable<AbstractMesh>,
  111517. /** the original (browser) event that triggered the ActionEvent */
  111518. sourceEvent?: any,
  111519. /** additional data for the event */
  111520. additionalData?: any);
  111521. /**
  111522. * Helper function to auto-create an ActionEvent from a source mesh.
  111523. * @param source The source mesh that triggered the event
  111524. * @param evt The original (browser) event
  111525. * @param additionalData additional data for the event
  111526. * @returns the new ActionEvent
  111527. */
  111528. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111529. /**
  111530. * Helper function to auto-create an ActionEvent from a source sprite
  111531. * @param source The source sprite that triggered the event
  111532. * @param scene Scene associated with the sprite
  111533. * @param evt The original (browser) event
  111534. * @param additionalData additional data for the event
  111535. * @returns the new ActionEvent
  111536. */
  111537. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111538. /**
  111539. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111540. * @param scene the scene where the event occurred
  111541. * @param evt The original (browser) event
  111542. * @returns the new ActionEvent
  111543. */
  111544. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111545. /**
  111546. * Helper function to auto-create an ActionEvent from a primitive
  111547. * @param prim defines the target primitive
  111548. * @param pointerPos defines the pointer position
  111549. * @param evt The original (browser) event
  111550. * @param additionalData additional data for the event
  111551. * @returns the new ActionEvent
  111552. */
  111553. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111554. }
  111555. }
  111556. declare module BABYLON {
  111557. /**
  111558. * Abstract class used to decouple action Manager from scene and meshes.
  111559. * Do not instantiate.
  111560. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111561. */
  111562. export abstract class AbstractActionManager implements IDisposable {
  111563. /** Gets the list of active triggers */
  111564. static Triggers: {
  111565. [key: string]: number;
  111566. };
  111567. /** Gets the cursor to use when hovering items */
  111568. hoverCursor: string;
  111569. /** Gets the list of actions */
  111570. actions: IAction[];
  111571. /**
  111572. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111573. */
  111574. isRecursive: boolean;
  111575. /**
  111576. * Releases all associated resources
  111577. */
  111578. abstract dispose(): void;
  111579. /**
  111580. * Does this action manager has pointer triggers
  111581. */
  111582. abstract get hasPointerTriggers(): boolean;
  111583. /**
  111584. * Does this action manager has pick triggers
  111585. */
  111586. abstract get hasPickTriggers(): boolean;
  111587. /**
  111588. * Process a specific trigger
  111589. * @param trigger defines the trigger to process
  111590. * @param evt defines the event details to be processed
  111591. */
  111592. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111593. /**
  111594. * Does this action manager handles actions of any of the given triggers
  111595. * @param triggers defines the triggers to be tested
  111596. * @return a boolean indicating whether one (or more) of the triggers is handled
  111597. */
  111598. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111599. /**
  111600. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111601. * speed.
  111602. * @param triggerA defines the trigger to be tested
  111603. * @param triggerB defines the trigger to be tested
  111604. * @return a boolean indicating whether one (or more) of the triggers is handled
  111605. */
  111606. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111607. /**
  111608. * Does this action manager handles actions of a given trigger
  111609. * @param trigger defines the trigger to be tested
  111610. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111611. * @return whether the trigger is handled
  111612. */
  111613. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111614. /**
  111615. * Serialize this manager to a JSON object
  111616. * @param name defines the property name to store this manager
  111617. * @returns a JSON representation of this manager
  111618. */
  111619. abstract serialize(name: string): any;
  111620. /**
  111621. * Registers an action to this action manager
  111622. * @param action defines the action to be registered
  111623. * @return the action amended (prepared) after registration
  111624. */
  111625. abstract registerAction(action: IAction): Nullable<IAction>;
  111626. /**
  111627. * Unregisters an action to this action manager
  111628. * @param action defines the action to be unregistered
  111629. * @return a boolean indicating whether the action has been unregistered
  111630. */
  111631. abstract unregisterAction(action: IAction): Boolean;
  111632. /**
  111633. * Does exist one action manager with at least one trigger
  111634. **/
  111635. static get HasTriggers(): boolean;
  111636. /**
  111637. * Does exist one action manager with at least one pick trigger
  111638. **/
  111639. static get HasPickTriggers(): boolean;
  111640. /**
  111641. * Does exist one action manager that handles actions of a given trigger
  111642. * @param trigger defines the trigger to be tested
  111643. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111644. **/
  111645. static HasSpecificTrigger(trigger: number): boolean;
  111646. }
  111647. }
  111648. declare module BABYLON {
  111649. /**
  111650. * Defines how a node can be built from a string name.
  111651. */
  111652. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111653. /**
  111654. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111655. */
  111656. export class Node implements IBehaviorAware<Node> {
  111657. /** @hidden */
  111658. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111659. private static _NodeConstructors;
  111660. /**
  111661. * Add a new node constructor
  111662. * @param type defines the type name of the node to construct
  111663. * @param constructorFunc defines the constructor function
  111664. */
  111665. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111666. /**
  111667. * Returns a node constructor based on type name
  111668. * @param type defines the type name
  111669. * @param name defines the new node name
  111670. * @param scene defines the hosting scene
  111671. * @param options defines optional options to transmit to constructors
  111672. * @returns the new constructor or null
  111673. */
  111674. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111675. /**
  111676. * Gets or sets the name of the node
  111677. */
  111678. name: string;
  111679. /**
  111680. * Gets or sets the id of the node
  111681. */
  111682. id: string;
  111683. /**
  111684. * Gets or sets the unique id of the node
  111685. */
  111686. uniqueId: number;
  111687. /**
  111688. * Gets or sets a string used to store user defined state for the node
  111689. */
  111690. state: string;
  111691. /**
  111692. * Gets or sets an object used to store user defined information for the node
  111693. */
  111694. metadata: any;
  111695. /**
  111696. * For internal use only. Please do not use.
  111697. */
  111698. reservedDataStore: any;
  111699. /**
  111700. * List of inspectable custom properties (used by the Inspector)
  111701. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111702. */
  111703. inspectableCustomProperties: IInspectable[];
  111704. private _doNotSerialize;
  111705. /**
  111706. * Gets or sets a boolean used to define if the node must be serialized
  111707. */
  111708. get doNotSerialize(): boolean;
  111709. set doNotSerialize(value: boolean);
  111710. /** @hidden */
  111711. _isDisposed: boolean;
  111712. /**
  111713. * Gets a list of Animations associated with the node
  111714. */
  111715. animations: Animation[];
  111716. protected _ranges: {
  111717. [name: string]: Nullable<AnimationRange>;
  111718. };
  111719. /**
  111720. * Callback raised when the node is ready to be used
  111721. */
  111722. onReady: Nullable<(node: Node) => void>;
  111723. private _isEnabled;
  111724. private _isParentEnabled;
  111725. private _isReady;
  111726. /** @hidden */
  111727. _currentRenderId: number;
  111728. private _parentUpdateId;
  111729. /** @hidden */
  111730. _childUpdateId: number;
  111731. /** @hidden */
  111732. _waitingParentId: Nullable<string>;
  111733. /** @hidden */
  111734. _scene: Scene;
  111735. /** @hidden */
  111736. _cache: any;
  111737. private _parentNode;
  111738. private _children;
  111739. /** @hidden */
  111740. _worldMatrix: Matrix;
  111741. /** @hidden */
  111742. _worldMatrixDeterminant: number;
  111743. /** @hidden */
  111744. _worldMatrixDeterminantIsDirty: boolean;
  111745. /** @hidden */
  111746. private _sceneRootNodesIndex;
  111747. /**
  111748. * Gets a boolean indicating if the node has been disposed
  111749. * @returns true if the node was disposed
  111750. */
  111751. isDisposed(): boolean;
  111752. /**
  111753. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111754. * @see https://doc.babylonjs.com/how_to/parenting
  111755. */
  111756. set parent(parent: Nullable<Node>);
  111757. get parent(): Nullable<Node>;
  111758. /** @hidden */
  111759. _addToSceneRootNodes(): void;
  111760. /** @hidden */
  111761. _removeFromSceneRootNodes(): void;
  111762. private _animationPropertiesOverride;
  111763. /**
  111764. * Gets or sets the animation properties override
  111765. */
  111766. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111767. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111768. /**
  111769. * Gets a string idenfifying the name of the class
  111770. * @returns "Node" string
  111771. */
  111772. getClassName(): string;
  111773. /** @hidden */
  111774. readonly _isNode: boolean;
  111775. /**
  111776. * An event triggered when the mesh is disposed
  111777. */
  111778. onDisposeObservable: Observable<Node>;
  111779. private _onDisposeObserver;
  111780. /**
  111781. * Sets a callback that will be raised when the node will be disposed
  111782. */
  111783. set onDispose(callback: () => void);
  111784. /**
  111785. * Creates a new Node
  111786. * @param name the name and id to be given to this node
  111787. * @param scene the scene this node will be added to
  111788. */
  111789. constructor(name: string, scene?: Nullable<Scene>);
  111790. /**
  111791. * Gets the scene of the node
  111792. * @returns a scene
  111793. */
  111794. getScene(): Scene;
  111795. /**
  111796. * Gets the engine of the node
  111797. * @returns a Engine
  111798. */
  111799. getEngine(): Engine;
  111800. private _behaviors;
  111801. /**
  111802. * Attach a behavior to the node
  111803. * @see https://doc.babylonjs.com/features/behaviour
  111804. * @param behavior defines the behavior to attach
  111805. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  111806. * @returns the current Node
  111807. */
  111808. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  111809. /**
  111810. * Remove an attached behavior
  111811. * @see https://doc.babylonjs.com/features/behaviour
  111812. * @param behavior defines the behavior to attach
  111813. * @returns the current Node
  111814. */
  111815. removeBehavior(behavior: Behavior<Node>): Node;
  111816. /**
  111817. * Gets the list of attached behaviors
  111818. * @see https://doc.babylonjs.com/features/behaviour
  111819. */
  111820. get behaviors(): Behavior<Node>[];
  111821. /**
  111822. * Gets an attached behavior by name
  111823. * @param name defines the name of the behavior to look for
  111824. * @see https://doc.babylonjs.com/features/behaviour
  111825. * @returns null if behavior was not found else the requested behavior
  111826. */
  111827. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  111828. /**
  111829. * Returns the latest update of the World matrix
  111830. * @returns a Matrix
  111831. */
  111832. getWorldMatrix(): Matrix;
  111833. /** @hidden */
  111834. _getWorldMatrixDeterminant(): number;
  111835. /**
  111836. * Returns directly the latest state of the mesh World matrix.
  111837. * A Matrix is returned.
  111838. */
  111839. get worldMatrixFromCache(): Matrix;
  111840. /** @hidden */
  111841. _initCache(): void;
  111842. /** @hidden */
  111843. updateCache(force?: boolean): void;
  111844. /** @hidden */
  111845. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111846. /** @hidden */
  111847. _updateCache(ignoreParentClass?: boolean): void;
  111848. /** @hidden */
  111849. _isSynchronized(): boolean;
  111850. /** @hidden */
  111851. _markSyncedWithParent(): void;
  111852. /** @hidden */
  111853. isSynchronizedWithParent(): boolean;
  111854. /** @hidden */
  111855. isSynchronized(): boolean;
  111856. /**
  111857. * Is this node ready to be used/rendered
  111858. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  111859. * @return true if the node is ready
  111860. */
  111861. isReady(completeCheck?: boolean): boolean;
  111862. /**
  111863. * Is this node enabled?
  111864. * 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
  111865. * @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
  111866. * @return whether this node (and its parent) is enabled
  111867. */
  111868. isEnabled(checkAncestors?: boolean): boolean;
  111869. /** @hidden */
  111870. protected _syncParentEnabledState(): void;
  111871. /**
  111872. * Set the enabled state of this node
  111873. * @param value defines the new enabled state
  111874. */
  111875. setEnabled(value: boolean): void;
  111876. /**
  111877. * Is this node a descendant of the given node?
  111878. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  111879. * @param ancestor defines the parent node to inspect
  111880. * @returns a boolean indicating if this node is a descendant of the given node
  111881. */
  111882. isDescendantOf(ancestor: Node): boolean;
  111883. /** @hidden */
  111884. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  111885. /**
  111886. * Will return all nodes that have this node as ascendant
  111887. * @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
  111888. * @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
  111889. * @return all children nodes of all types
  111890. */
  111891. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  111892. /**
  111893. * Get all child-meshes of this node
  111894. * @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)
  111895. * @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
  111896. * @returns an array of AbstractMesh
  111897. */
  111898. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  111899. /**
  111900. * Get all direct children of this node
  111901. * @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
  111902. * @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)
  111903. * @returns an array of Node
  111904. */
  111905. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  111906. /** @hidden */
  111907. _setReady(state: boolean): void;
  111908. /**
  111909. * Get an animation by name
  111910. * @param name defines the name of the animation to look for
  111911. * @returns null if not found else the requested animation
  111912. */
  111913. getAnimationByName(name: string): Nullable<Animation>;
  111914. /**
  111915. * Creates an animation range for this node
  111916. * @param name defines the name of the range
  111917. * @param from defines the starting key
  111918. * @param to defines the end key
  111919. */
  111920. createAnimationRange(name: string, from: number, to: number): void;
  111921. /**
  111922. * Delete a specific animation range
  111923. * @param name defines the name of the range to delete
  111924. * @param deleteFrames defines if animation frames from the range must be deleted as well
  111925. */
  111926. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  111927. /**
  111928. * Get an animation range by name
  111929. * @param name defines the name of the animation range to look for
  111930. * @returns null if not found else the requested animation range
  111931. */
  111932. getAnimationRange(name: string): Nullable<AnimationRange>;
  111933. /**
  111934. * Gets the list of all animation ranges defined on this node
  111935. * @returns an array
  111936. */
  111937. getAnimationRanges(): Nullable<AnimationRange>[];
  111938. /**
  111939. * Will start the animation sequence
  111940. * @param name defines the range frames for animation sequence
  111941. * @param loop defines if the animation should loop (false by default)
  111942. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  111943. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  111944. * @returns the object created for this animation. If range does not exist, it will return null
  111945. */
  111946. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  111947. /**
  111948. * Serialize animation ranges into a JSON compatible object
  111949. * @returns serialization object
  111950. */
  111951. serializeAnimationRanges(): any;
  111952. /**
  111953. * Computes the world matrix of the node
  111954. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111955. * @returns the world matrix
  111956. */
  111957. computeWorldMatrix(force?: boolean): Matrix;
  111958. /**
  111959. * Releases resources associated with this node.
  111960. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111961. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111962. */
  111963. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111964. /**
  111965. * Parse animation range data from a serialization object and store them into a given node
  111966. * @param node defines where to store the animation ranges
  111967. * @param parsedNode defines the serialization object to read data from
  111968. * @param scene defines the hosting scene
  111969. */
  111970. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  111971. /**
  111972. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  111973. * @param includeDescendants Include bounding info from descendants as well (true by default)
  111974. * @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
  111975. * @returns the new bounding vectors
  111976. */
  111977. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  111978. min: Vector3;
  111979. max: Vector3;
  111980. };
  111981. }
  111982. }
  111983. declare module BABYLON {
  111984. /**
  111985. * @hidden
  111986. */
  111987. export class _IAnimationState {
  111988. key: number;
  111989. repeatCount: number;
  111990. workValue?: any;
  111991. loopMode?: number;
  111992. offsetValue?: any;
  111993. highLimitValue?: any;
  111994. }
  111995. /**
  111996. * Class used to store any kind of animation
  111997. */
  111998. export class Animation {
  111999. /**Name of the animation */
  112000. name: string;
  112001. /**Property to animate */
  112002. targetProperty: string;
  112003. /**The frames per second of the animation */
  112004. framePerSecond: number;
  112005. /**The data type of the animation */
  112006. dataType: number;
  112007. /**The loop mode of the animation */
  112008. loopMode?: number | undefined;
  112009. /**Specifies if blending should be enabled */
  112010. enableBlending?: boolean | undefined;
  112011. /**
  112012. * Use matrix interpolation instead of using direct key value when animating matrices
  112013. */
  112014. static AllowMatricesInterpolation: boolean;
  112015. /**
  112016. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112017. */
  112018. static AllowMatrixDecomposeForInterpolation: boolean;
  112019. /** Define the Url to load snippets */
  112020. static SnippetUrl: string;
  112021. /** Snippet ID if the animation was created from the snippet server */
  112022. snippetId: string;
  112023. /**
  112024. * Stores the key frames of the animation
  112025. */
  112026. private _keys;
  112027. /**
  112028. * Stores the easing function of the animation
  112029. */
  112030. private _easingFunction;
  112031. /**
  112032. * @hidden Internal use only
  112033. */
  112034. _runtimeAnimations: RuntimeAnimation[];
  112035. /**
  112036. * The set of event that will be linked to this animation
  112037. */
  112038. private _events;
  112039. /**
  112040. * Stores an array of target property paths
  112041. */
  112042. targetPropertyPath: string[];
  112043. /**
  112044. * Stores the blending speed of the animation
  112045. */
  112046. blendingSpeed: number;
  112047. /**
  112048. * Stores the animation ranges for the animation
  112049. */
  112050. private _ranges;
  112051. /**
  112052. * @hidden Internal use
  112053. */
  112054. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112055. /**
  112056. * Sets up an animation
  112057. * @param property The property to animate
  112058. * @param animationType The animation type to apply
  112059. * @param framePerSecond The frames per second of the animation
  112060. * @param easingFunction The easing function used in the animation
  112061. * @returns The created animation
  112062. */
  112063. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112064. /**
  112065. * Create and start an animation on a node
  112066. * @param name defines the name of the global animation that will be run on all nodes
  112067. * @param node defines the root node where the animation will take place
  112068. * @param targetProperty defines property to animate
  112069. * @param framePerSecond defines the number of frame per second yo use
  112070. * @param totalFrame defines the number of frames in total
  112071. * @param from defines the initial value
  112072. * @param to defines the final value
  112073. * @param loopMode defines which loop mode you want to use (off by default)
  112074. * @param easingFunction defines the easing function to use (linear by default)
  112075. * @param onAnimationEnd defines the callback to call when animation end
  112076. * @returns the animatable created for this animation
  112077. */
  112078. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112079. /**
  112080. * Create and start an animation on a node and its descendants
  112081. * @param name defines the name of the global animation that will be run on all nodes
  112082. * @param node defines the root node where the animation will take place
  112083. * @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
  112084. * @param targetProperty defines property to animate
  112085. * @param framePerSecond defines the number of frame per second to use
  112086. * @param totalFrame defines the number of frames in total
  112087. * @param from defines the initial value
  112088. * @param to defines the final value
  112089. * @param loopMode defines which loop mode you want to use (off by default)
  112090. * @param easingFunction defines the easing function to use (linear by default)
  112091. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112092. * @returns the list of animatables created for all nodes
  112093. * @example https://www.babylonjs-playground.com/#MH0VLI
  112094. */
  112095. 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[]>;
  112096. /**
  112097. * Creates a new animation, merges it with the existing animations and starts it
  112098. * @param name Name of the animation
  112099. * @param node Node which contains the scene that begins the animations
  112100. * @param targetProperty Specifies which property to animate
  112101. * @param framePerSecond The frames per second of the animation
  112102. * @param totalFrame The total number of frames
  112103. * @param from The frame at the beginning of the animation
  112104. * @param to The frame at the end of the animation
  112105. * @param loopMode Specifies the loop mode of the animation
  112106. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112107. * @param onAnimationEnd Callback to run once the animation is complete
  112108. * @returns Nullable animation
  112109. */
  112110. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112111. /**
  112112. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112113. * @param sourceAnimation defines the Animation containing keyframes to convert
  112114. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112115. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112116. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112117. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112118. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112119. */
  112120. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112121. /**
  112122. * Transition property of an host to the target Value
  112123. * @param property The property to transition
  112124. * @param targetValue The target Value of the property
  112125. * @param host The object where the property to animate belongs
  112126. * @param scene Scene used to run the animation
  112127. * @param frameRate Framerate (in frame/s) to use
  112128. * @param transition The transition type we want to use
  112129. * @param duration The duration of the animation, in milliseconds
  112130. * @param onAnimationEnd Callback trigger at the end of the animation
  112131. * @returns Nullable animation
  112132. */
  112133. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112134. /**
  112135. * Return the array of runtime animations currently using this animation
  112136. */
  112137. get runtimeAnimations(): RuntimeAnimation[];
  112138. /**
  112139. * Specifies if any of the runtime animations are currently running
  112140. */
  112141. get hasRunningRuntimeAnimations(): boolean;
  112142. /**
  112143. * Initializes the animation
  112144. * @param name Name of the animation
  112145. * @param targetProperty Property to animate
  112146. * @param framePerSecond The frames per second of the animation
  112147. * @param dataType The data type of the animation
  112148. * @param loopMode The loop mode of the animation
  112149. * @param enableBlending Specifies if blending should be enabled
  112150. */
  112151. constructor(
  112152. /**Name of the animation */
  112153. name: string,
  112154. /**Property to animate */
  112155. targetProperty: string,
  112156. /**The frames per second of the animation */
  112157. framePerSecond: number,
  112158. /**The data type of the animation */
  112159. dataType: number,
  112160. /**The loop mode of the animation */
  112161. loopMode?: number | undefined,
  112162. /**Specifies if blending should be enabled */
  112163. enableBlending?: boolean | undefined);
  112164. /**
  112165. * Converts the animation to a string
  112166. * @param fullDetails support for multiple levels of logging within scene loading
  112167. * @returns String form of the animation
  112168. */
  112169. toString(fullDetails?: boolean): string;
  112170. /**
  112171. * Add an event to this animation
  112172. * @param event Event to add
  112173. */
  112174. addEvent(event: AnimationEvent): void;
  112175. /**
  112176. * Remove all events found at the given frame
  112177. * @param frame The frame to remove events from
  112178. */
  112179. removeEvents(frame: number): void;
  112180. /**
  112181. * Retrieves all the events from the animation
  112182. * @returns Events from the animation
  112183. */
  112184. getEvents(): AnimationEvent[];
  112185. /**
  112186. * Creates an animation range
  112187. * @param name Name of the animation range
  112188. * @param from Starting frame of the animation range
  112189. * @param to Ending frame of the animation
  112190. */
  112191. createRange(name: string, from: number, to: number): void;
  112192. /**
  112193. * Deletes an animation range by name
  112194. * @param name Name of the animation range to delete
  112195. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112196. */
  112197. deleteRange(name: string, deleteFrames?: boolean): void;
  112198. /**
  112199. * Gets the animation range by name, or null if not defined
  112200. * @param name Name of the animation range
  112201. * @returns Nullable animation range
  112202. */
  112203. getRange(name: string): Nullable<AnimationRange>;
  112204. /**
  112205. * Gets the key frames from the animation
  112206. * @returns The key frames of the animation
  112207. */
  112208. getKeys(): Array<IAnimationKey>;
  112209. /**
  112210. * Gets the highest frame rate of the animation
  112211. * @returns Highest frame rate of the animation
  112212. */
  112213. getHighestFrame(): number;
  112214. /**
  112215. * Gets the easing function of the animation
  112216. * @returns Easing function of the animation
  112217. */
  112218. getEasingFunction(): IEasingFunction;
  112219. /**
  112220. * Sets the easing function of the animation
  112221. * @param easingFunction A custom mathematical formula for animation
  112222. */
  112223. setEasingFunction(easingFunction: EasingFunction): void;
  112224. /**
  112225. * Interpolates a scalar linearly
  112226. * @param startValue Start value of the animation curve
  112227. * @param endValue End value of the animation curve
  112228. * @param gradient Scalar amount to interpolate
  112229. * @returns Interpolated scalar value
  112230. */
  112231. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112232. /**
  112233. * Interpolates a scalar cubically
  112234. * @param startValue Start value of the animation curve
  112235. * @param outTangent End tangent of the animation
  112236. * @param endValue End value of the animation curve
  112237. * @param inTangent Start tangent of the animation curve
  112238. * @param gradient Scalar amount to interpolate
  112239. * @returns Interpolated scalar value
  112240. */
  112241. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112242. /**
  112243. * Interpolates a quaternion using a spherical linear interpolation
  112244. * @param startValue Start value of the animation curve
  112245. * @param endValue End value of the animation curve
  112246. * @param gradient Scalar amount to interpolate
  112247. * @returns Interpolated quaternion value
  112248. */
  112249. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112250. /**
  112251. * Interpolates a quaternion cubically
  112252. * @param startValue Start value of the animation curve
  112253. * @param outTangent End tangent of the animation curve
  112254. * @param endValue End value of the animation curve
  112255. * @param inTangent Start tangent of the animation curve
  112256. * @param gradient Scalar amount to interpolate
  112257. * @returns Interpolated quaternion value
  112258. */
  112259. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112260. /**
  112261. * Interpolates a Vector3 linearl
  112262. * @param startValue Start value of the animation curve
  112263. * @param endValue End value of the animation curve
  112264. * @param gradient Scalar amount to interpolate
  112265. * @returns Interpolated scalar value
  112266. */
  112267. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112268. /**
  112269. * Interpolates a Vector3 cubically
  112270. * @param startValue Start value of the animation curve
  112271. * @param outTangent End tangent of the animation
  112272. * @param endValue End value of the animation curve
  112273. * @param inTangent Start tangent of the animation curve
  112274. * @param gradient Scalar amount to interpolate
  112275. * @returns InterpolatedVector3 value
  112276. */
  112277. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112278. /**
  112279. * Interpolates a Vector2 linearly
  112280. * @param startValue Start value of the animation curve
  112281. * @param endValue End value of the animation curve
  112282. * @param gradient Scalar amount to interpolate
  112283. * @returns Interpolated Vector2 value
  112284. */
  112285. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112286. /**
  112287. * Interpolates a Vector2 cubically
  112288. * @param startValue Start value of the animation curve
  112289. * @param outTangent End tangent of the animation
  112290. * @param endValue End value of the animation curve
  112291. * @param inTangent Start tangent of the animation curve
  112292. * @param gradient Scalar amount to interpolate
  112293. * @returns Interpolated Vector2 value
  112294. */
  112295. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112296. /**
  112297. * Interpolates a size linearly
  112298. * @param startValue Start value of the animation curve
  112299. * @param endValue End value of the animation curve
  112300. * @param gradient Scalar amount to interpolate
  112301. * @returns Interpolated Size value
  112302. */
  112303. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112304. /**
  112305. * Interpolates a Color3 linearly
  112306. * @param startValue Start value of the animation curve
  112307. * @param endValue End value of the animation curve
  112308. * @param gradient Scalar amount to interpolate
  112309. * @returns Interpolated Color3 value
  112310. */
  112311. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112312. /**
  112313. * Interpolates a Color4 linearly
  112314. * @param startValue Start value of the animation curve
  112315. * @param endValue End value of the animation curve
  112316. * @param gradient Scalar amount to interpolate
  112317. * @returns Interpolated Color3 value
  112318. */
  112319. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112320. /**
  112321. * @hidden Internal use only
  112322. */
  112323. _getKeyValue(value: any): any;
  112324. /**
  112325. * @hidden Internal use only
  112326. */
  112327. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112328. /**
  112329. * Defines the function to use to interpolate matrices
  112330. * @param startValue defines the start matrix
  112331. * @param endValue defines the end matrix
  112332. * @param gradient defines the gradient between both matrices
  112333. * @param result defines an optional target matrix where to store the interpolation
  112334. * @returns the interpolated matrix
  112335. */
  112336. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112337. /**
  112338. * Makes a copy of the animation
  112339. * @returns Cloned animation
  112340. */
  112341. clone(): Animation;
  112342. /**
  112343. * Sets the key frames of the animation
  112344. * @param values The animation key frames to set
  112345. */
  112346. setKeys(values: Array<IAnimationKey>): void;
  112347. /**
  112348. * Serializes the animation to an object
  112349. * @returns Serialized object
  112350. */
  112351. serialize(): any;
  112352. /**
  112353. * Float animation type
  112354. */
  112355. static readonly ANIMATIONTYPE_FLOAT: number;
  112356. /**
  112357. * Vector3 animation type
  112358. */
  112359. static readonly ANIMATIONTYPE_VECTOR3: number;
  112360. /**
  112361. * Quaternion animation type
  112362. */
  112363. static readonly ANIMATIONTYPE_QUATERNION: number;
  112364. /**
  112365. * Matrix animation type
  112366. */
  112367. static readonly ANIMATIONTYPE_MATRIX: number;
  112368. /**
  112369. * Color3 animation type
  112370. */
  112371. static readonly ANIMATIONTYPE_COLOR3: number;
  112372. /**
  112373. * Color3 animation type
  112374. */
  112375. static readonly ANIMATIONTYPE_COLOR4: number;
  112376. /**
  112377. * Vector2 animation type
  112378. */
  112379. static readonly ANIMATIONTYPE_VECTOR2: number;
  112380. /**
  112381. * Size animation type
  112382. */
  112383. static readonly ANIMATIONTYPE_SIZE: number;
  112384. /**
  112385. * Relative Loop Mode
  112386. */
  112387. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112388. /**
  112389. * Cycle Loop Mode
  112390. */
  112391. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112392. /**
  112393. * Constant Loop Mode
  112394. */
  112395. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112396. /** @hidden */
  112397. static _UniversalLerp(left: any, right: any, amount: number): any;
  112398. /**
  112399. * Parses an animation object and creates an animation
  112400. * @param parsedAnimation Parsed animation object
  112401. * @returns Animation object
  112402. */
  112403. static Parse(parsedAnimation: any): Animation;
  112404. /**
  112405. * Appends the serialized animations from the source animations
  112406. * @param source Source containing the animations
  112407. * @param destination Target to store the animations
  112408. */
  112409. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112410. /**
  112411. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112412. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112413. * @param url defines the url to load from
  112414. * @returns a promise that will resolve to the new animation or an array of animations
  112415. */
  112416. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112417. /**
  112418. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112419. * @param snippetId defines the snippet to load
  112420. * @returns a promise that will resolve to the new animation or a new array of animations
  112421. */
  112422. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112423. }
  112424. }
  112425. declare module BABYLON {
  112426. /**
  112427. * Interface containing an array of animations
  112428. */
  112429. export interface IAnimatable {
  112430. /**
  112431. * Array of animations
  112432. */
  112433. animations: Nullable<Array<Animation>>;
  112434. }
  112435. }
  112436. declare module BABYLON {
  112437. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112438. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112439. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112440. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112441. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112442. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112443. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112444. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112445. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112446. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112447. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112448. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112449. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112450. /**
  112451. * Decorator used to define property that can be serialized as reference to a camera
  112452. * @param sourceName defines the name of the property to decorate
  112453. */
  112454. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112455. /**
  112456. * Class used to help serialization objects
  112457. */
  112458. export class SerializationHelper {
  112459. /** @hidden */
  112460. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112461. /** @hidden */
  112462. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112463. /** @hidden */
  112464. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112465. /** @hidden */
  112466. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112467. /**
  112468. * Appends the serialized animations from the source animations
  112469. * @param source Source containing the animations
  112470. * @param destination Target to store the animations
  112471. */
  112472. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112473. /**
  112474. * Static function used to serialized a specific entity
  112475. * @param entity defines the entity to serialize
  112476. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112477. * @returns a JSON compatible object representing the serialization of the entity
  112478. */
  112479. static Serialize<T>(entity: T, serializationObject?: any): any;
  112480. /**
  112481. * Creates a new entity from a serialization data object
  112482. * @param creationFunction defines a function used to instanciated the new entity
  112483. * @param source defines the source serialization data
  112484. * @param scene defines the hosting scene
  112485. * @param rootUrl defines the root url for resources
  112486. * @returns a new entity
  112487. */
  112488. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112489. /**
  112490. * Clones an object
  112491. * @param creationFunction defines the function used to instanciate the new object
  112492. * @param source defines the source object
  112493. * @returns the cloned object
  112494. */
  112495. static Clone<T>(creationFunction: () => T, source: T): T;
  112496. /**
  112497. * Instanciates a new object based on a source one (some data will be shared between both object)
  112498. * @param creationFunction defines the function used to instanciate the new object
  112499. * @param source defines the source object
  112500. * @returns the new object
  112501. */
  112502. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112503. }
  112504. }
  112505. declare module BABYLON {
  112506. /**
  112507. * Base class of all the textures in babylon.
  112508. * It groups all the common properties the materials, post process, lights... might need
  112509. * in order to make a correct use of the texture.
  112510. */
  112511. export class BaseTexture implements IAnimatable {
  112512. /**
  112513. * Default anisotropic filtering level for the application.
  112514. * It is set to 4 as a good tradeoff between perf and quality.
  112515. */
  112516. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112517. /**
  112518. * Gets or sets the unique id of the texture
  112519. */
  112520. uniqueId: number;
  112521. /**
  112522. * Define the name of the texture.
  112523. */
  112524. name: string;
  112525. /**
  112526. * Gets or sets an object used to store user defined information.
  112527. */
  112528. metadata: any;
  112529. /**
  112530. * For internal use only. Please do not use.
  112531. */
  112532. reservedDataStore: any;
  112533. private _hasAlpha;
  112534. /**
  112535. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112536. */
  112537. set hasAlpha(value: boolean);
  112538. get hasAlpha(): boolean;
  112539. /**
  112540. * Defines if the alpha value should be determined via the rgb values.
  112541. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112542. */
  112543. getAlphaFromRGB: boolean;
  112544. /**
  112545. * Intensity or strength of the texture.
  112546. * It is commonly used by materials to fine tune the intensity of the texture
  112547. */
  112548. level: number;
  112549. /**
  112550. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112551. * This is part of the texture as textures usually maps to one uv set.
  112552. */
  112553. coordinatesIndex: number;
  112554. private _coordinatesMode;
  112555. /**
  112556. * How a texture is mapped.
  112557. *
  112558. * | Value | Type | Description |
  112559. * | ----- | ----------------------------------- | ----------- |
  112560. * | 0 | EXPLICIT_MODE | |
  112561. * | 1 | SPHERICAL_MODE | |
  112562. * | 2 | PLANAR_MODE | |
  112563. * | 3 | CUBIC_MODE | |
  112564. * | 4 | PROJECTION_MODE | |
  112565. * | 5 | SKYBOX_MODE | |
  112566. * | 6 | INVCUBIC_MODE | |
  112567. * | 7 | EQUIRECTANGULAR_MODE | |
  112568. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112569. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112570. */
  112571. set coordinatesMode(value: number);
  112572. get coordinatesMode(): number;
  112573. /**
  112574. * | Value | Type | Description |
  112575. * | ----- | ------------------ | ----------- |
  112576. * | 0 | CLAMP_ADDRESSMODE | |
  112577. * | 1 | WRAP_ADDRESSMODE | |
  112578. * | 2 | MIRROR_ADDRESSMODE | |
  112579. */
  112580. wrapU: number;
  112581. /**
  112582. * | Value | Type | Description |
  112583. * | ----- | ------------------ | ----------- |
  112584. * | 0 | CLAMP_ADDRESSMODE | |
  112585. * | 1 | WRAP_ADDRESSMODE | |
  112586. * | 2 | MIRROR_ADDRESSMODE | |
  112587. */
  112588. wrapV: number;
  112589. /**
  112590. * | Value | Type | Description |
  112591. * | ----- | ------------------ | ----------- |
  112592. * | 0 | CLAMP_ADDRESSMODE | |
  112593. * | 1 | WRAP_ADDRESSMODE | |
  112594. * | 2 | MIRROR_ADDRESSMODE | |
  112595. */
  112596. wrapR: number;
  112597. /**
  112598. * With compliant hardware and browser (supporting anisotropic filtering)
  112599. * this defines the level of anisotropic filtering in the texture.
  112600. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112601. */
  112602. anisotropicFilteringLevel: number;
  112603. /**
  112604. * Define if the texture is a cube texture or if false a 2d texture.
  112605. */
  112606. get isCube(): boolean;
  112607. set isCube(value: boolean);
  112608. /**
  112609. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112610. */
  112611. get is3D(): boolean;
  112612. set is3D(value: boolean);
  112613. /**
  112614. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112615. */
  112616. get is2DArray(): boolean;
  112617. set is2DArray(value: boolean);
  112618. /**
  112619. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112620. * HDR texture are usually stored in linear space.
  112621. * This only impacts the PBR and Background materials
  112622. */
  112623. gammaSpace: boolean;
  112624. /**
  112625. * Gets or sets whether or not the texture contains RGBD data.
  112626. */
  112627. get isRGBD(): boolean;
  112628. set isRGBD(value: boolean);
  112629. /**
  112630. * Is Z inverted in the texture (useful in a cube texture).
  112631. */
  112632. invertZ: boolean;
  112633. /**
  112634. * Are mip maps generated for this texture or not.
  112635. */
  112636. get noMipmap(): boolean;
  112637. /**
  112638. * @hidden
  112639. */
  112640. lodLevelInAlpha: boolean;
  112641. /**
  112642. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112643. */
  112644. get lodGenerationOffset(): number;
  112645. set lodGenerationOffset(value: number);
  112646. /**
  112647. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112648. */
  112649. get lodGenerationScale(): number;
  112650. set lodGenerationScale(value: number);
  112651. /**
  112652. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112653. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112654. * average roughness values.
  112655. */
  112656. get linearSpecularLOD(): boolean;
  112657. set linearSpecularLOD(value: boolean);
  112658. /**
  112659. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112660. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112661. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112662. */
  112663. get irradianceTexture(): Nullable<BaseTexture>;
  112664. set irradianceTexture(value: Nullable<BaseTexture>);
  112665. /**
  112666. * Define if the texture is a render target.
  112667. */
  112668. isRenderTarget: boolean;
  112669. /**
  112670. * Define the unique id of the texture in the scene.
  112671. */
  112672. get uid(): string;
  112673. /** @hidden */
  112674. _prefiltered: boolean;
  112675. /**
  112676. * Return a string representation of the texture.
  112677. * @returns the texture as a string
  112678. */
  112679. toString(): string;
  112680. /**
  112681. * Get the class name of the texture.
  112682. * @returns "BaseTexture"
  112683. */
  112684. getClassName(): string;
  112685. /**
  112686. * Define the list of animation attached to the texture.
  112687. */
  112688. animations: Animation[];
  112689. /**
  112690. * An event triggered when the texture is disposed.
  112691. */
  112692. onDisposeObservable: Observable<BaseTexture>;
  112693. private _onDisposeObserver;
  112694. /**
  112695. * Callback triggered when the texture has been disposed.
  112696. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112697. */
  112698. set onDispose(callback: () => void);
  112699. /**
  112700. * Define the current state of the loading sequence when in delayed load mode.
  112701. */
  112702. delayLoadState: number;
  112703. private _scene;
  112704. private _engine;
  112705. /** @hidden */
  112706. _texture: Nullable<InternalTexture>;
  112707. private _uid;
  112708. /**
  112709. * Define if the texture is preventinga material to render or not.
  112710. * If not and the texture is not ready, the engine will use a default black texture instead.
  112711. */
  112712. get isBlocking(): boolean;
  112713. /**
  112714. * Instantiates a new BaseTexture.
  112715. * Base class of all the textures in babylon.
  112716. * It groups all the common properties the materials, post process, lights... might need
  112717. * in order to make a correct use of the texture.
  112718. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112719. */
  112720. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112721. /**
  112722. * Get the scene the texture belongs to.
  112723. * @returns the scene or null if undefined
  112724. */
  112725. getScene(): Nullable<Scene>;
  112726. /** @hidden */
  112727. protected _getEngine(): Nullable<ThinEngine>;
  112728. /**
  112729. * Get the texture transform matrix used to offset tile the texture for istance.
  112730. * @returns the transformation matrix
  112731. */
  112732. getTextureMatrix(): Matrix;
  112733. /**
  112734. * Get the texture reflection matrix used to rotate/transform the reflection.
  112735. * @returns the reflection matrix
  112736. */
  112737. getReflectionTextureMatrix(): Matrix;
  112738. /**
  112739. * Get the underlying lower level texture from Babylon.
  112740. * @returns the insternal texture
  112741. */
  112742. getInternalTexture(): Nullable<InternalTexture>;
  112743. /**
  112744. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112745. * @returns true if ready or not blocking
  112746. */
  112747. isReadyOrNotBlocking(): boolean;
  112748. /**
  112749. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112750. * @returns true if fully ready
  112751. */
  112752. isReady(): boolean;
  112753. private _cachedSize;
  112754. /**
  112755. * Get the size of the texture.
  112756. * @returns the texture size.
  112757. */
  112758. getSize(): ISize;
  112759. /**
  112760. * Get the base size of the texture.
  112761. * It can be different from the size if the texture has been resized for POT for instance
  112762. * @returns the base size
  112763. */
  112764. getBaseSize(): ISize;
  112765. /**
  112766. * Update the sampling mode of the texture.
  112767. * Default is Trilinear mode.
  112768. *
  112769. * | Value | Type | Description |
  112770. * | ----- | ------------------ | ----------- |
  112771. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112772. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112773. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112774. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112775. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112776. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112777. * | 7 | NEAREST_LINEAR | |
  112778. * | 8 | NEAREST_NEAREST | |
  112779. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112780. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112781. * | 11 | LINEAR_LINEAR | |
  112782. * | 12 | LINEAR_NEAREST | |
  112783. *
  112784. * > _mag_: magnification filter (close to the viewer)
  112785. * > _min_: minification filter (far from the viewer)
  112786. * > _mip_: filter used between mip map levels
  112787. *@param samplingMode Define the new sampling mode of the texture
  112788. */
  112789. updateSamplingMode(samplingMode: number): void;
  112790. /**
  112791. * Scales the texture if is `canRescale()`
  112792. * @param ratio the resize factor we want to use to rescale
  112793. */
  112794. scale(ratio: number): void;
  112795. /**
  112796. * Get if the texture can rescale.
  112797. */
  112798. get canRescale(): boolean;
  112799. /** @hidden */
  112800. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  112801. /** @hidden */
  112802. _rebuild(): void;
  112803. /**
  112804. * Triggers the load sequence in delayed load mode.
  112805. */
  112806. delayLoad(): void;
  112807. /**
  112808. * Clones the texture.
  112809. * @returns the cloned texture
  112810. */
  112811. clone(): Nullable<BaseTexture>;
  112812. /**
  112813. * Get the texture underlying type (INT, FLOAT...)
  112814. */
  112815. get textureType(): number;
  112816. /**
  112817. * Get the texture underlying format (RGB, RGBA...)
  112818. */
  112819. get textureFormat(): number;
  112820. /**
  112821. * Indicates that textures need to be re-calculated for all materials
  112822. */
  112823. protected _markAllSubMeshesAsTexturesDirty(): void;
  112824. /**
  112825. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  112826. * This will returns an RGBA array buffer containing either in values (0-255) or
  112827. * float values (0-1) depending of the underlying buffer type.
  112828. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  112829. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  112830. * @param buffer defines a user defined buffer to fill with data (can be null)
  112831. * @returns The Array buffer containing the pixels data.
  112832. */
  112833. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  112834. /**
  112835. * Release and destroy the underlying lower level texture aka internalTexture.
  112836. */
  112837. releaseInternalTexture(): void;
  112838. /** @hidden */
  112839. get _lodTextureHigh(): Nullable<BaseTexture>;
  112840. /** @hidden */
  112841. get _lodTextureMid(): Nullable<BaseTexture>;
  112842. /** @hidden */
  112843. get _lodTextureLow(): Nullable<BaseTexture>;
  112844. /**
  112845. * Dispose the texture and release its associated resources.
  112846. */
  112847. dispose(): void;
  112848. /**
  112849. * Serialize the texture into a JSON representation that can be parsed later on.
  112850. * @returns the JSON representation of the texture
  112851. */
  112852. serialize(): any;
  112853. /**
  112854. * Helper function to be called back once a list of texture contains only ready textures.
  112855. * @param textures Define the list of textures to wait for
  112856. * @param callback Define the callback triggered once the entire list will be ready
  112857. */
  112858. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  112859. private static _isScene;
  112860. }
  112861. }
  112862. declare module BABYLON {
  112863. /**
  112864. * Options to be used when creating an effect.
  112865. */
  112866. export interface IEffectCreationOptions {
  112867. /**
  112868. * Atrributes that will be used in the shader.
  112869. */
  112870. attributes: string[];
  112871. /**
  112872. * Uniform varible names that will be set in the shader.
  112873. */
  112874. uniformsNames: string[];
  112875. /**
  112876. * Uniform buffer variable names that will be set in the shader.
  112877. */
  112878. uniformBuffersNames: string[];
  112879. /**
  112880. * Sampler texture variable names that will be set in the shader.
  112881. */
  112882. samplers: string[];
  112883. /**
  112884. * Define statements that will be set in the shader.
  112885. */
  112886. defines: any;
  112887. /**
  112888. * Possible fallbacks for this effect to improve performance when needed.
  112889. */
  112890. fallbacks: Nullable<IEffectFallbacks>;
  112891. /**
  112892. * Callback that will be called when the shader is compiled.
  112893. */
  112894. onCompiled: Nullable<(effect: Effect) => void>;
  112895. /**
  112896. * Callback that will be called if an error occurs during shader compilation.
  112897. */
  112898. onError: Nullable<(effect: Effect, errors: string) => void>;
  112899. /**
  112900. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112901. */
  112902. indexParameters?: any;
  112903. /**
  112904. * Max number of lights that can be used in the shader.
  112905. */
  112906. maxSimultaneousLights?: number;
  112907. /**
  112908. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  112909. */
  112910. transformFeedbackVaryings?: Nullable<string[]>;
  112911. /**
  112912. * 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
  112913. */
  112914. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  112915. /**
  112916. * Is this effect rendering to several color attachments ?
  112917. */
  112918. multiTarget?: boolean;
  112919. }
  112920. /**
  112921. * Effect containing vertex and fragment shader that can be executed on an object.
  112922. */
  112923. export class Effect implements IDisposable {
  112924. /**
  112925. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112926. */
  112927. static ShadersRepository: string;
  112928. /**
  112929. * Enable logging of the shader code when a compilation error occurs
  112930. */
  112931. static LogShaderCodeOnCompilationError: boolean;
  112932. /**
  112933. * Name of the effect.
  112934. */
  112935. name: any;
  112936. /**
  112937. * String container all the define statements that should be set on the shader.
  112938. */
  112939. defines: string;
  112940. /**
  112941. * Callback that will be called when the shader is compiled.
  112942. */
  112943. onCompiled: Nullable<(effect: Effect) => void>;
  112944. /**
  112945. * Callback that will be called if an error occurs during shader compilation.
  112946. */
  112947. onError: Nullable<(effect: Effect, errors: string) => void>;
  112948. /**
  112949. * Callback that will be called when effect is bound.
  112950. */
  112951. onBind: Nullable<(effect: Effect) => void>;
  112952. /**
  112953. * Unique ID of the effect.
  112954. */
  112955. uniqueId: number;
  112956. /**
  112957. * Observable that will be called when the shader is compiled.
  112958. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  112959. */
  112960. onCompileObservable: Observable<Effect>;
  112961. /**
  112962. * Observable that will be called if an error occurs during shader compilation.
  112963. */
  112964. onErrorObservable: Observable<Effect>;
  112965. /** @hidden */
  112966. _onBindObservable: Nullable<Observable<Effect>>;
  112967. /**
  112968. * @hidden
  112969. * Specifies if the effect was previously ready
  112970. */
  112971. _wasPreviouslyReady: boolean;
  112972. /**
  112973. * Observable that will be called when effect is bound.
  112974. */
  112975. get onBindObservable(): Observable<Effect>;
  112976. /** @hidden */
  112977. _bonesComputationForcedToCPU: boolean;
  112978. /** @hidden */
  112979. _multiTarget: boolean;
  112980. private static _uniqueIdSeed;
  112981. private _engine;
  112982. private _uniformBuffersNames;
  112983. private _uniformBuffersNamesList;
  112984. private _uniformsNames;
  112985. private _samplerList;
  112986. private _samplers;
  112987. private _isReady;
  112988. private _compilationError;
  112989. private _allFallbacksProcessed;
  112990. private _attributesNames;
  112991. private _attributes;
  112992. private _attributeLocationByName;
  112993. private _uniforms;
  112994. /**
  112995. * Key for the effect.
  112996. * @hidden
  112997. */
  112998. _key: string;
  112999. private _indexParameters;
  113000. private _fallbacks;
  113001. private _vertexSourceCode;
  113002. private _fragmentSourceCode;
  113003. private _vertexSourceCodeOverride;
  113004. private _fragmentSourceCodeOverride;
  113005. private _transformFeedbackVaryings;
  113006. /**
  113007. * Compiled shader to webGL program.
  113008. * @hidden
  113009. */
  113010. _pipelineContext: Nullable<IPipelineContext>;
  113011. private _valueCache;
  113012. private static _baseCache;
  113013. /**
  113014. * Instantiates an effect.
  113015. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113016. * @param baseName Name of the effect.
  113017. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113018. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113019. * @param samplers List of sampler variables that will be passed to the shader.
  113020. * @param engine Engine to be used to render the effect
  113021. * @param defines Define statements to be added to the shader.
  113022. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113023. * @param onCompiled Callback that will be called when the shader is compiled.
  113024. * @param onError Callback that will be called if an error occurs during shader compilation.
  113025. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113026. */
  113027. 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);
  113028. private _useFinalCode;
  113029. /**
  113030. * Unique key for this effect
  113031. */
  113032. get key(): string;
  113033. /**
  113034. * If the effect has been compiled and prepared.
  113035. * @returns if the effect is compiled and prepared.
  113036. */
  113037. isReady(): boolean;
  113038. private _isReadyInternal;
  113039. /**
  113040. * The engine the effect was initialized with.
  113041. * @returns the engine.
  113042. */
  113043. getEngine(): Engine;
  113044. /**
  113045. * The pipeline context for this effect
  113046. * @returns the associated pipeline context
  113047. */
  113048. getPipelineContext(): Nullable<IPipelineContext>;
  113049. /**
  113050. * The set of names of attribute variables for the shader.
  113051. * @returns An array of attribute names.
  113052. */
  113053. getAttributesNames(): string[];
  113054. /**
  113055. * Returns the attribute at the given index.
  113056. * @param index The index of the attribute.
  113057. * @returns The location of the attribute.
  113058. */
  113059. getAttributeLocation(index: number): number;
  113060. /**
  113061. * Returns the attribute based on the name of the variable.
  113062. * @param name of the attribute to look up.
  113063. * @returns the attribute location.
  113064. */
  113065. getAttributeLocationByName(name: string): number;
  113066. /**
  113067. * The number of attributes.
  113068. * @returns the numnber of attributes.
  113069. */
  113070. getAttributesCount(): number;
  113071. /**
  113072. * Gets the index of a uniform variable.
  113073. * @param uniformName of the uniform to look up.
  113074. * @returns the index.
  113075. */
  113076. getUniformIndex(uniformName: string): number;
  113077. /**
  113078. * Returns the attribute based on the name of the variable.
  113079. * @param uniformName of the uniform to look up.
  113080. * @returns the location of the uniform.
  113081. */
  113082. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113083. /**
  113084. * Returns an array of sampler variable names
  113085. * @returns The array of sampler variable names.
  113086. */
  113087. getSamplers(): string[];
  113088. /**
  113089. * Returns an array of uniform variable names
  113090. * @returns The array of uniform variable names.
  113091. */
  113092. getUniformNames(): string[];
  113093. /**
  113094. * Returns an array of uniform buffer variable names
  113095. * @returns The array of uniform buffer variable names.
  113096. */
  113097. getUniformBuffersNames(): string[];
  113098. /**
  113099. * Returns the index parameters used to create the effect
  113100. * @returns The index parameters object
  113101. */
  113102. getIndexParameters(): any;
  113103. /**
  113104. * The error from the last compilation.
  113105. * @returns the error string.
  113106. */
  113107. getCompilationError(): string;
  113108. /**
  113109. * Gets a boolean indicating that all fallbacks were used during compilation
  113110. * @returns true if all fallbacks were used
  113111. */
  113112. allFallbacksProcessed(): boolean;
  113113. /**
  113114. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113115. * @param func The callback to be used.
  113116. */
  113117. executeWhenCompiled(func: (effect: Effect) => void): void;
  113118. private _checkIsReady;
  113119. private _loadShader;
  113120. /**
  113121. * Gets the vertex shader source code of this effect
  113122. */
  113123. get vertexSourceCode(): string;
  113124. /**
  113125. * Gets the fragment shader source code of this effect
  113126. */
  113127. get fragmentSourceCode(): string;
  113128. /**
  113129. * Recompiles the webGL program
  113130. * @param vertexSourceCode The source code for the vertex shader.
  113131. * @param fragmentSourceCode The source code for the fragment shader.
  113132. * @param onCompiled Callback called when completed.
  113133. * @param onError Callback called on error.
  113134. * @hidden
  113135. */
  113136. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113137. /**
  113138. * Prepares the effect
  113139. * @hidden
  113140. */
  113141. _prepareEffect(): void;
  113142. private _getShaderCodeAndErrorLine;
  113143. private _processCompilationErrors;
  113144. /**
  113145. * Checks if the effect is supported. (Must be called after compilation)
  113146. */
  113147. get isSupported(): boolean;
  113148. /**
  113149. * Binds a texture to the engine to be used as output of the shader.
  113150. * @param channel Name of the output variable.
  113151. * @param texture Texture to bind.
  113152. * @hidden
  113153. */
  113154. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113155. /**
  113156. * Sets a texture on the engine to be used in the shader.
  113157. * @param channel Name of the sampler variable.
  113158. * @param texture Texture to set.
  113159. */
  113160. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113161. /**
  113162. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113163. * @param channel Name of the sampler variable.
  113164. * @param texture Texture to set.
  113165. */
  113166. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113167. /**
  113168. * Sets an array of textures on the engine to be used in the shader.
  113169. * @param channel Name of the variable.
  113170. * @param textures Textures to set.
  113171. */
  113172. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113173. /**
  113174. * 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)
  113175. * @param channel Name of the sampler variable.
  113176. * @param postProcess Post process to get the input texture from.
  113177. */
  113178. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113179. /**
  113180. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113181. * 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)
  113182. * @param channel Name of the sampler variable.
  113183. * @param postProcess Post process to get the output texture from.
  113184. */
  113185. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113186. /** @hidden */
  113187. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113188. /** @hidden */
  113189. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113190. /** @hidden */
  113191. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113192. /** @hidden */
  113193. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113194. /**
  113195. * Binds a buffer to a uniform.
  113196. * @param buffer Buffer to bind.
  113197. * @param name Name of the uniform variable to bind to.
  113198. */
  113199. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113200. /**
  113201. * Binds block to a uniform.
  113202. * @param blockName Name of the block to bind.
  113203. * @param index Index to bind.
  113204. */
  113205. bindUniformBlock(blockName: string, index: number): void;
  113206. /**
  113207. * Sets an interger value on a uniform variable.
  113208. * @param uniformName Name of the variable.
  113209. * @param value Value to be set.
  113210. * @returns this effect.
  113211. */
  113212. setInt(uniformName: string, value: number): Effect;
  113213. /**
  113214. * Sets an int array on a uniform variable.
  113215. * @param uniformName Name of the variable.
  113216. * @param array array to be set.
  113217. * @returns this effect.
  113218. */
  113219. setIntArray(uniformName: string, array: Int32Array): Effect;
  113220. /**
  113221. * 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)
  113222. * @param uniformName Name of the variable.
  113223. * @param array array to be set.
  113224. * @returns this effect.
  113225. */
  113226. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113227. /**
  113228. * 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)
  113229. * @param uniformName Name of the variable.
  113230. * @param array array to be set.
  113231. * @returns this effect.
  113232. */
  113233. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113234. /**
  113235. * 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)
  113236. * @param uniformName Name of the variable.
  113237. * @param array array to be set.
  113238. * @returns this effect.
  113239. */
  113240. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113241. /**
  113242. * Sets an float array on a uniform variable.
  113243. * @param uniformName Name of the variable.
  113244. * @param array array to be set.
  113245. * @returns this effect.
  113246. */
  113247. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113248. /**
  113249. * 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)
  113250. * @param uniformName Name of the variable.
  113251. * @param array array to be set.
  113252. * @returns this effect.
  113253. */
  113254. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113255. /**
  113256. * 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)
  113257. * @param uniformName Name of the variable.
  113258. * @param array array to be set.
  113259. * @returns this effect.
  113260. */
  113261. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113262. /**
  113263. * 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)
  113264. * @param uniformName Name of the variable.
  113265. * @param array array to be set.
  113266. * @returns this effect.
  113267. */
  113268. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113269. /**
  113270. * Sets an array on a uniform variable.
  113271. * @param uniformName Name of the variable.
  113272. * @param array array to be set.
  113273. * @returns this effect.
  113274. */
  113275. setArray(uniformName: string, array: number[]): Effect;
  113276. /**
  113277. * 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)
  113278. * @param uniformName Name of the variable.
  113279. * @param array array to be set.
  113280. * @returns this effect.
  113281. */
  113282. setArray2(uniformName: string, array: number[]): Effect;
  113283. /**
  113284. * 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)
  113285. * @param uniformName Name of the variable.
  113286. * @param array array to be set.
  113287. * @returns this effect.
  113288. */
  113289. setArray3(uniformName: string, array: number[]): Effect;
  113290. /**
  113291. * 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)
  113292. * @param uniformName Name of the variable.
  113293. * @param array array to be set.
  113294. * @returns this effect.
  113295. */
  113296. setArray4(uniformName: string, array: number[]): Effect;
  113297. /**
  113298. * Sets matrices on a uniform variable.
  113299. * @param uniformName Name of the variable.
  113300. * @param matrices matrices to be set.
  113301. * @returns this effect.
  113302. */
  113303. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113304. /**
  113305. * Sets matrix on a uniform variable.
  113306. * @param uniformName Name of the variable.
  113307. * @param matrix matrix to be set.
  113308. * @returns this effect.
  113309. */
  113310. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113311. /**
  113312. * 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)
  113313. * @param uniformName Name of the variable.
  113314. * @param matrix matrix to be set.
  113315. * @returns this effect.
  113316. */
  113317. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113318. /**
  113319. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113320. * @param uniformName Name of the variable.
  113321. * @param matrix matrix to be set.
  113322. * @returns this effect.
  113323. */
  113324. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113325. /**
  113326. * Sets a float on a uniform variable.
  113327. * @param uniformName Name of the variable.
  113328. * @param value value to be set.
  113329. * @returns this effect.
  113330. */
  113331. setFloat(uniformName: string, value: number): Effect;
  113332. /**
  113333. * Sets a boolean on a uniform variable.
  113334. * @param uniformName Name of the variable.
  113335. * @param bool value to be set.
  113336. * @returns this effect.
  113337. */
  113338. setBool(uniformName: string, bool: boolean): Effect;
  113339. /**
  113340. * Sets a Vector2 on a uniform variable.
  113341. * @param uniformName Name of the variable.
  113342. * @param vector2 vector2 to be set.
  113343. * @returns this effect.
  113344. */
  113345. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113346. /**
  113347. * Sets a float2 on a uniform variable.
  113348. * @param uniformName Name of the variable.
  113349. * @param x First float in float2.
  113350. * @param y Second float in float2.
  113351. * @returns this effect.
  113352. */
  113353. setFloat2(uniformName: string, x: number, y: number): Effect;
  113354. /**
  113355. * Sets a Vector3 on a uniform variable.
  113356. * @param uniformName Name of the variable.
  113357. * @param vector3 Value to be set.
  113358. * @returns this effect.
  113359. */
  113360. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113361. /**
  113362. * Sets a float3 on a uniform variable.
  113363. * @param uniformName Name of the variable.
  113364. * @param x First float in float3.
  113365. * @param y Second float in float3.
  113366. * @param z Third float in float3.
  113367. * @returns this effect.
  113368. */
  113369. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113370. /**
  113371. * Sets a Vector4 on a uniform variable.
  113372. * @param uniformName Name of the variable.
  113373. * @param vector4 Value to be set.
  113374. * @returns this effect.
  113375. */
  113376. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113377. /**
  113378. * Sets a float4 on a uniform variable.
  113379. * @param uniformName Name of the variable.
  113380. * @param x First float in float4.
  113381. * @param y Second float in float4.
  113382. * @param z Third float in float4.
  113383. * @param w Fourth float in float4.
  113384. * @returns this effect.
  113385. */
  113386. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113387. /**
  113388. * Sets a Color3 on a uniform variable.
  113389. * @param uniformName Name of the variable.
  113390. * @param color3 Value to be set.
  113391. * @returns this effect.
  113392. */
  113393. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113394. /**
  113395. * Sets a Color4 on a uniform variable.
  113396. * @param uniformName Name of the variable.
  113397. * @param color3 Value to be set.
  113398. * @param alpha Alpha value to be set.
  113399. * @returns this effect.
  113400. */
  113401. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113402. /**
  113403. * Sets a Color4 on a uniform variable
  113404. * @param uniformName defines the name of the variable
  113405. * @param color4 defines the value to be set
  113406. * @returns this effect.
  113407. */
  113408. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113409. /** Release all associated resources */
  113410. dispose(): void;
  113411. /**
  113412. * This function will add a new shader to the shader store
  113413. * @param name the name of the shader
  113414. * @param pixelShader optional pixel shader content
  113415. * @param vertexShader optional vertex shader content
  113416. */
  113417. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113418. /**
  113419. * Store of each shader (The can be looked up using effect.key)
  113420. */
  113421. static ShadersStore: {
  113422. [key: string]: string;
  113423. };
  113424. /**
  113425. * Store of each included file for a shader (The can be looked up using effect.key)
  113426. */
  113427. static IncludesShadersStore: {
  113428. [key: string]: string;
  113429. };
  113430. /**
  113431. * Resets the cache of effects.
  113432. */
  113433. static ResetCache(): void;
  113434. }
  113435. }
  113436. declare module BABYLON {
  113437. /**
  113438. * Interface used to describe the capabilities of the engine relatively to the current browser
  113439. */
  113440. export interface EngineCapabilities {
  113441. /** Maximum textures units per fragment shader */
  113442. maxTexturesImageUnits: number;
  113443. /** Maximum texture units per vertex shader */
  113444. maxVertexTextureImageUnits: number;
  113445. /** Maximum textures units in the entire pipeline */
  113446. maxCombinedTexturesImageUnits: number;
  113447. /** Maximum texture size */
  113448. maxTextureSize: number;
  113449. /** Maximum texture samples */
  113450. maxSamples?: number;
  113451. /** Maximum cube texture size */
  113452. maxCubemapTextureSize: number;
  113453. /** Maximum render texture size */
  113454. maxRenderTextureSize: number;
  113455. /** Maximum number of vertex attributes */
  113456. maxVertexAttribs: number;
  113457. /** Maximum number of varyings */
  113458. maxVaryingVectors: number;
  113459. /** Maximum number of uniforms per vertex shader */
  113460. maxVertexUniformVectors: number;
  113461. /** Maximum number of uniforms per fragment shader */
  113462. maxFragmentUniformVectors: number;
  113463. /** Defines if standard derivates (dx/dy) are supported */
  113464. standardDerivatives: boolean;
  113465. /** Defines if s3tc texture compression is supported */
  113466. s3tc?: WEBGL_compressed_texture_s3tc;
  113467. /** Defines if pvrtc texture compression is supported */
  113468. pvrtc: any;
  113469. /** Defines if etc1 texture compression is supported */
  113470. etc1: any;
  113471. /** Defines if etc2 texture compression is supported */
  113472. etc2: any;
  113473. /** Defines if astc texture compression is supported */
  113474. astc: any;
  113475. /** Defines if float textures are supported */
  113476. textureFloat: boolean;
  113477. /** Defines if vertex array objects are supported */
  113478. vertexArrayObject: boolean;
  113479. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113480. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113481. /** Gets the maximum level of anisotropy supported */
  113482. maxAnisotropy: number;
  113483. /** Defines if instancing is supported */
  113484. instancedArrays: boolean;
  113485. /** Defines if 32 bits indices are supported */
  113486. uintIndices: boolean;
  113487. /** Defines if high precision shaders are supported */
  113488. highPrecisionShaderSupported: boolean;
  113489. /** Defines if depth reading in the fragment shader is supported */
  113490. fragmentDepthSupported: boolean;
  113491. /** Defines if float texture linear filtering is supported*/
  113492. textureFloatLinearFiltering: boolean;
  113493. /** Defines if rendering to float textures is supported */
  113494. textureFloatRender: boolean;
  113495. /** Defines if half float textures are supported*/
  113496. textureHalfFloat: boolean;
  113497. /** Defines if half float texture linear filtering is supported*/
  113498. textureHalfFloatLinearFiltering: boolean;
  113499. /** Defines if rendering to half float textures is supported */
  113500. textureHalfFloatRender: boolean;
  113501. /** Defines if textureLOD shader command is supported */
  113502. textureLOD: boolean;
  113503. /** Defines if draw buffers extension is supported */
  113504. drawBuffersExtension: boolean;
  113505. /** Defines if depth textures are supported */
  113506. depthTextureExtension: boolean;
  113507. /** Defines if float color buffer are supported */
  113508. colorBufferFloat: boolean;
  113509. /** Gets disjoint timer query extension (null if not supported) */
  113510. timerQuery?: EXT_disjoint_timer_query;
  113511. /** Defines if timestamp can be used with timer query */
  113512. canUseTimestampForTimerQuery: boolean;
  113513. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113514. multiview?: any;
  113515. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113516. oculusMultiview?: any;
  113517. /** Function used to let the system compiles shaders in background */
  113518. parallelShaderCompile?: {
  113519. COMPLETION_STATUS_KHR: number;
  113520. };
  113521. /** Max number of texture samples for MSAA */
  113522. maxMSAASamples: number;
  113523. /** Defines if the blend min max extension is supported */
  113524. blendMinMax: boolean;
  113525. }
  113526. }
  113527. declare module BABYLON {
  113528. /**
  113529. * @hidden
  113530. **/
  113531. export class DepthCullingState {
  113532. private _isDepthTestDirty;
  113533. private _isDepthMaskDirty;
  113534. private _isDepthFuncDirty;
  113535. private _isCullFaceDirty;
  113536. private _isCullDirty;
  113537. private _isZOffsetDirty;
  113538. private _isFrontFaceDirty;
  113539. private _depthTest;
  113540. private _depthMask;
  113541. private _depthFunc;
  113542. private _cull;
  113543. private _cullFace;
  113544. private _zOffset;
  113545. private _frontFace;
  113546. /**
  113547. * Initializes the state.
  113548. */
  113549. constructor();
  113550. get isDirty(): boolean;
  113551. get zOffset(): number;
  113552. set zOffset(value: number);
  113553. get cullFace(): Nullable<number>;
  113554. set cullFace(value: Nullable<number>);
  113555. get cull(): Nullable<boolean>;
  113556. set cull(value: Nullable<boolean>);
  113557. get depthFunc(): Nullable<number>;
  113558. set depthFunc(value: Nullable<number>);
  113559. get depthMask(): boolean;
  113560. set depthMask(value: boolean);
  113561. get depthTest(): boolean;
  113562. set depthTest(value: boolean);
  113563. get frontFace(): Nullable<number>;
  113564. set frontFace(value: Nullable<number>);
  113565. reset(): void;
  113566. apply(gl: WebGLRenderingContext): void;
  113567. }
  113568. }
  113569. declare module BABYLON {
  113570. /**
  113571. * @hidden
  113572. **/
  113573. export class StencilState {
  113574. /** 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 */
  113575. static readonly ALWAYS: number;
  113576. /** Passed to stencilOperation to specify that stencil value must be kept */
  113577. static readonly KEEP: number;
  113578. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113579. static readonly REPLACE: number;
  113580. private _isStencilTestDirty;
  113581. private _isStencilMaskDirty;
  113582. private _isStencilFuncDirty;
  113583. private _isStencilOpDirty;
  113584. private _stencilTest;
  113585. private _stencilMask;
  113586. private _stencilFunc;
  113587. private _stencilFuncRef;
  113588. private _stencilFuncMask;
  113589. private _stencilOpStencilFail;
  113590. private _stencilOpDepthFail;
  113591. private _stencilOpStencilDepthPass;
  113592. get isDirty(): boolean;
  113593. get stencilFunc(): number;
  113594. set stencilFunc(value: number);
  113595. get stencilFuncRef(): number;
  113596. set stencilFuncRef(value: number);
  113597. get stencilFuncMask(): number;
  113598. set stencilFuncMask(value: number);
  113599. get stencilOpStencilFail(): number;
  113600. set stencilOpStencilFail(value: number);
  113601. get stencilOpDepthFail(): number;
  113602. set stencilOpDepthFail(value: number);
  113603. get stencilOpStencilDepthPass(): number;
  113604. set stencilOpStencilDepthPass(value: number);
  113605. get stencilMask(): number;
  113606. set stencilMask(value: number);
  113607. get stencilTest(): boolean;
  113608. set stencilTest(value: boolean);
  113609. constructor();
  113610. reset(): void;
  113611. apply(gl: WebGLRenderingContext): void;
  113612. }
  113613. }
  113614. declare module BABYLON {
  113615. /**
  113616. * @hidden
  113617. **/
  113618. export class AlphaState {
  113619. private _isAlphaBlendDirty;
  113620. private _isBlendFunctionParametersDirty;
  113621. private _isBlendEquationParametersDirty;
  113622. private _isBlendConstantsDirty;
  113623. private _alphaBlend;
  113624. private _blendFunctionParameters;
  113625. private _blendEquationParameters;
  113626. private _blendConstants;
  113627. /**
  113628. * Initializes the state.
  113629. */
  113630. constructor();
  113631. get isDirty(): boolean;
  113632. get alphaBlend(): boolean;
  113633. set alphaBlend(value: boolean);
  113634. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113635. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113636. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113637. reset(): void;
  113638. apply(gl: WebGLRenderingContext): void;
  113639. }
  113640. }
  113641. declare module BABYLON {
  113642. /** @hidden */
  113643. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113644. attributeProcessor(attribute: string): string;
  113645. varyingProcessor(varying: string, isFragment: boolean): string;
  113646. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113647. }
  113648. }
  113649. declare module BABYLON {
  113650. /**
  113651. * Interface for attribute information associated with buffer instanciation
  113652. */
  113653. export interface InstancingAttributeInfo {
  113654. /**
  113655. * Name of the GLSL attribute
  113656. * if attribute index is not specified, this is used to retrieve the index from the effect
  113657. */
  113658. attributeName: string;
  113659. /**
  113660. * Index/offset of the attribute in the vertex shader
  113661. * if not specified, this will be computes from the name.
  113662. */
  113663. index?: number;
  113664. /**
  113665. * size of the attribute, 1, 2, 3 or 4
  113666. */
  113667. attributeSize: number;
  113668. /**
  113669. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113670. */
  113671. offset: number;
  113672. /**
  113673. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113674. * default to 1
  113675. */
  113676. divisor?: number;
  113677. /**
  113678. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113679. * default is FLOAT
  113680. */
  113681. attributeType?: number;
  113682. /**
  113683. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113684. */
  113685. normalized?: boolean;
  113686. }
  113687. }
  113688. declare module BABYLON {
  113689. interface ThinEngine {
  113690. /**
  113691. * Update a video texture
  113692. * @param texture defines the texture to update
  113693. * @param video defines the video element to use
  113694. * @param invertY defines if data must be stored with Y axis inverted
  113695. */
  113696. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113697. }
  113698. }
  113699. declare module BABYLON {
  113700. interface ThinEngine {
  113701. /**
  113702. * Creates a dynamic texture
  113703. * @param width defines the width of the texture
  113704. * @param height defines the height of the texture
  113705. * @param generateMipMaps defines if the engine should generate the mip levels
  113706. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113707. * @returns the dynamic texture inside an InternalTexture
  113708. */
  113709. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113710. /**
  113711. * Update the content of a dynamic texture
  113712. * @param texture defines the texture to update
  113713. * @param canvas defines the canvas containing the source
  113714. * @param invertY defines if data must be stored with Y axis inverted
  113715. * @param premulAlpha defines if alpha is stored as premultiplied
  113716. * @param format defines the format of the data
  113717. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113718. */
  113719. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113720. }
  113721. }
  113722. declare module BABYLON {
  113723. /**
  113724. * Settings for finer control over video usage
  113725. */
  113726. export interface VideoTextureSettings {
  113727. /**
  113728. * Applies `autoplay` to video, if specified
  113729. */
  113730. autoPlay?: boolean;
  113731. /**
  113732. * Applies `loop` to video, if specified
  113733. */
  113734. loop?: boolean;
  113735. /**
  113736. * Automatically updates internal texture from video at every frame in the render loop
  113737. */
  113738. autoUpdateTexture: boolean;
  113739. /**
  113740. * Image src displayed during the video loading or until the user interacts with the video.
  113741. */
  113742. poster?: string;
  113743. }
  113744. /**
  113745. * If you want to display a video in your scene, this is the special texture for that.
  113746. * This special texture works similar to other textures, with the exception of a few parameters.
  113747. * @see https://doc.babylonjs.com/how_to/video_texture
  113748. */
  113749. export class VideoTexture extends Texture {
  113750. /**
  113751. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113752. */
  113753. readonly autoUpdateTexture: boolean;
  113754. /**
  113755. * The video instance used by the texture internally
  113756. */
  113757. readonly video: HTMLVideoElement;
  113758. private _onUserActionRequestedObservable;
  113759. /**
  113760. * Event triggerd when a dom action is required by the user to play the video.
  113761. * This happens due to recent changes in browser policies preventing video to auto start.
  113762. */
  113763. get onUserActionRequestedObservable(): Observable<Texture>;
  113764. private _generateMipMaps;
  113765. private _stillImageCaptured;
  113766. private _displayingPosterTexture;
  113767. private _settings;
  113768. private _createInternalTextureOnEvent;
  113769. private _frameId;
  113770. private _currentSrc;
  113771. /**
  113772. * Creates a video texture.
  113773. * If you want to display a video in your scene, this is the special texture for that.
  113774. * This special texture works similar to other textures, with the exception of a few parameters.
  113775. * @see https://doc.babylonjs.com/how_to/video_texture
  113776. * @param name optional name, will detect from video source, if not defined
  113777. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113778. * @param scene is obviously the current scene.
  113779. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113780. * @param invertY is false by default but can be used to invert video on Y axis
  113781. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113782. * @param settings allows finer control over video usage
  113783. */
  113784. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113785. private _getName;
  113786. private _getVideo;
  113787. private _createInternalTexture;
  113788. private reset;
  113789. /**
  113790. * @hidden Internal method to initiate `update`.
  113791. */
  113792. _rebuild(): void;
  113793. /**
  113794. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113795. */
  113796. update(): void;
  113797. /**
  113798. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  113799. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  113800. */
  113801. updateTexture(isVisible: boolean): void;
  113802. protected _updateInternalTexture: () => void;
  113803. /**
  113804. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  113805. * @param url New url.
  113806. */
  113807. updateURL(url: string): void;
  113808. /**
  113809. * Clones the texture.
  113810. * @returns the cloned texture
  113811. */
  113812. clone(): VideoTexture;
  113813. /**
  113814. * Dispose the texture and release its associated resources.
  113815. */
  113816. dispose(): void;
  113817. /**
  113818. * Creates a video texture straight from a stream.
  113819. * @param scene Define the scene the texture should be created in
  113820. * @param stream Define the stream the texture should be created from
  113821. * @returns The created video texture as a promise
  113822. */
  113823. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  113824. /**
  113825. * Creates a video texture straight from your WebCam video feed.
  113826. * @param scene Define the scene the texture should be created in
  113827. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113828. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113829. * @returns The created video texture as a promise
  113830. */
  113831. static CreateFromWebCamAsync(scene: Scene, constraints: {
  113832. minWidth: number;
  113833. maxWidth: number;
  113834. minHeight: number;
  113835. maxHeight: number;
  113836. deviceId: string;
  113837. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  113838. /**
  113839. * Creates a video texture straight from your WebCam video feed.
  113840. * @param scene Define the scene the texture should be created in
  113841. * @param onReady Define a callback to triggered once the texture will be ready
  113842. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113843. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113844. */
  113845. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  113846. minWidth: number;
  113847. maxWidth: number;
  113848. minHeight: number;
  113849. maxHeight: number;
  113850. deviceId: string;
  113851. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  113852. }
  113853. }
  113854. declare module BABYLON {
  113855. /**
  113856. * Defines the interface used by objects working like Scene
  113857. * @hidden
  113858. */
  113859. export interface ISceneLike {
  113860. _addPendingData(data: any): void;
  113861. _removePendingData(data: any): void;
  113862. offlineProvider: IOfflineProvider;
  113863. }
  113864. /** Interface defining initialization parameters for Engine class */
  113865. export interface EngineOptions extends WebGLContextAttributes {
  113866. /**
  113867. * Defines if the engine should no exceed a specified device ratio
  113868. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  113869. */
  113870. limitDeviceRatio?: number;
  113871. /**
  113872. * Defines if webvr should be enabled automatically
  113873. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113874. */
  113875. autoEnableWebVR?: boolean;
  113876. /**
  113877. * Defines if webgl2 should be turned off even if supported
  113878. * @see https://doc.babylonjs.com/features/webgl2
  113879. */
  113880. disableWebGL2Support?: boolean;
  113881. /**
  113882. * Defines if webaudio should be initialized as well
  113883. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113884. */
  113885. audioEngine?: boolean;
  113886. /**
  113887. * Defines if animations should run using a deterministic lock step
  113888. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113889. */
  113890. deterministicLockstep?: boolean;
  113891. /** Defines the maximum steps to use with deterministic lock step mode */
  113892. lockstepMaxSteps?: number;
  113893. /** Defines the seconds between each deterministic lock step */
  113894. timeStep?: number;
  113895. /**
  113896. * Defines that engine should ignore context lost events
  113897. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  113898. */
  113899. doNotHandleContextLost?: boolean;
  113900. /**
  113901. * Defines that engine should ignore modifying touch action attribute and style
  113902. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  113903. */
  113904. doNotHandleTouchAction?: boolean;
  113905. /**
  113906. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  113907. */
  113908. useHighPrecisionFloats?: boolean;
  113909. /**
  113910. * Make the canvas XR Compatible for XR sessions
  113911. */
  113912. xrCompatible?: boolean;
  113913. /**
  113914. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  113915. */
  113916. useHighPrecisionMatrix?: boolean;
  113917. }
  113918. /**
  113919. * The base engine class (root of all engines)
  113920. */
  113921. export class ThinEngine {
  113922. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  113923. static ExceptionList: ({
  113924. key: string;
  113925. capture: string;
  113926. captureConstraint: number;
  113927. targets: string[];
  113928. } | {
  113929. key: string;
  113930. capture: null;
  113931. captureConstraint: null;
  113932. targets: string[];
  113933. })[];
  113934. /** @hidden */
  113935. static _TextureLoaders: IInternalTextureLoader[];
  113936. /**
  113937. * Returns the current npm package of the sdk
  113938. */
  113939. static get NpmPackage(): string;
  113940. /**
  113941. * Returns the current version of the framework
  113942. */
  113943. static get Version(): string;
  113944. /**
  113945. * Returns a string describing the current engine
  113946. */
  113947. get description(): string;
  113948. /**
  113949. * Gets or sets the epsilon value used by collision engine
  113950. */
  113951. static CollisionsEpsilon: number;
  113952. /**
  113953. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113954. */
  113955. static get ShadersRepository(): string;
  113956. static set ShadersRepository(value: string);
  113957. /** @hidden */
  113958. _shaderProcessor: IShaderProcessor;
  113959. /**
  113960. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  113961. */
  113962. forcePOTTextures: boolean;
  113963. /**
  113964. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  113965. */
  113966. isFullscreen: boolean;
  113967. /**
  113968. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  113969. */
  113970. cullBackFaces: boolean;
  113971. /**
  113972. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  113973. */
  113974. renderEvenInBackground: boolean;
  113975. /**
  113976. * Gets or sets a boolean indicating that cache can be kept between frames
  113977. */
  113978. preventCacheWipeBetweenFrames: boolean;
  113979. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  113980. validateShaderPrograms: boolean;
  113981. /**
  113982. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  113983. * This can provide greater z depth for distant objects.
  113984. */
  113985. useReverseDepthBuffer: boolean;
  113986. /**
  113987. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  113988. */
  113989. disableUniformBuffers: boolean;
  113990. /** @hidden */
  113991. _uniformBuffers: UniformBuffer[];
  113992. /**
  113993. * Gets a boolean indicating that the engine supports uniform buffers
  113994. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  113995. */
  113996. get supportsUniformBuffers(): boolean;
  113997. /** @hidden */
  113998. _gl: WebGLRenderingContext;
  113999. /** @hidden */
  114000. _webGLVersion: number;
  114001. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114002. protected _windowIsBackground: boolean;
  114003. protected _creationOptions: EngineOptions;
  114004. protected _highPrecisionShadersAllowed: boolean;
  114005. /** @hidden */
  114006. get _shouldUseHighPrecisionShader(): boolean;
  114007. /**
  114008. * Gets a boolean indicating that only power of 2 textures are supported
  114009. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114010. */
  114011. get needPOTTextures(): boolean;
  114012. /** @hidden */
  114013. _badOS: boolean;
  114014. /** @hidden */
  114015. _badDesktopOS: boolean;
  114016. private _hardwareScalingLevel;
  114017. /** @hidden */
  114018. _caps: EngineCapabilities;
  114019. private _isStencilEnable;
  114020. private _glVersion;
  114021. private _glRenderer;
  114022. private _glVendor;
  114023. /** @hidden */
  114024. _videoTextureSupported: boolean;
  114025. protected _renderingQueueLaunched: boolean;
  114026. protected _activeRenderLoops: (() => void)[];
  114027. /**
  114028. * Observable signaled when a context lost event is raised
  114029. */
  114030. onContextLostObservable: Observable<ThinEngine>;
  114031. /**
  114032. * Observable signaled when a context restored event is raised
  114033. */
  114034. onContextRestoredObservable: Observable<ThinEngine>;
  114035. private _onContextLost;
  114036. private _onContextRestored;
  114037. protected _contextWasLost: boolean;
  114038. /** @hidden */
  114039. _doNotHandleContextLost: boolean;
  114040. /**
  114041. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114042. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114043. */
  114044. get doNotHandleContextLost(): boolean;
  114045. set doNotHandleContextLost(value: boolean);
  114046. /**
  114047. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114048. */
  114049. disableVertexArrayObjects: boolean;
  114050. /** @hidden */
  114051. protected _colorWrite: boolean;
  114052. /** @hidden */
  114053. protected _colorWriteChanged: boolean;
  114054. /** @hidden */
  114055. protected _depthCullingState: DepthCullingState;
  114056. /** @hidden */
  114057. protected _stencilState: StencilState;
  114058. /** @hidden */
  114059. _alphaState: AlphaState;
  114060. /** @hidden */
  114061. _alphaMode: number;
  114062. /** @hidden */
  114063. _alphaEquation: number;
  114064. /** @hidden */
  114065. _internalTexturesCache: InternalTexture[];
  114066. /** @hidden */
  114067. protected _activeChannel: number;
  114068. private _currentTextureChannel;
  114069. /** @hidden */
  114070. protected _boundTexturesCache: {
  114071. [key: string]: Nullable<InternalTexture>;
  114072. };
  114073. /** @hidden */
  114074. protected _currentEffect: Nullable<Effect>;
  114075. /** @hidden */
  114076. protected _currentProgram: Nullable<WebGLProgram>;
  114077. private _compiledEffects;
  114078. private _vertexAttribArraysEnabled;
  114079. /** @hidden */
  114080. protected _cachedViewport: Nullable<IViewportLike>;
  114081. private _cachedVertexArrayObject;
  114082. /** @hidden */
  114083. protected _cachedVertexBuffers: any;
  114084. /** @hidden */
  114085. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114086. /** @hidden */
  114087. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114088. /** @hidden */
  114089. _currentRenderTarget: Nullable<InternalTexture>;
  114090. private _uintIndicesCurrentlySet;
  114091. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114092. /** @hidden */
  114093. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114094. /** @hidden */
  114095. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114096. private _currentBufferPointers;
  114097. private _currentInstanceLocations;
  114098. private _currentInstanceBuffers;
  114099. private _textureUnits;
  114100. /** @hidden */
  114101. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114102. /** @hidden */
  114103. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114104. /** @hidden */
  114105. _boundRenderFunction: any;
  114106. private _vaoRecordInProgress;
  114107. private _mustWipeVertexAttributes;
  114108. private _emptyTexture;
  114109. private _emptyCubeTexture;
  114110. private _emptyTexture3D;
  114111. private _emptyTexture2DArray;
  114112. /** @hidden */
  114113. _frameHandler: number;
  114114. private _nextFreeTextureSlots;
  114115. private _maxSimultaneousTextures;
  114116. private _activeRequests;
  114117. /** @hidden */
  114118. _transformTextureUrl: Nullable<(url: string) => string>;
  114119. protected get _supportsHardwareTextureRescaling(): boolean;
  114120. private _framebufferDimensionsObject;
  114121. /**
  114122. * sets the object from which width and height will be taken from when getting render width and height
  114123. * Will fallback to the gl object
  114124. * @param dimensions the framebuffer width and height that will be used.
  114125. */
  114126. set framebufferDimensionsObject(dimensions: Nullable<{
  114127. framebufferWidth: number;
  114128. framebufferHeight: number;
  114129. }>);
  114130. /**
  114131. * Gets the current viewport
  114132. */
  114133. get currentViewport(): Nullable<IViewportLike>;
  114134. /**
  114135. * Gets the default empty texture
  114136. */
  114137. get emptyTexture(): InternalTexture;
  114138. /**
  114139. * Gets the default empty 3D texture
  114140. */
  114141. get emptyTexture3D(): InternalTexture;
  114142. /**
  114143. * Gets the default empty 2D array texture
  114144. */
  114145. get emptyTexture2DArray(): InternalTexture;
  114146. /**
  114147. * Gets the default empty cube texture
  114148. */
  114149. get emptyCubeTexture(): InternalTexture;
  114150. /**
  114151. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114152. */
  114153. readonly premultipliedAlpha: boolean;
  114154. /**
  114155. * Observable event triggered before each texture is initialized
  114156. */
  114157. onBeforeTextureInitObservable: Observable<Texture>;
  114158. /**
  114159. * Creates a new engine
  114160. * @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
  114161. * @param antialias defines enable antialiasing (default: false)
  114162. * @param options defines further options to be sent to the getContext() function
  114163. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114164. */
  114165. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114166. private _rebuildInternalTextures;
  114167. private _rebuildEffects;
  114168. /**
  114169. * Gets a boolean indicating if all created effects are ready
  114170. * @returns true if all effects are ready
  114171. */
  114172. areAllEffectsReady(): boolean;
  114173. protected _rebuildBuffers(): void;
  114174. protected _initGLContext(): void;
  114175. /**
  114176. * Gets version of the current webGL context
  114177. */
  114178. get webGLVersion(): number;
  114179. /**
  114180. * Gets a string idenfifying the name of the class
  114181. * @returns "Engine" string
  114182. */
  114183. getClassName(): string;
  114184. /**
  114185. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114186. */
  114187. get isStencilEnable(): boolean;
  114188. /** @hidden */
  114189. _prepareWorkingCanvas(): void;
  114190. /**
  114191. * Reset the texture cache to empty state
  114192. */
  114193. resetTextureCache(): void;
  114194. /**
  114195. * Gets an object containing information about the current webGL context
  114196. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114197. */
  114198. getGlInfo(): {
  114199. vendor: string;
  114200. renderer: string;
  114201. version: string;
  114202. };
  114203. /**
  114204. * Defines the hardware scaling level.
  114205. * By default the hardware scaling level is computed from the window device ratio.
  114206. * 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.
  114207. * @param level defines the level to use
  114208. */
  114209. setHardwareScalingLevel(level: number): void;
  114210. /**
  114211. * Gets the current hardware scaling level.
  114212. * By default the hardware scaling level is computed from the window device ratio.
  114213. * 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.
  114214. * @returns a number indicating the current hardware scaling level
  114215. */
  114216. getHardwareScalingLevel(): number;
  114217. /**
  114218. * Gets the list of loaded textures
  114219. * @returns an array containing all loaded textures
  114220. */
  114221. getLoadedTexturesCache(): InternalTexture[];
  114222. /**
  114223. * Gets the object containing all engine capabilities
  114224. * @returns the EngineCapabilities object
  114225. */
  114226. getCaps(): EngineCapabilities;
  114227. /**
  114228. * stop executing a render loop function and remove it from the execution array
  114229. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114230. */
  114231. stopRenderLoop(renderFunction?: () => void): void;
  114232. /** @hidden */
  114233. _renderLoop(): void;
  114234. /**
  114235. * Gets the HTML canvas attached with the current webGL context
  114236. * @returns a HTML canvas
  114237. */
  114238. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114239. /**
  114240. * Gets host window
  114241. * @returns the host window object
  114242. */
  114243. getHostWindow(): Nullable<Window>;
  114244. /**
  114245. * Gets the current render width
  114246. * @param useScreen defines if screen size must be used (or the current render target if any)
  114247. * @returns a number defining the current render width
  114248. */
  114249. getRenderWidth(useScreen?: boolean): number;
  114250. /**
  114251. * Gets the current render height
  114252. * @param useScreen defines if screen size must be used (or the current render target if any)
  114253. * @returns a number defining the current render height
  114254. */
  114255. getRenderHeight(useScreen?: boolean): number;
  114256. /**
  114257. * Can be used to override the current requestAnimationFrame requester.
  114258. * @hidden
  114259. */
  114260. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114261. /**
  114262. * Register and execute a render loop. The engine can have more than one render function
  114263. * @param renderFunction defines the function to continuously execute
  114264. */
  114265. runRenderLoop(renderFunction: () => void): void;
  114266. /**
  114267. * Clear the current render buffer or the current render target (if any is set up)
  114268. * @param color defines the color to use
  114269. * @param backBuffer defines if the back buffer must be cleared
  114270. * @param depth defines if the depth buffer must be cleared
  114271. * @param stencil defines if the stencil buffer must be cleared
  114272. */
  114273. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114274. private _viewportCached;
  114275. /** @hidden */
  114276. _viewport(x: number, y: number, width: number, height: number): void;
  114277. /**
  114278. * Set the WebGL's viewport
  114279. * @param viewport defines the viewport element to be used
  114280. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114281. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114282. */
  114283. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114284. /**
  114285. * Begin a new frame
  114286. */
  114287. beginFrame(): void;
  114288. /**
  114289. * Enf the current frame
  114290. */
  114291. endFrame(): void;
  114292. /**
  114293. * Resize the view according to the canvas' size
  114294. */
  114295. resize(): void;
  114296. /**
  114297. * Force a specific size of the canvas
  114298. * @param width defines the new canvas' width
  114299. * @param height defines the new canvas' height
  114300. * @returns true if the size was changed
  114301. */
  114302. setSize(width: number, height: number): boolean;
  114303. /**
  114304. * Binds the frame buffer to the specified texture.
  114305. * @param texture The texture to render to or null for the default canvas
  114306. * @param faceIndex The face of the texture to render to in case of cube texture
  114307. * @param requiredWidth The width of the target to render to
  114308. * @param requiredHeight The height of the target to render to
  114309. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114310. * @param lodLevel defines the lod level to bind to the frame buffer
  114311. * @param layer defines the 2d array index to bind to frame buffer to
  114312. */
  114313. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114314. /** @hidden */
  114315. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114316. /**
  114317. * Unbind the current render target texture from the webGL context
  114318. * @param texture defines the render target texture to unbind
  114319. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114320. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114321. */
  114322. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114323. /**
  114324. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114325. */
  114326. flushFramebuffer(): void;
  114327. /**
  114328. * Unbind the current render target and bind the default framebuffer
  114329. */
  114330. restoreDefaultFramebuffer(): void;
  114331. /** @hidden */
  114332. protected _resetVertexBufferBinding(): void;
  114333. /**
  114334. * Creates a vertex buffer
  114335. * @param data the data for the vertex buffer
  114336. * @returns the new WebGL static buffer
  114337. */
  114338. createVertexBuffer(data: DataArray): DataBuffer;
  114339. private _createVertexBuffer;
  114340. /**
  114341. * Creates a dynamic vertex buffer
  114342. * @param data the data for the dynamic vertex buffer
  114343. * @returns the new WebGL dynamic buffer
  114344. */
  114345. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114346. protected _resetIndexBufferBinding(): void;
  114347. /**
  114348. * Creates a new index buffer
  114349. * @param indices defines the content of the index buffer
  114350. * @param updatable defines if the index buffer must be updatable
  114351. * @returns a new webGL buffer
  114352. */
  114353. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114354. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114355. /**
  114356. * Bind a webGL buffer to the webGL context
  114357. * @param buffer defines the buffer to bind
  114358. */
  114359. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114360. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114361. private bindBuffer;
  114362. /**
  114363. * update the bound buffer with the given data
  114364. * @param data defines the data to update
  114365. */
  114366. updateArrayBuffer(data: Float32Array): void;
  114367. private _vertexAttribPointer;
  114368. /** @hidden */
  114369. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114370. private _bindVertexBuffersAttributes;
  114371. /**
  114372. * Records a vertex array object
  114373. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114374. * @param vertexBuffers defines the list of vertex buffers to store
  114375. * @param indexBuffer defines the index buffer to store
  114376. * @param effect defines the effect to store
  114377. * @returns the new vertex array object
  114378. */
  114379. recordVertexArrayObject(vertexBuffers: {
  114380. [key: string]: VertexBuffer;
  114381. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114382. /**
  114383. * Bind a specific vertex array object
  114384. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114385. * @param vertexArrayObject defines the vertex array object to bind
  114386. * @param indexBuffer defines the index buffer to bind
  114387. */
  114388. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114389. /**
  114390. * Bind webGl buffers directly to the webGL context
  114391. * @param vertexBuffer defines the vertex buffer to bind
  114392. * @param indexBuffer defines the index buffer to bind
  114393. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114394. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114395. * @param effect defines the effect associated with the vertex buffer
  114396. */
  114397. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114398. private _unbindVertexArrayObject;
  114399. /**
  114400. * Bind a list of vertex buffers to the webGL context
  114401. * @param vertexBuffers defines the list of vertex buffers to bind
  114402. * @param indexBuffer defines the index buffer to bind
  114403. * @param effect defines the effect associated with the vertex buffers
  114404. */
  114405. bindBuffers(vertexBuffers: {
  114406. [key: string]: Nullable<VertexBuffer>;
  114407. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114408. /**
  114409. * Unbind all instance attributes
  114410. */
  114411. unbindInstanceAttributes(): void;
  114412. /**
  114413. * Release and free the memory of a vertex array object
  114414. * @param vao defines the vertex array object to delete
  114415. */
  114416. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114417. /** @hidden */
  114418. _releaseBuffer(buffer: DataBuffer): boolean;
  114419. protected _deleteBuffer(buffer: DataBuffer): void;
  114420. /**
  114421. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114422. * @param instancesBuffer defines the webGL buffer to update and bind
  114423. * @param data defines the data to store in the buffer
  114424. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114425. */
  114426. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114427. /**
  114428. * Bind the content of a webGL buffer used with instantiation
  114429. * @param instancesBuffer defines the webGL buffer to bind
  114430. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114431. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114432. */
  114433. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114434. /**
  114435. * Disable the instance attribute corresponding to the name in parameter
  114436. * @param name defines the name of the attribute to disable
  114437. */
  114438. disableInstanceAttributeByName(name: string): void;
  114439. /**
  114440. * Disable the instance attribute corresponding to the location in parameter
  114441. * @param attributeLocation defines the attribute location of the attribute to disable
  114442. */
  114443. disableInstanceAttribute(attributeLocation: number): void;
  114444. /**
  114445. * Disable the attribute corresponding to the location in parameter
  114446. * @param attributeLocation defines the attribute location of the attribute to disable
  114447. */
  114448. disableAttributeByIndex(attributeLocation: number): void;
  114449. /**
  114450. * Send a draw order
  114451. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114452. * @param indexStart defines the starting index
  114453. * @param indexCount defines the number of index to draw
  114454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114455. */
  114456. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114457. /**
  114458. * Draw a list of points
  114459. * @param verticesStart defines the index of first vertex to draw
  114460. * @param verticesCount defines the count of vertices to draw
  114461. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114462. */
  114463. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114464. /**
  114465. * Draw a list of unindexed primitives
  114466. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114467. * @param verticesStart defines the index of first vertex to draw
  114468. * @param verticesCount defines the count of vertices to draw
  114469. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114470. */
  114471. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114472. /**
  114473. * Draw a list of indexed primitives
  114474. * @param fillMode defines the primitive to use
  114475. * @param indexStart defines the starting index
  114476. * @param indexCount defines the number of index to draw
  114477. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114478. */
  114479. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114480. /**
  114481. * Draw a list of unindexed primitives
  114482. * @param fillMode defines the primitive to use
  114483. * @param verticesStart defines the index of first vertex to draw
  114484. * @param verticesCount defines the count of vertices to draw
  114485. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114486. */
  114487. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114488. private _drawMode;
  114489. /** @hidden */
  114490. protected _reportDrawCall(): void;
  114491. /** @hidden */
  114492. _releaseEffect(effect: Effect): void;
  114493. /** @hidden */
  114494. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114495. /**
  114496. * Create a new effect (used to store vertex/fragment shaders)
  114497. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114498. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114499. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114500. * @param samplers defines an array of string used to represent textures
  114501. * @param defines defines the string containing the defines to use to compile the shaders
  114502. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114503. * @param onCompiled defines a function to call when the effect creation is successful
  114504. * @param onError defines a function to call when the effect creation has failed
  114505. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114506. * @returns the new Effect
  114507. */
  114508. 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;
  114509. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114510. private _compileShader;
  114511. private _compileRawShader;
  114512. /** @hidden */
  114513. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114514. /**
  114515. * Directly creates a webGL program
  114516. * @param pipelineContext defines the pipeline context to attach to
  114517. * @param vertexCode defines the vertex shader code to use
  114518. * @param fragmentCode defines the fragment shader code to use
  114519. * @param context defines the webGL context to use (if not set, the current one will be used)
  114520. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114521. * @returns the new webGL program
  114522. */
  114523. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114524. /**
  114525. * Creates a webGL program
  114526. * @param pipelineContext defines the pipeline context to attach to
  114527. * @param vertexCode defines the vertex shader code to use
  114528. * @param fragmentCode defines the fragment shader code to use
  114529. * @param defines defines the string containing the defines to use to compile the shaders
  114530. * @param context defines the webGL context to use (if not set, the current one will be used)
  114531. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114532. * @returns the new webGL program
  114533. */
  114534. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114535. /**
  114536. * Creates a new pipeline context
  114537. * @returns the new pipeline
  114538. */
  114539. createPipelineContext(): IPipelineContext;
  114540. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114541. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114542. /** @hidden */
  114543. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114544. /** @hidden */
  114545. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114546. /** @hidden */
  114547. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114548. /**
  114549. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114550. * @param pipelineContext defines the pipeline context to use
  114551. * @param uniformsNames defines the list of uniform names
  114552. * @returns an array of webGL uniform locations
  114553. */
  114554. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114555. /**
  114556. * Gets the lsit of active attributes for a given webGL program
  114557. * @param pipelineContext defines the pipeline context to use
  114558. * @param attributesNames defines the list of attribute names to get
  114559. * @returns an array of indices indicating the offset of each attribute
  114560. */
  114561. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114562. /**
  114563. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114564. * @param effect defines the effect to activate
  114565. */
  114566. enableEffect(effect: Nullable<Effect>): void;
  114567. /**
  114568. * Set the value of an uniform to a number (int)
  114569. * @param uniform defines the webGL uniform location where to store the value
  114570. * @param value defines the int number to store
  114571. */
  114572. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114573. /**
  114574. * Set the value of an uniform to an array of int32
  114575. * @param uniform defines the webGL uniform location where to store the value
  114576. * @param array defines the array of int32 to store
  114577. */
  114578. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114579. /**
  114580. * Set the value of an uniform to an array of int32 (stored as vec2)
  114581. * @param uniform defines the webGL uniform location where to store the value
  114582. * @param array defines the array of int32 to store
  114583. */
  114584. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114585. /**
  114586. * Set the value of an uniform to an array of int32 (stored as vec3)
  114587. * @param uniform defines the webGL uniform location where to store the value
  114588. * @param array defines the array of int32 to store
  114589. */
  114590. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114591. /**
  114592. * Set the value of an uniform to an array of int32 (stored as vec4)
  114593. * @param uniform defines the webGL uniform location where to store the value
  114594. * @param array defines the array of int32 to store
  114595. */
  114596. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114597. /**
  114598. * Set the value of an uniform to an array of number
  114599. * @param uniform defines the webGL uniform location where to store the value
  114600. * @param array defines the array of number to store
  114601. */
  114602. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114603. /**
  114604. * Set the value of an uniform to an array of number (stored as vec2)
  114605. * @param uniform defines the webGL uniform location where to store the value
  114606. * @param array defines the array of number to store
  114607. */
  114608. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114609. /**
  114610. * Set the value of an uniform to an array of number (stored as vec3)
  114611. * @param uniform defines the webGL uniform location where to store the value
  114612. * @param array defines the array of number to store
  114613. */
  114614. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114615. /**
  114616. * Set the value of an uniform to an array of number (stored as vec4)
  114617. * @param uniform defines the webGL uniform location where to store the value
  114618. * @param array defines the array of number to store
  114619. */
  114620. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114621. /**
  114622. * Set the value of an uniform to an array of float32 (stored as matrices)
  114623. * @param uniform defines the webGL uniform location where to store the value
  114624. * @param matrices defines the array of float32 to store
  114625. */
  114626. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114627. /**
  114628. * Set the value of an uniform to a matrix (3x3)
  114629. * @param uniform defines the webGL uniform location where to store the value
  114630. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114631. */
  114632. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114633. /**
  114634. * Set the value of an uniform to a matrix (2x2)
  114635. * @param uniform defines the webGL uniform location where to store the value
  114636. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114637. */
  114638. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114639. /**
  114640. * Set the value of an uniform to a number (float)
  114641. * @param uniform defines the webGL uniform location where to store the value
  114642. * @param value defines the float number to store
  114643. */
  114644. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114645. /**
  114646. * Set the value of an uniform to a vec2
  114647. * @param uniform defines the webGL uniform location where to store the value
  114648. * @param x defines the 1st component of the value
  114649. * @param y defines the 2nd component of the value
  114650. */
  114651. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114652. /**
  114653. * Set the value of an uniform to a vec3
  114654. * @param uniform defines the webGL uniform location where to store the value
  114655. * @param x defines the 1st component of the value
  114656. * @param y defines the 2nd component of the value
  114657. * @param z defines the 3rd component of the value
  114658. */
  114659. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114660. /**
  114661. * Set the value of an uniform to a vec4
  114662. * @param uniform defines the webGL uniform location where to store the value
  114663. * @param x defines the 1st component of the value
  114664. * @param y defines the 2nd component of the value
  114665. * @param z defines the 3rd component of the value
  114666. * @param w defines the 4th component of the value
  114667. */
  114668. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114669. /**
  114670. * Apply all cached states (depth, culling, stencil and alpha)
  114671. */
  114672. applyStates(): void;
  114673. /**
  114674. * Enable or disable color writing
  114675. * @param enable defines the state to set
  114676. */
  114677. setColorWrite(enable: boolean): void;
  114678. /**
  114679. * Gets a boolean indicating if color writing is enabled
  114680. * @returns the current color writing state
  114681. */
  114682. getColorWrite(): boolean;
  114683. /**
  114684. * Gets the depth culling state manager
  114685. */
  114686. get depthCullingState(): DepthCullingState;
  114687. /**
  114688. * Gets the alpha state manager
  114689. */
  114690. get alphaState(): AlphaState;
  114691. /**
  114692. * Gets the stencil state manager
  114693. */
  114694. get stencilState(): StencilState;
  114695. /**
  114696. * Clears the list of texture accessible through engine.
  114697. * This can help preventing texture load conflict due to name collision.
  114698. */
  114699. clearInternalTexturesCache(): void;
  114700. /**
  114701. * Force the entire cache to be cleared
  114702. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114703. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114704. */
  114705. wipeCaches(bruteForce?: boolean): void;
  114706. /** @hidden */
  114707. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114708. min: number;
  114709. mag: number;
  114710. };
  114711. /** @hidden */
  114712. _createTexture(): WebGLTexture;
  114713. /**
  114714. * Usually called from Texture.ts.
  114715. * Passed information to create a WebGLTexture
  114716. * @param url defines a value which contains one of the following:
  114717. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114718. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114719. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114721. * @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)
  114722. * @param scene needed for loading to the correct scene
  114723. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114724. * @param onLoad optional callback to be called upon successful completion
  114725. * @param onError optional callback to be called upon failure
  114726. * @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
  114727. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114728. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114729. * @param forcedExtension defines the extension to use to pick the right loader
  114730. * @param mimeType defines an optional mime type
  114731. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114732. */
  114733. 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;
  114734. /**
  114735. * Loads an image as an HTMLImageElement.
  114736. * @param input url string, ArrayBuffer, or Blob to load
  114737. * @param onLoad callback called when the image successfully loads
  114738. * @param onError callback called when the image fails to load
  114739. * @param offlineProvider offline provider for caching
  114740. * @param mimeType optional mime type
  114741. * @returns the HTMLImageElement of the loaded image
  114742. * @hidden
  114743. */
  114744. 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>;
  114745. /**
  114746. * @hidden
  114747. */
  114748. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114749. private _unpackFlipYCached;
  114750. /**
  114751. * In case you are sharing the context with other applications, it might
  114752. * be interested to not cache the unpack flip y state to ensure a consistent
  114753. * value would be set.
  114754. */
  114755. enableUnpackFlipYCached: boolean;
  114756. /** @hidden */
  114757. _unpackFlipY(value: boolean): void;
  114758. /** @hidden */
  114759. _getUnpackAlignement(): number;
  114760. private _getTextureTarget;
  114761. /**
  114762. * Update the sampling mode of a given texture
  114763. * @param samplingMode defines the required sampling mode
  114764. * @param texture defines the texture to update
  114765. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114766. */
  114767. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114768. /**
  114769. * Update the sampling mode of a given texture
  114770. * @param texture defines the texture to update
  114771. * @param wrapU defines the texture wrap mode of the u coordinates
  114772. * @param wrapV defines the texture wrap mode of the v coordinates
  114773. * @param wrapR defines the texture wrap mode of the r coordinates
  114774. */
  114775. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114776. /** @hidden */
  114777. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114778. width: number;
  114779. height: number;
  114780. layers?: number;
  114781. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114782. /** @hidden */
  114783. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114784. /** @hidden */
  114785. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114786. /**
  114787. * Update a portion of an internal texture
  114788. * @param texture defines the texture to update
  114789. * @param imageData defines the data to store into the texture
  114790. * @param xOffset defines the x coordinates of the update rectangle
  114791. * @param yOffset defines the y coordinates of the update rectangle
  114792. * @param width defines the width of the update rectangle
  114793. * @param height defines the height of the update rectangle
  114794. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114795. * @param lod defines the lod level to update (0 by default)
  114796. */
  114797. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114798. /** @hidden */
  114799. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114800. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  114801. private _prepareWebGLTexture;
  114802. /** @hidden */
  114803. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  114804. private _getDepthStencilBuffer;
  114805. /** @hidden */
  114806. _releaseFramebufferObjects(texture: InternalTexture): void;
  114807. /** @hidden */
  114808. _releaseTexture(texture: InternalTexture): void;
  114809. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114810. protected _setProgram(program: WebGLProgram): void;
  114811. protected _boundUniforms: {
  114812. [key: number]: WebGLUniformLocation;
  114813. };
  114814. /**
  114815. * Binds an effect to the webGL context
  114816. * @param effect defines the effect to bind
  114817. */
  114818. bindSamplers(effect: Effect): void;
  114819. private _activateCurrentTexture;
  114820. /** @hidden */
  114821. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  114822. /** @hidden */
  114823. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  114824. /**
  114825. * Unbind all textures from the webGL context
  114826. */
  114827. unbindAllTextures(): void;
  114828. /**
  114829. * Sets a texture to the according uniform.
  114830. * @param channel The texture channel
  114831. * @param uniform The uniform to set
  114832. * @param texture The texture to apply
  114833. */
  114834. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  114835. private _bindSamplerUniformToChannel;
  114836. private _getTextureWrapMode;
  114837. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114838. /**
  114839. * Sets an array of texture to the webGL context
  114840. * @param channel defines the channel where the texture array must be set
  114841. * @param uniform defines the associated uniform location
  114842. * @param textures defines the array of textures to bind
  114843. */
  114844. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  114845. /** @hidden */
  114846. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  114847. private _setTextureParameterFloat;
  114848. private _setTextureParameterInteger;
  114849. /**
  114850. * Unbind all vertex attributes from the webGL context
  114851. */
  114852. unbindAllAttributes(): void;
  114853. /**
  114854. * 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
  114855. */
  114856. releaseEffects(): void;
  114857. /**
  114858. * Dispose and release all associated resources
  114859. */
  114860. dispose(): void;
  114861. /**
  114862. * Attach a new callback raised when context lost event is fired
  114863. * @param callback defines the callback to call
  114864. */
  114865. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114866. /**
  114867. * Attach a new callback raised when context restored event is fired
  114868. * @param callback defines the callback to call
  114869. */
  114870. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114871. /**
  114872. * Get the current error code of the webGL context
  114873. * @returns the error code
  114874. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114875. */
  114876. getError(): number;
  114877. private _canRenderToFloatFramebuffer;
  114878. private _canRenderToHalfFloatFramebuffer;
  114879. private _canRenderToFramebuffer;
  114880. /** @hidden */
  114881. _getWebGLTextureType(type: number): number;
  114882. /** @hidden */
  114883. _getInternalFormat(format: number): number;
  114884. /** @hidden */
  114885. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  114886. /** @hidden */
  114887. _getRGBAMultiSampleBufferFormat(type: number): number;
  114888. /** @hidden */
  114889. _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;
  114890. /**
  114891. * Loads a file from a url
  114892. * @param url url to load
  114893. * @param onSuccess callback called when the file successfully loads
  114894. * @param onProgress callback called while file is loading (if the server supports this mode)
  114895. * @param offlineProvider defines the offline provider for caching
  114896. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114897. * @param onError callback called when the file fails to load
  114898. * @returns a file request object
  114899. * @hidden
  114900. */
  114901. 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;
  114902. /**
  114903. * Reads pixels from the current frame buffer. Please note that this function can be slow
  114904. * @param x defines the x coordinate of the rectangle where pixels must be read
  114905. * @param y defines the y coordinate of the rectangle where pixels must be read
  114906. * @param width defines the width of the rectangle where pixels must be read
  114907. * @param height defines the height of the rectangle where pixels must be read
  114908. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  114909. * @returns a Uint8Array containing RGBA colors
  114910. */
  114911. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  114912. private static _isSupported;
  114913. /**
  114914. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  114915. * @returns true if the engine can be created
  114916. * @ignorenaming
  114917. */
  114918. static isSupported(): boolean;
  114919. /**
  114920. * Find the next highest power of two.
  114921. * @param x Number to start search from.
  114922. * @return Next highest power of two.
  114923. */
  114924. static CeilingPOT(x: number): number;
  114925. /**
  114926. * Find the next lowest power of two.
  114927. * @param x Number to start search from.
  114928. * @return Next lowest power of two.
  114929. */
  114930. static FloorPOT(x: number): number;
  114931. /**
  114932. * Find the nearest power of two.
  114933. * @param x Number to start search from.
  114934. * @return Next nearest power of two.
  114935. */
  114936. static NearestPOT(x: number): number;
  114937. /**
  114938. * Get the closest exponent of two
  114939. * @param value defines the value to approximate
  114940. * @param max defines the maximum value to return
  114941. * @param mode defines how to define the closest value
  114942. * @returns closest exponent of two of the given value
  114943. */
  114944. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  114945. /**
  114946. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  114947. * @param func - the function to be called
  114948. * @param requester - the object that will request the next frame. Falls back to window.
  114949. * @returns frame number
  114950. */
  114951. static QueueNewFrame(func: () => void, requester?: any): number;
  114952. /**
  114953. * Gets host document
  114954. * @returns the host document object
  114955. */
  114956. getHostDocument(): Nullable<Document>;
  114957. }
  114958. }
  114959. declare module BABYLON {
  114960. /**
  114961. * Class representing spherical harmonics coefficients to the 3rd degree
  114962. */
  114963. export class SphericalHarmonics {
  114964. /**
  114965. * Defines whether or not the harmonics have been prescaled for rendering.
  114966. */
  114967. preScaled: boolean;
  114968. /**
  114969. * The l0,0 coefficients of the spherical harmonics
  114970. */
  114971. l00: Vector3;
  114972. /**
  114973. * The l1,-1 coefficients of the spherical harmonics
  114974. */
  114975. l1_1: Vector3;
  114976. /**
  114977. * The l1,0 coefficients of the spherical harmonics
  114978. */
  114979. l10: Vector3;
  114980. /**
  114981. * The l1,1 coefficients of the spherical harmonics
  114982. */
  114983. l11: Vector3;
  114984. /**
  114985. * The l2,-2 coefficients of the spherical harmonics
  114986. */
  114987. l2_2: Vector3;
  114988. /**
  114989. * The l2,-1 coefficients of the spherical harmonics
  114990. */
  114991. l2_1: Vector3;
  114992. /**
  114993. * The l2,0 coefficients of the spherical harmonics
  114994. */
  114995. l20: Vector3;
  114996. /**
  114997. * The l2,1 coefficients of the spherical harmonics
  114998. */
  114999. l21: Vector3;
  115000. /**
  115001. * The l2,2 coefficients of the spherical harmonics
  115002. */
  115003. l22: Vector3;
  115004. /**
  115005. * Adds a light to the spherical harmonics
  115006. * @param direction the direction of the light
  115007. * @param color the color of the light
  115008. * @param deltaSolidAngle the delta solid angle of the light
  115009. */
  115010. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115011. /**
  115012. * Scales the spherical harmonics by the given amount
  115013. * @param scale the amount to scale
  115014. */
  115015. scaleInPlace(scale: number): void;
  115016. /**
  115017. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115018. *
  115019. * ```
  115020. * E_lm = A_l * L_lm
  115021. * ```
  115022. *
  115023. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115024. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115025. * the scaling factors are given in equation 9.
  115026. */
  115027. convertIncidentRadianceToIrradiance(): void;
  115028. /**
  115029. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115030. *
  115031. * ```
  115032. * L = (1/pi) * E * rho
  115033. * ```
  115034. *
  115035. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115036. */
  115037. convertIrradianceToLambertianRadiance(): void;
  115038. /**
  115039. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115040. * required operations at run time.
  115041. *
  115042. * This is simply done by scaling back the SH with Ylm constants parameter.
  115043. * The trigonometric part being applied by the shader at run time.
  115044. */
  115045. preScaleForRendering(): void;
  115046. /**
  115047. * Constructs a spherical harmonics from an array.
  115048. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115049. * @returns the spherical harmonics
  115050. */
  115051. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115052. /**
  115053. * Gets the spherical harmonics from polynomial
  115054. * @param polynomial the spherical polynomial
  115055. * @returns the spherical harmonics
  115056. */
  115057. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115058. }
  115059. /**
  115060. * Class representing spherical polynomial coefficients to the 3rd degree
  115061. */
  115062. export class SphericalPolynomial {
  115063. private _harmonics;
  115064. /**
  115065. * The spherical harmonics used to create the polynomials.
  115066. */
  115067. get preScaledHarmonics(): SphericalHarmonics;
  115068. /**
  115069. * The x coefficients of the spherical polynomial
  115070. */
  115071. x: Vector3;
  115072. /**
  115073. * The y coefficients of the spherical polynomial
  115074. */
  115075. y: Vector3;
  115076. /**
  115077. * The z coefficients of the spherical polynomial
  115078. */
  115079. z: Vector3;
  115080. /**
  115081. * The xx coefficients of the spherical polynomial
  115082. */
  115083. xx: Vector3;
  115084. /**
  115085. * The yy coefficients of the spherical polynomial
  115086. */
  115087. yy: Vector3;
  115088. /**
  115089. * The zz coefficients of the spherical polynomial
  115090. */
  115091. zz: Vector3;
  115092. /**
  115093. * The xy coefficients of the spherical polynomial
  115094. */
  115095. xy: Vector3;
  115096. /**
  115097. * The yz coefficients of the spherical polynomial
  115098. */
  115099. yz: Vector3;
  115100. /**
  115101. * The zx coefficients of the spherical polynomial
  115102. */
  115103. zx: Vector3;
  115104. /**
  115105. * Adds an ambient color to the spherical polynomial
  115106. * @param color the color to add
  115107. */
  115108. addAmbient(color: Color3): void;
  115109. /**
  115110. * Scales the spherical polynomial by the given amount
  115111. * @param scale the amount to scale
  115112. */
  115113. scaleInPlace(scale: number): void;
  115114. /**
  115115. * Gets the spherical polynomial from harmonics
  115116. * @param harmonics the spherical harmonics
  115117. * @returns the spherical polynomial
  115118. */
  115119. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115120. /**
  115121. * Constructs a spherical polynomial from an array.
  115122. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115123. * @returns the spherical polynomial
  115124. */
  115125. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115126. }
  115127. }
  115128. declare module BABYLON {
  115129. /**
  115130. * Defines the source of the internal texture
  115131. */
  115132. export enum InternalTextureSource {
  115133. /**
  115134. * The source of the texture data is unknown
  115135. */
  115136. Unknown = 0,
  115137. /**
  115138. * Texture data comes from an URL
  115139. */
  115140. Url = 1,
  115141. /**
  115142. * Texture data is only used for temporary storage
  115143. */
  115144. Temp = 2,
  115145. /**
  115146. * Texture data comes from raw data (ArrayBuffer)
  115147. */
  115148. Raw = 3,
  115149. /**
  115150. * Texture content is dynamic (video or dynamic texture)
  115151. */
  115152. Dynamic = 4,
  115153. /**
  115154. * Texture content is generated by rendering to it
  115155. */
  115156. RenderTarget = 5,
  115157. /**
  115158. * Texture content is part of a multi render target process
  115159. */
  115160. MultiRenderTarget = 6,
  115161. /**
  115162. * Texture data comes from a cube data file
  115163. */
  115164. Cube = 7,
  115165. /**
  115166. * Texture data comes from a raw cube data
  115167. */
  115168. CubeRaw = 8,
  115169. /**
  115170. * Texture data come from a prefiltered cube data file
  115171. */
  115172. CubePrefiltered = 9,
  115173. /**
  115174. * Texture content is raw 3D data
  115175. */
  115176. Raw3D = 10,
  115177. /**
  115178. * Texture content is raw 2D array data
  115179. */
  115180. Raw2DArray = 11,
  115181. /**
  115182. * Texture content is a depth texture
  115183. */
  115184. Depth = 12,
  115185. /**
  115186. * Texture data comes from a raw cube data encoded with RGBD
  115187. */
  115188. CubeRawRGBD = 13
  115189. }
  115190. /**
  115191. * Class used to store data associated with WebGL texture data for the engine
  115192. * This class should not be used directly
  115193. */
  115194. export class InternalTexture {
  115195. /** @hidden */
  115196. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115197. /**
  115198. * Defines if the texture is ready
  115199. */
  115200. isReady: boolean;
  115201. /**
  115202. * Defines if the texture is a cube texture
  115203. */
  115204. isCube: boolean;
  115205. /**
  115206. * Defines if the texture contains 3D data
  115207. */
  115208. is3D: boolean;
  115209. /**
  115210. * Defines if the texture contains 2D array data
  115211. */
  115212. is2DArray: boolean;
  115213. /**
  115214. * Defines if the texture contains multiview data
  115215. */
  115216. isMultiview: boolean;
  115217. /**
  115218. * Gets the URL used to load this texture
  115219. */
  115220. url: string;
  115221. /**
  115222. * Gets the sampling mode of the texture
  115223. */
  115224. samplingMode: number;
  115225. /**
  115226. * Gets a boolean indicating if the texture needs mipmaps generation
  115227. */
  115228. generateMipMaps: boolean;
  115229. /**
  115230. * Gets the number of samples used by the texture (WebGL2+ only)
  115231. */
  115232. samples: number;
  115233. /**
  115234. * Gets the type of the texture (int, float...)
  115235. */
  115236. type: number;
  115237. /**
  115238. * Gets the format of the texture (RGB, RGBA...)
  115239. */
  115240. format: number;
  115241. /**
  115242. * Observable called when the texture is loaded
  115243. */
  115244. onLoadedObservable: Observable<InternalTexture>;
  115245. /**
  115246. * Gets the width of the texture
  115247. */
  115248. width: number;
  115249. /**
  115250. * Gets the height of the texture
  115251. */
  115252. height: number;
  115253. /**
  115254. * Gets the depth of the texture
  115255. */
  115256. depth: number;
  115257. /**
  115258. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115259. */
  115260. baseWidth: number;
  115261. /**
  115262. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115263. */
  115264. baseHeight: number;
  115265. /**
  115266. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115267. */
  115268. baseDepth: number;
  115269. /**
  115270. * Gets a boolean indicating if the texture is inverted on Y axis
  115271. */
  115272. invertY: boolean;
  115273. /** @hidden */
  115274. _invertVScale: boolean;
  115275. /** @hidden */
  115276. _associatedChannel: number;
  115277. /** @hidden */
  115278. _source: InternalTextureSource;
  115279. /** @hidden */
  115280. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115281. /** @hidden */
  115282. _bufferView: Nullable<ArrayBufferView>;
  115283. /** @hidden */
  115284. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115285. /** @hidden */
  115286. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115287. /** @hidden */
  115288. _size: number;
  115289. /** @hidden */
  115290. _extension: string;
  115291. /** @hidden */
  115292. _files: Nullable<string[]>;
  115293. /** @hidden */
  115294. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115295. /** @hidden */
  115296. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115297. /** @hidden */
  115298. _framebuffer: Nullable<WebGLFramebuffer>;
  115299. /** @hidden */
  115300. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115301. /** @hidden */
  115302. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115303. /** @hidden */
  115304. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115305. /** @hidden */
  115306. _attachments: Nullable<number[]>;
  115307. /** @hidden */
  115308. _textureArray: Nullable<InternalTexture[]>;
  115309. /** @hidden */
  115310. _cachedCoordinatesMode: Nullable<number>;
  115311. /** @hidden */
  115312. _cachedWrapU: Nullable<number>;
  115313. /** @hidden */
  115314. _cachedWrapV: Nullable<number>;
  115315. /** @hidden */
  115316. _cachedWrapR: Nullable<number>;
  115317. /** @hidden */
  115318. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115319. /** @hidden */
  115320. _isDisabled: boolean;
  115321. /** @hidden */
  115322. _compression: Nullable<string>;
  115323. /** @hidden */
  115324. _generateStencilBuffer: boolean;
  115325. /** @hidden */
  115326. _generateDepthBuffer: boolean;
  115327. /** @hidden */
  115328. _comparisonFunction: number;
  115329. /** @hidden */
  115330. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115331. /** @hidden */
  115332. _lodGenerationScale: number;
  115333. /** @hidden */
  115334. _lodGenerationOffset: number;
  115335. /** @hidden */
  115336. _depthStencilTexture: Nullable<InternalTexture>;
  115337. /** @hidden */
  115338. _colorTextureArray: Nullable<WebGLTexture>;
  115339. /** @hidden */
  115340. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115341. /** @hidden */
  115342. _lodTextureHigh: Nullable<BaseTexture>;
  115343. /** @hidden */
  115344. _lodTextureMid: Nullable<BaseTexture>;
  115345. /** @hidden */
  115346. _lodTextureLow: Nullable<BaseTexture>;
  115347. /** @hidden */
  115348. _isRGBD: boolean;
  115349. /** @hidden */
  115350. _linearSpecularLOD: boolean;
  115351. /** @hidden */
  115352. _irradianceTexture: Nullable<BaseTexture>;
  115353. /** @hidden */
  115354. _webGLTexture: Nullable<WebGLTexture>;
  115355. /** @hidden */
  115356. _references: number;
  115357. private _engine;
  115358. /**
  115359. * Gets the Engine the texture belongs to.
  115360. * @returns The babylon engine
  115361. */
  115362. getEngine(): ThinEngine;
  115363. /**
  115364. * Gets the data source type of the texture
  115365. */
  115366. get source(): InternalTextureSource;
  115367. /**
  115368. * Creates a new InternalTexture
  115369. * @param engine defines the engine to use
  115370. * @param source defines the type of data that will be used
  115371. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115372. */
  115373. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115374. /**
  115375. * Increments the number of references (ie. the number of Texture that point to it)
  115376. */
  115377. incrementReferences(): void;
  115378. /**
  115379. * Change the size of the texture (not the size of the content)
  115380. * @param width defines the new width
  115381. * @param height defines the new height
  115382. * @param depth defines the new depth (1 by default)
  115383. */
  115384. updateSize(width: int, height: int, depth?: int): void;
  115385. /** @hidden */
  115386. _rebuild(): void;
  115387. /** @hidden */
  115388. _swapAndDie(target: InternalTexture): void;
  115389. /**
  115390. * Dispose the current allocated resources
  115391. */
  115392. dispose(): void;
  115393. }
  115394. }
  115395. declare module BABYLON {
  115396. /**
  115397. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115398. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115399. */
  115400. export class Analyser {
  115401. /**
  115402. * Gets or sets the smoothing
  115403. * @ignorenaming
  115404. */
  115405. SMOOTHING: number;
  115406. /**
  115407. * Gets or sets the FFT table size
  115408. * @ignorenaming
  115409. */
  115410. FFT_SIZE: number;
  115411. /**
  115412. * Gets or sets the bar graph amplitude
  115413. * @ignorenaming
  115414. */
  115415. BARGRAPHAMPLITUDE: number;
  115416. /**
  115417. * Gets or sets the position of the debug canvas
  115418. * @ignorenaming
  115419. */
  115420. DEBUGCANVASPOS: {
  115421. x: number;
  115422. y: number;
  115423. };
  115424. /**
  115425. * Gets or sets the debug canvas size
  115426. * @ignorenaming
  115427. */
  115428. DEBUGCANVASSIZE: {
  115429. width: number;
  115430. height: number;
  115431. };
  115432. private _byteFreqs;
  115433. private _byteTime;
  115434. private _floatFreqs;
  115435. private _webAudioAnalyser;
  115436. private _debugCanvas;
  115437. private _debugCanvasContext;
  115438. private _scene;
  115439. private _registerFunc;
  115440. private _audioEngine;
  115441. /**
  115442. * Creates a new analyser
  115443. * @param scene defines hosting scene
  115444. */
  115445. constructor(scene: Scene);
  115446. /**
  115447. * Get the number of data values you will have to play with for the visualization
  115448. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115449. * @returns a number
  115450. */
  115451. getFrequencyBinCount(): number;
  115452. /**
  115453. * Gets the current frequency data as a byte array
  115454. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115455. * @returns a Uint8Array
  115456. */
  115457. getByteFrequencyData(): Uint8Array;
  115458. /**
  115459. * Gets the current waveform as a byte array
  115460. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115461. * @returns a Uint8Array
  115462. */
  115463. getByteTimeDomainData(): Uint8Array;
  115464. /**
  115465. * Gets the current frequency data as a float array
  115466. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115467. * @returns a Float32Array
  115468. */
  115469. getFloatFrequencyData(): Float32Array;
  115470. /**
  115471. * Renders the debug canvas
  115472. */
  115473. drawDebugCanvas(): void;
  115474. /**
  115475. * Stops rendering the debug canvas and removes it
  115476. */
  115477. stopDebugCanvas(): void;
  115478. /**
  115479. * Connects two audio nodes
  115480. * @param inputAudioNode defines first node to connect
  115481. * @param outputAudioNode defines second node to connect
  115482. */
  115483. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115484. /**
  115485. * Releases all associated resources
  115486. */
  115487. dispose(): void;
  115488. }
  115489. }
  115490. declare module BABYLON {
  115491. /**
  115492. * This represents an audio engine and it is responsible
  115493. * to play, synchronize and analyse sounds throughout the application.
  115494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115495. */
  115496. export interface IAudioEngine extends IDisposable {
  115497. /**
  115498. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115499. */
  115500. readonly canUseWebAudio: boolean;
  115501. /**
  115502. * Gets the current AudioContext if available.
  115503. */
  115504. readonly audioContext: Nullable<AudioContext>;
  115505. /**
  115506. * The master gain node defines the global audio volume of your audio engine.
  115507. */
  115508. readonly masterGain: GainNode;
  115509. /**
  115510. * Gets whether or not mp3 are supported by your browser.
  115511. */
  115512. readonly isMP3supported: boolean;
  115513. /**
  115514. * Gets whether or not ogg are supported by your browser.
  115515. */
  115516. readonly isOGGsupported: boolean;
  115517. /**
  115518. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115519. * @ignoreNaming
  115520. */
  115521. WarnedWebAudioUnsupported: boolean;
  115522. /**
  115523. * Defines if the audio engine relies on a custom unlocked button.
  115524. * In this case, the embedded button will not be displayed.
  115525. */
  115526. useCustomUnlockedButton: boolean;
  115527. /**
  115528. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115529. */
  115530. readonly unlocked: boolean;
  115531. /**
  115532. * Event raised when audio has been unlocked on the browser.
  115533. */
  115534. onAudioUnlockedObservable: Observable<AudioEngine>;
  115535. /**
  115536. * Event raised when audio has been locked on the browser.
  115537. */
  115538. onAudioLockedObservable: Observable<AudioEngine>;
  115539. /**
  115540. * Flags the audio engine in Locked state.
  115541. * This happens due to new browser policies preventing audio to autoplay.
  115542. */
  115543. lock(): void;
  115544. /**
  115545. * Unlocks the audio engine once a user action has been done on the dom.
  115546. * This is helpful to resume play once browser policies have been satisfied.
  115547. */
  115548. unlock(): void;
  115549. /**
  115550. * Gets the global volume sets on the master gain.
  115551. * @returns the global volume if set or -1 otherwise
  115552. */
  115553. getGlobalVolume(): number;
  115554. /**
  115555. * Sets the global volume of your experience (sets on the master gain).
  115556. * @param newVolume Defines the new global volume of the application
  115557. */
  115558. setGlobalVolume(newVolume: number): void;
  115559. /**
  115560. * Connect the audio engine to an audio analyser allowing some amazing
  115561. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115562. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115563. * @param analyser The analyser to connect to the engine
  115564. */
  115565. connectToAnalyser(analyser: Analyser): void;
  115566. }
  115567. /**
  115568. * This represents the default audio engine used in babylon.
  115569. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115570. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115571. */
  115572. export class AudioEngine implements IAudioEngine {
  115573. private _audioContext;
  115574. private _audioContextInitialized;
  115575. private _muteButton;
  115576. private _hostElement;
  115577. /**
  115578. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115579. */
  115580. canUseWebAudio: boolean;
  115581. /**
  115582. * The master gain node defines the global audio volume of your audio engine.
  115583. */
  115584. masterGain: GainNode;
  115585. /**
  115586. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115587. * @ignoreNaming
  115588. */
  115589. WarnedWebAudioUnsupported: boolean;
  115590. /**
  115591. * Gets whether or not mp3 are supported by your browser.
  115592. */
  115593. isMP3supported: boolean;
  115594. /**
  115595. * Gets whether or not ogg are supported by your browser.
  115596. */
  115597. isOGGsupported: boolean;
  115598. /**
  115599. * Gets whether audio has been unlocked on the device.
  115600. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115601. * a user interaction has happened.
  115602. */
  115603. unlocked: boolean;
  115604. /**
  115605. * Defines if the audio engine relies on a custom unlocked button.
  115606. * In this case, the embedded button will not be displayed.
  115607. */
  115608. useCustomUnlockedButton: boolean;
  115609. /**
  115610. * Event raised when audio has been unlocked on the browser.
  115611. */
  115612. onAudioUnlockedObservable: Observable<AudioEngine>;
  115613. /**
  115614. * Event raised when audio has been locked on the browser.
  115615. */
  115616. onAudioLockedObservable: Observable<AudioEngine>;
  115617. /**
  115618. * Gets the current AudioContext if available.
  115619. */
  115620. get audioContext(): Nullable<AudioContext>;
  115621. private _connectedAnalyser;
  115622. /**
  115623. * Instantiates a new audio engine.
  115624. *
  115625. * There should be only one per page as some browsers restrict the number
  115626. * of audio contexts you can create.
  115627. * @param hostElement defines the host element where to display the mute icon if necessary
  115628. */
  115629. constructor(hostElement?: Nullable<HTMLElement>);
  115630. /**
  115631. * Flags the audio engine in Locked state.
  115632. * This happens due to new browser policies preventing audio to autoplay.
  115633. */
  115634. lock(): void;
  115635. /**
  115636. * Unlocks the audio engine once a user action has been done on the dom.
  115637. * This is helpful to resume play once browser policies have been satisfied.
  115638. */
  115639. unlock(): void;
  115640. private _resumeAudioContext;
  115641. private _initializeAudioContext;
  115642. private _tryToRun;
  115643. private _triggerRunningState;
  115644. private _triggerSuspendedState;
  115645. private _displayMuteButton;
  115646. private _moveButtonToTopLeft;
  115647. private _onResize;
  115648. private _hideMuteButton;
  115649. /**
  115650. * Destroy and release the resources associated with the audio ccontext.
  115651. */
  115652. dispose(): void;
  115653. /**
  115654. * Gets the global volume sets on the master gain.
  115655. * @returns the global volume if set or -1 otherwise
  115656. */
  115657. getGlobalVolume(): number;
  115658. /**
  115659. * Sets the global volume of your experience (sets on the master gain).
  115660. * @param newVolume Defines the new global volume of the application
  115661. */
  115662. setGlobalVolume(newVolume: number): void;
  115663. /**
  115664. * Connect the audio engine to an audio analyser allowing some amazing
  115665. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115666. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115667. * @param analyser The analyser to connect to the engine
  115668. */
  115669. connectToAnalyser(analyser: Analyser): void;
  115670. }
  115671. }
  115672. declare module BABYLON {
  115673. /**
  115674. * Interface used to present a loading screen while loading a scene
  115675. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115676. */
  115677. export interface ILoadingScreen {
  115678. /**
  115679. * Function called to display the loading screen
  115680. */
  115681. displayLoadingUI: () => void;
  115682. /**
  115683. * Function called to hide the loading screen
  115684. */
  115685. hideLoadingUI: () => void;
  115686. /**
  115687. * Gets or sets the color to use for the background
  115688. */
  115689. loadingUIBackgroundColor: string;
  115690. /**
  115691. * Gets or sets the text to display while loading
  115692. */
  115693. loadingUIText: string;
  115694. }
  115695. /**
  115696. * Class used for the default loading screen
  115697. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115698. */
  115699. export class DefaultLoadingScreen implements ILoadingScreen {
  115700. private _renderingCanvas;
  115701. private _loadingText;
  115702. private _loadingDivBackgroundColor;
  115703. private _loadingDiv;
  115704. private _loadingTextDiv;
  115705. /** Gets or sets the logo url to use for the default loading screen */
  115706. static DefaultLogoUrl: string;
  115707. /** Gets or sets the spinner url to use for the default loading screen */
  115708. static DefaultSpinnerUrl: string;
  115709. /**
  115710. * Creates a new default loading screen
  115711. * @param _renderingCanvas defines the canvas used to render the scene
  115712. * @param _loadingText defines the default text to display
  115713. * @param _loadingDivBackgroundColor defines the default background color
  115714. */
  115715. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115716. /**
  115717. * Function called to display the loading screen
  115718. */
  115719. displayLoadingUI(): void;
  115720. /**
  115721. * Function called to hide the loading screen
  115722. */
  115723. hideLoadingUI(): void;
  115724. /**
  115725. * Gets or sets the text to display while loading
  115726. */
  115727. set loadingUIText(text: string);
  115728. get loadingUIText(): string;
  115729. /**
  115730. * Gets or sets the color to use for the background
  115731. */
  115732. get loadingUIBackgroundColor(): string;
  115733. set loadingUIBackgroundColor(color: string);
  115734. private _resizeLoadingUI;
  115735. }
  115736. }
  115737. declare module BABYLON {
  115738. /**
  115739. * Interface for any object that can request an animation frame
  115740. */
  115741. export interface ICustomAnimationFrameRequester {
  115742. /**
  115743. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115744. */
  115745. renderFunction?: Function;
  115746. /**
  115747. * Called to request the next frame to render to
  115748. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115749. */
  115750. requestAnimationFrame: Function;
  115751. /**
  115752. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115753. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115754. */
  115755. requestID?: number;
  115756. }
  115757. }
  115758. declare module BABYLON {
  115759. /**
  115760. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115761. */
  115762. export class PerformanceMonitor {
  115763. private _enabled;
  115764. private _rollingFrameTime;
  115765. private _lastFrameTimeMs;
  115766. /**
  115767. * constructor
  115768. * @param frameSampleSize The number of samples required to saturate the sliding window
  115769. */
  115770. constructor(frameSampleSize?: number);
  115771. /**
  115772. * Samples current frame
  115773. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115774. */
  115775. sampleFrame(timeMs?: number): void;
  115776. /**
  115777. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115778. */
  115779. get averageFrameTime(): number;
  115780. /**
  115781. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115782. */
  115783. get averageFrameTimeVariance(): number;
  115784. /**
  115785. * Returns the frame time of the most recent frame
  115786. */
  115787. get instantaneousFrameTime(): number;
  115788. /**
  115789. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115790. */
  115791. get averageFPS(): number;
  115792. /**
  115793. * Returns the average framerate in frames per second using the most recent frame time
  115794. */
  115795. get instantaneousFPS(): number;
  115796. /**
  115797. * Returns true if enough samples have been taken to completely fill the sliding window
  115798. */
  115799. get isSaturated(): boolean;
  115800. /**
  115801. * Enables contributions to the sliding window sample set
  115802. */
  115803. enable(): void;
  115804. /**
  115805. * Disables contributions to the sliding window sample set
  115806. * Samples will not be interpolated over the disabled period
  115807. */
  115808. disable(): void;
  115809. /**
  115810. * Returns true if sampling is enabled
  115811. */
  115812. get isEnabled(): boolean;
  115813. /**
  115814. * Resets performance monitor
  115815. */
  115816. reset(): void;
  115817. }
  115818. /**
  115819. * RollingAverage
  115820. *
  115821. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  115822. */
  115823. export class RollingAverage {
  115824. /**
  115825. * Current average
  115826. */
  115827. average: number;
  115828. /**
  115829. * Current variance
  115830. */
  115831. variance: number;
  115832. protected _samples: Array<number>;
  115833. protected _sampleCount: number;
  115834. protected _pos: number;
  115835. protected _m2: number;
  115836. /**
  115837. * constructor
  115838. * @param length The number of samples required to saturate the sliding window
  115839. */
  115840. constructor(length: number);
  115841. /**
  115842. * Adds a sample to the sample set
  115843. * @param v The sample value
  115844. */
  115845. add(v: number): void;
  115846. /**
  115847. * Returns previously added values or null if outside of history or outside the sliding window domain
  115848. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  115849. * @return Value previously recorded with add() or null if outside of range
  115850. */
  115851. history(i: number): number;
  115852. /**
  115853. * Returns true if enough samples have been taken to completely fill the sliding window
  115854. * @return true if sample-set saturated
  115855. */
  115856. isSaturated(): boolean;
  115857. /**
  115858. * Resets the rolling average (equivalent to 0 samples taken so far)
  115859. */
  115860. reset(): void;
  115861. /**
  115862. * Wraps a value around the sample range boundaries
  115863. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  115864. * @return Wrapped position in sample range
  115865. */
  115866. protected _wrapPosition(i: number): number;
  115867. }
  115868. }
  115869. declare module BABYLON {
  115870. /**
  115871. * This class is used to track a performance counter which is number based.
  115872. * The user has access to many properties which give statistics of different nature.
  115873. *
  115874. * The implementer can track two kinds of Performance Counter: time and count.
  115875. * 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.
  115876. * 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.
  115877. */
  115878. export class PerfCounter {
  115879. /**
  115880. * Gets or sets a global boolean to turn on and off all the counters
  115881. */
  115882. static Enabled: boolean;
  115883. /**
  115884. * Returns the smallest value ever
  115885. */
  115886. get min(): number;
  115887. /**
  115888. * Returns the biggest value ever
  115889. */
  115890. get max(): number;
  115891. /**
  115892. * Returns the average value since the performance counter is running
  115893. */
  115894. get average(): number;
  115895. /**
  115896. * Returns the average value of the last second the counter was monitored
  115897. */
  115898. get lastSecAverage(): number;
  115899. /**
  115900. * Returns the current value
  115901. */
  115902. get current(): number;
  115903. /**
  115904. * Gets the accumulated total
  115905. */
  115906. get total(): number;
  115907. /**
  115908. * Gets the total value count
  115909. */
  115910. get count(): number;
  115911. /**
  115912. * Creates a new counter
  115913. */
  115914. constructor();
  115915. /**
  115916. * Call this method to start monitoring a new frame.
  115917. * 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.
  115918. */
  115919. fetchNewFrame(): void;
  115920. /**
  115921. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  115922. * @param newCount the count value to add to the monitored count
  115923. * @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.
  115924. */
  115925. addCount(newCount: number, fetchResult: boolean): void;
  115926. /**
  115927. * Start monitoring this performance counter
  115928. */
  115929. beginMonitoring(): void;
  115930. /**
  115931. * Compute the time lapsed since the previous beginMonitoring() call.
  115932. * @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
  115933. */
  115934. endMonitoring(newFrame?: boolean): void;
  115935. private _fetchResult;
  115936. private _startMonitoringTime;
  115937. private _min;
  115938. private _max;
  115939. private _average;
  115940. private _current;
  115941. private _totalValueCount;
  115942. private _totalAccumulated;
  115943. private _lastSecAverage;
  115944. private _lastSecAccumulated;
  115945. private _lastSecTime;
  115946. private _lastSecValueCount;
  115947. }
  115948. }
  115949. declare module BABYLON {
  115950. interface ThinEngine {
  115951. /**
  115952. * Sets alpha constants used by some alpha blending modes
  115953. * @param r defines the red component
  115954. * @param g defines the green component
  115955. * @param b defines the blue component
  115956. * @param a defines the alpha component
  115957. */
  115958. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115959. /**
  115960. * Sets the current alpha mode
  115961. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  115962. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115963. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115964. */
  115965. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115966. /**
  115967. * Gets the current alpha mode
  115968. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115969. * @returns the current alpha mode
  115970. */
  115971. getAlphaMode(): number;
  115972. /**
  115973. * Sets the current alpha equation
  115974. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  115975. */
  115976. setAlphaEquation(equation: number): void;
  115977. /**
  115978. * Gets the current alpha equation.
  115979. * @returns the current alpha equation
  115980. */
  115981. getAlphaEquation(): number;
  115982. }
  115983. }
  115984. declare module BABYLON {
  115985. interface ThinEngine {
  115986. /** @hidden */
  115987. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  115988. }
  115989. }
  115990. declare module BABYLON {
  115991. /**
  115992. * Defines the interface used by display changed events
  115993. */
  115994. export interface IDisplayChangedEventArgs {
  115995. /** Gets the vrDisplay object (if any) */
  115996. vrDisplay: Nullable<any>;
  115997. /** Gets a boolean indicating if webVR is supported */
  115998. vrSupported: boolean;
  115999. }
  116000. /**
  116001. * Defines the interface used by objects containing a viewport (like a camera)
  116002. */
  116003. interface IViewportOwnerLike {
  116004. /**
  116005. * Gets or sets the viewport
  116006. */
  116007. viewport: IViewportLike;
  116008. }
  116009. /**
  116010. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116011. */
  116012. export class Engine extends ThinEngine {
  116013. /** Defines that alpha blending is disabled */
  116014. static readonly ALPHA_DISABLE: number;
  116015. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116016. static readonly ALPHA_ADD: number;
  116017. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116018. static readonly ALPHA_COMBINE: number;
  116019. /** Defines that alpha blending to DEST - SRC * DEST */
  116020. static readonly ALPHA_SUBTRACT: number;
  116021. /** Defines that alpha blending to SRC * DEST */
  116022. static readonly ALPHA_MULTIPLY: number;
  116023. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116024. static readonly ALPHA_MAXIMIZED: number;
  116025. /** Defines that alpha blending to SRC + DEST */
  116026. static readonly ALPHA_ONEONE: number;
  116027. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116028. static readonly ALPHA_PREMULTIPLIED: number;
  116029. /**
  116030. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116031. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116032. */
  116033. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116034. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116035. static readonly ALPHA_INTERPOLATE: number;
  116036. /**
  116037. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116038. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116039. */
  116040. static readonly ALPHA_SCREENMODE: number;
  116041. /** Defines that the ressource is not delayed*/
  116042. static readonly DELAYLOADSTATE_NONE: number;
  116043. /** Defines that the ressource was successfully delay loaded */
  116044. static readonly DELAYLOADSTATE_LOADED: number;
  116045. /** Defines that the ressource is currently delay loading */
  116046. static readonly DELAYLOADSTATE_LOADING: number;
  116047. /** Defines that the ressource is delayed and has not started loading */
  116048. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116050. static readonly NEVER: number;
  116051. /** 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 */
  116052. static readonly ALWAYS: number;
  116053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116054. static readonly LESS: number;
  116055. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116056. static readonly EQUAL: number;
  116057. /** 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 */
  116058. static readonly LEQUAL: number;
  116059. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116060. static readonly GREATER: number;
  116061. /** 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 */
  116062. static readonly GEQUAL: number;
  116063. /** 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 */
  116064. static readonly NOTEQUAL: number;
  116065. /** Passed to stencilOperation to specify that stencil value must be kept */
  116066. static readonly KEEP: number;
  116067. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116068. static readonly REPLACE: number;
  116069. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116070. static readonly INCR: number;
  116071. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116072. static readonly DECR: number;
  116073. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116074. static readonly INVERT: number;
  116075. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116076. static readonly INCR_WRAP: number;
  116077. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116078. static readonly DECR_WRAP: number;
  116079. /** Texture is not repeating outside of 0..1 UVs */
  116080. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116081. /** Texture is repeating outside of 0..1 UVs */
  116082. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116083. /** Texture is repeating and mirrored */
  116084. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116085. /** ALPHA */
  116086. static readonly TEXTUREFORMAT_ALPHA: number;
  116087. /** LUMINANCE */
  116088. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116089. /** LUMINANCE_ALPHA */
  116090. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116091. /** RGB */
  116092. static readonly TEXTUREFORMAT_RGB: number;
  116093. /** RGBA */
  116094. static readonly TEXTUREFORMAT_RGBA: number;
  116095. /** RED */
  116096. static readonly TEXTUREFORMAT_RED: number;
  116097. /** RED (2nd reference) */
  116098. static readonly TEXTUREFORMAT_R: number;
  116099. /** RG */
  116100. static readonly TEXTUREFORMAT_RG: number;
  116101. /** RED_INTEGER */
  116102. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116103. /** RED_INTEGER (2nd reference) */
  116104. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116105. /** RG_INTEGER */
  116106. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116107. /** RGB_INTEGER */
  116108. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116109. /** RGBA_INTEGER */
  116110. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116111. /** UNSIGNED_BYTE */
  116112. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116113. /** UNSIGNED_BYTE (2nd reference) */
  116114. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116115. /** FLOAT */
  116116. static readonly TEXTURETYPE_FLOAT: number;
  116117. /** HALF_FLOAT */
  116118. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116119. /** BYTE */
  116120. static readonly TEXTURETYPE_BYTE: number;
  116121. /** SHORT */
  116122. static readonly TEXTURETYPE_SHORT: number;
  116123. /** UNSIGNED_SHORT */
  116124. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116125. /** INT */
  116126. static readonly TEXTURETYPE_INT: number;
  116127. /** UNSIGNED_INT */
  116128. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116129. /** UNSIGNED_SHORT_4_4_4_4 */
  116130. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116131. /** UNSIGNED_SHORT_5_5_5_1 */
  116132. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116133. /** UNSIGNED_SHORT_5_6_5 */
  116134. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116135. /** UNSIGNED_INT_2_10_10_10_REV */
  116136. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116137. /** UNSIGNED_INT_24_8 */
  116138. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116139. /** UNSIGNED_INT_10F_11F_11F_REV */
  116140. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116141. /** UNSIGNED_INT_5_9_9_9_REV */
  116142. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116143. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116144. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116145. /** nearest is mag = nearest and min = nearest and mip = linear */
  116146. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116148. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116149. /** Trilinear is mag = linear and min = linear and mip = linear */
  116150. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116151. /** nearest is mag = nearest and min = nearest and mip = linear */
  116152. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116153. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116154. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116155. /** Trilinear is mag = linear and min = linear and mip = linear */
  116156. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116157. /** mag = nearest and min = nearest and mip = nearest */
  116158. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116159. /** mag = nearest and min = linear and mip = nearest */
  116160. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116161. /** mag = nearest and min = linear and mip = linear */
  116162. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116163. /** mag = nearest and min = linear and mip = none */
  116164. static readonly TEXTURE_NEAREST_LINEAR: number;
  116165. /** mag = nearest and min = nearest and mip = none */
  116166. static readonly TEXTURE_NEAREST_NEAREST: number;
  116167. /** mag = linear and min = nearest and mip = nearest */
  116168. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116169. /** mag = linear and min = nearest and mip = linear */
  116170. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116171. /** mag = linear and min = linear and mip = none */
  116172. static readonly TEXTURE_LINEAR_LINEAR: number;
  116173. /** mag = linear and min = nearest and mip = none */
  116174. static readonly TEXTURE_LINEAR_NEAREST: number;
  116175. /** Explicit coordinates mode */
  116176. static readonly TEXTURE_EXPLICIT_MODE: number;
  116177. /** Spherical coordinates mode */
  116178. static readonly TEXTURE_SPHERICAL_MODE: number;
  116179. /** Planar coordinates mode */
  116180. static readonly TEXTURE_PLANAR_MODE: number;
  116181. /** Cubic coordinates mode */
  116182. static readonly TEXTURE_CUBIC_MODE: number;
  116183. /** Projection coordinates mode */
  116184. static readonly TEXTURE_PROJECTION_MODE: number;
  116185. /** Skybox coordinates mode */
  116186. static readonly TEXTURE_SKYBOX_MODE: number;
  116187. /** Inverse Cubic coordinates mode */
  116188. static readonly TEXTURE_INVCUBIC_MODE: number;
  116189. /** Equirectangular coordinates mode */
  116190. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116191. /** Equirectangular Fixed coordinates mode */
  116192. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116193. /** Equirectangular Fixed Mirrored coordinates mode */
  116194. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116195. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116196. static readonly SCALEMODE_FLOOR: number;
  116197. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116198. static readonly SCALEMODE_NEAREST: number;
  116199. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116200. static readonly SCALEMODE_CEILING: number;
  116201. /**
  116202. * Returns the current npm package of the sdk
  116203. */
  116204. static get NpmPackage(): string;
  116205. /**
  116206. * Returns the current version of the framework
  116207. */
  116208. static get Version(): string;
  116209. /** Gets the list of created engines */
  116210. static get Instances(): Engine[];
  116211. /**
  116212. * Gets the latest created engine
  116213. */
  116214. static get LastCreatedEngine(): Nullable<Engine>;
  116215. /**
  116216. * Gets the latest created scene
  116217. */
  116218. static get LastCreatedScene(): Nullable<Scene>;
  116219. /**
  116220. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116221. * @param flag defines which part of the materials must be marked as dirty
  116222. * @param predicate defines a predicate used to filter which materials should be affected
  116223. */
  116224. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116225. /**
  116226. * Method called to create the default loading screen.
  116227. * This can be overriden in your own app.
  116228. * @param canvas The rendering canvas element
  116229. * @returns The loading screen
  116230. */
  116231. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116232. /**
  116233. * Method called to create the default rescale post process on each engine.
  116234. */
  116235. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116236. /**
  116237. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116238. **/
  116239. enableOfflineSupport: boolean;
  116240. /**
  116241. * 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)
  116242. **/
  116243. disableManifestCheck: boolean;
  116244. /**
  116245. * Gets the list of created scenes
  116246. */
  116247. scenes: Scene[];
  116248. /**
  116249. * Event raised when a new scene is created
  116250. */
  116251. onNewSceneAddedObservable: Observable<Scene>;
  116252. /**
  116253. * Gets the list of created postprocesses
  116254. */
  116255. postProcesses: PostProcess[];
  116256. /**
  116257. * Gets a boolean indicating if the pointer is currently locked
  116258. */
  116259. isPointerLock: boolean;
  116260. /**
  116261. * Observable event triggered each time the rendering canvas is resized
  116262. */
  116263. onResizeObservable: Observable<Engine>;
  116264. /**
  116265. * Observable event triggered each time the canvas loses focus
  116266. */
  116267. onCanvasBlurObservable: Observable<Engine>;
  116268. /**
  116269. * Observable event triggered each time the canvas gains focus
  116270. */
  116271. onCanvasFocusObservable: Observable<Engine>;
  116272. /**
  116273. * Observable event triggered each time the canvas receives pointerout event
  116274. */
  116275. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116276. /**
  116277. * Observable raised when the engine begins a new frame
  116278. */
  116279. onBeginFrameObservable: Observable<Engine>;
  116280. /**
  116281. * If set, will be used to request the next animation frame for the render loop
  116282. */
  116283. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116284. /**
  116285. * Observable raised when the engine ends the current frame
  116286. */
  116287. onEndFrameObservable: Observable<Engine>;
  116288. /**
  116289. * Observable raised when the engine is about to compile a shader
  116290. */
  116291. onBeforeShaderCompilationObservable: Observable<Engine>;
  116292. /**
  116293. * Observable raised when the engine has jsut compiled a shader
  116294. */
  116295. onAfterShaderCompilationObservable: Observable<Engine>;
  116296. /**
  116297. * Gets the audio engine
  116298. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116299. * @ignorenaming
  116300. */
  116301. static audioEngine: IAudioEngine;
  116302. /**
  116303. * Default AudioEngine factory responsible of creating the Audio Engine.
  116304. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116305. */
  116306. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116307. /**
  116308. * Default offline support factory responsible of creating a tool used to store data locally.
  116309. * By default, this will create a Database object if the workload has been embedded.
  116310. */
  116311. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116312. private _loadingScreen;
  116313. private _pointerLockRequested;
  116314. private _rescalePostProcess;
  116315. private _deterministicLockstep;
  116316. private _lockstepMaxSteps;
  116317. private _timeStep;
  116318. protected get _supportsHardwareTextureRescaling(): boolean;
  116319. private _fps;
  116320. private _deltaTime;
  116321. /** @hidden */
  116322. _drawCalls: PerfCounter;
  116323. /** 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 */
  116324. canvasTabIndex: number;
  116325. /**
  116326. * Turn this value on if you want to pause FPS computation when in background
  116327. */
  116328. disablePerformanceMonitorInBackground: boolean;
  116329. private _performanceMonitor;
  116330. /**
  116331. * Gets the performance monitor attached to this engine
  116332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116333. */
  116334. get performanceMonitor(): PerformanceMonitor;
  116335. private _onFocus;
  116336. private _onBlur;
  116337. private _onCanvasPointerOut;
  116338. private _onCanvasBlur;
  116339. private _onCanvasFocus;
  116340. private _onFullscreenChange;
  116341. private _onPointerLockChange;
  116342. /**
  116343. * Gets the HTML element used to attach event listeners
  116344. * @returns a HTML element
  116345. */
  116346. getInputElement(): Nullable<HTMLElement>;
  116347. /**
  116348. * Creates a new engine
  116349. * @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
  116350. * @param antialias defines enable antialiasing (default: false)
  116351. * @param options defines further options to be sent to the getContext() function
  116352. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116353. */
  116354. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116355. /**
  116356. * Gets current aspect ratio
  116357. * @param viewportOwner defines the camera to use to get the aspect ratio
  116358. * @param useScreen defines if screen size must be used (or the current render target if any)
  116359. * @returns a number defining the aspect ratio
  116360. */
  116361. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116362. /**
  116363. * Gets current screen aspect ratio
  116364. * @returns a number defining the aspect ratio
  116365. */
  116366. getScreenAspectRatio(): number;
  116367. /**
  116368. * Gets the client rect of the HTML canvas attached with the current webGL context
  116369. * @returns a client rectanglee
  116370. */
  116371. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116372. /**
  116373. * Gets the client rect of the HTML element used for events
  116374. * @returns a client rectanglee
  116375. */
  116376. getInputElementClientRect(): Nullable<ClientRect>;
  116377. /**
  116378. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116379. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116380. * @returns true if engine is in deterministic lock step mode
  116381. */
  116382. isDeterministicLockStep(): boolean;
  116383. /**
  116384. * Gets the max steps when engine is running in deterministic lock step
  116385. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116386. * @returns the max steps
  116387. */
  116388. getLockstepMaxSteps(): number;
  116389. /**
  116390. * Returns the time in ms between steps when using deterministic lock step.
  116391. * @returns time step in (ms)
  116392. */
  116393. getTimeStep(): number;
  116394. /**
  116395. * Force the mipmap generation for the given render target texture
  116396. * @param texture defines the render target texture to use
  116397. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116398. */
  116399. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116400. /** States */
  116401. /**
  116402. * Set various states to the webGL context
  116403. * @param culling defines backface culling state
  116404. * @param zOffset defines the value to apply to zOffset (0 by default)
  116405. * @param force defines if states must be applied even if cache is up to date
  116406. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116407. */
  116408. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116409. /**
  116410. * Set the z offset to apply to current rendering
  116411. * @param value defines the offset to apply
  116412. */
  116413. setZOffset(value: number): void;
  116414. /**
  116415. * Gets the current value of the zOffset
  116416. * @returns the current zOffset state
  116417. */
  116418. getZOffset(): number;
  116419. /**
  116420. * Enable or disable depth buffering
  116421. * @param enable defines the state to set
  116422. */
  116423. setDepthBuffer(enable: boolean): void;
  116424. /**
  116425. * Gets a boolean indicating if depth writing is enabled
  116426. * @returns the current depth writing state
  116427. */
  116428. getDepthWrite(): boolean;
  116429. /**
  116430. * Enable or disable depth writing
  116431. * @param enable defines the state to set
  116432. */
  116433. setDepthWrite(enable: boolean): void;
  116434. /**
  116435. * Gets a boolean indicating if stencil buffer is enabled
  116436. * @returns the current stencil buffer state
  116437. */
  116438. getStencilBuffer(): boolean;
  116439. /**
  116440. * Enable or disable the stencil buffer
  116441. * @param enable defines if the stencil buffer must be enabled or disabled
  116442. */
  116443. setStencilBuffer(enable: boolean): void;
  116444. /**
  116445. * Gets the current stencil mask
  116446. * @returns a number defining the new stencil mask to use
  116447. */
  116448. getStencilMask(): number;
  116449. /**
  116450. * Sets the current stencil mask
  116451. * @param mask defines the new stencil mask to use
  116452. */
  116453. setStencilMask(mask: number): void;
  116454. /**
  116455. * Gets the current stencil function
  116456. * @returns a number defining the stencil function to use
  116457. */
  116458. getStencilFunction(): number;
  116459. /**
  116460. * Gets the current stencil reference value
  116461. * @returns a number defining the stencil reference value to use
  116462. */
  116463. getStencilFunctionReference(): number;
  116464. /**
  116465. * Gets the current stencil mask
  116466. * @returns a number defining the stencil mask to use
  116467. */
  116468. getStencilFunctionMask(): number;
  116469. /**
  116470. * Sets the current stencil function
  116471. * @param stencilFunc defines the new stencil function to use
  116472. */
  116473. setStencilFunction(stencilFunc: number): void;
  116474. /**
  116475. * Sets the current stencil reference
  116476. * @param reference defines the new stencil reference to use
  116477. */
  116478. setStencilFunctionReference(reference: number): void;
  116479. /**
  116480. * Sets the current stencil mask
  116481. * @param mask defines the new stencil mask to use
  116482. */
  116483. setStencilFunctionMask(mask: number): void;
  116484. /**
  116485. * Gets the current stencil operation when stencil fails
  116486. * @returns a number defining stencil operation to use when stencil fails
  116487. */
  116488. getStencilOperationFail(): number;
  116489. /**
  116490. * Gets the current stencil operation when depth fails
  116491. * @returns a number defining stencil operation to use when depth fails
  116492. */
  116493. getStencilOperationDepthFail(): number;
  116494. /**
  116495. * Gets the current stencil operation when stencil passes
  116496. * @returns a number defining stencil operation to use when stencil passes
  116497. */
  116498. getStencilOperationPass(): number;
  116499. /**
  116500. * Sets the stencil operation to use when stencil fails
  116501. * @param operation defines the stencil operation to use when stencil fails
  116502. */
  116503. setStencilOperationFail(operation: number): void;
  116504. /**
  116505. * Sets the stencil operation to use when depth fails
  116506. * @param operation defines the stencil operation to use when depth fails
  116507. */
  116508. setStencilOperationDepthFail(operation: number): void;
  116509. /**
  116510. * Sets the stencil operation to use when stencil passes
  116511. * @param operation defines the stencil operation to use when stencil passes
  116512. */
  116513. setStencilOperationPass(operation: number): void;
  116514. /**
  116515. * Sets a boolean indicating if the dithering state is enabled or disabled
  116516. * @param value defines the dithering state
  116517. */
  116518. setDitheringState(value: boolean): void;
  116519. /**
  116520. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116521. * @param value defines the rasterizer state
  116522. */
  116523. setRasterizerState(value: boolean): void;
  116524. /**
  116525. * Gets the current depth function
  116526. * @returns a number defining the depth function
  116527. */
  116528. getDepthFunction(): Nullable<number>;
  116529. /**
  116530. * Sets the current depth function
  116531. * @param depthFunc defines the function to use
  116532. */
  116533. setDepthFunction(depthFunc: number): void;
  116534. /**
  116535. * Sets the current depth function to GREATER
  116536. */
  116537. setDepthFunctionToGreater(): void;
  116538. /**
  116539. * Sets the current depth function to GEQUAL
  116540. */
  116541. setDepthFunctionToGreaterOrEqual(): void;
  116542. /**
  116543. * Sets the current depth function to LESS
  116544. */
  116545. setDepthFunctionToLess(): void;
  116546. /**
  116547. * Sets the current depth function to LEQUAL
  116548. */
  116549. setDepthFunctionToLessOrEqual(): void;
  116550. private _cachedStencilBuffer;
  116551. private _cachedStencilFunction;
  116552. private _cachedStencilMask;
  116553. private _cachedStencilOperationPass;
  116554. private _cachedStencilOperationFail;
  116555. private _cachedStencilOperationDepthFail;
  116556. private _cachedStencilReference;
  116557. /**
  116558. * Caches the the state of the stencil buffer
  116559. */
  116560. cacheStencilState(): void;
  116561. /**
  116562. * Restores the state of the stencil buffer
  116563. */
  116564. restoreStencilState(): void;
  116565. /**
  116566. * Directly set the WebGL Viewport
  116567. * @param x defines the x coordinate of the viewport (in screen space)
  116568. * @param y defines the y coordinate of the viewport (in screen space)
  116569. * @param width defines the width of the viewport (in screen space)
  116570. * @param height defines the height of the viewport (in screen space)
  116571. * @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
  116572. */
  116573. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116574. /**
  116575. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116576. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116577. * @param y defines the y-coordinate of the corner of the clear rectangle
  116578. * @param width defines the width of the clear rectangle
  116579. * @param height defines the height of the clear rectangle
  116580. * @param clearColor defines the clear color
  116581. */
  116582. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116583. /**
  116584. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116585. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116586. * @param y defines the y-coordinate of the corner of the clear rectangle
  116587. * @param width defines the width of the clear rectangle
  116588. * @param height defines the height of the clear rectangle
  116589. */
  116590. enableScissor(x: number, y: number, width: number, height: number): void;
  116591. /**
  116592. * Disable previously set scissor test rectangle
  116593. */
  116594. disableScissor(): void;
  116595. protected _reportDrawCall(): void;
  116596. /**
  116597. * Initializes a webVR display and starts listening to display change events
  116598. * The onVRDisplayChangedObservable will be notified upon these changes
  116599. * @returns The onVRDisplayChangedObservable
  116600. */
  116601. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116602. /** @hidden */
  116603. _prepareVRComponent(): void;
  116604. /** @hidden */
  116605. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116606. /** @hidden */
  116607. _submitVRFrame(): void;
  116608. /**
  116609. * Call this function to leave webVR mode
  116610. * Will do nothing if webVR is not supported or if there is no webVR device
  116611. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116612. */
  116613. disableVR(): void;
  116614. /**
  116615. * Gets a boolean indicating that the system is in VR mode and is presenting
  116616. * @returns true if VR mode is engaged
  116617. */
  116618. isVRPresenting(): boolean;
  116619. /** @hidden */
  116620. _requestVRFrame(): void;
  116621. /** @hidden */
  116622. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116623. /**
  116624. * Gets the source code of the vertex shader associated with a specific webGL program
  116625. * @param program defines the program to use
  116626. * @returns a string containing the source code of the vertex shader associated with the program
  116627. */
  116628. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116629. /**
  116630. * Gets the source code of the fragment shader associated with a specific webGL program
  116631. * @param program defines the program to use
  116632. * @returns a string containing the source code of the fragment shader associated with the program
  116633. */
  116634. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116635. /**
  116636. * Sets a depth stencil texture from a render target to the according uniform.
  116637. * @param channel The texture channel
  116638. * @param uniform The uniform to set
  116639. * @param texture The render target texture containing the depth stencil texture to apply
  116640. */
  116641. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116642. /**
  116643. * Sets a texture to the webGL context from a postprocess
  116644. * @param channel defines the channel to use
  116645. * @param postProcess defines the source postprocess
  116646. */
  116647. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116648. /**
  116649. * Binds the output of the passed in post process to the texture channel specified
  116650. * @param channel The channel the texture should be bound to
  116651. * @param postProcess The post process which's output should be bound
  116652. */
  116653. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116654. protected _rebuildBuffers(): void;
  116655. /** @hidden */
  116656. _renderFrame(): void;
  116657. _renderLoop(): void;
  116658. /** @hidden */
  116659. _renderViews(): boolean;
  116660. /**
  116661. * Toggle full screen mode
  116662. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116663. */
  116664. switchFullscreen(requestPointerLock: boolean): void;
  116665. /**
  116666. * Enters full screen mode
  116667. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116668. */
  116669. enterFullscreen(requestPointerLock: boolean): void;
  116670. /**
  116671. * Exits full screen mode
  116672. */
  116673. exitFullscreen(): void;
  116674. /**
  116675. * Enters Pointerlock mode
  116676. */
  116677. enterPointerlock(): void;
  116678. /**
  116679. * Exits Pointerlock mode
  116680. */
  116681. exitPointerlock(): void;
  116682. /**
  116683. * Begin a new frame
  116684. */
  116685. beginFrame(): void;
  116686. /**
  116687. * Enf the current frame
  116688. */
  116689. endFrame(): void;
  116690. resize(): void;
  116691. /**
  116692. * Force a specific size of the canvas
  116693. * @param width defines the new canvas' width
  116694. * @param height defines the new canvas' height
  116695. * @returns true if the size was changed
  116696. */
  116697. setSize(width: number, height: number): boolean;
  116698. /**
  116699. * Updates a dynamic vertex buffer.
  116700. * @param vertexBuffer the vertex buffer to update
  116701. * @param data the data used to update the vertex buffer
  116702. * @param byteOffset the byte offset of the data
  116703. * @param byteLength the byte length of the data
  116704. */
  116705. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116706. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116707. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116708. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116709. _releaseTexture(texture: InternalTexture): void;
  116710. /**
  116711. * @hidden
  116712. * Rescales a texture
  116713. * @param source input texutre
  116714. * @param destination destination texture
  116715. * @param scene scene to use to render the resize
  116716. * @param internalFormat format to use when resizing
  116717. * @param onComplete callback to be called when resize has completed
  116718. */
  116719. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116720. /**
  116721. * Gets the current framerate
  116722. * @returns a number representing the framerate
  116723. */
  116724. getFps(): number;
  116725. /**
  116726. * Gets the time spent between current and previous frame
  116727. * @returns a number representing the delta time in ms
  116728. */
  116729. getDeltaTime(): number;
  116730. private _measureFps;
  116731. /** @hidden */
  116732. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116733. /**
  116734. * Update a dynamic index buffer
  116735. * @param indexBuffer defines the target index buffer
  116736. * @param indices defines the data to update
  116737. * @param offset defines the offset in the target index buffer where update should start
  116738. */
  116739. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116740. /**
  116741. * Updates the sample count of a render target texture
  116742. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116743. * @param texture defines the texture to update
  116744. * @param samples defines the sample count to set
  116745. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116746. */
  116747. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116748. /**
  116749. * Updates a depth texture Comparison Mode and Function.
  116750. * If the comparison Function is equal to 0, the mode will be set to none.
  116751. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116752. * @param texture The texture to set the comparison function for
  116753. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116754. */
  116755. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116756. /**
  116757. * Creates a webGL buffer to use with instanciation
  116758. * @param capacity defines the size of the buffer
  116759. * @returns the webGL buffer
  116760. */
  116761. createInstancesBuffer(capacity: number): DataBuffer;
  116762. /**
  116763. * Delete a webGL buffer used with instanciation
  116764. * @param buffer defines the webGL buffer to delete
  116765. */
  116766. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116767. private _clientWaitAsync;
  116768. /** @hidden */
  116769. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116770. dispose(): void;
  116771. private _disableTouchAction;
  116772. /**
  116773. * Display the loading screen
  116774. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116775. */
  116776. displayLoadingUI(): void;
  116777. /**
  116778. * Hide the loading screen
  116779. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116780. */
  116781. hideLoadingUI(): void;
  116782. /**
  116783. * Gets the current loading screen object
  116784. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116785. */
  116786. get loadingScreen(): ILoadingScreen;
  116787. /**
  116788. * Sets the current loading screen object
  116789. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116790. */
  116791. set loadingScreen(loadingScreen: ILoadingScreen);
  116792. /**
  116793. * Sets the current loading screen text
  116794. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116795. */
  116796. set loadingUIText(text: string);
  116797. /**
  116798. * Sets the current loading screen background color
  116799. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116800. */
  116801. set loadingUIBackgroundColor(color: string);
  116802. /** Pointerlock and fullscreen */
  116803. /**
  116804. * Ask the browser to promote the current element to pointerlock mode
  116805. * @param element defines the DOM element to promote
  116806. */
  116807. static _RequestPointerlock(element: HTMLElement): void;
  116808. /**
  116809. * Asks the browser to exit pointerlock mode
  116810. */
  116811. static _ExitPointerlock(): void;
  116812. /**
  116813. * Ask the browser to promote the current element to fullscreen rendering mode
  116814. * @param element defines the DOM element to promote
  116815. */
  116816. static _RequestFullscreen(element: HTMLElement): void;
  116817. /**
  116818. * Asks the browser to exit fullscreen mode
  116819. */
  116820. static _ExitFullscreen(): void;
  116821. }
  116822. }
  116823. declare module BABYLON {
  116824. /**
  116825. * The engine store class is responsible to hold all the instances of Engine and Scene created
  116826. * during the life time of the application.
  116827. */
  116828. export class EngineStore {
  116829. /** Gets the list of created engines */
  116830. static Instances: Engine[];
  116831. /** @hidden */
  116832. static _LastCreatedScene: Nullable<Scene>;
  116833. /**
  116834. * Gets the latest created engine
  116835. */
  116836. static get LastCreatedEngine(): Nullable<Engine>;
  116837. /**
  116838. * Gets the latest created scene
  116839. */
  116840. static get LastCreatedScene(): Nullable<Scene>;
  116841. /**
  116842. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116843. * @ignorenaming
  116844. */
  116845. static UseFallbackTexture: boolean;
  116846. /**
  116847. * Texture content used if a texture cannot loaded
  116848. * @ignorenaming
  116849. */
  116850. static FallbackTexture: string;
  116851. }
  116852. }
  116853. declare module BABYLON {
  116854. /**
  116855. * Helper class that provides a small promise polyfill
  116856. */
  116857. export class PromisePolyfill {
  116858. /**
  116859. * Static function used to check if the polyfill is required
  116860. * If this is the case then the function will inject the polyfill to window.Promise
  116861. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  116862. */
  116863. static Apply(force?: boolean): void;
  116864. }
  116865. }
  116866. declare module BABYLON {
  116867. /**
  116868. * Interface for screenshot methods with describe argument called `size` as object with options
  116869. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  116870. */
  116871. export interface IScreenshotSize {
  116872. /**
  116873. * number in pixels for canvas height
  116874. */
  116875. height?: number;
  116876. /**
  116877. * multiplier allowing render at a higher or lower resolution
  116878. * If value is defined then height and width will be ignored and taken from camera
  116879. */
  116880. precision?: number;
  116881. /**
  116882. * number in pixels for canvas width
  116883. */
  116884. width?: number;
  116885. }
  116886. }
  116887. declare module BABYLON {
  116888. interface IColor4Like {
  116889. r: float;
  116890. g: float;
  116891. b: float;
  116892. a: float;
  116893. }
  116894. /**
  116895. * Class containing a set of static utilities functions
  116896. */
  116897. export class Tools {
  116898. /**
  116899. * Gets or sets the base URL to use to load assets
  116900. */
  116901. static get BaseUrl(): string;
  116902. static set BaseUrl(value: string);
  116903. /**
  116904. * Enable/Disable Custom HTTP Request Headers globally.
  116905. * default = false
  116906. * @see CustomRequestHeaders
  116907. */
  116908. static UseCustomRequestHeaders: boolean;
  116909. /**
  116910. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  116911. * i.e. when loading files, where the server/service expects an Authorization header
  116912. */
  116913. static CustomRequestHeaders: {
  116914. [key: string]: string;
  116915. };
  116916. /**
  116917. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  116918. */
  116919. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  116920. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  116921. /**
  116922. * Default behaviour for cors in the application.
  116923. * It can be a string if the expected behavior is identical in the entire app.
  116924. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  116925. */
  116926. static get CorsBehavior(): string | ((url: string | string[]) => string);
  116927. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  116928. /**
  116929. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116930. * @ignorenaming
  116931. */
  116932. static get UseFallbackTexture(): boolean;
  116933. static set UseFallbackTexture(value: boolean);
  116934. /**
  116935. * Use this object to register external classes like custom textures or material
  116936. * to allow the laoders to instantiate them
  116937. */
  116938. static get RegisteredExternalClasses(): {
  116939. [key: string]: Object;
  116940. };
  116941. static set RegisteredExternalClasses(classes: {
  116942. [key: string]: Object;
  116943. });
  116944. /**
  116945. * Texture content used if a texture cannot loaded
  116946. * @ignorenaming
  116947. */
  116948. static get fallbackTexture(): string;
  116949. static set fallbackTexture(value: string);
  116950. /**
  116951. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  116952. * @param u defines the coordinate on X axis
  116953. * @param v defines the coordinate on Y axis
  116954. * @param width defines the width of the source data
  116955. * @param height defines the height of the source data
  116956. * @param pixels defines the source byte array
  116957. * @param color defines the output color
  116958. */
  116959. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  116960. /**
  116961. * Interpolates between a and b via alpha
  116962. * @param a The lower value (returned when alpha = 0)
  116963. * @param b The upper value (returned when alpha = 1)
  116964. * @param alpha The interpolation-factor
  116965. * @return The mixed value
  116966. */
  116967. static Mix(a: number, b: number, alpha: number): number;
  116968. /**
  116969. * Tries to instantiate a new object from a given class name
  116970. * @param className defines the class name to instantiate
  116971. * @returns the new object or null if the system was not able to do the instantiation
  116972. */
  116973. static Instantiate(className: string): any;
  116974. /**
  116975. * Provides a slice function that will work even on IE
  116976. * @param data defines the array to slice
  116977. * @param start defines the start of the data (optional)
  116978. * @param end defines the end of the data (optional)
  116979. * @returns the new sliced array
  116980. */
  116981. static Slice<T>(data: T, start?: number, end?: number): T;
  116982. /**
  116983. * Polyfill for setImmediate
  116984. * @param action defines the action to execute after the current execution block
  116985. */
  116986. static SetImmediate(action: () => void): void;
  116987. /**
  116988. * Function indicating if a number is an exponent of 2
  116989. * @param value defines the value to test
  116990. * @returns true if the value is an exponent of 2
  116991. */
  116992. static IsExponentOfTwo(value: number): boolean;
  116993. private static _tmpFloatArray;
  116994. /**
  116995. * Returns the nearest 32-bit single precision float representation of a Number
  116996. * @param value A Number. If the parameter is of a different type, it will get converted
  116997. * to a number or to NaN if it cannot be converted
  116998. * @returns number
  116999. */
  117000. static FloatRound(value: number): number;
  117001. /**
  117002. * Extracts the filename from a path
  117003. * @param path defines the path to use
  117004. * @returns the filename
  117005. */
  117006. static GetFilename(path: string): string;
  117007. /**
  117008. * Extracts the "folder" part of a path (everything before the filename).
  117009. * @param uri The URI to extract the info from
  117010. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117011. * @returns The "folder" part of the path
  117012. */
  117013. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117014. /**
  117015. * Extracts text content from a DOM element hierarchy
  117016. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117017. */
  117018. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117019. /**
  117020. * Convert an angle in radians to degrees
  117021. * @param angle defines the angle to convert
  117022. * @returns the angle in degrees
  117023. */
  117024. static ToDegrees(angle: number): number;
  117025. /**
  117026. * Convert an angle in degrees to radians
  117027. * @param angle defines the angle to convert
  117028. * @returns the angle in radians
  117029. */
  117030. static ToRadians(angle: number): number;
  117031. /**
  117032. * Returns an array if obj is not an array
  117033. * @param obj defines the object to evaluate as an array
  117034. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117035. * @returns either obj directly if obj is an array or a new array containing obj
  117036. */
  117037. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117038. /**
  117039. * Gets the pointer prefix to use
  117040. * @param engine defines the engine we are finding the prefix for
  117041. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117042. */
  117043. static GetPointerPrefix(engine: Engine): string;
  117044. /**
  117045. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117046. * @param url define the url we are trying
  117047. * @param element define the dom element where to configure the cors policy
  117048. */
  117049. static SetCorsBehavior(url: string | string[], element: {
  117050. crossOrigin: string | null;
  117051. }): void;
  117052. /**
  117053. * Removes unwanted characters from an url
  117054. * @param url defines the url to clean
  117055. * @returns the cleaned url
  117056. */
  117057. static CleanUrl(url: string): string;
  117058. /**
  117059. * Gets or sets a function used to pre-process url before using them to load assets
  117060. */
  117061. static get PreprocessUrl(): (url: string) => string;
  117062. static set PreprocessUrl(processor: (url: string) => string);
  117063. /**
  117064. * Loads an image as an HTMLImageElement.
  117065. * @param input url string, ArrayBuffer, or Blob to load
  117066. * @param onLoad callback called when the image successfully loads
  117067. * @param onError callback called when the image fails to load
  117068. * @param offlineProvider offline provider for caching
  117069. * @param mimeType optional mime type
  117070. * @returns the HTMLImageElement of the loaded image
  117071. */
  117072. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117073. /**
  117074. * Loads a file from a url
  117075. * @param url url string, ArrayBuffer, or Blob to load
  117076. * @param onSuccess callback called when the file successfully loads
  117077. * @param onProgress callback called while file is loading (if the server supports this mode)
  117078. * @param offlineProvider defines the offline provider for caching
  117079. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117080. * @param onError callback called when the file fails to load
  117081. * @returns a file request object
  117082. */
  117083. 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;
  117084. /**
  117085. * Loads a file from a url
  117086. * @param url the file url to load
  117087. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117088. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117089. */
  117090. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117091. /**
  117092. * Load a script (identified by an url). When the url returns, the
  117093. * content of this file is added into a new script element, attached to the DOM (body element)
  117094. * @param scriptUrl defines the url of the script to laod
  117095. * @param onSuccess defines the callback called when the script is loaded
  117096. * @param onError defines the callback to call if an error occurs
  117097. * @param scriptId defines the id of the script element
  117098. */
  117099. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117100. /**
  117101. * Load an asynchronous script (identified by an url). When the url returns, the
  117102. * content of this file is added into a new script element, attached to the DOM (body element)
  117103. * @param scriptUrl defines the url of the script to laod
  117104. * @param scriptId defines the id of the script element
  117105. * @returns a promise request object
  117106. */
  117107. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117108. /**
  117109. * Loads a file from a blob
  117110. * @param fileToLoad defines the blob to use
  117111. * @param callback defines the callback to call when data is loaded
  117112. * @param progressCallback defines the callback to call during loading process
  117113. * @returns a file request object
  117114. */
  117115. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117116. /**
  117117. * Reads a file from a File object
  117118. * @param file defines the file to load
  117119. * @param onSuccess defines the callback to call when data is loaded
  117120. * @param onProgress defines the callback to call during loading process
  117121. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117122. * @param onError defines the callback to call when an error occurs
  117123. * @returns a file request object
  117124. */
  117125. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117126. /**
  117127. * Creates a data url from a given string content
  117128. * @param content defines the content to convert
  117129. * @returns the new data url link
  117130. */
  117131. static FileAsURL(content: string): string;
  117132. /**
  117133. * Format the given number to a specific decimal format
  117134. * @param value defines the number to format
  117135. * @param decimals defines the number of decimals to use
  117136. * @returns the formatted string
  117137. */
  117138. static Format(value: number, decimals?: number): string;
  117139. /**
  117140. * Tries to copy an object by duplicating every property
  117141. * @param source defines the source object
  117142. * @param destination defines the target object
  117143. * @param doNotCopyList defines a list of properties to avoid
  117144. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117145. */
  117146. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117147. /**
  117148. * Gets a boolean indicating if the given object has no own property
  117149. * @param obj defines the object to test
  117150. * @returns true if object has no own property
  117151. */
  117152. static IsEmpty(obj: any): boolean;
  117153. /**
  117154. * Function used to register events at window level
  117155. * @param windowElement defines the Window object to use
  117156. * @param events defines the events to register
  117157. */
  117158. static RegisterTopRootEvents(windowElement: Window, events: {
  117159. name: string;
  117160. handler: Nullable<(e: FocusEvent) => any>;
  117161. }[]): void;
  117162. /**
  117163. * Function used to unregister events from window level
  117164. * @param windowElement defines the Window object to use
  117165. * @param events defines the events to unregister
  117166. */
  117167. static UnregisterTopRootEvents(windowElement: Window, events: {
  117168. name: string;
  117169. handler: Nullable<(e: FocusEvent) => any>;
  117170. }[]): void;
  117171. /**
  117172. * @ignore
  117173. */
  117174. static _ScreenshotCanvas: HTMLCanvasElement;
  117175. /**
  117176. * Dumps the current bound framebuffer
  117177. * @param width defines the rendering width
  117178. * @param height defines the rendering height
  117179. * @param engine defines the hosting engine
  117180. * @param successCallback defines the callback triggered once the data are available
  117181. * @param mimeType defines the mime type of the result
  117182. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117183. */
  117184. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117185. /**
  117186. * Converts the canvas data to blob.
  117187. * This acts as a polyfill for browsers not supporting the to blob function.
  117188. * @param canvas Defines the canvas to extract the data from
  117189. * @param successCallback Defines the callback triggered once the data are available
  117190. * @param mimeType Defines the mime type of the result
  117191. */
  117192. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117193. /**
  117194. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117195. * @param successCallback defines the callback triggered once the data are available
  117196. * @param mimeType defines the mime type of the result
  117197. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117198. */
  117199. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117200. /**
  117201. * Downloads a blob in the browser
  117202. * @param blob defines the blob to download
  117203. * @param fileName defines the name of the downloaded file
  117204. */
  117205. static Download(blob: Blob, fileName: string): void;
  117206. /**
  117207. * Captures a screenshot of the current rendering
  117208. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117209. * @param engine defines the rendering engine
  117210. * @param camera defines the source camera
  117211. * @param size This parameter can be set to a single number or to an object with the
  117212. * following (optional) properties: precision, width, height. If a single number is passed,
  117213. * it will be used for both width and height. If an object is passed, the screenshot size
  117214. * will be derived from the parameters. The precision property is a multiplier allowing
  117215. * rendering at a higher or lower resolution
  117216. * @param successCallback defines the callback receives a single parameter which contains the
  117217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117218. * src parameter of an <img> to display it
  117219. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117220. * Check your browser for supported MIME types
  117221. */
  117222. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117223. /**
  117224. * Captures a screenshot of the current rendering
  117225. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117226. * @param engine defines the rendering engine
  117227. * @param camera defines the source camera
  117228. * @param size This parameter can be set to a single number or to an object with the
  117229. * following (optional) properties: precision, width, height. If a single number is passed,
  117230. * it will be used for both width and height. If an object is passed, the screenshot size
  117231. * will be derived from the parameters. The precision property is a multiplier allowing
  117232. * rendering at a higher or lower resolution
  117233. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117234. * Check your browser for supported MIME types
  117235. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117236. * to the src parameter of an <img> to display it
  117237. */
  117238. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117239. /**
  117240. * Generates an image screenshot from the specified camera.
  117241. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117242. * @param engine The engine to use for rendering
  117243. * @param camera The camera to use for rendering
  117244. * @param size This parameter can be set to a single number or to an object with the
  117245. * following (optional) properties: precision, width, height. If a single number is passed,
  117246. * it will be used for both width and height. If an object is passed, the screenshot size
  117247. * will be derived from the parameters. The precision property is a multiplier allowing
  117248. * rendering at a higher or lower resolution
  117249. * @param successCallback The callback receives a single parameter which contains the
  117250. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117251. * src parameter of an <img> to display it
  117252. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117253. * Check your browser for supported MIME types
  117254. * @param samples Texture samples (default: 1)
  117255. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117256. * @param fileName A name for for the downloaded file.
  117257. */
  117258. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117259. /**
  117260. * Generates an image screenshot from the specified camera.
  117261. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117262. * @param engine The engine to use for rendering
  117263. * @param camera The camera to use for rendering
  117264. * @param size This parameter can be set to a single number or to an object with the
  117265. * following (optional) properties: precision, width, height. If a single number is passed,
  117266. * it will be used for both width and height. If an object is passed, the screenshot size
  117267. * will be derived from the parameters. The precision property is a multiplier allowing
  117268. * rendering at a higher or lower resolution
  117269. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117270. * Check your browser for supported MIME types
  117271. * @param samples Texture samples (default: 1)
  117272. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117273. * @param fileName A name for for the downloaded file.
  117274. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117275. * to the src parameter of an <img> to display it
  117276. */
  117277. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117278. /**
  117279. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117280. * Be aware Math.random() could cause collisions, but:
  117281. * "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"
  117282. * @returns a pseudo random id
  117283. */
  117284. static RandomId(): string;
  117285. /**
  117286. * Test if the given uri is a base64 string
  117287. * @param uri The uri to test
  117288. * @return True if the uri is a base64 string or false otherwise
  117289. */
  117290. static IsBase64(uri: string): boolean;
  117291. /**
  117292. * Decode the given base64 uri.
  117293. * @param uri The uri to decode
  117294. * @return The decoded base64 data.
  117295. */
  117296. static DecodeBase64(uri: string): ArrayBuffer;
  117297. /**
  117298. * Gets the absolute url.
  117299. * @param url the input url
  117300. * @return the absolute url
  117301. */
  117302. static GetAbsoluteUrl(url: string): string;
  117303. /**
  117304. * No log
  117305. */
  117306. static readonly NoneLogLevel: number;
  117307. /**
  117308. * Only message logs
  117309. */
  117310. static readonly MessageLogLevel: number;
  117311. /**
  117312. * Only warning logs
  117313. */
  117314. static readonly WarningLogLevel: number;
  117315. /**
  117316. * Only error logs
  117317. */
  117318. static readonly ErrorLogLevel: number;
  117319. /**
  117320. * All logs
  117321. */
  117322. static readonly AllLogLevel: number;
  117323. /**
  117324. * Gets a value indicating the number of loading errors
  117325. * @ignorenaming
  117326. */
  117327. static get errorsCount(): number;
  117328. /**
  117329. * Callback called when a new log is added
  117330. */
  117331. static OnNewCacheEntry: (entry: string) => void;
  117332. /**
  117333. * Log a message to the console
  117334. * @param message defines the message to log
  117335. */
  117336. static Log(message: string): void;
  117337. /**
  117338. * Write a warning message to the console
  117339. * @param message defines the message to log
  117340. */
  117341. static Warn(message: string): void;
  117342. /**
  117343. * Write an error message to the console
  117344. * @param message defines the message to log
  117345. */
  117346. static Error(message: string): void;
  117347. /**
  117348. * Gets current log cache (list of logs)
  117349. */
  117350. static get LogCache(): string;
  117351. /**
  117352. * Clears the log cache
  117353. */
  117354. static ClearLogCache(): void;
  117355. /**
  117356. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117357. */
  117358. static set LogLevels(level: number);
  117359. /**
  117360. * Checks if the window object exists
  117361. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117362. */
  117363. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117364. /**
  117365. * No performance log
  117366. */
  117367. static readonly PerformanceNoneLogLevel: number;
  117368. /**
  117369. * Use user marks to log performance
  117370. */
  117371. static readonly PerformanceUserMarkLogLevel: number;
  117372. /**
  117373. * Log performance to the console
  117374. */
  117375. static readonly PerformanceConsoleLogLevel: number;
  117376. private static _performance;
  117377. /**
  117378. * Sets the current performance log level
  117379. */
  117380. static set PerformanceLogLevel(level: number);
  117381. private static _StartPerformanceCounterDisabled;
  117382. private static _EndPerformanceCounterDisabled;
  117383. private static _StartUserMark;
  117384. private static _EndUserMark;
  117385. private static _StartPerformanceConsole;
  117386. private static _EndPerformanceConsole;
  117387. /**
  117388. * Starts a performance counter
  117389. */
  117390. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117391. /**
  117392. * Ends a specific performance coutner
  117393. */
  117394. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117395. /**
  117396. * Gets either window.performance.now() if supported or Date.now() else
  117397. */
  117398. static get Now(): number;
  117399. /**
  117400. * This method will return the name of the class used to create the instance of the given object.
  117401. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117402. * @param object the object to get the class name from
  117403. * @param isType defines if the object is actually a type
  117404. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117405. */
  117406. static GetClassName(object: any, isType?: boolean): string;
  117407. /**
  117408. * Gets the first element of an array satisfying a given predicate
  117409. * @param array defines the array to browse
  117410. * @param predicate defines the predicate to use
  117411. * @returns null if not found or the element
  117412. */
  117413. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117414. /**
  117415. * This method will return the name of the full name of the class, including its owning module (if any).
  117416. * 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).
  117417. * @param object the object to get the class name from
  117418. * @param isType defines if the object is actually a type
  117419. * @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.
  117420. * @ignorenaming
  117421. */
  117422. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117423. /**
  117424. * Returns a promise that resolves after the given amount of time.
  117425. * @param delay Number of milliseconds to delay
  117426. * @returns Promise that resolves after the given amount of time
  117427. */
  117428. static DelayAsync(delay: number): Promise<void>;
  117429. /**
  117430. * Utility function to detect if the current user agent is Safari
  117431. * @returns whether or not the current user agent is safari
  117432. */
  117433. static IsSafari(): boolean;
  117434. }
  117435. /**
  117436. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117437. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117438. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117439. * @param name The name of the class, case should be preserved
  117440. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117441. */
  117442. export function className(name: string, module?: string): (target: Object) => void;
  117443. /**
  117444. * An implementation of a loop for asynchronous functions.
  117445. */
  117446. export class AsyncLoop {
  117447. /**
  117448. * Defines the number of iterations for the loop
  117449. */
  117450. iterations: number;
  117451. /**
  117452. * Defines the current index of the loop.
  117453. */
  117454. index: number;
  117455. private _done;
  117456. private _fn;
  117457. private _successCallback;
  117458. /**
  117459. * Constructor.
  117460. * @param iterations the number of iterations.
  117461. * @param func the function to run each iteration
  117462. * @param successCallback the callback that will be called upon succesful execution
  117463. * @param offset starting offset.
  117464. */
  117465. constructor(
  117466. /**
  117467. * Defines the number of iterations for the loop
  117468. */
  117469. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117470. /**
  117471. * Execute the next iteration. Must be called after the last iteration was finished.
  117472. */
  117473. executeNext(): void;
  117474. /**
  117475. * Break the loop and run the success callback.
  117476. */
  117477. breakLoop(): void;
  117478. /**
  117479. * Create and run an async loop.
  117480. * @param iterations the number of iterations.
  117481. * @param fn the function to run each iteration
  117482. * @param successCallback the callback that will be called upon succesful execution
  117483. * @param offset starting offset.
  117484. * @returns the created async loop object
  117485. */
  117486. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117487. /**
  117488. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117489. * @param iterations total number of iterations
  117490. * @param syncedIterations number of synchronous iterations in each async iteration.
  117491. * @param fn the function to call each iteration.
  117492. * @param callback a success call back that will be called when iterating stops.
  117493. * @param breakFunction a break condition (optional)
  117494. * @param timeout timeout settings for the setTimeout function. default - 0.
  117495. * @returns the created async loop object
  117496. */
  117497. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117498. }
  117499. }
  117500. declare module BABYLON {
  117501. /**
  117502. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117503. * The underlying implementation relies on an associative array to ensure the best performances.
  117504. * The value can be anything including 'null' but except 'undefined'
  117505. */
  117506. export class StringDictionary<T> {
  117507. /**
  117508. * This will clear this dictionary and copy the content from the 'source' one.
  117509. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117510. * @param source the dictionary to take the content from and copy to this dictionary
  117511. */
  117512. copyFrom(source: StringDictionary<T>): void;
  117513. /**
  117514. * Get a value based from its key
  117515. * @param key the given key to get the matching value from
  117516. * @return the value if found, otherwise undefined is returned
  117517. */
  117518. get(key: string): T | undefined;
  117519. /**
  117520. * Get a value from its key or add it if it doesn't exist.
  117521. * This method will ensure you that a given key/data will be present in the dictionary.
  117522. * @param key the given key to get the matching value from
  117523. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117524. * The factory will only be invoked if there's no data for the given key.
  117525. * @return the value corresponding to the key.
  117526. */
  117527. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117528. /**
  117529. * Get a value from its key if present in the dictionary otherwise add it
  117530. * @param key the key to get the value from
  117531. * @param val if there's no such key/value pair in the dictionary add it with this value
  117532. * @return the value corresponding to the key
  117533. */
  117534. getOrAdd(key: string, val: T): T;
  117535. /**
  117536. * Check if there's a given key in the dictionary
  117537. * @param key the key to check for
  117538. * @return true if the key is present, false otherwise
  117539. */
  117540. contains(key: string): boolean;
  117541. /**
  117542. * Add a new key and its corresponding value
  117543. * @param key the key to add
  117544. * @param value the value corresponding to the key
  117545. * @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
  117546. */
  117547. add(key: string, value: T): boolean;
  117548. /**
  117549. * Update a specific value associated to a key
  117550. * @param key defines the key to use
  117551. * @param value defines the value to store
  117552. * @returns true if the value was updated (or false if the key was not found)
  117553. */
  117554. set(key: string, value: T): boolean;
  117555. /**
  117556. * Get the element of the given key and remove it from the dictionary
  117557. * @param key defines the key to search
  117558. * @returns the value associated with the key or null if not found
  117559. */
  117560. getAndRemove(key: string): Nullable<T>;
  117561. /**
  117562. * Remove a key/value from the dictionary.
  117563. * @param key the key to remove
  117564. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117565. */
  117566. remove(key: string): boolean;
  117567. /**
  117568. * Clear the whole content of the dictionary
  117569. */
  117570. clear(): void;
  117571. /**
  117572. * Gets the current count
  117573. */
  117574. get count(): number;
  117575. /**
  117576. * Execute a callback on each key/val of the dictionary.
  117577. * Note that you can remove any element in this dictionary in the callback implementation
  117578. * @param callback the callback to execute on a given key/value pair
  117579. */
  117580. forEach(callback: (key: string, val: T) => void): void;
  117581. /**
  117582. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117583. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117584. * Note that you can remove any element in this dictionary in the callback implementation
  117585. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117586. * @returns the first item
  117587. */
  117588. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117589. private _count;
  117590. private _data;
  117591. }
  117592. }
  117593. declare module BABYLON {
  117594. /** @hidden */
  117595. export interface ICollisionCoordinator {
  117596. createCollider(): Collider;
  117597. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117598. init(scene: Scene): void;
  117599. }
  117600. /** @hidden */
  117601. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117602. private _scene;
  117603. private _scaledPosition;
  117604. private _scaledVelocity;
  117605. private _finalPosition;
  117606. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117607. createCollider(): Collider;
  117608. init(scene: Scene): void;
  117609. private _collideWithWorld;
  117610. }
  117611. }
  117612. declare module BABYLON {
  117613. /**
  117614. * Class used to manage all inputs for the scene.
  117615. */
  117616. export class InputManager {
  117617. /** The distance in pixel that you have to move to prevent some events */
  117618. static DragMovementThreshold: number;
  117619. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117620. static LongPressDelay: number;
  117621. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117622. static DoubleClickDelay: number;
  117623. /** If you need to check double click without raising a single click at first click, enable this flag */
  117624. static ExclusiveDoubleClickMode: boolean;
  117625. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  117626. private _alreadyAttached;
  117627. private _wheelEventName;
  117628. private _onPointerMove;
  117629. private _onPointerDown;
  117630. private _onPointerUp;
  117631. private _initClickEvent;
  117632. private _initActionManager;
  117633. private _delayedSimpleClick;
  117634. private _delayedSimpleClickTimeout;
  117635. private _previousDelayedSimpleClickTimeout;
  117636. private _meshPickProceed;
  117637. private _previousButtonPressed;
  117638. private _currentPickResult;
  117639. private _previousPickResult;
  117640. private _totalPointersPressed;
  117641. private _doubleClickOccured;
  117642. private _pointerOverMesh;
  117643. private _pickedDownMesh;
  117644. private _pickedUpMesh;
  117645. private _pointerX;
  117646. private _pointerY;
  117647. private _unTranslatedPointerX;
  117648. private _unTranslatedPointerY;
  117649. private _startingPointerPosition;
  117650. private _previousStartingPointerPosition;
  117651. private _startingPointerTime;
  117652. private _previousStartingPointerTime;
  117653. private _pointerCaptures;
  117654. private _onKeyDown;
  117655. private _onKeyUp;
  117656. private _onCanvasFocusObserver;
  117657. private _onCanvasBlurObserver;
  117658. private _scene;
  117659. /**
  117660. * Creates a new InputManager
  117661. * @param scene defines the hosting scene
  117662. */
  117663. constructor(scene: Scene);
  117664. /**
  117665. * Gets the mesh that is currently under the pointer
  117666. */
  117667. get meshUnderPointer(): Nullable<AbstractMesh>;
  117668. /**
  117669. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117670. */
  117671. get unTranslatedPointer(): Vector2;
  117672. /**
  117673. * Gets or sets the current on-screen X position of the pointer
  117674. */
  117675. get pointerX(): number;
  117676. set pointerX(value: number);
  117677. /**
  117678. * Gets or sets the current on-screen Y position of the pointer
  117679. */
  117680. get pointerY(): number;
  117681. set pointerY(value: number);
  117682. private _updatePointerPosition;
  117683. private _processPointerMove;
  117684. private _setRayOnPointerInfo;
  117685. private _checkPrePointerObservable;
  117686. /**
  117687. * Use this method to simulate a pointer move on a mesh
  117688. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117689. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117690. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117691. */
  117692. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117693. /**
  117694. * Use this method to simulate a pointer down on a mesh
  117695. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117696. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117697. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117698. */
  117699. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117700. private _processPointerDown;
  117701. /** @hidden */
  117702. _isPointerSwiping(): boolean;
  117703. /**
  117704. * Use this method to simulate a pointer up on a mesh
  117705. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117706. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117707. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117708. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117709. */
  117710. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117711. private _processPointerUp;
  117712. /**
  117713. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117714. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117715. * @returns true if the pointer was captured
  117716. */
  117717. isPointerCaptured(pointerId?: number): boolean;
  117718. /**
  117719. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117720. * @param attachUp defines if you want to attach events to pointerup
  117721. * @param attachDown defines if you want to attach events to pointerdown
  117722. * @param attachMove defines if you want to attach events to pointermove
  117723. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117724. */
  117725. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117726. /**
  117727. * Detaches all event handlers
  117728. */
  117729. detachControl(): void;
  117730. /**
  117731. * Force the value of meshUnderPointer
  117732. * @param mesh defines the mesh to use
  117733. */
  117734. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117735. /**
  117736. * Gets the mesh under the pointer
  117737. * @returns a Mesh or null if no mesh is under the pointer
  117738. */
  117739. getPointerOverMesh(): Nullable<AbstractMesh>;
  117740. }
  117741. }
  117742. declare module BABYLON {
  117743. /**
  117744. * This class defines the direct association between an animation and a target
  117745. */
  117746. export class TargetedAnimation {
  117747. /**
  117748. * Animation to perform
  117749. */
  117750. animation: Animation;
  117751. /**
  117752. * Target to animate
  117753. */
  117754. target: any;
  117755. /**
  117756. * Returns the string "TargetedAnimation"
  117757. * @returns "TargetedAnimation"
  117758. */
  117759. getClassName(): string;
  117760. /**
  117761. * Serialize the object
  117762. * @returns the JSON object representing the current entity
  117763. */
  117764. serialize(): any;
  117765. }
  117766. /**
  117767. * Use this class to create coordinated animations on multiple targets
  117768. */
  117769. export class AnimationGroup implements IDisposable {
  117770. /** The name of the animation group */
  117771. name: string;
  117772. private _scene;
  117773. private _targetedAnimations;
  117774. private _animatables;
  117775. private _from;
  117776. private _to;
  117777. private _isStarted;
  117778. private _isPaused;
  117779. private _speedRatio;
  117780. private _loopAnimation;
  117781. private _isAdditive;
  117782. /**
  117783. * Gets or sets the unique id of the node
  117784. */
  117785. uniqueId: number;
  117786. /**
  117787. * This observable will notify when one animation have ended
  117788. */
  117789. onAnimationEndObservable: Observable<TargetedAnimation>;
  117790. /**
  117791. * Observer raised when one animation loops
  117792. */
  117793. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117794. /**
  117795. * Observer raised when all animations have looped
  117796. */
  117797. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117798. /**
  117799. * This observable will notify when all animations have ended.
  117800. */
  117801. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  117802. /**
  117803. * This observable will notify when all animations have paused.
  117804. */
  117805. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  117806. /**
  117807. * This observable will notify when all animations are playing.
  117808. */
  117809. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  117810. /**
  117811. * Gets the first frame
  117812. */
  117813. get from(): number;
  117814. /**
  117815. * Gets the last frame
  117816. */
  117817. get to(): number;
  117818. /**
  117819. * Define if the animations are started
  117820. */
  117821. get isStarted(): boolean;
  117822. /**
  117823. * Gets a value indicating that the current group is playing
  117824. */
  117825. get isPlaying(): boolean;
  117826. /**
  117827. * Gets or sets the speed ratio to use for all animations
  117828. */
  117829. get speedRatio(): number;
  117830. /**
  117831. * Gets or sets the speed ratio to use for all animations
  117832. */
  117833. set speedRatio(value: number);
  117834. /**
  117835. * Gets or sets if all animations should loop or not
  117836. */
  117837. get loopAnimation(): boolean;
  117838. set loopAnimation(value: boolean);
  117839. /**
  117840. * Gets or sets if all animations should be evaluated additively
  117841. */
  117842. get isAdditive(): boolean;
  117843. set isAdditive(value: boolean);
  117844. /**
  117845. * Gets the targeted animations for this animation group
  117846. */
  117847. get targetedAnimations(): Array<TargetedAnimation>;
  117848. /**
  117849. * returning the list of animatables controlled by this animation group.
  117850. */
  117851. get animatables(): Array<Animatable>;
  117852. /**
  117853. * Gets the list of target animations
  117854. */
  117855. get children(): TargetedAnimation[];
  117856. /**
  117857. * Instantiates a new Animation Group.
  117858. * This helps managing several animations at once.
  117859. * @see https://doc.babylonjs.com/how_to/group
  117860. * @param name Defines the name of the group
  117861. * @param scene Defines the scene the group belongs to
  117862. */
  117863. constructor(
  117864. /** The name of the animation group */
  117865. name: string, scene?: Nullable<Scene>);
  117866. /**
  117867. * Add an animation (with its target) in the group
  117868. * @param animation defines the animation we want to add
  117869. * @param target defines the target of the animation
  117870. * @returns the TargetedAnimation object
  117871. */
  117872. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  117873. /**
  117874. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  117875. * It can add constant keys at begin or end
  117876. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  117877. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  117878. * @returns the animation group
  117879. */
  117880. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  117881. private _animationLoopCount;
  117882. private _animationLoopFlags;
  117883. private _processLoop;
  117884. /**
  117885. * Start all animations on given targets
  117886. * @param loop defines if animations must loop
  117887. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  117888. * @param from defines the from key (optional)
  117889. * @param to defines the to key (optional)
  117890. * @param isAdditive defines the additive state for the resulting animatables (optional)
  117891. * @returns the current animation group
  117892. */
  117893. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  117894. /**
  117895. * Pause all animations
  117896. * @returns the animation group
  117897. */
  117898. pause(): AnimationGroup;
  117899. /**
  117900. * Play all animations to initial state
  117901. * This function will start() the animations if they were not started or will restart() them if they were paused
  117902. * @param loop defines if animations must loop
  117903. * @returns the animation group
  117904. */
  117905. play(loop?: boolean): AnimationGroup;
  117906. /**
  117907. * Reset all animations to initial state
  117908. * @returns the animation group
  117909. */
  117910. reset(): AnimationGroup;
  117911. /**
  117912. * Restart animations from key 0
  117913. * @returns the animation group
  117914. */
  117915. restart(): AnimationGroup;
  117916. /**
  117917. * Stop all animations
  117918. * @returns the animation group
  117919. */
  117920. stop(): AnimationGroup;
  117921. /**
  117922. * Set animation weight for all animatables
  117923. * @param weight defines the weight to use
  117924. * @return the animationGroup
  117925. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117926. */
  117927. setWeightForAllAnimatables(weight: number): AnimationGroup;
  117928. /**
  117929. * Synchronize and normalize all animatables with a source animatable
  117930. * @param root defines the root animatable to synchronize with
  117931. * @return the animationGroup
  117932. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  117933. */
  117934. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  117935. /**
  117936. * Goes to a specific frame in this animation group
  117937. * @param frame the frame number to go to
  117938. * @return the animationGroup
  117939. */
  117940. goToFrame(frame: number): AnimationGroup;
  117941. /**
  117942. * Dispose all associated resources
  117943. */
  117944. dispose(): void;
  117945. private _checkAnimationGroupEnded;
  117946. /**
  117947. * Clone the current animation group and returns a copy
  117948. * @param newName defines the name of the new group
  117949. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  117950. * @returns the new aniamtion group
  117951. */
  117952. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  117953. /**
  117954. * Serializes the animationGroup to an object
  117955. * @returns Serialized object
  117956. */
  117957. serialize(): any;
  117958. /**
  117959. * Returns a new AnimationGroup object parsed from the source provided.
  117960. * @param parsedAnimationGroup defines the source
  117961. * @param scene defines the scene that will receive the animationGroup
  117962. * @returns a new AnimationGroup
  117963. */
  117964. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  117965. /**
  117966. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  117967. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  117968. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  117969. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  117970. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  117971. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  117972. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  117973. */
  117974. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  117975. /**
  117976. * Returns the string "AnimationGroup"
  117977. * @returns "AnimationGroup"
  117978. */
  117979. getClassName(): string;
  117980. /**
  117981. * Creates a detailled string about the object
  117982. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  117983. * @returns a string representing the object
  117984. */
  117985. toString(fullDetails?: boolean): string;
  117986. }
  117987. }
  117988. declare module BABYLON {
  117989. /**
  117990. * Define an interface for all classes that will hold resources
  117991. */
  117992. export interface IDisposable {
  117993. /**
  117994. * Releases all held resources
  117995. */
  117996. dispose(): void;
  117997. }
  117998. /** Interface defining initialization parameters for Scene class */
  117999. export interface SceneOptions {
  118000. /**
  118001. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118002. * It will improve performance when the number of geometries becomes important.
  118003. */
  118004. useGeometryUniqueIdsMap?: boolean;
  118005. /**
  118006. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118007. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118008. */
  118009. useMaterialMeshMap?: boolean;
  118010. /**
  118011. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118012. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118013. */
  118014. useClonedMeshMap?: boolean;
  118015. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118016. virtual?: boolean;
  118017. }
  118018. /**
  118019. * Represents a scene to be rendered by the engine.
  118020. * @see https://doc.babylonjs.com/features/scene
  118021. */
  118022. export class Scene extends AbstractScene implements IAnimatable {
  118023. /** The fog is deactivated */
  118024. static readonly FOGMODE_NONE: number;
  118025. /** The fog density is following an exponential function */
  118026. static readonly FOGMODE_EXP: number;
  118027. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118028. static readonly FOGMODE_EXP2: number;
  118029. /** The fog density is following a linear function. */
  118030. static readonly FOGMODE_LINEAR: number;
  118031. /**
  118032. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118033. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118034. */
  118035. static MinDeltaTime: number;
  118036. /**
  118037. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118038. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118039. */
  118040. static MaxDeltaTime: number;
  118041. /**
  118042. * Factory used to create the default material.
  118043. * @param name The name of the material to create
  118044. * @param scene The scene to create the material for
  118045. * @returns The default material
  118046. */
  118047. static DefaultMaterialFactory(scene: Scene): Material;
  118048. /**
  118049. * Factory used to create the a collision coordinator.
  118050. * @returns The collision coordinator
  118051. */
  118052. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118053. /** @hidden */
  118054. _inputManager: InputManager;
  118055. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118056. cameraToUseForPointers: Nullable<Camera>;
  118057. /** @hidden */
  118058. readonly _isScene: boolean;
  118059. /** @hidden */
  118060. _blockEntityCollection: boolean;
  118061. /**
  118062. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118063. */
  118064. autoClear: boolean;
  118065. /**
  118066. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118067. */
  118068. autoClearDepthAndStencil: boolean;
  118069. /**
  118070. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118071. */
  118072. clearColor: Color4;
  118073. /**
  118074. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118075. */
  118076. ambientColor: Color3;
  118077. /**
  118078. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118079. * It should only be one of the following (if not the default embedded one):
  118080. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118081. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118082. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118083. * The material properties need to be setup according to the type of texture in use.
  118084. */
  118085. environmentBRDFTexture: BaseTexture;
  118086. /** @hidden */
  118087. protected _environmentTexture: Nullable<BaseTexture>;
  118088. /**
  118089. * Texture used in all pbr material as the reflection texture.
  118090. * As in the majority of the scene they are the same (exception for multi room and so on),
  118091. * this is easier to reference from here than from all the materials.
  118092. */
  118093. get environmentTexture(): Nullable<BaseTexture>;
  118094. /**
  118095. * Texture used in all pbr material as the reflection texture.
  118096. * As in the majority of the scene they are the same (exception for multi room and so on),
  118097. * this is easier to set here than in all the materials.
  118098. */
  118099. set environmentTexture(value: Nullable<BaseTexture>);
  118100. /** @hidden */
  118101. protected _environmentIntensity: number;
  118102. /**
  118103. * Intensity of the environment in all pbr material.
  118104. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118105. * As in the majority of the scene they are the same (exception for multi room and so on),
  118106. * this is easier to reference from here than from all the materials.
  118107. */
  118108. get environmentIntensity(): number;
  118109. /**
  118110. * Intensity of the environment in all pbr material.
  118111. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118112. * As in the majority of the scene they are the same (exception for multi room and so on),
  118113. * this is easier to set here than in all the materials.
  118114. */
  118115. set environmentIntensity(value: number);
  118116. /** @hidden */
  118117. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118118. /**
  118119. * Default image processing configuration used either in the rendering
  118120. * Forward main pass or through the imageProcessingPostProcess if present.
  118121. * As in the majority of the scene they are the same (exception for multi camera),
  118122. * this is easier to reference from here than from all the materials and post process.
  118123. *
  118124. * No setter as we it is a shared configuration, you can set the values instead.
  118125. */
  118126. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118127. private _forceWireframe;
  118128. /**
  118129. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118130. */
  118131. set forceWireframe(value: boolean);
  118132. get forceWireframe(): boolean;
  118133. private _skipFrustumClipping;
  118134. /**
  118135. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118136. */
  118137. set skipFrustumClipping(value: boolean);
  118138. get skipFrustumClipping(): boolean;
  118139. private _forcePointsCloud;
  118140. /**
  118141. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118142. */
  118143. set forcePointsCloud(value: boolean);
  118144. get forcePointsCloud(): boolean;
  118145. /**
  118146. * Gets or sets the active clipplane 1
  118147. */
  118148. clipPlane: Nullable<Plane>;
  118149. /**
  118150. * Gets or sets the active clipplane 2
  118151. */
  118152. clipPlane2: Nullable<Plane>;
  118153. /**
  118154. * Gets or sets the active clipplane 3
  118155. */
  118156. clipPlane3: Nullable<Plane>;
  118157. /**
  118158. * Gets or sets the active clipplane 4
  118159. */
  118160. clipPlane4: Nullable<Plane>;
  118161. /**
  118162. * Gets or sets the active clipplane 5
  118163. */
  118164. clipPlane5: Nullable<Plane>;
  118165. /**
  118166. * Gets or sets the active clipplane 6
  118167. */
  118168. clipPlane6: Nullable<Plane>;
  118169. /**
  118170. * Gets or sets a boolean indicating if animations are enabled
  118171. */
  118172. animationsEnabled: boolean;
  118173. private _animationPropertiesOverride;
  118174. /**
  118175. * Gets or sets the animation properties override
  118176. */
  118177. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118178. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118179. /**
  118180. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118181. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118182. */
  118183. useConstantAnimationDeltaTime: boolean;
  118184. /**
  118185. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118186. * Please note that it requires to run a ray cast through the scene on every frame
  118187. */
  118188. constantlyUpdateMeshUnderPointer: boolean;
  118189. /**
  118190. * Defines the HTML cursor to use when hovering over interactive elements
  118191. */
  118192. hoverCursor: string;
  118193. /**
  118194. * Defines the HTML default cursor to use (empty by default)
  118195. */
  118196. defaultCursor: string;
  118197. /**
  118198. * Defines whether cursors are handled by the scene.
  118199. */
  118200. doNotHandleCursors: boolean;
  118201. /**
  118202. * This is used to call preventDefault() on pointer down
  118203. * in order to block unwanted artifacts like system double clicks
  118204. */
  118205. preventDefaultOnPointerDown: boolean;
  118206. /**
  118207. * This is used to call preventDefault() on pointer up
  118208. * in order to block unwanted artifacts like system double clicks
  118209. */
  118210. preventDefaultOnPointerUp: boolean;
  118211. /**
  118212. * Gets or sets user defined metadata
  118213. */
  118214. metadata: any;
  118215. /**
  118216. * For internal use only. Please do not use.
  118217. */
  118218. reservedDataStore: any;
  118219. /**
  118220. * Gets the name of the plugin used to load this scene (null by default)
  118221. */
  118222. loadingPluginName: string;
  118223. /**
  118224. * Use this array to add regular expressions used to disable offline support for specific urls
  118225. */
  118226. disableOfflineSupportExceptionRules: RegExp[];
  118227. /**
  118228. * An event triggered when the scene is disposed.
  118229. */
  118230. onDisposeObservable: Observable<Scene>;
  118231. private _onDisposeObserver;
  118232. /** Sets a function to be executed when this scene is disposed. */
  118233. set onDispose(callback: () => void);
  118234. /**
  118235. * An event triggered before rendering the scene (right after animations and physics)
  118236. */
  118237. onBeforeRenderObservable: Observable<Scene>;
  118238. private _onBeforeRenderObserver;
  118239. /** Sets a function to be executed before rendering this scene */
  118240. set beforeRender(callback: Nullable<() => void>);
  118241. /**
  118242. * An event triggered after rendering the scene
  118243. */
  118244. onAfterRenderObservable: Observable<Scene>;
  118245. /**
  118246. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118247. */
  118248. onAfterRenderCameraObservable: Observable<Camera>;
  118249. private _onAfterRenderObserver;
  118250. /** Sets a function to be executed after rendering this scene */
  118251. set afterRender(callback: Nullable<() => void>);
  118252. /**
  118253. * An event triggered before animating the scene
  118254. */
  118255. onBeforeAnimationsObservable: Observable<Scene>;
  118256. /**
  118257. * An event triggered after animations processing
  118258. */
  118259. onAfterAnimationsObservable: Observable<Scene>;
  118260. /**
  118261. * An event triggered before draw calls are ready to be sent
  118262. */
  118263. onBeforeDrawPhaseObservable: Observable<Scene>;
  118264. /**
  118265. * An event triggered after draw calls have been sent
  118266. */
  118267. onAfterDrawPhaseObservable: Observable<Scene>;
  118268. /**
  118269. * An event triggered when the scene is ready
  118270. */
  118271. onReadyObservable: Observable<Scene>;
  118272. /**
  118273. * An event triggered before rendering a camera
  118274. */
  118275. onBeforeCameraRenderObservable: Observable<Camera>;
  118276. private _onBeforeCameraRenderObserver;
  118277. /** Sets a function to be executed before rendering a camera*/
  118278. set beforeCameraRender(callback: () => void);
  118279. /**
  118280. * An event triggered after rendering a camera
  118281. */
  118282. onAfterCameraRenderObservable: Observable<Camera>;
  118283. private _onAfterCameraRenderObserver;
  118284. /** Sets a function to be executed after rendering a camera*/
  118285. set afterCameraRender(callback: () => void);
  118286. /**
  118287. * An event triggered when active meshes evaluation is about to start
  118288. */
  118289. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118290. /**
  118291. * An event triggered when active meshes evaluation is done
  118292. */
  118293. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118294. /**
  118295. * An event triggered when particles rendering is about to start
  118296. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118297. */
  118298. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118299. /**
  118300. * An event triggered when particles rendering is done
  118301. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118302. */
  118303. onAfterParticlesRenderingObservable: Observable<Scene>;
  118304. /**
  118305. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118306. */
  118307. onDataLoadedObservable: Observable<Scene>;
  118308. /**
  118309. * An event triggered when a camera is created
  118310. */
  118311. onNewCameraAddedObservable: Observable<Camera>;
  118312. /**
  118313. * An event triggered when a camera is removed
  118314. */
  118315. onCameraRemovedObservable: Observable<Camera>;
  118316. /**
  118317. * An event triggered when a light is created
  118318. */
  118319. onNewLightAddedObservable: Observable<Light>;
  118320. /**
  118321. * An event triggered when a light is removed
  118322. */
  118323. onLightRemovedObservable: Observable<Light>;
  118324. /**
  118325. * An event triggered when a geometry is created
  118326. */
  118327. onNewGeometryAddedObservable: Observable<Geometry>;
  118328. /**
  118329. * An event triggered when a geometry is removed
  118330. */
  118331. onGeometryRemovedObservable: Observable<Geometry>;
  118332. /**
  118333. * An event triggered when a transform node is created
  118334. */
  118335. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118336. /**
  118337. * An event triggered when a transform node is removed
  118338. */
  118339. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118340. /**
  118341. * An event triggered when a mesh is created
  118342. */
  118343. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118344. /**
  118345. * An event triggered when a mesh is removed
  118346. */
  118347. onMeshRemovedObservable: Observable<AbstractMesh>;
  118348. /**
  118349. * An event triggered when a skeleton is created
  118350. */
  118351. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118352. /**
  118353. * An event triggered when a skeleton is removed
  118354. */
  118355. onSkeletonRemovedObservable: Observable<Skeleton>;
  118356. /**
  118357. * An event triggered when a material is created
  118358. */
  118359. onNewMaterialAddedObservable: Observable<Material>;
  118360. /**
  118361. * An event triggered when a material is removed
  118362. */
  118363. onMaterialRemovedObservable: Observable<Material>;
  118364. /**
  118365. * An event triggered when a texture is created
  118366. */
  118367. onNewTextureAddedObservable: Observable<BaseTexture>;
  118368. /**
  118369. * An event triggered when a texture is removed
  118370. */
  118371. onTextureRemovedObservable: Observable<BaseTexture>;
  118372. /**
  118373. * An event triggered when render targets are about to be rendered
  118374. * Can happen multiple times per frame.
  118375. */
  118376. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118377. /**
  118378. * An event triggered when render targets were rendered.
  118379. * Can happen multiple times per frame.
  118380. */
  118381. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118382. /**
  118383. * An event triggered before calculating deterministic simulation step
  118384. */
  118385. onBeforeStepObservable: Observable<Scene>;
  118386. /**
  118387. * An event triggered after calculating deterministic simulation step
  118388. */
  118389. onAfterStepObservable: Observable<Scene>;
  118390. /**
  118391. * An event triggered when the activeCamera property is updated
  118392. */
  118393. onActiveCameraChanged: Observable<Scene>;
  118394. /**
  118395. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118396. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118397. * 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)
  118398. */
  118399. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118400. /**
  118401. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118402. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118403. * 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)
  118404. */
  118405. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118406. /**
  118407. * This Observable will when a mesh has been imported into the scene.
  118408. */
  118409. onMeshImportedObservable: Observable<AbstractMesh>;
  118410. /**
  118411. * This Observable will when an animation file has been imported into the scene.
  118412. */
  118413. onAnimationFileImportedObservable: Observable<Scene>;
  118414. /**
  118415. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118416. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118417. */
  118418. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118419. /** @hidden */
  118420. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118421. /**
  118422. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118423. */
  118424. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118425. /**
  118426. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118427. */
  118428. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118429. /**
  118430. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118431. */
  118432. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118433. /** Callback called when a pointer move is detected */
  118434. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118435. /** Callback called when a pointer down is detected */
  118436. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118437. /** Callback called when a pointer up is detected */
  118438. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118439. /** Callback called when a pointer pick is detected */
  118440. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118441. /**
  118442. * 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).
  118443. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118444. */
  118445. onPrePointerObservable: Observable<PointerInfoPre>;
  118446. /**
  118447. * Observable event triggered each time an input event is received from the rendering canvas
  118448. */
  118449. onPointerObservable: Observable<PointerInfo>;
  118450. /**
  118451. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118452. */
  118453. get unTranslatedPointer(): Vector2;
  118454. /**
  118455. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118456. */
  118457. static get DragMovementThreshold(): number;
  118458. static set DragMovementThreshold(value: number);
  118459. /**
  118460. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118461. */
  118462. static get LongPressDelay(): number;
  118463. static set LongPressDelay(value: number);
  118464. /**
  118465. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118466. */
  118467. static get DoubleClickDelay(): number;
  118468. static set DoubleClickDelay(value: number);
  118469. /** If you need to check double click without raising a single click at first click, enable this flag */
  118470. static get ExclusiveDoubleClickMode(): boolean;
  118471. static set ExclusiveDoubleClickMode(value: boolean);
  118472. /** @hidden */
  118473. _mirroredCameraPosition: Nullable<Vector3>;
  118474. /**
  118475. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118476. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118477. */
  118478. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118479. /**
  118480. * Observable event triggered each time an keyboard event is received from the hosting window
  118481. */
  118482. onKeyboardObservable: Observable<KeyboardInfo>;
  118483. private _useRightHandedSystem;
  118484. /**
  118485. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118486. */
  118487. set useRightHandedSystem(value: boolean);
  118488. get useRightHandedSystem(): boolean;
  118489. private _timeAccumulator;
  118490. private _currentStepId;
  118491. private _currentInternalStep;
  118492. /**
  118493. * Sets the step Id used by deterministic lock step
  118494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118495. * @param newStepId defines the step Id
  118496. */
  118497. setStepId(newStepId: number): void;
  118498. /**
  118499. * Gets the step Id used by deterministic lock step
  118500. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118501. * @returns the step Id
  118502. */
  118503. getStepId(): number;
  118504. /**
  118505. * Gets the internal step used by deterministic lock step
  118506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118507. * @returns the internal step
  118508. */
  118509. getInternalStep(): number;
  118510. private _fogEnabled;
  118511. /**
  118512. * Gets or sets a boolean indicating if fog is enabled on this scene
  118513. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118514. * (Default is true)
  118515. */
  118516. set fogEnabled(value: boolean);
  118517. get fogEnabled(): boolean;
  118518. private _fogMode;
  118519. /**
  118520. * Gets or sets the fog mode to use
  118521. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118522. * | mode | value |
  118523. * | --- | --- |
  118524. * | FOGMODE_NONE | 0 |
  118525. * | FOGMODE_EXP | 1 |
  118526. * | FOGMODE_EXP2 | 2 |
  118527. * | FOGMODE_LINEAR | 3 |
  118528. */
  118529. set fogMode(value: number);
  118530. get fogMode(): number;
  118531. /**
  118532. * Gets or sets the fog color to use
  118533. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118534. * (Default is Color3(0.2, 0.2, 0.3))
  118535. */
  118536. fogColor: Color3;
  118537. /**
  118538. * Gets or sets the fog density to use
  118539. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118540. * (Default is 0.1)
  118541. */
  118542. fogDensity: number;
  118543. /**
  118544. * Gets or sets the fog start distance to use
  118545. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118546. * (Default is 0)
  118547. */
  118548. fogStart: number;
  118549. /**
  118550. * Gets or sets the fog end distance to use
  118551. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118552. * (Default is 1000)
  118553. */
  118554. fogEnd: number;
  118555. /**
  118556. * Flag indicating that the frame buffer binding is handled by another component
  118557. */
  118558. prePass: boolean;
  118559. private _shadowsEnabled;
  118560. /**
  118561. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118562. */
  118563. set shadowsEnabled(value: boolean);
  118564. get shadowsEnabled(): boolean;
  118565. private _lightsEnabled;
  118566. /**
  118567. * Gets or sets a boolean indicating if lights are enabled on this scene
  118568. */
  118569. set lightsEnabled(value: boolean);
  118570. get lightsEnabled(): boolean;
  118571. /** All of the active cameras added to this scene. */
  118572. activeCameras: Camera[];
  118573. /** @hidden */
  118574. _activeCamera: Nullable<Camera>;
  118575. /** Gets or sets the current active camera */
  118576. get activeCamera(): Nullable<Camera>;
  118577. set activeCamera(value: Nullable<Camera>);
  118578. private _defaultMaterial;
  118579. /** The default material used on meshes when no material is affected */
  118580. get defaultMaterial(): Material;
  118581. /** The default material used on meshes when no material is affected */
  118582. set defaultMaterial(value: Material);
  118583. private _texturesEnabled;
  118584. /**
  118585. * Gets or sets a boolean indicating if textures are enabled on this scene
  118586. */
  118587. set texturesEnabled(value: boolean);
  118588. get texturesEnabled(): boolean;
  118589. /**
  118590. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118591. */
  118592. physicsEnabled: boolean;
  118593. /**
  118594. * Gets or sets a boolean indicating if particles are enabled on this scene
  118595. */
  118596. particlesEnabled: boolean;
  118597. /**
  118598. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118599. */
  118600. spritesEnabled: boolean;
  118601. private _skeletonsEnabled;
  118602. /**
  118603. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118604. */
  118605. set skeletonsEnabled(value: boolean);
  118606. get skeletonsEnabled(): boolean;
  118607. /**
  118608. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118609. */
  118610. lensFlaresEnabled: boolean;
  118611. /**
  118612. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118613. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118614. */
  118615. collisionsEnabled: boolean;
  118616. private _collisionCoordinator;
  118617. /** @hidden */
  118618. get collisionCoordinator(): ICollisionCoordinator;
  118619. /**
  118620. * Defines the gravity applied to this scene (used only for collisions)
  118621. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118622. */
  118623. gravity: Vector3;
  118624. /**
  118625. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118626. */
  118627. postProcessesEnabled: boolean;
  118628. /**
  118629. * The list of postprocesses added to the scene
  118630. */
  118631. postProcesses: PostProcess[];
  118632. /**
  118633. * Gets the current postprocess manager
  118634. */
  118635. postProcessManager: PostProcessManager;
  118636. /**
  118637. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118638. */
  118639. renderTargetsEnabled: boolean;
  118640. /**
  118641. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118642. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118643. */
  118644. dumpNextRenderTargets: boolean;
  118645. /**
  118646. * The list of user defined render targets added to the scene
  118647. */
  118648. customRenderTargets: RenderTargetTexture[];
  118649. /**
  118650. * Defines if texture loading must be delayed
  118651. * If true, textures will only be loaded when they need to be rendered
  118652. */
  118653. useDelayedTextureLoading: boolean;
  118654. /**
  118655. * Gets the list of meshes imported to the scene through SceneLoader
  118656. */
  118657. importedMeshesFiles: String[];
  118658. /**
  118659. * Gets or sets a boolean indicating if probes are enabled on this scene
  118660. */
  118661. probesEnabled: boolean;
  118662. /**
  118663. * Gets or sets the current offline provider to use to store scene data
  118664. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118665. */
  118666. offlineProvider: IOfflineProvider;
  118667. /**
  118668. * Gets or sets the action manager associated with the scene
  118669. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118670. */
  118671. actionManager: AbstractActionManager;
  118672. private _meshesForIntersections;
  118673. /**
  118674. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118675. */
  118676. proceduralTexturesEnabled: boolean;
  118677. private _engine;
  118678. private _totalVertices;
  118679. /** @hidden */
  118680. _activeIndices: PerfCounter;
  118681. /** @hidden */
  118682. _activeParticles: PerfCounter;
  118683. /** @hidden */
  118684. _activeBones: PerfCounter;
  118685. private _animationRatio;
  118686. /** @hidden */
  118687. _animationTimeLast: number;
  118688. /** @hidden */
  118689. _animationTime: number;
  118690. /**
  118691. * Gets or sets a general scale for animation speed
  118692. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118693. */
  118694. animationTimeScale: number;
  118695. /** @hidden */
  118696. _cachedMaterial: Nullable<Material>;
  118697. /** @hidden */
  118698. _cachedEffect: Nullable<Effect>;
  118699. /** @hidden */
  118700. _cachedVisibility: Nullable<number>;
  118701. private _renderId;
  118702. private _frameId;
  118703. private _executeWhenReadyTimeoutId;
  118704. private _intermediateRendering;
  118705. private _viewUpdateFlag;
  118706. private _projectionUpdateFlag;
  118707. /** @hidden */
  118708. _toBeDisposed: Nullable<IDisposable>[];
  118709. private _activeRequests;
  118710. /** @hidden */
  118711. _pendingData: any[];
  118712. private _isDisposed;
  118713. /**
  118714. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118715. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118716. */
  118717. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118718. private _activeMeshes;
  118719. private _processedMaterials;
  118720. private _renderTargets;
  118721. /** @hidden */
  118722. _activeParticleSystems: SmartArray<IParticleSystem>;
  118723. private _activeSkeletons;
  118724. private _softwareSkinnedMeshes;
  118725. private _renderingManager;
  118726. /** @hidden */
  118727. _activeAnimatables: Animatable[];
  118728. private _transformMatrix;
  118729. private _sceneUbo;
  118730. /** @hidden */
  118731. _viewMatrix: Matrix;
  118732. private _projectionMatrix;
  118733. /** @hidden */
  118734. _forcedViewPosition: Nullable<Vector3>;
  118735. /** @hidden */
  118736. _frustumPlanes: Plane[];
  118737. /**
  118738. * Gets the list of frustum planes (built from the active camera)
  118739. */
  118740. get frustumPlanes(): Plane[];
  118741. /**
  118742. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118743. * This is useful if there are more lights that the maximum simulteanous authorized
  118744. */
  118745. requireLightSorting: boolean;
  118746. /** @hidden */
  118747. readonly useMaterialMeshMap: boolean;
  118748. /** @hidden */
  118749. readonly useClonedMeshMap: boolean;
  118750. private _externalData;
  118751. private _uid;
  118752. /**
  118753. * @hidden
  118754. * Backing store of defined scene components.
  118755. */
  118756. _components: ISceneComponent[];
  118757. /**
  118758. * @hidden
  118759. * Backing store of defined scene components.
  118760. */
  118761. _serializableComponents: ISceneSerializableComponent[];
  118762. /**
  118763. * List of components to register on the next registration step.
  118764. */
  118765. private _transientComponents;
  118766. /**
  118767. * Registers the transient components if needed.
  118768. */
  118769. private _registerTransientComponents;
  118770. /**
  118771. * @hidden
  118772. * Add a component to the scene.
  118773. * Note that the ccomponent could be registered on th next frame if this is called after
  118774. * the register component stage.
  118775. * @param component Defines the component to add to the scene
  118776. */
  118777. _addComponent(component: ISceneComponent): void;
  118778. /**
  118779. * @hidden
  118780. * Gets a component from the scene.
  118781. * @param name defines the name of the component to retrieve
  118782. * @returns the component or null if not present
  118783. */
  118784. _getComponent(name: string): Nullable<ISceneComponent>;
  118785. /**
  118786. * @hidden
  118787. * Defines the actions happening before camera updates.
  118788. */
  118789. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118790. /**
  118791. * @hidden
  118792. * Defines the actions happening before clear the canvas.
  118793. */
  118794. _beforeClearStage: Stage<SimpleStageAction>;
  118795. /**
  118796. * @hidden
  118797. * Defines the actions when collecting render targets for the frame.
  118798. */
  118799. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118800. /**
  118801. * @hidden
  118802. * Defines the actions happening for one camera in the frame.
  118803. */
  118804. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118805. /**
  118806. * @hidden
  118807. * Defines the actions happening during the per mesh ready checks.
  118808. */
  118809. _isReadyForMeshStage: Stage<MeshStageAction>;
  118810. /**
  118811. * @hidden
  118812. * Defines the actions happening before evaluate active mesh checks.
  118813. */
  118814. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  118815. /**
  118816. * @hidden
  118817. * Defines the actions happening during the evaluate sub mesh checks.
  118818. */
  118819. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  118820. /**
  118821. * @hidden
  118822. * Defines the actions happening during the active mesh stage.
  118823. */
  118824. _activeMeshStage: Stage<ActiveMeshStageAction>;
  118825. /**
  118826. * @hidden
  118827. * Defines the actions happening during the per camera render target step.
  118828. */
  118829. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  118830. /**
  118831. * @hidden
  118832. * Defines the actions happening just before the active camera is drawing.
  118833. */
  118834. _beforeCameraDrawStage: Stage<CameraStageAction>;
  118835. /**
  118836. * @hidden
  118837. * Defines the actions happening just before a render target is drawing.
  118838. */
  118839. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118840. /**
  118841. * @hidden
  118842. * Defines the actions happening just before a rendering group is drawing.
  118843. */
  118844. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118845. /**
  118846. * @hidden
  118847. * Defines the actions happening just before a mesh is drawing.
  118848. */
  118849. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118850. /**
  118851. * @hidden
  118852. * Defines the actions happening just after a mesh has been drawn.
  118853. */
  118854. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118855. /**
  118856. * @hidden
  118857. * Defines the actions happening just after a rendering group has been drawn.
  118858. */
  118859. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118860. /**
  118861. * @hidden
  118862. * Defines the actions happening just after the active camera has been drawn.
  118863. */
  118864. _afterCameraDrawStage: Stage<CameraStageAction>;
  118865. /**
  118866. * @hidden
  118867. * Defines the actions happening just after a render target has been drawn.
  118868. */
  118869. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118870. /**
  118871. * @hidden
  118872. * Defines the actions happening just after rendering all cameras and computing intersections.
  118873. */
  118874. _afterRenderStage: Stage<SimpleStageAction>;
  118875. /**
  118876. * @hidden
  118877. * Defines the actions happening when a pointer move event happens.
  118878. */
  118879. _pointerMoveStage: Stage<PointerMoveStageAction>;
  118880. /**
  118881. * @hidden
  118882. * Defines the actions happening when a pointer down event happens.
  118883. */
  118884. _pointerDownStage: Stage<PointerUpDownStageAction>;
  118885. /**
  118886. * @hidden
  118887. * Defines the actions happening when a pointer up event happens.
  118888. */
  118889. _pointerUpStage: Stage<PointerUpDownStageAction>;
  118890. /**
  118891. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  118892. */
  118893. private geometriesByUniqueId;
  118894. /**
  118895. * Creates a new Scene
  118896. * @param engine defines the engine to use to render this scene
  118897. * @param options defines the scene options
  118898. */
  118899. constructor(engine: Engine, options?: SceneOptions);
  118900. /**
  118901. * Gets a string idenfifying the name of the class
  118902. * @returns "Scene" string
  118903. */
  118904. getClassName(): string;
  118905. private _defaultMeshCandidates;
  118906. /**
  118907. * @hidden
  118908. */
  118909. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118910. private _defaultSubMeshCandidates;
  118911. /**
  118912. * @hidden
  118913. */
  118914. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118915. /**
  118916. * Sets the default candidate providers for the scene.
  118917. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  118918. * and getCollidingSubMeshCandidates to their default function
  118919. */
  118920. setDefaultCandidateProviders(): void;
  118921. /**
  118922. * Gets the mesh that is currently under the pointer
  118923. */
  118924. get meshUnderPointer(): Nullable<AbstractMesh>;
  118925. /**
  118926. * Gets or sets the current on-screen X position of the pointer
  118927. */
  118928. get pointerX(): number;
  118929. set pointerX(value: number);
  118930. /**
  118931. * Gets or sets the current on-screen Y position of the pointer
  118932. */
  118933. get pointerY(): number;
  118934. set pointerY(value: number);
  118935. /**
  118936. * Gets the cached material (ie. the latest rendered one)
  118937. * @returns the cached material
  118938. */
  118939. getCachedMaterial(): Nullable<Material>;
  118940. /**
  118941. * Gets the cached effect (ie. the latest rendered one)
  118942. * @returns the cached effect
  118943. */
  118944. getCachedEffect(): Nullable<Effect>;
  118945. /**
  118946. * Gets the cached visibility state (ie. the latest rendered one)
  118947. * @returns the cached visibility state
  118948. */
  118949. getCachedVisibility(): Nullable<number>;
  118950. /**
  118951. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  118952. * @param material defines the current material
  118953. * @param effect defines the current effect
  118954. * @param visibility defines the current visibility state
  118955. * @returns true if one parameter is not cached
  118956. */
  118957. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  118958. /**
  118959. * Gets the engine associated with the scene
  118960. * @returns an Engine
  118961. */
  118962. getEngine(): Engine;
  118963. /**
  118964. * Gets the total number of vertices rendered per frame
  118965. * @returns the total number of vertices rendered per frame
  118966. */
  118967. getTotalVertices(): number;
  118968. /**
  118969. * Gets the performance counter for total vertices
  118970. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118971. */
  118972. get totalVerticesPerfCounter(): PerfCounter;
  118973. /**
  118974. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  118975. * @returns the total number of active indices rendered per frame
  118976. */
  118977. getActiveIndices(): number;
  118978. /**
  118979. * Gets the performance counter for active indices
  118980. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118981. */
  118982. get totalActiveIndicesPerfCounter(): PerfCounter;
  118983. /**
  118984. * Gets the total number of active particles rendered per frame
  118985. * @returns the total number of active particles rendered per frame
  118986. */
  118987. getActiveParticles(): number;
  118988. /**
  118989. * Gets the performance counter for active particles
  118990. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  118991. */
  118992. get activeParticlesPerfCounter(): PerfCounter;
  118993. /**
  118994. * Gets the total number of active bones rendered per frame
  118995. * @returns the total number of active bones rendered per frame
  118996. */
  118997. getActiveBones(): number;
  118998. /**
  118999. * Gets the performance counter for active bones
  119000. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119001. */
  119002. get activeBonesPerfCounter(): PerfCounter;
  119003. /**
  119004. * Gets the array of active meshes
  119005. * @returns an array of AbstractMesh
  119006. */
  119007. getActiveMeshes(): SmartArray<AbstractMesh>;
  119008. /**
  119009. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119010. * @returns a number
  119011. */
  119012. getAnimationRatio(): number;
  119013. /**
  119014. * Gets an unique Id for the current render phase
  119015. * @returns a number
  119016. */
  119017. getRenderId(): number;
  119018. /**
  119019. * Gets an unique Id for the current frame
  119020. * @returns a number
  119021. */
  119022. getFrameId(): number;
  119023. /** Call this function if you want to manually increment the render Id*/
  119024. incrementRenderId(): void;
  119025. private _createUbo;
  119026. /**
  119027. * Use this method to simulate a pointer move on a mesh
  119028. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119029. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119030. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119031. * @returns the current scene
  119032. */
  119033. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119034. /**
  119035. * Use this method to simulate a pointer down on a mesh
  119036. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119037. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119038. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119039. * @returns the current scene
  119040. */
  119041. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119042. /**
  119043. * Use this method to simulate a pointer up on a mesh
  119044. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119045. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119046. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119047. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119048. * @returns the current scene
  119049. */
  119050. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119051. /**
  119052. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119053. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119054. * @returns true if the pointer was captured
  119055. */
  119056. isPointerCaptured(pointerId?: number): boolean;
  119057. /**
  119058. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119059. * @param attachUp defines if you want to attach events to pointerup
  119060. * @param attachDown defines if you want to attach events to pointerdown
  119061. * @param attachMove defines if you want to attach events to pointermove
  119062. */
  119063. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119064. /** Detaches all event handlers*/
  119065. detachControl(): void;
  119066. /**
  119067. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119068. * Delay loaded resources are not taking in account
  119069. * @return true if all required resources are ready
  119070. */
  119071. isReady(): boolean;
  119072. /** Resets all cached information relative to material (including effect and visibility) */
  119073. resetCachedMaterial(): void;
  119074. /**
  119075. * Registers a function to be called before every frame render
  119076. * @param func defines the function to register
  119077. */
  119078. registerBeforeRender(func: () => void): void;
  119079. /**
  119080. * Unregisters a function called before every frame render
  119081. * @param func defines the function to unregister
  119082. */
  119083. unregisterBeforeRender(func: () => void): void;
  119084. /**
  119085. * Registers a function to be called after every frame render
  119086. * @param func defines the function to register
  119087. */
  119088. registerAfterRender(func: () => void): void;
  119089. /**
  119090. * Unregisters a function called after every frame render
  119091. * @param func defines the function to unregister
  119092. */
  119093. unregisterAfterRender(func: () => void): void;
  119094. private _executeOnceBeforeRender;
  119095. /**
  119096. * The provided function will run before render once and will be disposed afterwards.
  119097. * A timeout delay can be provided so that the function will be executed in N ms.
  119098. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119099. * @param func The function to be executed.
  119100. * @param timeout optional delay in ms
  119101. */
  119102. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119103. /** @hidden */
  119104. _addPendingData(data: any): void;
  119105. /** @hidden */
  119106. _removePendingData(data: any): void;
  119107. /**
  119108. * Returns the number of items waiting to be loaded
  119109. * @returns the number of items waiting to be loaded
  119110. */
  119111. getWaitingItemsCount(): number;
  119112. /**
  119113. * Returns a boolean indicating if the scene is still loading data
  119114. */
  119115. get isLoading(): boolean;
  119116. /**
  119117. * Registers a function to be executed when the scene is ready
  119118. * @param {Function} func - the function to be executed
  119119. */
  119120. executeWhenReady(func: () => void): void;
  119121. /**
  119122. * Returns a promise that resolves when the scene is ready
  119123. * @returns A promise that resolves when the scene is ready
  119124. */
  119125. whenReadyAsync(): Promise<void>;
  119126. /** @hidden */
  119127. _checkIsReady(): void;
  119128. /**
  119129. * Gets all animatable attached to the scene
  119130. */
  119131. get animatables(): Animatable[];
  119132. /**
  119133. * Resets the last animation time frame.
  119134. * Useful to override when animations start running when loading a scene for the first time.
  119135. */
  119136. resetLastAnimationTimeFrame(): void;
  119137. /**
  119138. * Gets the current view matrix
  119139. * @returns a Matrix
  119140. */
  119141. getViewMatrix(): Matrix;
  119142. /**
  119143. * Gets the current projection matrix
  119144. * @returns a Matrix
  119145. */
  119146. getProjectionMatrix(): Matrix;
  119147. /**
  119148. * Gets the current transform matrix
  119149. * @returns a Matrix made of View * Projection
  119150. */
  119151. getTransformMatrix(): Matrix;
  119152. /**
  119153. * Sets the current transform matrix
  119154. * @param viewL defines the View matrix to use
  119155. * @param projectionL defines the Projection matrix to use
  119156. * @param viewR defines the right View matrix to use (if provided)
  119157. * @param projectionR defines the right Projection matrix to use (if provided)
  119158. */
  119159. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119160. /**
  119161. * Gets the uniform buffer used to store scene data
  119162. * @returns a UniformBuffer
  119163. */
  119164. getSceneUniformBuffer(): UniformBuffer;
  119165. /**
  119166. * Gets an unique (relatively to the current scene) Id
  119167. * @returns an unique number for the scene
  119168. */
  119169. getUniqueId(): number;
  119170. /**
  119171. * Add a mesh to the list of scene's meshes
  119172. * @param newMesh defines the mesh to add
  119173. * @param recursive if all child meshes should also be added to the scene
  119174. */
  119175. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119176. /**
  119177. * Remove a mesh for the list of scene's meshes
  119178. * @param toRemove defines the mesh to remove
  119179. * @param recursive if all child meshes should also be removed from the scene
  119180. * @returns the index where the mesh was in the mesh list
  119181. */
  119182. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119183. /**
  119184. * Add a transform node to the list of scene's transform nodes
  119185. * @param newTransformNode defines the transform node to add
  119186. */
  119187. addTransformNode(newTransformNode: TransformNode): void;
  119188. /**
  119189. * Remove a transform node for the list of scene's transform nodes
  119190. * @param toRemove defines the transform node to remove
  119191. * @returns the index where the transform node was in the transform node list
  119192. */
  119193. removeTransformNode(toRemove: TransformNode): number;
  119194. /**
  119195. * Remove a skeleton for the list of scene's skeletons
  119196. * @param toRemove defines the skeleton to remove
  119197. * @returns the index where the skeleton was in the skeleton list
  119198. */
  119199. removeSkeleton(toRemove: Skeleton): number;
  119200. /**
  119201. * Remove a morph target for the list of scene's morph targets
  119202. * @param toRemove defines the morph target to remove
  119203. * @returns the index where the morph target was in the morph target list
  119204. */
  119205. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119206. /**
  119207. * Remove a light for the list of scene's lights
  119208. * @param toRemove defines the light to remove
  119209. * @returns the index where the light was in the light list
  119210. */
  119211. removeLight(toRemove: Light): number;
  119212. /**
  119213. * Remove a camera for the list of scene's cameras
  119214. * @param toRemove defines the camera to remove
  119215. * @returns the index where the camera was in the camera list
  119216. */
  119217. removeCamera(toRemove: Camera): number;
  119218. /**
  119219. * Remove a particle system for the list of scene's particle systems
  119220. * @param toRemove defines the particle system to remove
  119221. * @returns the index where the particle system was in the particle system list
  119222. */
  119223. removeParticleSystem(toRemove: IParticleSystem): number;
  119224. /**
  119225. * Remove a animation for the list of scene's animations
  119226. * @param toRemove defines the animation to remove
  119227. * @returns the index where the animation was in the animation list
  119228. */
  119229. removeAnimation(toRemove: Animation): number;
  119230. /**
  119231. * Will stop the animation of the given target
  119232. * @param target - the target
  119233. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119234. * @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)
  119235. */
  119236. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119237. /**
  119238. * Removes the given animation group from this scene.
  119239. * @param toRemove The animation group to remove
  119240. * @returns The index of the removed animation group
  119241. */
  119242. removeAnimationGroup(toRemove: AnimationGroup): number;
  119243. /**
  119244. * Removes the given multi-material from this scene.
  119245. * @param toRemove The multi-material to remove
  119246. * @returns The index of the removed multi-material
  119247. */
  119248. removeMultiMaterial(toRemove: MultiMaterial): number;
  119249. /**
  119250. * Removes the given material from this scene.
  119251. * @param toRemove The material to remove
  119252. * @returns The index of the removed material
  119253. */
  119254. removeMaterial(toRemove: Material): number;
  119255. /**
  119256. * Removes the given action manager from this scene.
  119257. * @param toRemove The action manager to remove
  119258. * @returns The index of the removed action manager
  119259. */
  119260. removeActionManager(toRemove: AbstractActionManager): number;
  119261. /**
  119262. * Removes the given texture from this scene.
  119263. * @param toRemove The texture to remove
  119264. * @returns The index of the removed texture
  119265. */
  119266. removeTexture(toRemove: BaseTexture): number;
  119267. /**
  119268. * Adds the given light to this scene
  119269. * @param newLight The light to add
  119270. */
  119271. addLight(newLight: Light): void;
  119272. /**
  119273. * Sorts the list list based on light priorities
  119274. */
  119275. sortLightsByPriority(): void;
  119276. /**
  119277. * Adds the given camera to this scene
  119278. * @param newCamera The camera to add
  119279. */
  119280. addCamera(newCamera: Camera): void;
  119281. /**
  119282. * Adds the given skeleton to this scene
  119283. * @param newSkeleton The skeleton to add
  119284. */
  119285. addSkeleton(newSkeleton: Skeleton): void;
  119286. /**
  119287. * Adds the given particle system to this scene
  119288. * @param newParticleSystem The particle system to add
  119289. */
  119290. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119291. /**
  119292. * Adds the given animation to this scene
  119293. * @param newAnimation The animation to add
  119294. */
  119295. addAnimation(newAnimation: Animation): void;
  119296. /**
  119297. * Adds the given animation group to this scene.
  119298. * @param newAnimationGroup The animation group to add
  119299. */
  119300. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119301. /**
  119302. * Adds the given multi-material to this scene
  119303. * @param newMultiMaterial The multi-material to add
  119304. */
  119305. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119306. /**
  119307. * Adds the given material to this scene
  119308. * @param newMaterial The material to add
  119309. */
  119310. addMaterial(newMaterial: Material): void;
  119311. /**
  119312. * Adds the given morph target to this scene
  119313. * @param newMorphTargetManager The morph target to add
  119314. */
  119315. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119316. /**
  119317. * Adds the given geometry to this scene
  119318. * @param newGeometry The geometry to add
  119319. */
  119320. addGeometry(newGeometry: Geometry): void;
  119321. /**
  119322. * Adds the given action manager to this scene
  119323. * @param newActionManager The action manager to add
  119324. */
  119325. addActionManager(newActionManager: AbstractActionManager): void;
  119326. /**
  119327. * Adds the given texture to this scene.
  119328. * @param newTexture The texture to add
  119329. */
  119330. addTexture(newTexture: BaseTexture): void;
  119331. /**
  119332. * Switch active camera
  119333. * @param newCamera defines the new active camera
  119334. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119335. */
  119336. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119337. /**
  119338. * sets the active camera of the scene using its ID
  119339. * @param id defines the camera's ID
  119340. * @return the new active camera or null if none found.
  119341. */
  119342. setActiveCameraByID(id: string): Nullable<Camera>;
  119343. /**
  119344. * sets the active camera of the scene using its name
  119345. * @param name defines the camera's name
  119346. * @returns the new active camera or null if none found.
  119347. */
  119348. setActiveCameraByName(name: string): Nullable<Camera>;
  119349. /**
  119350. * get an animation group using its name
  119351. * @param name defines the material's name
  119352. * @return the animation group or null if none found.
  119353. */
  119354. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119355. /**
  119356. * Get a material using its unique id
  119357. * @param uniqueId defines the material's unique id
  119358. * @return the material or null if none found.
  119359. */
  119360. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119361. /**
  119362. * get a material using its id
  119363. * @param id defines the material's ID
  119364. * @return the material or null if none found.
  119365. */
  119366. getMaterialByID(id: string): Nullable<Material>;
  119367. /**
  119368. * Gets a the last added material using a given id
  119369. * @param id defines the material's ID
  119370. * @return the last material with the given id or null if none found.
  119371. */
  119372. getLastMaterialByID(id: string): Nullable<Material>;
  119373. /**
  119374. * Gets a material using its name
  119375. * @param name defines the material's name
  119376. * @return the material or null if none found.
  119377. */
  119378. getMaterialByName(name: string): Nullable<Material>;
  119379. /**
  119380. * Get a texture using its unique id
  119381. * @param uniqueId defines the texture's unique id
  119382. * @return the texture or null if none found.
  119383. */
  119384. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119385. /**
  119386. * Gets a camera using its id
  119387. * @param id defines the id to look for
  119388. * @returns the camera or null if not found
  119389. */
  119390. getCameraByID(id: string): Nullable<Camera>;
  119391. /**
  119392. * Gets a camera using its unique id
  119393. * @param uniqueId defines the unique id to look for
  119394. * @returns the camera or null if not found
  119395. */
  119396. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119397. /**
  119398. * Gets a camera using its name
  119399. * @param name defines the camera's name
  119400. * @return the camera or null if none found.
  119401. */
  119402. getCameraByName(name: string): Nullable<Camera>;
  119403. /**
  119404. * Gets a bone using its id
  119405. * @param id defines the bone's id
  119406. * @return the bone or null if not found
  119407. */
  119408. getBoneByID(id: string): Nullable<Bone>;
  119409. /**
  119410. * Gets a bone using its id
  119411. * @param name defines the bone's name
  119412. * @return the bone or null if not found
  119413. */
  119414. getBoneByName(name: string): Nullable<Bone>;
  119415. /**
  119416. * Gets a light node using its name
  119417. * @param name defines the the light's name
  119418. * @return the light or null if none found.
  119419. */
  119420. getLightByName(name: string): Nullable<Light>;
  119421. /**
  119422. * Gets a light node using its id
  119423. * @param id defines the light's id
  119424. * @return the light or null if none found.
  119425. */
  119426. getLightByID(id: string): Nullable<Light>;
  119427. /**
  119428. * Gets a light node using its scene-generated unique ID
  119429. * @param uniqueId defines the light's unique id
  119430. * @return the light or null if none found.
  119431. */
  119432. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119433. /**
  119434. * Gets a particle system by id
  119435. * @param id defines the particle system id
  119436. * @return the corresponding system or null if none found
  119437. */
  119438. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119439. /**
  119440. * Gets a geometry using its ID
  119441. * @param id defines the geometry's id
  119442. * @return the geometry or null if none found.
  119443. */
  119444. getGeometryByID(id: string): Nullable<Geometry>;
  119445. private _getGeometryByUniqueID;
  119446. /**
  119447. * Add a new geometry to this scene
  119448. * @param geometry defines the geometry to be added to the scene.
  119449. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119450. * @return a boolean defining if the geometry was added or not
  119451. */
  119452. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119453. /**
  119454. * Removes an existing geometry
  119455. * @param geometry defines the geometry to be removed from the scene
  119456. * @return a boolean defining if the geometry was removed or not
  119457. */
  119458. removeGeometry(geometry: Geometry): boolean;
  119459. /**
  119460. * Gets the list of geometries attached to the scene
  119461. * @returns an array of Geometry
  119462. */
  119463. getGeometries(): Geometry[];
  119464. /**
  119465. * Gets the first added mesh found of a given ID
  119466. * @param id defines the id to search for
  119467. * @return the mesh found or null if not found at all
  119468. */
  119469. getMeshByID(id: string): Nullable<AbstractMesh>;
  119470. /**
  119471. * Gets a list of meshes using their id
  119472. * @param id defines the id to search for
  119473. * @returns a list of meshes
  119474. */
  119475. getMeshesByID(id: string): Array<AbstractMesh>;
  119476. /**
  119477. * Gets the first added transform node found of a given ID
  119478. * @param id defines the id to search for
  119479. * @return the found transform node or null if not found at all.
  119480. */
  119481. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119482. /**
  119483. * Gets a transform node with its auto-generated unique id
  119484. * @param uniqueId efines the unique id to search for
  119485. * @return the found transform node or null if not found at all.
  119486. */
  119487. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119488. /**
  119489. * Gets a list of transform nodes using their id
  119490. * @param id defines the id to search for
  119491. * @returns a list of transform nodes
  119492. */
  119493. getTransformNodesByID(id: string): Array<TransformNode>;
  119494. /**
  119495. * Gets a mesh with its auto-generated unique id
  119496. * @param uniqueId defines the unique id to search for
  119497. * @return the found mesh or null if not found at all.
  119498. */
  119499. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119500. /**
  119501. * Gets a the last added mesh using a given id
  119502. * @param id defines the id to search for
  119503. * @return the found mesh or null if not found at all.
  119504. */
  119505. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119506. /**
  119507. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119508. * @param id defines the id to search for
  119509. * @return the found node or null if not found at all
  119510. */
  119511. getLastEntryByID(id: string): Nullable<Node>;
  119512. /**
  119513. * Gets a node (Mesh, Camera, Light) using a given id
  119514. * @param id defines the id to search for
  119515. * @return the found node or null if not found at all
  119516. */
  119517. getNodeByID(id: string): Nullable<Node>;
  119518. /**
  119519. * Gets a node (Mesh, Camera, Light) using a given name
  119520. * @param name defines the name to search for
  119521. * @return the found node or null if not found at all.
  119522. */
  119523. getNodeByName(name: string): Nullable<Node>;
  119524. /**
  119525. * Gets a mesh using a given name
  119526. * @param name defines the name to search for
  119527. * @return the found mesh or null if not found at all.
  119528. */
  119529. getMeshByName(name: string): Nullable<AbstractMesh>;
  119530. /**
  119531. * Gets a transform node using a given name
  119532. * @param name defines the name to search for
  119533. * @return the found transform node or null if not found at all.
  119534. */
  119535. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119536. /**
  119537. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119538. * @param id defines the id to search for
  119539. * @return the found skeleton or null if not found at all.
  119540. */
  119541. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119542. /**
  119543. * Gets a skeleton using a given auto generated unique id
  119544. * @param uniqueId defines the unique id to search for
  119545. * @return the found skeleton or null if not found at all.
  119546. */
  119547. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119548. /**
  119549. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119550. * @param id defines the id to search for
  119551. * @return the found skeleton or null if not found at all.
  119552. */
  119553. getSkeletonById(id: string): Nullable<Skeleton>;
  119554. /**
  119555. * Gets a skeleton using a given name
  119556. * @param name defines the name to search for
  119557. * @return the found skeleton or null if not found at all.
  119558. */
  119559. getSkeletonByName(name: string): Nullable<Skeleton>;
  119560. /**
  119561. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119562. * @param id defines the id to search for
  119563. * @return the found morph target manager or null if not found at all.
  119564. */
  119565. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119566. /**
  119567. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119568. * @param id defines the id to search for
  119569. * @return the found morph target or null if not found at all.
  119570. */
  119571. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119572. /**
  119573. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119574. * @param name defines the name to search for
  119575. * @return the found morph target or null if not found at all.
  119576. */
  119577. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119578. /**
  119579. * Gets a boolean indicating if the given mesh is active
  119580. * @param mesh defines the mesh to look for
  119581. * @returns true if the mesh is in the active list
  119582. */
  119583. isActiveMesh(mesh: AbstractMesh): boolean;
  119584. /**
  119585. * Return a unique id as a string which can serve as an identifier for the scene
  119586. */
  119587. get uid(): string;
  119588. /**
  119589. * Add an externaly attached data from its key.
  119590. * This method call will fail and return false, if such key already exists.
  119591. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119592. * @param key the unique key that identifies the data
  119593. * @param data the data object to associate to the key for this Engine instance
  119594. * @return true if no such key were already present and the data was added successfully, false otherwise
  119595. */
  119596. addExternalData<T>(key: string, data: T): boolean;
  119597. /**
  119598. * Get an externaly attached data from its key
  119599. * @param key the unique key that identifies the data
  119600. * @return the associated data, if present (can be null), or undefined if not present
  119601. */
  119602. getExternalData<T>(key: string): Nullable<T>;
  119603. /**
  119604. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119605. * @param key the unique key that identifies the data
  119606. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119607. * @return the associated data, can be null if the factory returned null.
  119608. */
  119609. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119610. /**
  119611. * Remove an externaly attached data from the Engine instance
  119612. * @param key the unique key that identifies the data
  119613. * @return true if the data was successfully removed, false if it doesn't exist
  119614. */
  119615. removeExternalData(key: string): boolean;
  119616. private _evaluateSubMesh;
  119617. /**
  119618. * Clear the processed materials smart array preventing retention point in material dispose.
  119619. */
  119620. freeProcessedMaterials(): void;
  119621. private _preventFreeActiveMeshesAndRenderingGroups;
  119622. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119623. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119624. * when disposing several meshes in a row or a hierarchy of meshes.
  119625. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119626. */
  119627. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119628. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119629. /**
  119630. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119631. */
  119632. freeActiveMeshes(): void;
  119633. /**
  119634. * Clear the info related to rendering groups preventing retention points during dispose.
  119635. */
  119636. freeRenderingGroups(): void;
  119637. /** @hidden */
  119638. _isInIntermediateRendering(): boolean;
  119639. /**
  119640. * Lambda returning the list of potentially active meshes.
  119641. */
  119642. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119643. /**
  119644. * Lambda returning the list of potentially active sub meshes.
  119645. */
  119646. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119647. /**
  119648. * Lambda returning the list of potentially intersecting sub meshes.
  119649. */
  119650. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119651. /**
  119652. * Lambda returning the list of potentially colliding sub meshes.
  119653. */
  119654. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119655. private _activeMeshesFrozen;
  119656. private _skipEvaluateActiveMeshesCompletely;
  119657. /**
  119658. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119659. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119660. * @returns the current scene
  119661. */
  119662. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119663. /**
  119664. * Use this function to restart evaluating active meshes on every frame
  119665. * @returns the current scene
  119666. */
  119667. unfreezeActiveMeshes(): Scene;
  119668. private _evaluateActiveMeshes;
  119669. private _activeMesh;
  119670. /**
  119671. * Update the transform matrix to update from the current active camera
  119672. * @param force defines a boolean used to force the update even if cache is up to date
  119673. */
  119674. updateTransformMatrix(force?: boolean): void;
  119675. private _bindFrameBuffer;
  119676. /** @hidden */
  119677. _allowPostProcessClearColor: boolean;
  119678. /** @hidden */
  119679. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119680. private _processSubCameras;
  119681. private _checkIntersections;
  119682. /** @hidden */
  119683. _advancePhysicsEngineStep(step: number): void;
  119684. /**
  119685. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119686. */
  119687. getDeterministicFrameTime: () => number;
  119688. /** @hidden */
  119689. _animate(): void;
  119690. /** Execute all animations (for a frame) */
  119691. animate(): void;
  119692. /**
  119693. * Render the scene
  119694. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119695. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119696. */
  119697. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119698. /**
  119699. * Freeze all materials
  119700. * A frozen material will not be updatable but should be faster to render
  119701. */
  119702. freezeMaterials(): void;
  119703. /**
  119704. * Unfreeze all materials
  119705. * A frozen material will not be updatable but should be faster to render
  119706. */
  119707. unfreezeMaterials(): void;
  119708. /**
  119709. * Releases all held ressources
  119710. */
  119711. dispose(): void;
  119712. /**
  119713. * Gets if the scene is already disposed
  119714. */
  119715. get isDisposed(): boolean;
  119716. /**
  119717. * Call this function to reduce memory footprint of the scene.
  119718. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119719. */
  119720. clearCachedVertexData(): void;
  119721. /**
  119722. * This function will remove the local cached buffer data from texture.
  119723. * It will save memory but will prevent the texture from being rebuilt
  119724. */
  119725. cleanCachedTextureBuffer(): void;
  119726. /**
  119727. * Get the world extend vectors with an optional filter
  119728. *
  119729. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119730. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119731. */
  119732. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119733. min: Vector3;
  119734. max: Vector3;
  119735. };
  119736. /**
  119737. * Creates a ray that can be used to pick in the scene
  119738. * @param x defines the x coordinate of the origin (on-screen)
  119739. * @param y defines the y coordinate of the origin (on-screen)
  119740. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119741. * @param camera defines the camera to use for the picking
  119742. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119743. * @returns a Ray
  119744. */
  119745. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119746. /**
  119747. * Creates a ray that can be used to pick in the scene
  119748. * @param x defines the x coordinate of the origin (on-screen)
  119749. * @param y defines the y coordinate of the origin (on-screen)
  119750. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119751. * @param result defines the ray where to store the picking ray
  119752. * @param camera defines the camera to use for the picking
  119753. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119754. * @returns the current scene
  119755. */
  119756. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119757. /**
  119758. * Creates a ray that can be used to pick in the scene
  119759. * @param x defines the x coordinate of the origin (on-screen)
  119760. * @param y defines the y coordinate of the origin (on-screen)
  119761. * @param camera defines the camera to use for the picking
  119762. * @returns a Ray
  119763. */
  119764. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119765. /**
  119766. * Creates a ray that can be used to pick in the scene
  119767. * @param x defines the x coordinate of the origin (on-screen)
  119768. * @param y defines the y coordinate of the origin (on-screen)
  119769. * @param result defines the ray where to store the picking ray
  119770. * @param camera defines the camera to use for the picking
  119771. * @returns the current scene
  119772. */
  119773. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119774. /** Launch a ray to try to pick a mesh in the scene
  119775. * @param x position on screen
  119776. * @param y position on screen
  119777. * @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
  119778. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119779. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119780. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119781. * @returns a PickingInfo
  119782. */
  119783. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119784. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119785. * @param x position on screen
  119786. * @param y position on screen
  119787. * @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
  119788. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119789. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119790. * @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)
  119791. */
  119792. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119793. /** Use the given ray to pick a mesh in the scene
  119794. * @param ray The ray to use to pick meshes
  119795. * @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
  119796. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119797. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119798. * @returns a PickingInfo
  119799. */
  119800. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119801. /**
  119802. * Launch a ray to try to pick a mesh in the scene
  119803. * @param x X position on screen
  119804. * @param y Y position on screen
  119805. * @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
  119806. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119807. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119808. * @returns an array of PickingInfo
  119809. */
  119810. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119811. /**
  119812. * Launch a ray to try to pick a mesh in the scene
  119813. * @param ray Ray to use
  119814. * @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
  119815. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119816. * @returns an array of PickingInfo
  119817. */
  119818. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119819. /**
  119820. * Force the value of meshUnderPointer
  119821. * @param mesh defines the mesh to use
  119822. */
  119823. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  119824. /**
  119825. * Gets the mesh under the pointer
  119826. * @returns a Mesh or null if no mesh is under the pointer
  119827. */
  119828. getPointerOverMesh(): Nullable<AbstractMesh>;
  119829. /** @hidden */
  119830. _rebuildGeometries(): void;
  119831. /** @hidden */
  119832. _rebuildTextures(): void;
  119833. private _getByTags;
  119834. /**
  119835. * Get a list of meshes by tags
  119836. * @param tagsQuery defines the tags query to use
  119837. * @param forEach defines a predicate used to filter results
  119838. * @returns an array of Mesh
  119839. */
  119840. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  119841. /**
  119842. * Get a list of cameras by tags
  119843. * @param tagsQuery defines the tags query to use
  119844. * @param forEach defines a predicate used to filter results
  119845. * @returns an array of Camera
  119846. */
  119847. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  119848. /**
  119849. * Get a list of lights by tags
  119850. * @param tagsQuery defines the tags query to use
  119851. * @param forEach defines a predicate used to filter results
  119852. * @returns an array of Light
  119853. */
  119854. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  119855. /**
  119856. * Get a list of materials by tags
  119857. * @param tagsQuery defines the tags query to use
  119858. * @param forEach defines a predicate used to filter results
  119859. * @returns an array of Material
  119860. */
  119861. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  119862. /**
  119863. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119864. * This allowed control for front to back rendering or reversly depending of the special needs.
  119865. *
  119866. * @param renderingGroupId The rendering group id corresponding to its index
  119867. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119868. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119869. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119870. */
  119871. 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;
  119872. /**
  119873. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119874. *
  119875. * @param renderingGroupId The rendering group id corresponding to its index
  119876. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119877. * @param depth Automatically clears depth between groups if true and autoClear is true.
  119878. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  119879. */
  119880. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  119881. /**
  119882. * Gets the current auto clear configuration for one rendering group of the rendering
  119883. * manager.
  119884. * @param index the rendering group index to get the information for
  119885. * @returns The auto clear setup for the requested rendering group
  119886. */
  119887. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  119888. private _blockMaterialDirtyMechanism;
  119889. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  119890. get blockMaterialDirtyMechanism(): boolean;
  119891. set blockMaterialDirtyMechanism(value: boolean);
  119892. /**
  119893. * Will flag all materials as dirty to trigger new shader compilation
  119894. * @param flag defines the flag used to specify which material part must be marked as dirty
  119895. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  119896. */
  119897. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  119898. /** @hidden */
  119899. _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;
  119900. /** @hidden */
  119901. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119902. /** @hidden */
  119903. _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;
  119904. /** @hidden */
  119905. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  119906. /** @hidden */
  119907. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119908. /** @hidden */
  119909. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119910. }
  119911. }
  119912. declare module BABYLON {
  119913. /**
  119914. * Set of assets to keep when moving a scene into an asset container.
  119915. */
  119916. export class KeepAssets extends AbstractScene {
  119917. }
  119918. /**
  119919. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  119920. */
  119921. export class InstantiatedEntries {
  119922. /**
  119923. * List of new root nodes (eg. nodes with no parent)
  119924. */
  119925. rootNodes: TransformNode[];
  119926. /**
  119927. * List of new skeletons
  119928. */
  119929. skeletons: Skeleton[];
  119930. /**
  119931. * List of new animation groups
  119932. */
  119933. animationGroups: AnimationGroup[];
  119934. }
  119935. /**
  119936. * Container with a set of assets that can be added or removed from a scene.
  119937. */
  119938. export class AssetContainer extends AbstractScene {
  119939. private _wasAddedToScene;
  119940. /**
  119941. * The scene the AssetContainer belongs to.
  119942. */
  119943. scene: Scene;
  119944. /**
  119945. * Instantiates an AssetContainer.
  119946. * @param scene The scene the AssetContainer belongs to.
  119947. */
  119948. constructor(scene: Scene);
  119949. /**
  119950. * Instantiate or clone all meshes and add the new ones to the scene.
  119951. * Skeletons and animation groups will all be cloned
  119952. * @param nameFunction defines an optional function used to get new names for clones
  119953. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  119954. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  119955. */
  119956. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  119957. /**
  119958. * Adds all the assets from the container to the scene.
  119959. */
  119960. addAllToScene(): void;
  119961. /**
  119962. * Removes all the assets in the container from the scene
  119963. */
  119964. removeAllFromScene(): void;
  119965. /**
  119966. * Disposes all the assets in the container
  119967. */
  119968. dispose(): void;
  119969. private _moveAssets;
  119970. /**
  119971. * Removes all the assets contained in the scene and adds them to the container.
  119972. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  119973. */
  119974. moveAllFromScene(keepAssets?: KeepAssets): void;
  119975. /**
  119976. * 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.
  119977. * @returns the root mesh
  119978. */
  119979. createRootMesh(): Mesh;
  119980. /**
  119981. * Merge animations (direct and animation groups) from this asset container into a scene
  119982. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  119983. * @param animatables set of animatables to retarget to a node from the scene
  119984. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  119985. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  119986. */
  119987. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  119988. }
  119989. }
  119990. declare module BABYLON {
  119991. /**
  119992. * Defines how the parser contract is defined.
  119993. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  119994. */
  119995. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  119996. /**
  119997. * Defines how the individual parser contract is defined.
  119998. * These parser can parse an individual asset
  119999. */
  120000. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120001. /**
  120002. * Base class of the scene acting as a container for the different elements composing a scene.
  120003. * This class is dynamically extended by the different components of the scene increasing
  120004. * flexibility and reducing coupling
  120005. */
  120006. export abstract class AbstractScene {
  120007. /**
  120008. * Stores the list of available parsers in the application.
  120009. */
  120010. private static _BabylonFileParsers;
  120011. /**
  120012. * Stores the list of available individual parsers in the application.
  120013. */
  120014. private static _IndividualBabylonFileParsers;
  120015. /**
  120016. * Adds a parser in the list of available ones
  120017. * @param name Defines the name of the parser
  120018. * @param parser Defines the parser to add
  120019. */
  120020. static AddParser(name: string, parser: BabylonFileParser): void;
  120021. /**
  120022. * Gets a general parser from the list of avaialble ones
  120023. * @param name Defines the name of the parser
  120024. * @returns the requested parser or null
  120025. */
  120026. static GetParser(name: string): Nullable<BabylonFileParser>;
  120027. /**
  120028. * Adds n individual parser in the list of available ones
  120029. * @param name Defines the name of the parser
  120030. * @param parser Defines the parser to add
  120031. */
  120032. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120033. /**
  120034. * Gets an individual parser from the list of avaialble ones
  120035. * @param name Defines the name of the parser
  120036. * @returns the requested parser or null
  120037. */
  120038. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120039. /**
  120040. * Parser json data and populate both a scene and its associated container object
  120041. * @param jsonData Defines the data to parse
  120042. * @param scene Defines the scene to parse the data for
  120043. * @param container Defines the container attached to the parsing sequence
  120044. * @param rootUrl Defines the root url of the data
  120045. */
  120046. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120047. /**
  120048. * Gets the list of root nodes (ie. nodes with no parent)
  120049. */
  120050. rootNodes: Node[];
  120051. /** All of the cameras added to this scene
  120052. * @see https://doc.babylonjs.com/babylon101/cameras
  120053. */
  120054. cameras: Camera[];
  120055. /**
  120056. * All of the lights added to this scene
  120057. * @see https://doc.babylonjs.com/babylon101/lights
  120058. */
  120059. lights: Light[];
  120060. /**
  120061. * All of the (abstract) meshes added to this scene
  120062. */
  120063. meshes: AbstractMesh[];
  120064. /**
  120065. * The list of skeletons added to the scene
  120066. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120067. */
  120068. skeletons: Skeleton[];
  120069. /**
  120070. * All of the particle systems added to this scene
  120071. * @see https://doc.babylonjs.com/babylon101/particles
  120072. */
  120073. particleSystems: IParticleSystem[];
  120074. /**
  120075. * Gets a list of Animations associated with the scene
  120076. */
  120077. animations: Animation[];
  120078. /**
  120079. * All of the animation groups added to this scene
  120080. * @see https://doc.babylonjs.com/how_to/group
  120081. */
  120082. animationGroups: AnimationGroup[];
  120083. /**
  120084. * All of the multi-materials added to this scene
  120085. * @see https://doc.babylonjs.com/how_to/multi_materials
  120086. */
  120087. multiMaterials: MultiMaterial[];
  120088. /**
  120089. * All of the materials added to this scene
  120090. * In the context of a Scene, it is not supposed to be modified manually.
  120091. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120092. * Note also that the order of the Material within the array is not significant and might change.
  120093. * @see https://doc.babylonjs.com/babylon101/materials
  120094. */
  120095. materials: Material[];
  120096. /**
  120097. * The list of morph target managers added to the scene
  120098. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120099. */
  120100. morphTargetManagers: MorphTargetManager[];
  120101. /**
  120102. * The list of geometries used in the scene.
  120103. */
  120104. geometries: Geometry[];
  120105. /**
  120106. * All of the tranform nodes added to this scene
  120107. * In the context of a Scene, it is not supposed to be modified manually.
  120108. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120109. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120110. * @see https://doc.babylonjs.com/how_to/transformnode
  120111. */
  120112. transformNodes: TransformNode[];
  120113. /**
  120114. * ActionManagers available on the scene.
  120115. */
  120116. actionManagers: AbstractActionManager[];
  120117. /**
  120118. * Textures to keep.
  120119. */
  120120. textures: BaseTexture[];
  120121. /**
  120122. * Environment texture for the scene
  120123. */
  120124. environmentTexture: Nullable<BaseTexture>;
  120125. /**
  120126. * @returns all meshes, lights, cameras, transformNodes and bones
  120127. */
  120128. getNodes(): Array<Node>;
  120129. }
  120130. }
  120131. declare module BABYLON {
  120132. /**
  120133. * Interface used to define options for Sound class
  120134. */
  120135. export interface ISoundOptions {
  120136. /**
  120137. * Does the sound autoplay once loaded.
  120138. */
  120139. autoplay?: boolean;
  120140. /**
  120141. * Does the sound loop after it finishes playing once.
  120142. */
  120143. loop?: boolean;
  120144. /**
  120145. * Sound's volume
  120146. */
  120147. volume?: number;
  120148. /**
  120149. * Is it a spatial sound?
  120150. */
  120151. spatialSound?: boolean;
  120152. /**
  120153. * Maximum distance to hear that sound
  120154. */
  120155. maxDistance?: number;
  120156. /**
  120157. * Uses user defined attenuation function
  120158. */
  120159. useCustomAttenuation?: boolean;
  120160. /**
  120161. * Define the roll off factor of spatial sounds.
  120162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120163. */
  120164. rolloffFactor?: number;
  120165. /**
  120166. * Define the reference distance the sound should be heard perfectly.
  120167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120168. */
  120169. refDistance?: number;
  120170. /**
  120171. * Define the distance attenuation model the sound will follow.
  120172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120173. */
  120174. distanceModel?: string;
  120175. /**
  120176. * Defines the playback speed (1 by default)
  120177. */
  120178. playbackRate?: number;
  120179. /**
  120180. * Defines if the sound is from a streaming source
  120181. */
  120182. streaming?: boolean;
  120183. /**
  120184. * Defines an optional length (in seconds) inside the sound file
  120185. */
  120186. length?: number;
  120187. /**
  120188. * Defines an optional offset (in seconds) inside the sound file
  120189. */
  120190. offset?: number;
  120191. /**
  120192. * If true, URLs will not be required to state the audio file codec to use.
  120193. */
  120194. skipCodecCheck?: boolean;
  120195. }
  120196. /**
  120197. * Defines a sound that can be played in the application.
  120198. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120200. */
  120201. export class Sound {
  120202. /**
  120203. * The name of the sound in the scene.
  120204. */
  120205. name: string;
  120206. /**
  120207. * Does the sound autoplay once loaded.
  120208. */
  120209. autoplay: boolean;
  120210. /**
  120211. * Does the sound loop after it finishes playing once.
  120212. */
  120213. loop: boolean;
  120214. /**
  120215. * Does the sound use a custom attenuation curve to simulate the falloff
  120216. * happening when the source gets further away from the camera.
  120217. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120218. */
  120219. useCustomAttenuation: boolean;
  120220. /**
  120221. * The sound track id this sound belongs to.
  120222. */
  120223. soundTrackId: number;
  120224. /**
  120225. * Is this sound currently played.
  120226. */
  120227. isPlaying: boolean;
  120228. /**
  120229. * Is this sound currently paused.
  120230. */
  120231. isPaused: boolean;
  120232. /**
  120233. * Does this sound enables spatial sound.
  120234. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120235. */
  120236. spatialSound: boolean;
  120237. /**
  120238. * Define the reference distance the sound should be heard perfectly.
  120239. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120240. */
  120241. refDistance: number;
  120242. /**
  120243. * Define the roll off factor of spatial sounds.
  120244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120245. */
  120246. rolloffFactor: number;
  120247. /**
  120248. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120249. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120250. */
  120251. maxDistance: number;
  120252. /**
  120253. * Define the distance attenuation model the sound will follow.
  120254. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120255. */
  120256. distanceModel: string;
  120257. /**
  120258. * @hidden
  120259. * Back Compat
  120260. **/
  120261. onended: () => any;
  120262. /**
  120263. * Gets or sets an object used to store user defined information for the sound.
  120264. */
  120265. metadata: any;
  120266. /**
  120267. * Observable event when the current playing sound finishes.
  120268. */
  120269. onEndedObservable: Observable<Sound>;
  120270. private _panningModel;
  120271. private _playbackRate;
  120272. private _streaming;
  120273. private _startTime;
  120274. private _startOffset;
  120275. private _position;
  120276. /** @hidden */
  120277. _positionInEmitterSpace: boolean;
  120278. private _localDirection;
  120279. private _volume;
  120280. private _isReadyToPlay;
  120281. private _isDirectional;
  120282. private _readyToPlayCallback;
  120283. private _audioBuffer;
  120284. private _soundSource;
  120285. private _streamingSource;
  120286. private _soundPanner;
  120287. private _soundGain;
  120288. private _inputAudioNode;
  120289. private _outputAudioNode;
  120290. private _coneInnerAngle;
  120291. private _coneOuterAngle;
  120292. private _coneOuterGain;
  120293. private _scene;
  120294. private _connectedTransformNode;
  120295. private _customAttenuationFunction;
  120296. private _registerFunc;
  120297. private _isOutputConnected;
  120298. private _htmlAudioElement;
  120299. private _urlType;
  120300. private _length?;
  120301. private _offset?;
  120302. /** @hidden */
  120303. static _SceneComponentInitialization: (scene: Scene) => void;
  120304. /**
  120305. * Create a sound and attach it to a scene
  120306. * @param name Name of your sound
  120307. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120308. * @param scene defines the scene the sound belongs to
  120309. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120310. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120311. */
  120312. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120313. /**
  120314. * Release the sound and its associated resources
  120315. */
  120316. dispose(): void;
  120317. /**
  120318. * Gets if the sounds is ready to be played or not.
  120319. * @returns true if ready, otherwise false
  120320. */
  120321. isReady(): boolean;
  120322. private _soundLoaded;
  120323. /**
  120324. * Sets the data of the sound from an audiobuffer
  120325. * @param audioBuffer The audioBuffer containing the data
  120326. */
  120327. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120328. /**
  120329. * Updates the current sounds options such as maxdistance, loop...
  120330. * @param options A JSON object containing values named as the object properties
  120331. */
  120332. updateOptions(options: ISoundOptions): void;
  120333. private _createSpatialParameters;
  120334. private _updateSpatialParameters;
  120335. /**
  120336. * Switch the panning model to HRTF:
  120337. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120339. */
  120340. switchPanningModelToHRTF(): void;
  120341. /**
  120342. * Switch the panning model to Equal Power:
  120343. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120344. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120345. */
  120346. switchPanningModelToEqualPower(): void;
  120347. private _switchPanningModel;
  120348. /**
  120349. * Connect this sound to a sound track audio node like gain...
  120350. * @param soundTrackAudioNode the sound track audio node to connect to
  120351. */
  120352. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120353. /**
  120354. * Transform this sound into a directional source
  120355. * @param coneInnerAngle Size of the inner cone in degree
  120356. * @param coneOuterAngle Size of the outer cone in degree
  120357. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120358. */
  120359. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120360. /**
  120361. * Gets or sets the inner angle for the directional cone.
  120362. */
  120363. get directionalConeInnerAngle(): number;
  120364. /**
  120365. * Gets or sets the inner angle for the directional cone.
  120366. */
  120367. set directionalConeInnerAngle(value: number);
  120368. /**
  120369. * Gets or sets the outer angle for the directional cone.
  120370. */
  120371. get directionalConeOuterAngle(): number;
  120372. /**
  120373. * Gets or sets the outer angle for the directional cone.
  120374. */
  120375. set directionalConeOuterAngle(value: number);
  120376. /**
  120377. * Sets the position of the emitter if spatial sound is enabled
  120378. * @param newPosition Defines the new posisiton
  120379. */
  120380. setPosition(newPosition: Vector3): void;
  120381. /**
  120382. * Sets the local direction of the emitter if spatial sound is enabled
  120383. * @param newLocalDirection Defines the new local direction
  120384. */
  120385. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120386. private _updateDirection;
  120387. /** @hidden */
  120388. updateDistanceFromListener(): void;
  120389. /**
  120390. * Sets a new custom attenuation function for the sound.
  120391. * @param callback Defines the function used for the attenuation
  120392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120393. */
  120394. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120395. /**
  120396. * Play the sound
  120397. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120398. * @param offset (optional) Start the sound at a specific time in seconds
  120399. * @param length (optional) Sound duration (in seconds)
  120400. */
  120401. play(time?: number, offset?: number, length?: number): void;
  120402. private _onended;
  120403. /**
  120404. * Stop the sound
  120405. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120406. */
  120407. stop(time?: number): void;
  120408. /**
  120409. * Put the sound in pause
  120410. */
  120411. pause(): void;
  120412. /**
  120413. * Sets a dedicated volume for this sounds
  120414. * @param newVolume Define the new volume of the sound
  120415. * @param time Define time for gradual change to new volume
  120416. */
  120417. setVolume(newVolume: number, time?: number): void;
  120418. /**
  120419. * Set the sound play back rate
  120420. * @param newPlaybackRate Define the playback rate the sound should be played at
  120421. */
  120422. setPlaybackRate(newPlaybackRate: number): void;
  120423. /**
  120424. * Gets the volume of the sound.
  120425. * @returns the volume of the sound
  120426. */
  120427. getVolume(): number;
  120428. /**
  120429. * Attach the sound to a dedicated mesh
  120430. * @param transformNode The transform node to connect the sound with
  120431. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120432. */
  120433. attachToMesh(transformNode: TransformNode): void;
  120434. /**
  120435. * Detach the sound from the previously attached mesh
  120436. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120437. */
  120438. detachFromMesh(): void;
  120439. private _onRegisterAfterWorldMatrixUpdate;
  120440. /**
  120441. * Clone the current sound in the scene.
  120442. * @returns the new sound clone
  120443. */
  120444. clone(): Nullable<Sound>;
  120445. /**
  120446. * Gets the current underlying audio buffer containing the data
  120447. * @returns the audio buffer
  120448. */
  120449. getAudioBuffer(): Nullable<AudioBuffer>;
  120450. /**
  120451. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120452. * @returns the source node
  120453. */
  120454. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120455. /**
  120456. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120457. * @returns the gain node
  120458. */
  120459. getSoundGain(): Nullable<GainNode>;
  120460. /**
  120461. * Serializes the Sound in a JSON representation
  120462. * @returns the JSON representation of the sound
  120463. */
  120464. serialize(): any;
  120465. /**
  120466. * Parse a JSON representation of a sound to innstantiate in a given scene
  120467. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120468. * @param scene Define the scene the new parsed sound should be created in
  120469. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120470. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120471. * @returns the newly parsed sound
  120472. */
  120473. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120474. }
  120475. }
  120476. declare module BABYLON {
  120477. /**
  120478. * This defines an action helpful to play a defined sound on a triggered action.
  120479. */
  120480. export class PlaySoundAction extends Action {
  120481. private _sound;
  120482. /**
  120483. * Instantiate the action
  120484. * @param triggerOptions defines the trigger options
  120485. * @param sound defines the sound to play
  120486. * @param condition defines the trigger related conditions
  120487. */
  120488. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120489. /** @hidden */
  120490. _prepare(): void;
  120491. /**
  120492. * Execute the action and play the sound.
  120493. */
  120494. execute(): void;
  120495. /**
  120496. * Serializes the actions and its related information.
  120497. * @param parent defines the object to serialize in
  120498. * @returns the serialized object
  120499. */
  120500. serialize(parent: any): any;
  120501. }
  120502. /**
  120503. * This defines an action helpful to stop a defined sound on a triggered action.
  120504. */
  120505. export class StopSoundAction extends Action {
  120506. private _sound;
  120507. /**
  120508. * Instantiate the action
  120509. * @param triggerOptions defines the trigger options
  120510. * @param sound defines the sound to stop
  120511. * @param condition defines the trigger related conditions
  120512. */
  120513. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120514. /** @hidden */
  120515. _prepare(): void;
  120516. /**
  120517. * Execute the action and stop the sound.
  120518. */
  120519. execute(): void;
  120520. /**
  120521. * Serializes the actions and its related information.
  120522. * @param parent defines the object to serialize in
  120523. * @returns the serialized object
  120524. */
  120525. serialize(parent: any): any;
  120526. }
  120527. }
  120528. declare module BABYLON {
  120529. /**
  120530. * This defines an action responsible to change the value of a property
  120531. * by interpolating between its current value and the newly set one once triggered.
  120532. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120533. */
  120534. export class InterpolateValueAction extends Action {
  120535. /**
  120536. * Defines the path of the property where the value should be interpolated
  120537. */
  120538. propertyPath: string;
  120539. /**
  120540. * Defines the target value at the end of the interpolation.
  120541. */
  120542. value: any;
  120543. /**
  120544. * Defines the time it will take for the property to interpolate to the value.
  120545. */
  120546. duration: number;
  120547. /**
  120548. * Defines if the other scene animations should be stopped when the action has been triggered
  120549. */
  120550. stopOtherAnimations?: boolean;
  120551. /**
  120552. * Defines a callback raised once the interpolation animation has been done.
  120553. */
  120554. onInterpolationDone?: () => void;
  120555. /**
  120556. * Observable triggered once the interpolation animation has been done.
  120557. */
  120558. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120559. private _target;
  120560. private _effectiveTarget;
  120561. private _property;
  120562. /**
  120563. * Instantiate the action
  120564. * @param triggerOptions defines the trigger options
  120565. * @param target defines the object containing the value to interpolate
  120566. * @param propertyPath defines the path to the property in the target object
  120567. * @param value defines the target value at the end of the interpolation
  120568. * @param duration deines the time it will take for the property to interpolate to the value.
  120569. * @param condition defines the trigger related conditions
  120570. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120571. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120572. */
  120573. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120574. /** @hidden */
  120575. _prepare(): void;
  120576. /**
  120577. * Execute the action starts the value interpolation.
  120578. */
  120579. execute(): void;
  120580. /**
  120581. * Serializes the actions and its related information.
  120582. * @param parent defines the object to serialize in
  120583. * @returns the serialized object
  120584. */
  120585. serialize(parent: any): any;
  120586. }
  120587. }
  120588. declare module BABYLON {
  120589. /**
  120590. * Options allowed during the creation of a sound track.
  120591. */
  120592. export interface ISoundTrackOptions {
  120593. /**
  120594. * The volume the sound track should take during creation
  120595. */
  120596. volume?: number;
  120597. /**
  120598. * Define if the sound track is the main sound track of the scene
  120599. */
  120600. mainTrack?: boolean;
  120601. }
  120602. /**
  120603. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120604. * It will be also used in a future release to apply effects on a specific track.
  120605. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120606. */
  120607. export class SoundTrack {
  120608. /**
  120609. * The unique identifier of the sound track in the scene.
  120610. */
  120611. id: number;
  120612. /**
  120613. * The list of sounds included in the sound track.
  120614. */
  120615. soundCollection: Array<Sound>;
  120616. private _outputAudioNode;
  120617. private _scene;
  120618. private _connectedAnalyser;
  120619. private _options;
  120620. private _isInitialized;
  120621. /**
  120622. * Creates a new sound track.
  120623. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120624. * @param scene Define the scene the sound track belongs to
  120625. * @param options
  120626. */
  120627. constructor(scene: Scene, options?: ISoundTrackOptions);
  120628. private _initializeSoundTrackAudioGraph;
  120629. /**
  120630. * Release the sound track and its associated resources
  120631. */
  120632. dispose(): void;
  120633. /**
  120634. * Adds a sound to this sound track
  120635. * @param sound define the cound to add
  120636. * @ignoreNaming
  120637. */
  120638. AddSound(sound: Sound): void;
  120639. /**
  120640. * Removes a sound to this sound track
  120641. * @param sound define the cound to remove
  120642. * @ignoreNaming
  120643. */
  120644. RemoveSound(sound: Sound): void;
  120645. /**
  120646. * Set a global volume for the full sound track.
  120647. * @param newVolume Define the new volume of the sound track
  120648. */
  120649. setVolume(newVolume: number): void;
  120650. /**
  120651. * Switch the panning model to HRTF:
  120652. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120654. */
  120655. switchPanningModelToHRTF(): void;
  120656. /**
  120657. * Switch the panning model to Equal Power:
  120658. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120660. */
  120661. switchPanningModelToEqualPower(): void;
  120662. /**
  120663. * Connect the sound track to an audio analyser allowing some amazing
  120664. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120665. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120666. * @param analyser The analyser to connect to the engine
  120667. */
  120668. connectToAnalyser(analyser: Analyser): void;
  120669. }
  120670. }
  120671. declare module BABYLON {
  120672. interface AbstractScene {
  120673. /**
  120674. * The list of sounds used in the scene.
  120675. */
  120676. sounds: Nullable<Array<Sound>>;
  120677. }
  120678. interface Scene {
  120679. /**
  120680. * @hidden
  120681. * Backing field
  120682. */
  120683. _mainSoundTrack: SoundTrack;
  120684. /**
  120685. * The main sound track played by the scene.
  120686. * It cotains your primary collection of sounds.
  120687. */
  120688. mainSoundTrack: SoundTrack;
  120689. /**
  120690. * The list of sound tracks added to the scene
  120691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120692. */
  120693. soundTracks: Nullable<Array<SoundTrack>>;
  120694. /**
  120695. * Gets a sound using a given name
  120696. * @param name defines the name to search for
  120697. * @return the found sound or null if not found at all.
  120698. */
  120699. getSoundByName(name: string): Nullable<Sound>;
  120700. /**
  120701. * Gets or sets if audio support is enabled
  120702. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120703. */
  120704. audioEnabled: boolean;
  120705. /**
  120706. * Gets or sets if audio will be output to headphones
  120707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120708. */
  120709. headphone: boolean;
  120710. /**
  120711. * Gets or sets custom audio listener position provider
  120712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120713. */
  120714. audioListenerPositionProvider: Nullable<() => Vector3>;
  120715. /**
  120716. * Gets or sets a refresh rate when using 3D audio positioning
  120717. */
  120718. audioPositioningRefreshRate: number;
  120719. }
  120720. /**
  120721. * Defines the sound scene component responsible to manage any sounds
  120722. * in a given scene.
  120723. */
  120724. export class AudioSceneComponent implements ISceneSerializableComponent {
  120725. /**
  120726. * The component name helpfull to identify the component in the list of scene components.
  120727. */
  120728. readonly name: string;
  120729. /**
  120730. * The scene the component belongs to.
  120731. */
  120732. scene: Scene;
  120733. private _audioEnabled;
  120734. /**
  120735. * Gets whether audio is enabled or not.
  120736. * Please use related enable/disable method to switch state.
  120737. */
  120738. get audioEnabled(): boolean;
  120739. private _headphone;
  120740. /**
  120741. * Gets whether audio is outputing to headphone or not.
  120742. * Please use the according Switch methods to change output.
  120743. */
  120744. get headphone(): boolean;
  120745. /**
  120746. * Gets or sets a refresh rate when using 3D audio positioning
  120747. */
  120748. audioPositioningRefreshRate: number;
  120749. private _audioListenerPositionProvider;
  120750. /**
  120751. * Gets the current audio listener position provider
  120752. */
  120753. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120754. /**
  120755. * Sets a custom listener position for all sounds in the scene
  120756. * By default, this is the position of the first active camera
  120757. */
  120758. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120759. /**
  120760. * Creates a new instance of the component for the given scene
  120761. * @param scene Defines the scene to register the component in
  120762. */
  120763. constructor(scene: Scene);
  120764. /**
  120765. * Registers the component in a given scene
  120766. */
  120767. register(): void;
  120768. /**
  120769. * Rebuilds the elements related to this component in case of
  120770. * context lost for instance.
  120771. */
  120772. rebuild(): void;
  120773. /**
  120774. * Serializes the component data to the specified json object
  120775. * @param serializationObject The object to serialize to
  120776. */
  120777. serialize(serializationObject: any): void;
  120778. /**
  120779. * Adds all the elements from the container to the scene
  120780. * @param container the container holding the elements
  120781. */
  120782. addFromContainer(container: AbstractScene): void;
  120783. /**
  120784. * Removes all the elements in the container from the scene
  120785. * @param container contains the elements to remove
  120786. * @param dispose if the removed element should be disposed (default: false)
  120787. */
  120788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120789. /**
  120790. * Disposes the component and the associated ressources.
  120791. */
  120792. dispose(): void;
  120793. /**
  120794. * Disables audio in the associated scene.
  120795. */
  120796. disableAudio(): void;
  120797. /**
  120798. * Enables audio in the associated scene.
  120799. */
  120800. enableAudio(): void;
  120801. /**
  120802. * Switch audio to headphone output.
  120803. */
  120804. switchAudioModeForHeadphones(): void;
  120805. /**
  120806. * Switch audio to normal speakers.
  120807. */
  120808. switchAudioModeForNormalSpeakers(): void;
  120809. private _cachedCameraDirection;
  120810. private _cachedCameraPosition;
  120811. private _lastCheck;
  120812. private _afterRender;
  120813. }
  120814. }
  120815. declare module BABYLON {
  120816. /**
  120817. * Wraps one or more Sound objects and selects one with random weight for playback.
  120818. */
  120819. export class WeightedSound {
  120820. /** When true a Sound will be selected and played when the current playing Sound completes. */
  120821. loop: boolean;
  120822. private _coneInnerAngle;
  120823. private _coneOuterAngle;
  120824. private _volume;
  120825. /** A Sound is currently playing. */
  120826. isPlaying: boolean;
  120827. /** A Sound is currently paused. */
  120828. isPaused: boolean;
  120829. private _sounds;
  120830. private _weights;
  120831. private _currentIndex?;
  120832. /**
  120833. * Creates a new WeightedSound from the list of sounds given.
  120834. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  120835. * @param sounds Array of Sounds that will be selected from.
  120836. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  120837. */
  120838. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  120839. /**
  120840. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  120841. */
  120842. get directionalConeInnerAngle(): number;
  120843. /**
  120844. * The size of cone in degress for a directional sound in which there will be no attenuation.
  120845. */
  120846. set directionalConeInnerAngle(value: number);
  120847. /**
  120848. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120849. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120850. */
  120851. get directionalConeOuterAngle(): number;
  120852. /**
  120853. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120854. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120855. */
  120856. set directionalConeOuterAngle(value: number);
  120857. /**
  120858. * Playback volume.
  120859. */
  120860. get volume(): number;
  120861. /**
  120862. * Playback volume.
  120863. */
  120864. set volume(value: number);
  120865. private _onended;
  120866. /**
  120867. * Suspend playback
  120868. */
  120869. pause(): void;
  120870. /**
  120871. * Stop playback
  120872. */
  120873. stop(): void;
  120874. /**
  120875. * Start playback.
  120876. * @param startOffset Position the clip head at a specific time in seconds.
  120877. */
  120878. play(startOffset?: number): void;
  120879. }
  120880. }
  120881. declare module BABYLON {
  120882. /**
  120883. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  120884. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120885. */
  120886. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  120887. /**
  120888. * Gets the name of the behavior.
  120889. */
  120890. get name(): string;
  120891. /**
  120892. * The easing function used by animations
  120893. */
  120894. static EasingFunction: BackEase;
  120895. /**
  120896. * The easing mode used by animations
  120897. */
  120898. static EasingMode: number;
  120899. /**
  120900. * The duration of the animation, in milliseconds
  120901. */
  120902. transitionDuration: number;
  120903. /**
  120904. * Length of the distance animated by the transition when lower radius is reached
  120905. */
  120906. lowerRadiusTransitionRange: number;
  120907. /**
  120908. * Length of the distance animated by the transition when upper radius is reached
  120909. */
  120910. upperRadiusTransitionRange: number;
  120911. private _autoTransitionRange;
  120912. /**
  120913. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120914. */
  120915. get autoTransitionRange(): boolean;
  120916. /**
  120917. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  120918. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  120919. */
  120920. set autoTransitionRange(value: boolean);
  120921. private _attachedCamera;
  120922. private _onAfterCheckInputsObserver;
  120923. private _onMeshTargetChangedObserver;
  120924. /**
  120925. * Initializes the behavior.
  120926. */
  120927. init(): void;
  120928. /**
  120929. * Attaches the behavior to its arc rotate camera.
  120930. * @param camera Defines the camera to attach the behavior to
  120931. */
  120932. attach(camera: ArcRotateCamera): void;
  120933. /**
  120934. * Detaches the behavior from its current arc rotate camera.
  120935. */
  120936. detach(): void;
  120937. private _radiusIsAnimating;
  120938. private _radiusBounceTransition;
  120939. private _animatables;
  120940. private _cachedWheelPrecision;
  120941. /**
  120942. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  120943. * @param radiusLimit The limit to check against.
  120944. * @return Bool to indicate if at limit.
  120945. */
  120946. private _isRadiusAtLimit;
  120947. /**
  120948. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  120949. * @param radiusDelta The delta by which to animate to. Can be negative.
  120950. */
  120951. private _applyBoundRadiusAnimation;
  120952. /**
  120953. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  120954. */
  120955. protected _clearAnimationLocks(): void;
  120956. /**
  120957. * Stops and removes all animations that have been applied to the camera
  120958. */
  120959. stopAllAnimations(): void;
  120960. }
  120961. }
  120962. declare module BABYLON {
  120963. /**
  120964. * 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.
  120965. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120966. */
  120967. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  120968. /**
  120969. * Gets the name of the behavior.
  120970. */
  120971. get name(): string;
  120972. private _mode;
  120973. private _radiusScale;
  120974. private _positionScale;
  120975. private _defaultElevation;
  120976. private _elevationReturnTime;
  120977. private _elevationReturnWaitTime;
  120978. private _zoomStopsAnimation;
  120979. private _framingTime;
  120980. /**
  120981. * The easing function used by animations
  120982. */
  120983. static EasingFunction: ExponentialEase;
  120984. /**
  120985. * The easing mode used by animations
  120986. */
  120987. static EasingMode: number;
  120988. /**
  120989. * Sets the current mode used by the behavior
  120990. */
  120991. set mode(mode: number);
  120992. /**
  120993. * Gets current mode used by the behavior.
  120994. */
  120995. get mode(): number;
  120996. /**
  120997. * Sets the scale applied to the radius (1 by default)
  120998. */
  120999. set radiusScale(radius: number);
  121000. /**
  121001. * Gets the scale applied to the radius
  121002. */
  121003. get radiusScale(): number;
  121004. /**
  121005. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121006. */
  121007. set positionScale(scale: number);
  121008. /**
  121009. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121010. */
  121011. get positionScale(): number;
  121012. /**
  121013. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121014. * behaviour is triggered, in radians.
  121015. */
  121016. set defaultElevation(elevation: number);
  121017. /**
  121018. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121019. * behaviour is triggered, in radians.
  121020. */
  121021. get defaultElevation(): number;
  121022. /**
  121023. * Sets the time (in milliseconds) taken to return to the default beta position.
  121024. * Negative value indicates camera should not return to default.
  121025. */
  121026. set elevationReturnTime(speed: number);
  121027. /**
  121028. * Gets the time (in milliseconds) taken to return to the default beta position.
  121029. * Negative value indicates camera should not return to default.
  121030. */
  121031. get elevationReturnTime(): number;
  121032. /**
  121033. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121034. */
  121035. set elevationReturnWaitTime(time: number);
  121036. /**
  121037. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121038. */
  121039. get elevationReturnWaitTime(): number;
  121040. /**
  121041. * Sets the flag that indicates if user zooming should stop animation.
  121042. */
  121043. set zoomStopsAnimation(flag: boolean);
  121044. /**
  121045. * Gets the flag that indicates if user zooming should stop animation.
  121046. */
  121047. get zoomStopsAnimation(): boolean;
  121048. /**
  121049. * Sets the transition time when framing the mesh, in milliseconds
  121050. */
  121051. set framingTime(time: number);
  121052. /**
  121053. * Gets the transition time when framing the mesh, in milliseconds
  121054. */
  121055. get framingTime(): number;
  121056. /**
  121057. * Define if the behavior should automatically change the configured
  121058. * camera limits and sensibilities.
  121059. */
  121060. autoCorrectCameraLimitsAndSensibility: boolean;
  121061. private _onPrePointerObservableObserver;
  121062. private _onAfterCheckInputsObserver;
  121063. private _onMeshTargetChangedObserver;
  121064. private _attachedCamera;
  121065. private _isPointerDown;
  121066. private _lastInteractionTime;
  121067. /**
  121068. * Initializes the behavior.
  121069. */
  121070. init(): void;
  121071. /**
  121072. * Attaches the behavior to its arc rotate camera.
  121073. * @param camera Defines the camera to attach the behavior to
  121074. */
  121075. attach(camera: ArcRotateCamera): void;
  121076. /**
  121077. * Detaches the behavior from its current arc rotate camera.
  121078. */
  121079. detach(): void;
  121080. private _animatables;
  121081. private _betaIsAnimating;
  121082. private _betaTransition;
  121083. private _radiusTransition;
  121084. private _vectorTransition;
  121085. /**
  121086. * Targets the given mesh and updates zoom level accordingly.
  121087. * @param mesh The mesh to target.
  121088. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121089. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121090. */
  121091. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121092. /**
  121093. * Targets the given mesh with its children and updates zoom level accordingly.
  121094. * @param mesh The mesh to target.
  121095. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121096. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121097. */
  121098. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121099. /**
  121100. * Targets the given meshes with their children and updates zoom level accordingly.
  121101. * @param meshes The mesh to target.
  121102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121104. */
  121105. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121106. /**
  121107. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121108. * @param minimumWorld Determines the smaller position of the bounding box extend
  121109. * @param maximumWorld Determines the bigger position of the bounding box extend
  121110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121112. */
  121113. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121114. /**
  121115. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121116. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121117. * frustum width.
  121118. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121119. * to fully enclose the mesh in the viewing frustum.
  121120. */
  121121. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121122. /**
  121123. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121124. * is automatically returned to its default position (expected to be above ground plane).
  121125. */
  121126. private _maintainCameraAboveGround;
  121127. /**
  121128. * Returns the frustum slope based on the canvas ratio and camera FOV
  121129. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121130. */
  121131. private _getFrustumSlope;
  121132. /**
  121133. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121134. */
  121135. private _clearAnimationLocks;
  121136. /**
  121137. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121138. */
  121139. private _applyUserInteraction;
  121140. /**
  121141. * Stops and removes all animations that have been applied to the camera
  121142. */
  121143. stopAllAnimations(): void;
  121144. /**
  121145. * Gets a value indicating if the user is moving the camera
  121146. */
  121147. get isUserIsMoving(): boolean;
  121148. /**
  121149. * The camera can move all the way towards the mesh.
  121150. */
  121151. static IgnoreBoundsSizeMode: number;
  121152. /**
  121153. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121154. */
  121155. static FitFrustumSidesMode: number;
  121156. }
  121157. }
  121158. declare module BABYLON {
  121159. /**
  121160. * Base class for Camera Pointer Inputs.
  121161. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121162. * for example usage.
  121163. */
  121164. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121165. /**
  121166. * Defines the camera the input is attached to.
  121167. */
  121168. abstract camera: Camera;
  121169. /**
  121170. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121171. */
  121172. protected _altKey: boolean;
  121173. protected _ctrlKey: boolean;
  121174. protected _metaKey: boolean;
  121175. protected _shiftKey: boolean;
  121176. /**
  121177. * Which mouse buttons were pressed at time of last mouse event.
  121178. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121179. */
  121180. protected _buttonsPressed: number;
  121181. /**
  121182. * Defines the buttons associated with the input to handle camera move.
  121183. */
  121184. buttons: number[];
  121185. /**
  121186. * Attach the input controls to a specific dom element to get the input from.
  121187. * @param element Defines the element the controls should be listened from
  121188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121189. */
  121190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121191. /**
  121192. * Detach the current controls from the specified dom element.
  121193. * @param element Defines the element to stop listening the inputs from
  121194. */
  121195. detachControl(element: Nullable<HTMLElement>): void;
  121196. /**
  121197. * Gets the class name of the current input.
  121198. * @returns the class name
  121199. */
  121200. getClassName(): string;
  121201. /**
  121202. * Get the friendly name associated with the input class.
  121203. * @returns the input friendly name
  121204. */
  121205. getSimpleName(): string;
  121206. /**
  121207. * Called on pointer POINTERDOUBLETAP event.
  121208. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121209. */
  121210. protected onDoubleTap(type: string): void;
  121211. /**
  121212. * Called on pointer POINTERMOVE event if only a single touch is active.
  121213. * Override this method to provide functionality.
  121214. */
  121215. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121216. /**
  121217. * Called on pointer POINTERMOVE event if multiple touches are active.
  121218. * Override this method to provide functionality.
  121219. */
  121220. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121221. /**
  121222. * Called on JS contextmenu event.
  121223. * Override this method to provide functionality.
  121224. */
  121225. protected onContextMenu(evt: PointerEvent): void;
  121226. /**
  121227. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121228. * press.
  121229. * Override this method to provide functionality.
  121230. */
  121231. protected onButtonDown(evt: PointerEvent): void;
  121232. /**
  121233. * Called each time a new POINTERUP event occurs. Ie, for each button
  121234. * release.
  121235. * Override this method to provide functionality.
  121236. */
  121237. protected onButtonUp(evt: PointerEvent): void;
  121238. /**
  121239. * Called when window becomes inactive.
  121240. * Override this method to provide functionality.
  121241. */
  121242. protected onLostFocus(): void;
  121243. private _pointerInput;
  121244. private _observer;
  121245. private _onLostFocus;
  121246. private pointA;
  121247. private pointB;
  121248. }
  121249. }
  121250. declare module BABYLON {
  121251. /**
  121252. * Manage the pointers inputs to control an arc rotate camera.
  121253. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121254. */
  121255. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121256. /**
  121257. * Defines the camera the input is attached to.
  121258. */
  121259. camera: ArcRotateCamera;
  121260. /**
  121261. * Gets the class name of the current input.
  121262. * @returns the class name
  121263. */
  121264. getClassName(): string;
  121265. /**
  121266. * Defines the buttons associated with the input to handle camera move.
  121267. */
  121268. buttons: number[];
  121269. /**
  121270. * Defines the pointer angular sensibility along the X axis or how fast is
  121271. * the camera rotating.
  121272. */
  121273. angularSensibilityX: number;
  121274. /**
  121275. * Defines the pointer angular sensibility along the Y axis or how fast is
  121276. * the camera rotating.
  121277. */
  121278. angularSensibilityY: number;
  121279. /**
  121280. * Defines the pointer pinch precision or how fast is the camera zooming.
  121281. */
  121282. pinchPrecision: number;
  121283. /**
  121284. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121285. * from 0.
  121286. * It defines the percentage of current camera.radius to use as delta when
  121287. * pinch zoom is used.
  121288. */
  121289. pinchDeltaPercentage: number;
  121290. /**
  121291. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121292. * that any object in the plane at the camera's target point will scale
  121293. * perfectly with finger motion.
  121294. * Overrides pinchDeltaPercentage and pinchPrecision.
  121295. */
  121296. useNaturalPinchZoom: boolean;
  121297. /**
  121298. * Defines the pointer panning sensibility or how fast is the camera moving.
  121299. */
  121300. panningSensibility: number;
  121301. /**
  121302. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121303. */
  121304. multiTouchPanning: boolean;
  121305. /**
  121306. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121307. * zoom (pinch) through multitouch.
  121308. */
  121309. multiTouchPanAndZoom: boolean;
  121310. /**
  121311. * Revers pinch action direction.
  121312. */
  121313. pinchInwards: boolean;
  121314. private _isPanClick;
  121315. private _twoFingerActivityCount;
  121316. private _isPinching;
  121317. /**
  121318. * Called on pointer POINTERMOVE event if only a single touch is active.
  121319. */
  121320. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121321. /**
  121322. * Called on pointer POINTERDOUBLETAP event.
  121323. */
  121324. protected onDoubleTap(type: string): void;
  121325. /**
  121326. * Called on pointer POINTERMOVE event if multiple touches are active.
  121327. */
  121328. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121329. /**
  121330. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121331. * press.
  121332. */
  121333. protected onButtonDown(evt: PointerEvent): void;
  121334. /**
  121335. * Called each time a new POINTERUP event occurs. Ie, for each button
  121336. * release.
  121337. */
  121338. protected onButtonUp(evt: PointerEvent): void;
  121339. /**
  121340. * Called when window becomes inactive.
  121341. */
  121342. protected onLostFocus(): void;
  121343. }
  121344. }
  121345. declare module BABYLON {
  121346. /**
  121347. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121349. */
  121350. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121351. /**
  121352. * Defines the camera the input is attached to.
  121353. */
  121354. camera: ArcRotateCamera;
  121355. /**
  121356. * Defines the list of key codes associated with the up action (increase alpha)
  121357. */
  121358. keysUp: number[];
  121359. /**
  121360. * Defines the list of key codes associated with the down action (decrease alpha)
  121361. */
  121362. keysDown: number[];
  121363. /**
  121364. * Defines the list of key codes associated with the left action (increase beta)
  121365. */
  121366. keysLeft: number[];
  121367. /**
  121368. * Defines the list of key codes associated with the right action (decrease beta)
  121369. */
  121370. keysRight: number[];
  121371. /**
  121372. * Defines the list of key codes associated with the reset action.
  121373. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121374. */
  121375. keysReset: number[];
  121376. /**
  121377. * Defines the panning sensibility of the inputs.
  121378. * (How fast is the camera panning)
  121379. */
  121380. panningSensibility: number;
  121381. /**
  121382. * Defines the zooming sensibility of the inputs.
  121383. * (How fast is the camera zooming)
  121384. */
  121385. zoomingSensibility: number;
  121386. /**
  121387. * Defines whether maintaining the alt key down switch the movement mode from
  121388. * orientation to zoom.
  121389. */
  121390. useAltToZoom: boolean;
  121391. /**
  121392. * Rotation speed of the camera
  121393. */
  121394. angularSpeed: number;
  121395. private _keys;
  121396. private _ctrlPressed;
  121397. private _altPressed;
  121398. private _onCanvasBlurObserver;
  121399. private _onKeyboardObserver;
  121400. private _engine;
  121401. private _scene;
  121402. /**
  121403. * Attach the input controls to a specific dom element to get the input from.
  121404. * @param element Defines the element the controls should be listened from
  121405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121406. */
  121407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121408. /**
  121409. * Detach the current controls from the specified dom element.
  121410. * @param element Defines the element to stop listening the inputs from
  121411. */
  121412. detachControl(element: Nullable<HTMLElement>): void;
  121413. /**
  121414. * Update the current camera state depending on the inputs that have been used this frame.
  121415. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121416. */
  121417. checkInputs(): void;
  121418. /**
  121419. * Gets the class name of the current intput.
  121420. * @returns the class name
  121421. */
  121422. getClassName(): string;
  121423. /**
  121424. * Get the friendly name associated with the input class.
  121425. * @returns the input friendly name
  121426. */
  121427. getSimpleName(): string;
  121428. }
  121429. }
  121430. declare module BABYLON {
  121431. /**
  121432. * Manage the mouse wheel inputs to control an arc rotate camera.
  121433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121434. */
  121435. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121436. /**
  121437. * Defines the camera the input is attached to.
  121438. */
  121439. camera: ArcRotateCamera;
  121440. /**
  121441. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121442. */
  121443. wheelPrecision: number;
  121444. /**
  121445. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121446. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121447. */
  121448. wheelDeltaPercentage: number;
  121449. private _wheel;
  121450. private _observer;
  121451. private computeDeltaFromMouseWheelLegacyEvent;
  121452. /**
  121453. * Attach the input controls to a specific dom element to get the input from.
  121454. * @param element Defines the element the controls should be listened from
  121455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121456. */
  121457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121458. /**
  121459. * Detach the current controls from the specified dom element.
  121460. * @param element Defines the element to stop listening the inputs from
  121461. */
  121462. detachControl(element: Nullable<HTMLElement>): void;
  121463. /**
  121464. * Gets the class name of the current intput.
  121465. * @returns the class name
  121466. */
  121467. getClassName(): string;
  121468. /**
  121469. * Get the friendly name associated with the input class.
  121470. * @returns the input friendly name
  121471. */
  121472. getSimpleName(): string;
  121473. }
  121474. }
  121475. declare module BABYLON {
  121476. /**
  121477. * Default Inputs manager for the ArcRotateCamera.
  121478. * It groups all the default supported inputs for ease of use.
  121479. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121480. */
  121481. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121482. /**
  121483. * Instantiates a new ArcRotateCameraInputsManager.
  121484. * @param camera Defines the camera the inputs belong to
  121485. */
  121486. constructor(camera: ArcRotateCamera);
  121487. /**
  121488. * Add mouse wheel input support to the input manager.
  121489. * @returns the current input manager
  121490. */
  121491. addMouseWheel(): ArcRotateCameraInputsManager;
  121492. /**
  121493. * Add pointers input support to the input manager.
  121494. * @returns the current input manager
  121495. */
  121496. addPointers(): ArcRotateCameraInputsManager;
  121497. /**
  121498. * Add keyboard input support to the input manager.
  121499. * @returns the current input manager
  121500. */
  121501. addKeyboard(): ArcRotateCameraInputsManager;
  121502. }
  121503. }
  121504. declare module BABYLON {
  121505. /**
  121506. * This represents an orbital type of camera.
  121507. *
  121508. * 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.
  121509. * 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.
  121510. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121511. */
  121512. export class ArcRotateCamera extends TargetCamera {
  121513. /**
  121514. * Defines the rotation angle of the camera along the longitudinal axis.
  121515. */
  121516. alpha: number;
  121517. /**
  121518. * Defines the rotation angle of the camera along the latitudinal axis.
  121519. */
  121520. beta: number;
  121521. /**
  121522. * Defines the radius of the camera from it s target point.
  121523. */
  121524. radius: number;
  121525. protected _target: Vector3;
  121526. protected _targetHost: Nullable<AbstractMesh>;
  121527. /**
  121528. * Defines the target point of the camera.
  121529. * The camera looks towards it form the radius distance.
  121530. */
  121531. get target(): Vector3;
  121532. set target(value: Vector3);
  121533. /**
  121534. * Define the current local position of the camera in the scene
  121535. */
  121536. get position(): Vector3;
  121537. set position(newPosition: Vector3);
  121538. protected _upVector: Vector3;
  121539. protected _upToYMatrix: Matrix;
  121540. protected _YToUpMatrix: Matrix;
  121541. /**
  121542. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121543. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121544. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121545. */
  121546. set upVector(vec: Vector3);
  121547. get upVector(): Vector3;
  121548. /**
  121549. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121550. */
  121551. setMatUp(): void;
  121552. /**
  121553. * Current inertia value on the longitudinal axis.
  121554. * The bigger this number the longer it will take for the camera to stop.
  121555. */
  121556. inertialAlphaOffset: number;
  121557. /**
  121558. * Current inertia value on the latitudinal axis.
  121559. * The bigger this number the longer it will take for the camera to stop.
  121560. */
  121561. inertialBetaOffset: number;
  121562. /**
  121563. * Current inertia value on the radius axis.
  121564. * The bigger this number the longer it will take for the camera to stop.
  121565. */
  121566. inertialRadiusOffset: number;
  121567. /**
  121568. * Minimum allowed angle on the longitudinal axis.
  121569. * This can help limiting how the Camera is able to move in the scene.
  121570. */
  121571. lowerAlphaLimit: Nullable<number>;
  121572. /**
  121573. * Maximum allowed angle on the longitudinal axis.
  121574. * This can help limiting how the Camera is able to move in the scene.
  121575. */
  121576. upperAlphaLimit: Nullable<number>;
  121577. /**
  121578. * Minimum allowed angle on the latitudinal axis.
  121579. * This can help limiting how the Camera is able to move in the scene.
  121580. */
  121581. lowerBetaLimit: number;
  121582. /**
  121583. * Maximum allowed angle on the latitudinal axis.
  121584. * This can help limiting how the Camera is able to move in the scene.
  121585. */
  121586. upperBetaLimit: number;
  121587. /**
  121588. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121589. * This can help limiting how the Camera is able to move in the scene.
  121590. */
  121591. lowerRadiusLimit: Nullable<number>;
  121592. /**
  121593. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121594. * This can help limiting how the Camera is able to move in the scene.
  121595. */
  121596. upperRadiusLimit: Nullable<number>;
  121597. /**
  121598. * Defines the current inertia value used during panning of the camera along the X axis.
  121599. */
  121600. inertialPanningX: number;
  121601. /**
  121602. * Defines the current inertia value used during panning of the camera along the Y axis.
  121603. */
  121604. inertialPanningY: number;
  121605. /**
  121606. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121607. * Basically if your fingers moves away from more than this distance you will be considered
  121608. * in pinch mode.
  121609. */
  121610. pinchToPanMaxDistance: number;
  121611. /**
  121612. * Defines the maximum distance the camera can pan.
  121613. * This could help keeping the cammera always in your scene.
  121614. */
  121615. panningDistanceLimit: Nullable<number>;
  121616. /**
  121617. * Defines the target of the camera before paning.
  121618. */
  121619. panningOriginTarget: Vector3;
  121620. /**
  121621. * Defines the value of the inertia used during panning.
  121622. * 0 would mean stop inertia and one would mean no decelleration at all.
  121623. */
  121624. panningInertia: number;
  121625. /**
  121626. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121627. */
  121628. get angularSensibilityX(): number;
  121629. set angularSensibilityX(value: number);
  121630. /**
  121631. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121632. */
  121633. get angularSensibilityY(): number;
  121634. set angularSensibilityY(value: number);
  121635. /**
  121636. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121637. */
  121638. get pinchPrecision(): number;
  121639. set pinchPrecision(value: number);
  121640. /**
  121641. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121642. * It will be used instead of pinchDeltaPrecision if different from 0.
  121643. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121644. */
  121645. get pinchDeltaPercentage(): number;
  121646. set pinchDeltaPercentage(value: number);
  121647. /**
  121648. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121649. * and pinch delta percentage.
  121650. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121651. * that any object in the plane at the camera's target point will scale
  121652. * perfectly with finger motion.
  121653. */
  121654. get useNaturalPinchZoom(): boolean;
  121655. set useNaturalPinchZoom(value: boolean);
  121656. /**
  121657. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121658. */
  121659. get panningSensibility(): number;
  121660. set panningSensibility(value: number);
  121661. /**
  121662. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121663. */
  121664. get keysUp(): number[];
  121665. set keysUp(value: number[]);
  121666. /**
  121667. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121668. */
  121669. get keysDown(): number[];
  121670. set keysDown(value: number[]);
  121671. /**
  121672. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121673. */
  121674. get keysLeft(): number[];
  121675. set keysLeft(value: number[]);
  121676. /**
  121677. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121678. */
  121679. get keysRight(): number[];
  121680. set keysRight(value: number[]);
  121681. /**
  121682. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121683. */
  121684. get wheelPrecision(): number;
  121685. set wheelPrecision(value: number);
  121686. /**
  121687. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121688. * It will be used instead of pinchDeltaPrecision if different from 0.
  121689. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121690. */
  121691. get wheelDeltaPercentage(): number;
  121692. set wheelDeltaPercentage(value: number);
  121693. /**
  121694. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121695. */
  121696. zoomOnFactor: number;
  121697. /**
  121698. * Defines a screen offset for the camera position.
  121699. */
  121700. targetScreenOffset: Vector2;
  121701. /**
  121702. * Allows the camera to be completely reversed.
  121703. * If false the camera can not arrive upside down.
  121704. */
  121705. allowUpsideDown: boolean;
  121706. /**
  121707. * Define if double tap/click is used to restore the previously saved state of the camera.
  121708. */
  121709. useInputToRestoreState: boolean;
  121710. /** @hidden */
  121711. _viewMatrix: Matrix;
  121712. /** @hidden */
  121713. _useCtrlForPanning: boolean;
  121714. /** @hidden */
  121715. _panningMouseButton: number;
  121716. /**
  121717. * Defines the input associated to the camera.
  121718. */
  121719. inputs: ArcRotateCameraInputsManager;
  121720. /** @hidden */
  121721. _reset: () => void;
  121722. /**
  121723. * Defines the allowed panning axis.
  121724. */
  121725. panningAxis: Vector3;
  121726. protected _localDirection: Vector3;
  121727. protected _transformedDirection: Vector3;
  121728. private _bouncingBehavior;
  121729. /**
  121730. * Gets the bouncing behavior of the camera if it has been enabled.
  121731. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121732. */
  121733. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121734. /**
  121735. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121736. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121737. */
  121738. get useBouncingBehavior(): boolean;
  121739. set useBouncingBehavior(value: boolean);
  121740. private _framingBehavior;
  121741. /**
  121742. * Gets the framing behavior of the camera if it has been enabled.
  121743. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121744. */
  121745. get framingBehavior(): Nullable<FramingBehavior>;
  121746. /**
  121747. * Defines if the framing behavior of the camera is enabled on the camera.
  121748. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121749. */
  121750. get useFramingBehavior(): boolean;
  121751. set useFramingBehavior(value: boolean);
  121752. private _autoRotationBehavior;
  121753. /**
  121754. * Gets the auto rotation behavior of the camera if it has been enabled.
  121755. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121756. */
  121757. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121758. /**
  121759. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121760. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121761. */
  121762. get useAutoRotationBehavior(): boolean;
  121763. set useAutoRotationBehavior(value: boolean);
  121764. /**
  121765. * Observable triggered when the mesh target has been changed on the camera.
  121766. */
  121767. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121768. /**
  121769. * Event raised when the camera is colliding with a mesh.
  121770. */
  121771. onCollide: (collidedMesh: AbstractMesh) => void;
  121772. /**
  121773. * Defines whether the camera should check collision with the objects oh the scene.
  121774. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121775. */
  121776. checkCollisions: boolean;
  121777. /**
  121778. * Defines the collision radius of the camera.
  121779. * This simulates a sphere around the camera.
  121780. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121781. */
  121782. collisionRadius: Vector3;
  121783. protected _collider: Collider;
  121784. protected _previousPosition: Vector3;
  121785. protected _collisionVelocity: Vector3;
  121786. protected _newPosition: Vector3;
  121787. protected _previousAlpha: number;
  121788. protected _previousBeta: number;
  121789. protected _previousRadius: number;
  121790. protected _collisionTriggered: boolean;
  121791. protected _targetBoundingCenter: Nullable<Vector3>;
  121792. private _computationVector;
  121793. /**
  121794. * Instantiates a new ArcRotateCamera in a given scene
  121795. * @param name Defines the name of the camera
  121796. * @param alpha Defines the camera rotation along the logitudinal axis
  121797. * @param beta Defines the camera rotation along the latitudinal axis
  121798. * @param radius Defines the camera distance from its target
  121799. * @param target Defines the camera target
  121800. * @param scene Defines the scene the camera belongs to
  121801. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  121802. */
  121803. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121804. /** @hidden */
  121805. _initCache(): void;
  121806. /** @hidden */
  121807. _updateCache(ignoreParentClass?: boolean): void;
  121808. protected _getTargetPosition(): Vector3;
  121809. private _storedAlpha;
  121810. private _storedBeta;
  121811. private _storedRadius;
  121812. private _storedTarget;
  121813. private _storedTargetScreenOffset;
  121814. /**
  121815. * Stores the current state of the camera (alpha, beta, radius and target)
  121816. * @returns the camera itself
  121817. */
  121818. storeState(): Camera;
  121819. /**
  121820. * @hidden
  121821. * Restored camera state. You must call storeState() first
  121822. */
  121823. _restoreStateValues(): boolean;
  121824. /** @hidden */
  121825. _isSynchronizedViewMatrix(): boolean;
  121826. /**
  121827. * Attached controls to the current camera.
  121828. * @param element Defines the element the controls should be listened from
  121829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121830. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  121831. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  121832. */
  121833. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  121834. /**
  121835. * Detach the current controls from the camera.
  121836. * The camera will stop reacting to inputs.
  121837. * @param element Defines the element to stop listening the inputs from
  121838. */
  121839. detachControl(element: HTMLElement): void;
  121840. /** @hidden */
  121841. _checkInputs(): void;
  121842. protected _checkLimits(): void;
  121843. /**
  121844. * Rebuilds angles (alpha, beta) and radius from the give position and target
  121845. */
  121846. rebuildAnglesAndRadius(): void;
  121847. /**
  121848. * Use a position to define the current camera related information like alpha, beta and radius
  121849. * @param position Defines the position to set the camera at
  121850. */
  121851. setPosition(position: Vector3): void;
  121852. /**
  121853. * Defines the target the camera should look at.
  121854. * This will automatically adapt alpha beta and radius to fit within the new target.
  121855. * @param target Defines the new target as a Vector or a mesh
  121856. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  121857. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  121858. */
  121859. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  121860. /** @hidden */
  121861. _getViewMatrix(): Matrix;
  121862. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  121863. /**
  121864. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  121865. * @param meshes Defines the mesh to zoom on
  121866. * @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)
  121867. */
  121868. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  121869. /**
  121870. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  121871. * The target will be changed but the radius
  121872. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  121873. * @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)
  121874. */
  121875. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  121876. min: Vector3;
  121877. max: Vector3;
  121878. distance: number;
  121879. }, doNotUpdateMaxZ?: boolean): void;
  121880. /**
  121881. * @override
  121882. * Override Camera.createRigCamera
  121883. */
  121884. createRigCamera(name: string, cameraIndex: number): Camera;
  121885. /**
  121886. * @hidden
  121887. * @override
  121888. * Override Camera._updateRigCameras
  121889. */
  121890. _updateRigCameras(): void;
  121891. /**
  121892. * Destroy the camera and release the current resources hold by it.
  121893. */
  121894. dispose(): void;
  121895. /**
  121896. * Gets the current object class name.
  121897. * @return the class name
  121898. */
  121899. getClassName(): string;
  121900. }
  121901. }
  121902. declare module BABYLON {
  121903. /**
  121904. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  121905. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121906. */
  121907. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  121908. /**
  121909. * Gets the name of the behavior.
  121910. */
  121911. get name(): string;
  121912. private _zoomStopsAnimation;
  121913. private _idleRotationSpeed;
  121914. private _idleRotationWaitTime;
  121915. private _idleRotationSpinupTime;
  121916. /**
  121917. * Sets the flag that indicates if user zooming should stop animation.
  121918. */
  121919. set zoomStopsAnimation(flag: boolean);
  121920. /**
  121921. * Gets the flag that indicates if user zooming should stop animation.
  121922. */
  121923. get zoomStopsAnimation(): boolean;
  121924. /**
  121925. * Sets the default speed at which the camera rotates around the model.
  121926. */
  121927. set idleRotationSpeed(speed: number);
  121928. /**
  121929. * Gets the default speed at which the camera rotates around the model.
  121930. */
  121931. get idleRotationSpeed(): number;
  121932. /**
  121933. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  121934. */
  121935. set idleRotationWaitTime(time: number);
  121936. /**
  121937. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  121938. */
  121939. get idleRotationWaitTime(): number;
  121940. /**
  121941. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121942. */
  121943. set idleRotationSpinupTime(time: number);
  121944. /**
  121945. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  121946. */
  121947. get idleRotationSpinupTime(): number;
  121948. /**
  121949. * Gets a value indicating if the camera is currently rotating because of this behavior
  121950. */
  121951. get rotationInProgress(): boolean;
  121952. private _onPrePointerObservableObserver;
  121953. private _onAfterCheckInputsObserver;
  121954. private _attachedCamera;
  121955. private _isPointerDown;
  121956. private _lastFrameTime;
  121957. private _lastInteractionTime;
  121958. private _cameraRotationSpeed;
  121959. /**
  121960. * Initializes the behavior.
  121961. */
  121962. init(): void;
  121963. /**
  121964. * Attaches the behavior to its arc rotate camera.
  121965. * @param camera Defines the camera to attach the behavior to
  121966. */
  121967. attach(camera: ArcRotateCamera): void;
  121968. /**
  121969. * Detaches the behavior from its current arc rotate camera.
  121970. */
  121971. detach(): void;
  121972. /**
  121973. * Returns true if user is scrolling.
  121974. * @return true if user is scrolling.
  121975. */
  121976. private _userIsZooming;
  121977. private _lastFrameRadius;
  121978. private _shouldAnimationStopForInteraction;
  121979. /**
  121980. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121981. */
  121982. private _applyUserInteraction;
  121983. private _userIsMoving;
  121984. }
  121985. }
  121986. declare module BABYLON {
  121987. /**
  121988. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  121989. */
  121990. export class AttachToBoxBehavior implements Behavior<Mesh> {
  121991. private ui;
  121992. /**
  121993. * The name of the behavior
  121994. */
  121995. name: string;
  121996. /**
  121997. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  121998. */
  121999. distanceAwayFromFace: number;
  122000. /**
  122001. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122002. */
  122003. distanceAwayFromBottomOfFace: number;
  122004. private _faceVectors;
  122005. private _target;
  122006. private _scene;
  122007. private _onRenderObserver;
  122008. private _tmpMatrix;
  122009. private _tmpVector;
  122010. /**
  122011. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122012. * @param ui The transform node that should be attched to the mesh
  122013. */
  122014. constructor(ui: TransformNode);
  122015. /**
  122016. * Initializes the behavior
  122017. */
  122018. init(): void;
  122019. private _closestFace;
  122020. private _zeroVector;
  122021. private _lookAtTmpMatrix;
  122022. private _lookAtToRef;
  122023. /**
  122024. * Attaches the AttachToBoxBehavior to the passed in mesh
  122025. * @param target The mesh that the specified node will be attached to
  122026. */
  122027. attach(target: Mesh): void;
  122028. /**
  122029. * Detaches the behavior from the mesh
  122030. */
  122031. detach(): void;
  122032. }
  122033. }
  122034. declare module BABYLON {
  122035. /**
  122036. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122037. */
  122038. export class FadeInOutBehavior implements Behavior<Mesh> {
  122039. /**
  122040. * Time in milliseconds to delay before fading in (Default: 0)
  122041. */
  122042. delay: number;
  122043. /**
  122044. * Time in milliseconds for the mesh to fade in (Default: 300)
  122045. */
  122046. fadeInTime: number;
  122047. private _millisecondsPerFrame;
  122048. private _hovered;
  122049. private _hoverValue;
  122050. private _ownerNode;
  122051. /**
  122052. * Instatiates the FadeInOutBehavior
  122053. */
  122054. constructor();
  122055. /**
  122056. * The name of the behavior
  122057. */
  122058. get name(): string;
  122059. /**
  122060. * Initializes the behavior
  122061. */
  122062. init(): void;
  122063. /**
  122064. * Attaches the fade behavior on the passed in mesh
  122065. * @param ownerNode The mesh that will be faded in/out once attached
  122066. */
  122067. attach(ownerNode: Mesh): void;
  122068. /**
  122069. * Detaches the behavior from the mesh
  122070. */
  122071. detach(): void;
  122072. /**
  122073. * Triggers the mesh to begin fading in or out
  122074. * @param value if the object should fade in or out (true to fade in)
  122075. */
  122076. fadeIn(value: boolean): void;
  122077. private _update;
  122078. private _setAllVisibility;
  122079. }
  122080. }
  122081. declare module BABYLON {
  122082. /**
  122083. * Class containing a set of static utilities functions for managing Pivots
  122084. * @hidden
  122085. */
  122086. export class PivotTools {
  122087. private static _PivotCached;
  122088. private static _OldPivotPoint;
  122089. private static _PivotTranslation;
  122090. private static _PivotTmpVector;
  122091. /** @hidden */
  122092. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122093. /** @hidden */
  122094. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122095. }
  122096. }
  122097. declare module BABYLON {
  122098. /**
  122099. * Class containing static functions to help procedurally build meshes
  122100. */
  122101. export class PlaneBuilder {
  122102. /**
  122103. * Creates a plane mesh
  122104. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122105. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122106. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122110. * @param name defines the name of the mesh
  122111. * @param options defines the options used to create the mesh
  122112. * @param scene defines the hosting scene
  122113. * @returns the plane mesh
  122114. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122115. */
  122116. static CreatePlane(name: string, options: {
  122117. size?: number;
  122118. width?: number;
  122119. height?: number;
  122120. sideOrientation?: number;
  122121. frontUVs?: Vector4;
  122122. backUVs?: Vector4;
  122123. updatable?: boolean;
  122124. sourcePlane?: Plane;
  122125. }, scene?: Nullable<Scene>): Mesh;
  122126. }
  122127. }
  122128. declare module BABYLON {
  122129. /**
  122130. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122131. */
  122132. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122133. private static _AnyMouseID;
  122134. /**
  122135. * Abstract mesh the behavior is set on
  122136. */
  122137. attachedNode: AbstractMesh;
  122138. private _dragPlane;
  122139. private _scene;
  122140. private _pointerObserver;
  122141. private _beforeRenderObserver;
  122142. private static _planeScene;
  122143. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122144. /**
  122145. * 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)
  122146. */
  122147. maxDragAngle: number;
  122148. /**
  122149. * @hidden
  122150. */
  122151. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122152. /**
  122153. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122154. */
  122155. currentDraggingPointerID: number;
  122156. /**
  122157. * The last position where the pointer hit the drag plane in world space
  122158. */
  122159. lastDragPosition: Vector3;
  122160. /**
  122161. * If the behavior is currently in a dragging state
  122162. */
  122163. dragging: boolean;
  122164. /**
  122165. * 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)
  122166. */
  122167. dragDeltaRatio: number;
  122168. /**
  122169. * If the drag plane orientation should be updated during the dragging (Default: true)
  122170. */
  122171. updateDragPlane: boolean;
  122172. private _debugMode;
  122173. private _moving;
  122174. /**
  122175. * Fires each time the attached mesh is dragged with the pointer
  122176. * * delta between last drag position and current drag position in world space
  122177. * * dragDistance along the drag axis
  122178. * * dragPlaneNormal normal of the current drag plane used during the drag
  122179. * * dragPlanePoint in world space where the drag intersects the drag plane
  122180. */
  122181. onDragObservable: Observable<{
  122182. delta: Vector3;
  122183. dragPlanePoint: Vector3;
  122184. dragPlaneNormal: Vector3;
  122185. dragDistance: number;
  122186. pointerId: number;
  122187. }>;
  122188. /**
  122189. * Fires each time a drag begins (eg. mouse down on mesh)
  122190. */
  122191. onDragStartObservable: Observable<{
  122192. dragPlanePoint: Vector3;
  122193. pointerId: number;
  122194. }>;
  122195. /**
  122196. * Fires each time a drag ends (eg. mouse release after drag)
  122197. */
  122198. onDragEndObservable: Observable<{
  122199. dragPlanePoint: Vector3;
  122200. pointerId: number;
  122201. }>;
  122202. /**
  122203. * If the attached mesh should be moved when dragged
  122204. */
  122205. moveAttached: boolean;
  122206. /**
  122207. * If the drag behavior will react to drag events (Default: true)
  122208. */
  122209. enabled: boolean;
  122210. /**
  122211. * If pointer events should start and release the drag (Default: true)
  122212. */
  122213. startAndReleaseDragOnPointerEvents: boolean;
  122214. /**
  122215. * If camera controls should be detached during the drag
  122216. */
  122217. detachCameraControls: boolean;
  122218. /**
  122219. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122220. */
  122221. useObjectOrientationForDragging: boolean;
  122222. private _options;
  122223. /**
  122224. * Gets the options used by the behavior
  122225. */
  122226. get options(): {
  122227. dragAxis?: Vector3;
  122228. dragPlaneNormal?: Vector3;
  122229. };
  122230. /**
  122231. * Sets the options used by the behavior
  122232. */
  122233. set options(options: {
  122234. dragAxis?: Vector3;
  122235. dragPlaneNormal?: Vector3;
  122236. });
  122237. /**
  122238. * Creates a pointer drag behavior that can be attached to a mesh
  122239. * @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)
  122240. */
  122241. constructor(options?: {
  122242. dragAxis?: Vector3;
  122243. dragPlaneNormal?: Vector3;
  122244. });
  122245. /**
  122246. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122247. */
  122248. validateDrag: (targetPosition: Vector3) => boolean;
  122249. /**
  122250. * The name of the behavior
  122251. */
  122252. get name(): string;
  122253. /**
  122254. * Initializes the behavior
  122255. */
  122256. init(): void;
  122257. private _tmpVector;
  122258. private _alternatePickedPoint;
  122259. private _worldDragAxis;
  122260. private _targetPosition;
  122261. private _attachedElement;
  122262. /**
  122263. * Attaches the drag behavior the passed in mesh
  122264. * @param ownerNode The mesh that will be dragged around once attached
  122265. * @param predicate Predicate to use for pick filtering
  122266. */
  122267. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122268. /**
  122269. * Force relase the drag action by code.
  122270. */
  122271. releaseDrag(): void;
  122272. private _startDragRay;
  122273. private _lastPointerRay;
  122274. /**
  122275. * Simulates the start of a pointer drag event on the behavior
  122276. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122277. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122278. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122279. */
  122280. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122281. private _startDrag;
  122282. private _dragDelta;
  122283. private _moveDrag;
  122284. private _pickWithRayOnDragPlane;
  122285. private _pointA;
  122286. private _pointC;
  122287. private _localAxis;
  122288. private _lookAt;
  122289. private _updateDragPlanePosition;
  122290. /**
  122291. * Detaches the behavior from the mesh
  122292. */
  122293. detach(): void;
  122294. }
  122295. }
  122296. declare module BABYLON {
  122297. /**
  122298. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122299. */
  122300. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122301. private _dragBehaviorA;
  122302. private _dragBehaviorB;
  122303. private _startDistance;
  122304. private _initialScale;
  122305. private _targetScale;
  122306. private _ownerNode;
  122307. private _sceneRenderObserver;
  122308. /**
  122309. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122310. */
  122311. constructor();
  122312. /**
  122313. * The name of the behavior
  122314. */
  122315. get name(): string;
  122316. /**
  122317. * Initializes the behavior
  122318. */
  122319. init(): void;
  122320. private _getCurrentDistance;
  122321. /**
  122322. * Attaches the scale behavior the passed in mesh
  122323. * @param ownerNode The mesh that will be scaled around once attached
  122324. */
  122325. attach(ownerNode: Mesh): void;
  122326. /**
  122327. * Detaches the behavior from the mesh
  122328. */
  122329. detach(): void;
  122330. }
  122331. }
  122332. declare module BABYLON {
  122333. /**
  122334. * 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
  122335. */
  122336. export class SixDofDragBehavior implements Behavior<Mesh> {
  122337. private static _virtualScene;
  122338. private _ownerNode;
  122339. private _sceneRenderObserver;
  122340. private _scene;
  122341. private _targetPosition;
  122342. private _virtualOriginMesh;
  122343. private _virtualDragMesh;
  122344. private _pointerObserver;
  122345. private _moving;
  122346. private _startingOrientation;
  122347. private _attachedElement;
  122348. /**
  122349. * 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)
  122350. */
  122351. private zDragFactor;
  122352. /**
  122353. * If the object should rotate to face the drag origin
  122354. */
  122355. rotateDraggedObject: boolean;
  122356. /**
  122357. * If the behavior is currently in a dragging state
  122358. */
  122359. dragging: boolean;
  122360. /**
  122361. * 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)
  122362. */
  122363. dragDeltaRatio: number;
  122364. /**
  122365. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122366. */
  122367. currentDraggingPointerID: number;
  122368. /**
  122369. * If camera controls should be detached during the drag
  122370. */
  122371. detachCameraControls: boolean;
  122372. /**
  122373. * Fires each time a drag starts
  122374. */
  122375. onDragStartObservable: Observable<{}>;
  122376. /**
  122377. * Fires each time a drag ends (eg. mouse release after drag)
  122378. */
  122379. onDragEndObservable: Observable<{}>;
  122380. /**
  122381. * 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
  122382. */
  122383. constructor();
  122384. /**
  122385. * The name of the behavior
  122386. */
  122387. get name(): string;
  122388. /**
  122389. * Initializes the behavior
  122390. */
  122391. init(): void;
  122392. /**
  122393. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122394. */
  122395. private get _pointerCamera();
  122396. /**
  122397. * Attaches the scale behavior the passed in mesh
  122398. * @param ownerNode The mesh that will be scaled around once attached
  122399. */
  122400. attach(ownerNode: Mesh): void;
  122401. /**
  122402. * Detaches the behavior from the mesh
  122403. */
  122404. detach(): void;
  122405. }
  122406. }
  122407. declare module BABYLON {
  122408. /**
  122409. * Class used to apply inverse kinematics to bones
  122410. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122411. */
  122412. export class BoneIKController {
  122413. private static _tmpVecs;
  122414. private static _tmpQuat;
  122415. private static _tmpMats;
  122416. /**
  122417. * Gets or sets the target mesh
  122418. */
  122419. targetMesh: AbstractMesh;
  122420. /** Gets or sets the mesh used as pole */
  122421. poleTargetMesh: AbstractMesh;
  122422. /**
  122423. * Gets or sets the bone used as pole
  122424. */
  122425. poleTargetBone: Nullable<Bone>;
  122426. /**
  122427. * Gets or sets the target position
  122428. */
  122429. targetPosition: Vector3;
  122430. /**
  122431. * Gets or sets the pole target position
  122432. */
  122433. poleTargetPosition: Vector3;
  122434. /**
  122435. * Gets or sets the pole target local offset
  122436. */
  122437. poleTargetLocalOffset: Vector3;
  122438. /**
  122439. * Gets or sets the pole angle
  122440. */
  122441. poleAngle: number;
  122442. /**
  122443. * Gets or sets the mesh associated with the controller
  122444. */
  122445. mesh: AbstractMesh;
  122446. /**
  122447. * 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)
  122448. */
  122449. slerpAmount: number;
  122450. private _bone1Quat;
  122451. private _bone1Mat;
  122452. private _bone2Ang;
  122453. private _bone1;
  122454. private _bone2;
  122455. private _bone1Length;
  122456. private _bone2Length;
  122457. private _maxAngle;
  122458. private _maxReach;
  122459. private _rightHandedSystem;
  122460. private _bendAxis;
  122461. private _slerping;
  122462. private _adjustRoll;
  122463. /**
  122464. * Gets or sets maximum allowed angle
  122465. */
  122466. get maxAngle(): number;
  122467. set maxAngle(value: number);
  122468. /**
  122469. * Creates a new BoneIKController
  122470. * @param mesh defines the mesh to control
  122471. * @param bone defines the bone to control
  122472. * @param options defines options to set up the controller
  122473. */
  122474. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122475. targetMesh?: AbstractMesh;
  122476. poleTargetMesh?: AbstractMesh;
  122477. poleTargetBone?: Bone;
  122478. poleTargetLocalOffset?: Vector3;
  122479. poleAngle?: number;
  122480. bendAxis?: Vector3;
  122481. maxAngle?: number;
  122482. slerpAmount?: number;
  122483. });
  122484. private _setMaxAngle;
  122485. /**
  122486. * Force the controller to update the bones
  122487. */
  122488. update(): void;
  122489. }
  122490. }
  122491. declare module BABYLON {
  122492. /**
  122493. * Class used to make a bone look toward a point in space
  122494. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122495. */
  122496. export class BoneLookController {
  122497. private static _tmpVecs;
  122498. private static _tmpQuat;
  122499. private static _tmpMats;
  122500. /**
  122501. * The target Vector3 that the bone will look at
  122502. */
  122503. target: Vector3;
  122504. /**
  122505. * The mesh that the bone is attached to
  122506. */
  122507. mesh: AbstractMesh;
  122508. /**
  122509. * The bone that will be looking to the target
  122510. */
  122511. bone: Bone;
  122512. /**
  122513. * The up axis of the coordinate system that is used when the bone is rotated
  122514. */
  122515. upAxis: Vector3;
  122516. /**
  122517. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122518. */
  122519. upAxisSpace: Space;
  122520. /**
  122521. * Used to make an adjustment to the yaw of the bone
  122522. */
  122523. adjustYaw: number;
  122524. /**
  122525. * Used to make an adjustment to the pitch of the bone
  122526. */
  122527. adjustPitch: number;
  122528. /**
  122529. * Used to make an adjustment to the roll of the bone
  122530. */
  122531. adjustRoll: number;
  122532. /**
  122533. * 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)
  122534. */
  122535. slerpAmount: number;
  122536. private _minYaw;
  122537. private _maxYaw;
  122538. private _minPitch;
  122539. private _maxPitch;
  122540. private _minYawSin;
  122541. private _minYawCos;
  122542. private _maxYawSin;
  122543. private _maxYawCos;
  122544. private _midYawConstraint;
  122545. private _minPitchTan;
  122546. private _maxPitchTan;
  122547. private _boneQuat;
  122548. private _slerping;
  122549. private _transformYawPitch;
  122550. private _transformYawPitchInv;
  122551. private _firstFrameSkipped;
  122552. private _yawRange;
  122553. private _fowardAxis;
  122554. /**
  122555. * Gets or sets the minimum yaw angle that the bone can look to
  122556. */
  122557. get minYaw(): number;
  122558. set minYaw(value: number);
  122559. /**
  122560. * Gets or sets the maximum yaw angle that the bone can look to
  122561. */
  122562. get maxYaw(): number;
  122563. set maxYaw(value: number);
  122564. /**
  122565. * Gets or sets the minimum pitch angle that the bone can look to
  122566. */
  122567. get minPitch(): number;
  122568. set minPitch(value: number);
  122569. /**
  122570. * Gets or sets the maximum pitch angle that the bone can look to
  122571. */
  122572. get maxPitch(): number;
  122573. set maxPitch(value: number);
  122574. /**
  122575. * Create a BoneLookController
  122576. * @param mesh the mesh that the bone belongs to
  122577. * @param bone the bone that will be looking to the target
  122578. * @param target the target Vector3 to look at
  122579. * @param options optional settings:
  122580. * * maxYaw: the maximum angle the bone will yaw to
  122581. * * minYaw: the minimum angle the bone will yaw to
  122582. * * maxPitch: the maximum angle the bone will pitch to
  122583. * * minPitch: the minimum angle the bone will yaw to
  122584. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122585. * * upAxis: the up axis of the coordinate system
  122586. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122587. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122588. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122589. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122590. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122591. * * adjustRoll: used to make an adjustment to the roll of the bone
  122592. **/
  122593. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122594. maxYaw?: number;
  122595. minYaw?: number;
  122596. maxPitch?: number;
  122597. minPitch?: number;
  122598. slerpAmount?: number;
  122599. upAxis?: Vector3;
  122600. upAxisSpace?: Space;
  122601. yawAxis?: Vector3;
  122602. pitchAxis?: Vector3;
  122603. adjustYaw?: number;
  122604. adjustPitch?: number;
  122605. adjustRoll?: number;
  122606. });
  122607. /**
  122608. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122609. */
  122610. update(): void;
  122611. private _getAngleDiff;
  122612. private _getAngleBetween;
  122613. private _isAngleBetween;
  122614. }
  122615. }
  122616. declare module BABYLON {
  122617. /**
  122618. * Manage the gamepad inputs to control an arc rotate camera.
  122619. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122620. */
  122621. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122622. /**
  122623. * Defines the camera the input is attached to.
  122624. */
  122625. camera: ArcRotateCamera;
  122626. /**
  122627. * Defines the gamepad the input is gathering event from.
  122628. */
  122629. gamepad: Nullable<Gamepad>;
  122630. /**
  122631. * Defines the gamepad rotation sensiblity.
  122632. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122633. */
  122634. gamepadRotationSensibility: number;
  122635. /**
  122636. * Defines the gamepad move sensiblity.
  122637. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122638. */
  122639. gamepadMoveSensibility: number;
  122640. private _yAxisScale;
  122641. /**
  122642. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122643. */
  122644. get invertYAxis(): boolean;
  122645. set invertYAxis(value: boolean);
  122646. private _onGamepadConnectedObserver;
  122647. private _onGamepadDisconnectedObserver;
  122648. /**
  122649. * Attach the input controls to a specific dom element to get the input from.
  122650. * @param element Defines the element the controls should be listened from
  122651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122652. */
  122653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122654. /**
  122655. * Detach the current controls from the specified dom element.
  122656. * @param element Defines the element to stop listening the inputs from
  122657. */
  122658. detachControl(element: Nullable<HTMLElement>): void;
  122659. /**
  122660. * Update the current camera state depending on the inputs that have been used this frame.
  122661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122662. */
  122663. checkInputs(): void;
  122664. /**
  122665. * Gets the class name of the current intput.
  122666. * @returns the class name
  122667. */
  122668. getClassName(): string;
  122669. /**
  122670. * Get the friendly name associated with the input class.
  122671. * @returns the input friendly name
  122672. */
  122673. getSimpleName(): string;
  122674. }
  122675. }
  122676. declare module BABYLON {
  122677. interface ArcRotateCameraInputsManager {
  122678. /**
  122679. * Add orientation input support to the input manager.
  122680. * @returns the current input manager
  122681. */
  122682. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122683. }
  122684. /**
  122685. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122687. */
  122688. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122689. /**
  122690. * Defines the camera the input is attached to.
  122691. */
  122692. camera: ArcRotateCamera;
  122693. /**
  122694. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122695. */
  122696. alphaCorrection: number;
  122697. /**
  122698. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122699. */
  122700. gammaCorrection: number;
  122701. private _alpha;
  122702. private _gamma;
  122703. private _dirty;
  122704. private _deviceOrientationHandler;
  122705. /**
  122706. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122707. */
  122708. constructor();
  122709. /**
  122710. * Attach the input controls to a specific dom element to get the input from.
  122711. * @param element Defines the element the controls should be listened from
  122712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122713. */
  122714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122715. /** @hidden */
  122716. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122717. /**
  122718. * Update the current camera state depending on the inputs that have been used this frame.
  122719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122720. */
  122721. checkInputs(): void;
  122722. /**
  122723. * Detach the current controls from the specified dom element.
  122724. * @param element Defines the element to stop listening the inputs from
  122725. */
  122726. detachControl(element: Nullable<HTMLElement>): void;
  122727. /**
  122728. * Gets the class name of the current intput.
  122729. * @returns the class name
  122730. */
  122731. getClassName(): string;
  122732. /**
  122733. * Get the friendly name associated with the input class.
  122734. * @returns the input friendly name
  122735. */
  122736. getSimpleName(): string;
  122737. }
  122738. }
  122739. declare module BABYLON {
  122740. /**
  122741. * Listen to mouse events to control the camera.
  122742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122743. */
  122744. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122745. /**
  122746. * Defines the camera the input is attached to.
  122747. */
  122748. camera: FlyCamera;
  122749. /**
  122750. * Defines if touch is enabled. (Default is true.)
  122751. */
  122752. touchEnabled: boolean;
  122753. /**
  122754. * Defines the buttons associated with the input to handle camera rotation.
  122755. */
  122756. buttons: number[];
  122757. /**
  122758. * Assign buttons for Yaw control.
  122759. */
  122760. buttonsYaw: number[];
  122761. /**
  122762. * Assign buttons for Pitch control.
  122763. */
  122764. buttonsPitch: number[];
  122765. /**
  122766. * Assign buttons for Roll control.
  122767. */
  122768. buttonsRoll: number[];
  122769. /**
  122770. * Detect if any button is being pressed while mouse is moved.
  122771. * -1 = Mouse locked.
  122772. * 0 = Left button.
  122773. * 1 = Middle Button.
  122774. * 2 = Right Button.
  122775. */
  122776. activeButton: number;
  122777. /**
  122778. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122779. * Higher values reduce its sensitivity.
  122780. */
  122781. angularSensibility: number;
  122782. private _mousemoveCallback;
  122783. private _observer;
  122784. private _rollObserver;
  122785. private previousPosition;
  122786. private noPreventDefault;
  122787. private element;
  122788. /**
  122789. * Listen to mouse events to control the camera.
  122790. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122791. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122792. */
  122793. constructor(touchEnabled?: boolean);
  122794. /**
  122795. * Attach the mouse control to the HTML DOM element.
  122796. * @param element Defines the element that listens to the input events.
  122797. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  122798. */
  122799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122800. /**
  122801. * Detach the current controls from the specified dom element.
  122802. * @param element Defines the element to stop listening the inputs from
  122803. */
  122804. detachControl(element: Nullable<HTMLElement>): void;
  122805. /**
  122806. * Gets the class name of the current input.
  122807. * @returns the class name.
  122808. */
  122809. getClassName(): string;
  122810. /**
  122811. * Get the friendly name associated with the input class.
  122812. * @returns the input's friendly name.
  122813. */
  122814. getSimpleName(): string;
  122815. private _pointerInput;
  122816. private _onMouseMove;
  122817. /**
  122818. * Rotate camera by mouse offset.
  122819. */
  122820. private rotateCamera;
  122821. }
  122822. }
  122823. declare module BABYLON {
  122824. /**
  122825. * Default Inputs manager for the FlyCamera.
  122826. * It groups all the default supported inputs for ease of use.
  122827. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122828. */
  122829. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  122830. /**
  122831. * Instantiates a new FlyCameraInputsManager.
  122832. * @param camera Defines the camera the inputs belong to.
  122833. */
  122834. constructor(camera: FlyCamera);
  122835. /**
  122836. * Add keyboard input support to the input manager.
  122837. * @returns the new FlyCameraKeyboardMoveInput().
  122838. */
  122839. addKeyboard(): FlyCameraInputsManager;
  122840. /**
  122841. * Add mouse input support to the input manager.
  122842. * @param touchEnabled Enable touch screen support.
  122843. * @returns the new FlyCameraMouseInput().
  122844. */
  122845. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  122846. }
  122847. }
  122848. declare module BABYLON {
  122849. /**
  122850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122851. * such as in a 3D Space Shooter or a Flight Simulator.
  122852. */
  122853. export class FlyCamera extends TargetCamera {
  122854. /**
  122855. * Define the collision ellipsoid of the camera.
  122856. * This is helpful for simulating a camera body, like a player's body.
  122857. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122858. */
  122859. ellipsoid: Vector3;
  122860. /**
  122861. * Define an offset for the position of the ellipsoid around the camera.
  122862. * This can be helpful if the camera is attached away from the player's body center,
  122863. * such as at its head.
  122864. */
  122865. ellipsoidOffset: Vector3;
  122866. /**
  122867. * Enable or disable collisions of the camera with the rest of the scene objects.
  122868. */
  122869. checkCollisions: boolean;
  122870. /**
  122871. * Enable or disable gravity on the camera.
  122872. */
  122873. applyGravity: boolean;
  122874. /**
  122875. * Define the current direction the camera is moving to.
  122876. */
  122877. cameraDirection: Vector3;
  122878. /**
  122879. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  122880. * This overrides and empties cameraRotation.
  122881. */
  122882. rotationQuaternion: Quaternion;
  122883. /**
  122884. * Track Roll to maintain the wanted Rolling when looking around.
  122885. */
  122886. _trackRoll: number;
  122887. /**
  122888. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  122889. */
  122890. rollCorrect: number;
  122891. /**
  122892. * Mimic a banked turn, Rolling the camera when Yawing.
  122893. * It's recommended to use rollCorrect = 10 for faster banking correction.
  122894. */
  122895. bankedTurn: boolean;
  122896. /**
  122897. * Limit in radians for how much Roll banking will add. (Default: 90°)
  122898. */
  122899. bankedTurnLimit: number;
  122900. /**
  122901. * Value of 0 disables the banked Roll.
  122902. * Value of 1 is equal to the Yaw angle in radians.
  122903. */
  122904. bankedTurnMultiplier: number;
  122905. /**
  122906. * The inputs manager loads all the input sources, such as keyboard and mouse.
  122907. */
  122908. inputs: FlyCameraInputsManager;
  122909. /**
  122910. * Gets the input sensibility for mouse input.
  122911. * Higher values reduce sensitivity.
  122912. */
  122913. get angularSensibility(): number;
  122914. /**
  122915. * Sets the input sensibility for a mouse input.
  122916. * Higher values reduce sensitivity.
  122917. */
  122918. set angularSensibility(value: number);
  122919. /**
  122920. * Get the keys for camera movement forward.
  122921. */
  122922. get keysForward(): number[];
  122923. /**
  122924. * Set the keys for camera movement forward.
  122925. */
  122926. set keysForward(value: number[]);
  122927. /**
  122928. * Get the keys for camera movement backward.
  122929. */
  122930. get keysBackward(): number[];
  122931. set keysBackward(value: number[]);
  122932. /**
  122933. * Get the keys for camera movement up.
  122934. */
  122935. get keysUp(): number[];
  122936. /**
  122937. * Set the keys for camera movement up.
  122938. */
  122939. set keysUp(value: number[]);
  122940. /**
  122941. * Get the keys for camera movement down.
  122942. */
  122943. get keysDown(): number[];
  122944. /**
  122945. * Set the keys for camera movement down.
  122946. */
  122947. set keysDown(value: number[]);
  122948. /**
  122949. * Get the keys for camera movement left.
  122950. */
  122951. get keysLeft(): number[];
  122952. /**
  122953. * Set the keys for camera movement left.
  122954. */
  122955. set keysLeft(value: number[]);
  122956. /**
  122957. * Set the keys for camera movement right.
  122958. */
  122959. get keysRight(): number[];
  122960. /**
  122961. * Set the keys for camera movement right.
  122962. */
  122963. set keysRight(value: number[]);
  122964. /**
  122965. * Event raised when the camera collides with a mesh in the scene.
  122966. */
  122967. onCollide: (collidedMesh: AbstractMesh) => void;
  122968. private _collider;
  122969. private _needMoveForGravity;
  122970. private _oldPosition;
  122971. private _diffPosition;
  122972. private _newPosition;
  122973. /** @hidden */
  122974. _localDirection: Vector3;
  122975. /** @hidden */
  122976. _transformedDirection: Vector3;
  122977. /**
  122978. * Instantiates a FlyCamera.
  122979. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122980. * such as in a 3D Space Shooter or a Flight Simulator.
  122981. * @param name Define the name of the camera in the scene.
  122982. * @param position Define the starting position of the camera in the scene.
  122983. * @param scene Define the scene the camera belongs to.
  122984. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  122985. */
  122986. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122987. /**
  122988. * Attach a control to the HTML DOM element.
  122989. * @param element Defines the element that listens to the input events.
  122990. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  122991. */
  122992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122993. /**
  122994. * Detach a control from the HTML DOM element.
  122995. * The camera will stop reacting to that input.
  122996. * @param element Defines the element that listens to the input events.
  122997. */
  122998. detachControl(element: HTMLElement): void;
  122999. private _collisionMask;
  123000. /**
  123001. * Get the mask that the camera ignores in collision events.
  123002. */
  123003. get collisionMask(): number;
  123004. /**
  123005. * Set the mask that the camera ignores in collision events.
  123006. */
  123007. set collisionMask(mask: number);
  123008. /** @hidden */
  123009. _collideWithWorld(displacement: Vector3): void;
  123010. /** @hidden */
  123011. private _onCollisionPositionChange;
  123012. /** @hidden */
  123013. _checkInputs(): void;
  123014. /** @hidden */
  123015. _decideIfNeedsToMove(): boolean;
  123016. /** @hidden */
  123017. _updatePosition(): void;
  123018. /**
  123019. * Restore the Roll to its target value at the rate specified.
  123020. * @param rate - Higher means slower restoring.
  123021. * @hidden
  123022. */
  123023. restoreRoll(rate: number): void;
  123024. /**
  123025. * Destroy the camera and release the current resources held by it.
  123026. */
  123027. dispose(): void;
  123028. /**
  123029. * Get the current object class name.
  123030. * @returns the class name.
  123031. */
  123032. getClassName(): string;
  123033. }
  123034. }
  123035. declare module BABYLON {
  123036. /**
  123037. * Listen to keyboard events to control the camera.
  123038. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123039. */
  123040. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123041. /**
  123042. * Defines the camera the input is attached to.
  123043. */
  123044. camera: FlyCamera;
  123045. /**
  123046. * The list of keyboard keys used to control the forward move of the camera.
  123047. */
  123048. keysForward: number[];
  123049. /**
  123050. * The list of keyboard keys used to control the backward move of the camera.
  123051. */
  123052. keysBackward: number[];
  123053. /**
  123054. * The list of keyboard keys used to control the forward move of the camera.
  123055. */
  123056. keysUp: number[];
  123057. /**
  123058. * The list of keyboard keys used to control the backward move of the camera.
  123059. */
  123060. keysDown: number[];
  123061. /**
  123062. * The list of keyboard keys used to control the right strafe move of the camera.
  123063. */
  123064. keysRight: number[];
  123065. /**
  123066. * The list of keyboard keys used to control the left strafe move of the camera.
  123067. */
  123068. keysLeft: number[];
  123069. private _keys;
  123070. private _onCanvasBlurObserver;
  123071. private _onKeyboardObserver;
  123072. private _engine;
  123073. private _scene;
  123074. /**
  123075. * Attach the input controls to a specific dom element to get the input from.
  123076. * @param element Defines the element the controls should be listened from
  123077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123078. */
  123079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123080. /**
  123081. * Detach the current controls from the specified dom element.
  123082. * @param element Defines the element to stop listening the inputs from
  123083. */
  123084. detachControl(element: Nullable<HTMLElement>): void;
  123085. /**
  123086. * Gets the class name of the current intput.
  123087. * @returns the class name
  123088. */
  123089. getClassName(): string;
  123090. /** @hidden */
  123091. _onLostFocus(e: FocusEvent): void;
  123092. /**
  123093. * Get the friendly name associated with the input class.
  123094. * @returns the input friendly name
  123095. */
  123096. getSimpleName(): string;
  123097. /**
  123098. * Update the current camera state depending on the inputs that have been used this frame.
  123099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123100. */
  123101. checkInputs(): void;
  123102. }
  123103. }
  123104. declare module BABYLON {
  123105. /**
  123106. * Manage the mouse wheel inputs to control a follow camera.
  123107. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123108. */
  123109. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123110. /**
  123111. * Defines the camera the input is attached to.
  123112. */
  123113. camera: FollowCamera;
  123114. /**
  123115. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123116. */
  123117. axisControlRadius: boolean;
  123118. /**
  123119. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123120. */
  123121. axisControlHeight: boolean;
  123122. /**
  123123. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123124. */
  123125. axisControlRotation: boolean;
  123126. /**
  123127. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123128. * relation to mouseWheel events.
  123129. */
  123130. wheelPrecision: number;
  123131. /**
  123132. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123133. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123134. */
  123135. wheelDeltaPercentage: number;
  123136. private _wheel;
  123137. private _observer;
  123138. /**
  123139. * Attach the input controls to a specific dom element to get the input from.
  123140. * @param element Defines the element the controls should be listened from
  123141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123142. */
  123143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123144. /**
  123145. * Detach the current controls from the specified dom element.
  123146. * @param element Defines the element to stop listening the inputs from
  123147. */
  123148. detachControl(element: Nullable<HTMLElement>): void;
  123149. /**
  123150. * Gets the class name of the current intput.
  123151. * @returns the class name
  123152. */
  123153. getClassName(): string;
  123154. /**
  123155. * Get the friendly name associated with the input class.
  123156. * @returns the input friendly name
  123157. */
  123158. getSimpleName(): string;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Manage the pointers inputs to control an follow camera.
  123164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123165. */
  123166. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123167. /**
  123168. * Defines the camera the input is attached to.
  123169. */
  123170. camera: FollowCamera;
  123171. /**
  123172. * Gets the class name of the current input.
  123173. * @returns the class name
  123174. */
  123175. getClassName(): string;
  123176. /**
  123177. * Defines the pointer angular sensibility along the X axis or how fast is
  123178. * the camera rotating.
  123179. * A negative number will reverse the axis direction.
  123180. */
  123181. angularSensibilityX: number;
  123182. /**
  123183. * Defines the pointer angular sensibility along the Y axis or how fast is
  123184. * the camera rotating.
  123185. * A negative number will reverse the axis direction.
  123186. */
  123187. angularSensibilityY: number;
  123188. /**
  123189. * Defines the pointer pinch precision or how fast is the camera zooming.
  123190. * A negative number will reverse the axis direction.
  123191. */
  123192. pinchPrecision: number;
  123193. /**
  123194. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123195. * from 0.
  123196. * It defines the percentage of current camera.radius to use as delta when
  123197. * pinch zoom is used.
  123198. */
  123199. pinchDeltaPercentage: number;
  123200. /**
  123201. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123202. */
  123203. axisXControlRadius: boolean;
  123204. /**
  123205. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123206. */
  123207. axisXControlHeight: boolean;
  123208. /**
  123209. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123210. */
  123211. axisXControlRotation: boolean;
  123212. /**
  123213. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123214. */
  123215. axisYControlRadius: boolean;
  123216. /**
  123217. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123218. */
  123219. axisYControlHeight: boolean;
  123220. /**
  123221. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123222. */
  123223. axisYControlRotation: boolean;
  123224. /**
  123225. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123226. */
  123227. axisPinchControlRadius: boolean;
  123228. /**
  123229. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123230. */
  123231. axisPinchControlHeight: boolean;
  123232. /**
  123233. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123234. */
  123235. axisPinchControlRotation: boolean;
  123236. /**
  123237. * Log error messages if basic misconfiguration has occurred.
  123238. */
  123239. warningEnable: boolean;
  123240. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123241. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123242. private _warningCounter;
  123243. private _warning;
  123244. }
  123245. }
  123246. declare module BABYLON {
  123247. /**
  123248. * Default Inputs manager for the FollowCamera.
  123249. * It groups all the default supported inputs for ease of use.
  123250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123251. */
  123252. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123253. /**
  123254. * Instantiates a new FollowCameraInputsManager.
  123255. * @param camera Defines the camera the inputs belong to
  123256. */
  123257. constructor(camera: FollowCamera);
  123258. /**
  123259. * Add keyboard input support to the input manager.
  123260. * @returns the current input manager
  123261. */
  123262. addKeyboard(): FollowCameraInputsManager;
  123263. /**
  123264. * Add mouse wheel input support to the input manager.
  123265. * @returns the current input manager
  123266. */
  123267. addMouseWheel(): FollowCameraInputsManager;
  123268. /**
  123269. * Add pointers input support to the input manager.
  123270. * @returns the current input manager
  123271. */
  123272. addPointers(): FollowCameraInputsManager;
  123273. /**
  123274. * Add orientation input support to the input manager.
  123275. * @returns the current input manager
  123276. */
  123277. addVRDeviceOrientation(): FollowCameraInputsManager;
  123278. }
  123279. }
  123280. declare module BABYLON {
  123281. /**
  123282. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123283. * an arc rotate version arcFollowCamera are available.
  123284. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123285. */
  123286. export class FollowCamera extends TargetCamera {
  123287. /**
  123288. * Distance the follow camera should follow an object at
  123289. */
  123290. radius: number;
  123291. /**
  123292. * Minimum allowed distance of the camera to the axis of rotation
  123293. * (The camera can not get closer).
  123294. * This can help limiting how the Camera is able to move in the scene.
  123295. */
  123296. lowerRadiusLimit: Nullable<number>;
  123297. /**
  123298. * Maximum allowed distance of the camera to the axis of rotation
  123299. * (The camera can not get further).
  123300. * This can help limiting how the Camera is able to move in the scene.
  123301. */
  123302. upperRadiusLimit: Nullable<number>;
  123303. /**
  123304. * Define a rotation offset between the camera and the object it follows
  123305. */
  123306. rotationOffset: number;
  123307. /**
  123308. * Minimum allowed angle to camera position relative to target object.
  123309. * This can help limiting how the Camera is able to move in the scene.
  123310. */
  123311. lowerRotationOffsetLimit: Nullable<number>;
  123312. /**
  123313. * Maximum allowed angle to camera position relative to target object.
  123314. * This can help limiting how the Camera is able to move in the scene.
  123315. */
  123316. upperRotationOffsetLimit: Nullable<number>;
  123317. /**
  123318. * Define a height offset between the camera and the object it follows.
  123319. * It can help following an object from the top (like a car chaing a plane)
  123320. */
  123321. heightOffset: number;
  123322. /**
  123323. * Minimum allowed height of camera position relative to target object.
  123324. * This can help limiting how the Camera is able to move in the scene.
  123325. */
  123326. lowerHeightOffsetLimit: Nullable<number>;
  123327. /**
  123328. * Maximum allowed height of camera position relative to target object.
  123329. * This can help limiting how the Camera is able to move in the scene.
  123330. */
  123331. upperHeightOffsetLimit: Nullable<number>;
  123332. /**
  123333. * Define how fast the camera can accelerate to follow it s target.
  123334. */
  123335. cameraAcceleration: number;
  123336. /**
  123337. * Define the speed limit of the camera following an object.
  123338. */
  123339. maxCameraSpeed: number;
  123340. /**
  123341. * Define the target of the camera.
  123342. */
  123343. lockedTarget: Nullable<AbstractMesh>;
  123344. /**
  123345. * Defines the input associated with the camera.
  123346. */
  123347. inputs: FollowCameraInputsManager;
  123348. /**
  123349. * Instantiates the follow camera.
  123350. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123351. * @param name Define the name of the camera in the scene
  123352. * @param position Define the position of the camera
  123353. * @param scene Define the scene the camera belong to
  123354. * @param lockedTarget Define the target of the camera
  123355. */
  123356. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123357. private _follow;
  123358. /**
  123359. * Attached controls to the current camera.
  123360. * @param element Defines the element the controls should be listened from
  123361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123362. */
  123363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123364. /**
  123365. * Detach the current controls from the camera.
  123366. * The camera will stop reacting to inputs.
  123367. * @param element Defines the element to stop listening the inputs from
  123368. */
  123369. detachControl(element: HTMLElement): void;
  123370. /** @hidden */
  123371. _checkInputs(): void;
  123372. private _checkLimits;
  123373. /**
  123374. * Gets the camera class name.
  123375. * @returns the class name
  123376. */
  123377. getClassName(): string;
  123378. }
  123379. /**
  123380. * Arc Rotate version of the follow camera.
  123381. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123382. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123383. */
  123384. export class ArcFollowCamera extends TargetCamera {
  123385. /** The longitudinal angle of the camera */
  123386. alpha: number;
  123387. /** The latitudinal angle of the camera */
  123388. beta: number;
  123389. /** The radius of the camera from its target */
  123390. radius: number;
  123391. /** Define the camera target (the mesh it should follow) */
  123392. target: Nullable<AbstractMesh>;
  123393. private _cartesianCoordinates;
  123394. /**
  123395. * Instantiates a new ArcFollowCamera
  123396. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123397. * @param name Define the name of the camera
  123398. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123399. * @param beta Define the rotation angle of the camera around the elevation axis
  123400. * @param radius Define the radius of the camera from its target point
  123401. * @param target Define the target of the camera
  123402. * @param scene Define the scene the camera belongs to
  123403. */
  123404. constructor(name: string,
  123405. /** The longitudinal angle of the camera */
  123406. alpha: number,
  123407. /** The latitudinal angle of the camera */
  123408. beta: number,
  123409. /** The radius of the camera from its target */
  123410. radius: number,
  123411. /** Define the camera target (the mesh it should follow) */
  123412. target: Nullable<AbstractMesh>, scene: Scene);
  123413. private _follow;
  123414. /** @hidden */
  123415. _checkInputs(): void;
  123416. /**
  123417. * Returns the class name of the object.
  123418. * It is mostly used internally for serialization purposes.
  123419. */
  123420. getClassName(): string;
  123421. }
  123422. }
  123423. declare module BABYLON {
  123424. /**
  123425. * Manage the keyboard inputs to control the movement of a follow camera.
  123426. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123427. */
  123428. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123429. /**
  123430. * Defines the camera the input is attached to.
  123431. */
  123432. camera: FollowCamera;
  123433. /**
  123434. * Defines the list of key codes associated with the up action (increase heightOffset)
  123435. */
  123436. keysHeightOffsetIncr: number[];
  123437. /**
  123438. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123439. */
  123440. keysHeightOffsetDecr: number[];
  123441. /**
  123442. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123443. */
  123444. keysHeightOffsetModifierAlt: boolean;
  123445. /**
  123446. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123447. */
  123448. keysHeightOffsetModifierCtrl: boolean;
  123449. /**
  123450. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123451. */
  123452. keysHeightOffsetModifierShift: boolean;
  123453. /**
  123454. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123455. */
  123456. keysRotationOffsetIncr: number[];
  123457. /**
  123458. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123459. */
  123460. keysRotationOffsetDecr: number[];
  123461. /**
  123462. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123463. */
  123464. keysRotationOffsetModifierAlt: boolean;
  123465. /**
  123466. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123467. */
  123468. keysRotationOffsetModifierCtrl: boolean;
  123469. /**
  123470. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123471. */
  123472. keysRotationOffsetModifierShift: boolean;
  123473. /**
  123474. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123475. */
  123476. keysRadiusIncr: number[];
  123477. /**
  123478. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123479. */
  123480. keysRadiusDecr: number[];
  123481. /**
  123482. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123483. */
  123484. keysRadiusModifierAlt: boolean;
  123485. /**
  123486. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123487. */
  123488. keysRadiusModifierCtrl: boolean;
  123489. /**
  123490. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123491. */
  123492. keysRadiusModifierShift: boolean;
  123493. /**
  123494. * Defines the rate of change of heightOffset.
  123495. */
  123496. heightSensibility: number;
  123497. /**
  123498. * Defines the rate of change of rotationOffset.
  123499. */
  123500. rotationSensibility: number;
  123501. /**
  123502. * Defines the rate of change of radius.
  123503. */
  123504. radiusSensibility: number;
  123505. private _keys;
  123506. private _ctrlPressed;
  123507. private _altPressed;
  123508. private _shiftPressed;
  123509. private _onCanvasBlurObserver;
  123510. private _onKeyboardObserver;
  123511. private _engine;
  123512. private _scene;
  123513. /**
  123514. * Attach the input controls to a specific dom element to get the input from.
  123515. * @param element Defines the element the controls should be listened from
  123516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123517. */
  123518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123519. /**
  123520. * Detach the current controls from the specified dom element.
  123521. * @param element Defines the element to stop listening the inputs from
  123522. */
  123523. detachControl(element: Nullable<HTMLElement>): void;
  123524. /**
  123525. * Update the current camera state depending on the inputs that have been used this frame.
  123526. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123527. */
  123528. checkInputs(): void;
  123529. /**
  123530. * Gets the class name of the current input.
  123531. * @returns the class name
  123532. */
  123533. getClassName(): string;
  123534. /**
  123535. * Get the friendly name associated with the input class.
  123536. * @returns the input friendly name
  123537. */
  123538. getSimpleName(): string;
  123539. /**
  123540. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123541. * allow modification of the heightOffset value.
  123542. */
  123543. private _modifierHeightOffset;
  123544. /**
  123545. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123546. * allow modification of the rotationOffset value.
  123547. */
  123548. private _modifierRotationOffset;
  123549. /**
  123550. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123551. * allow modification of the radius value.
  123552. */
  123553. private _modifierRadius;
  123554. }
  123555. }
  123556. declare module BABYLON {
  123557. interface FreeCameraInputsManager {
  123558. /**
  123559. * @hidden
  123560. */
  123561. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123562. /**
  123563. * Add orientation input support to the input manager.
  123564. * @returns the current input manager
  123565. */
  123566. addDeviceOrientation(): FreeCameraInputsManager;
  123567. }
  123568. /**
  123569. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123570. * Screen rotation is taken into account.
  123571. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123572. */
  123573. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123574. private _camera;
  123575. private _screenOrientationAngle;
  123576. private _constantTranform;
  123577. private _screenQuaternion;
  123578. private _alpha;
  123579. private _beta;
  123580. private _gamma;
  123581. /**
  123582. * Can be used to detect if a device orientation sensor is available on a device
  123583. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123584. * @returns a promise that will resolve on orientation change
  123585. */
  123586. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123587. /**
  123588. * @hidden
  123589. */
  123590. _onDeviceOrientationChangedObservable: Observable<void>;
  123591. /**
  123592. * Instantiates a new input
  123593. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123594. */
  123595. constructor();
  123596. /**
  123597. * Define the camera controlled by the input.
  123598. */
  123599. get camera(): FreeCamera;
  123600. set camera(camera: FreeCamera);
  123601. /**
  123602. * Attach the input controls to a specific dom element to get the input from.
  123603. * @param element Defines the element the controls should be listened from
  123604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123605. */
  123606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123607. private _orientationChanged;
  123608. private _deviceOrientation;
  123609. /**
  123610. * Detach the current controls from the specified dom element.
  123611. * @param element Defines the element to stop listening the inputs from
  123612. */
  123613. detachControl(element: Nullable<HTMLElement>): void;
  123614. /**
  123615. * Update the current camera state depending on the inputs that have been used this frame.
  123616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123617. */
  123618. checkInputs(): void;
  123619. /**
  123620. * Gets the class name of the current intput.
  123621. * @returns the class name
  123622. */
  123623. getClassName(): string;
  123624. /**
  123625. * Get the friendly name associated with the input class.
  123626. * @returns the input friendly name
  123627. */
  123628. getSimpleName(): string;
  123629. }
  123630. }
  123631. declare module BABYLON {
  123632. /**
  123633. * Manage the gamepad inputs to control a free camera.
  123634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123635. */
  123636. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123637. /**
  123638. * Define the camera the input is attached to.
  123639. */
  123640. camera: FreeCamera;
  123641. /**
  123642. * Define the Gamepad controlling the input
  123643. */
  123644. gamepad: Nullable<Gamepad>;
  123645. /**
  123646. * Defines the gamepad rotation sensiblity.
  123647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123648. */
  123649. gamepadAngularSensibility: number;
  123650. /**
  123651. * Defines the gamepad move sensiblity.
  123652. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123653. */
  123654. gamepadMoveSensibility: number;
  123655. private _yAxisScale;
  123656. /**
  123657. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123658. */
  123659. get invertYAxis(): boolean;
  123660. set invertYAxis(value: boolean);
  123661. private _onGamepadConnectedObserver;
  123662. private _onGamepadDisconnectedObserver;
  123663. private _cameraTransform;
  123664. private _deltaTransform;
  123665. private _vector3;
  123666. private _vector2;
  123667. /**
  123668. * Attach the input controls to a specific dom element to get the input from.
  123669. * @param element Defines the element the controls should be listened from
  123670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123671. */
  123672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123673. /**
  123674. * Detach the current controls from the specified dom element.
  123675. * @param element Defines the element to stop listening the inputs from
  123676. */
  123677. detachControl(element: Nullable<HTMLElement>): void;
  123678. /**
  123679. * Update the current camera state depending on the inputs that have been used this frame.
  123680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123681. */
  123682. checkInputs(): void;
  123683. /**
  123684. * Gets the class name of the current intput.
  123685. * @returns the class name
  123686. */
  123687. getClassName(): string;
  123688. /**
  123689. * Get the friendly name associated with the input class.
  123690. * @returns the input friendly name
  123691. */
  123692. getSimpleName(): string;
  123693. }
  123694. }
  123695. declare module BABYLON {
  123696. /**
  123697. * Defines the potential axis of a Joystick
  123698. */
  123699. export enum JoystickAxis {
  123700. /** X axis */
  123701. X = 0,
  123702. /** Y axis */
  123703. Y = 1,
  123704. /** Z axis */
  123705. Z = 2
  123706. }
  123707. /**
  123708. * Represents the different customization options available
  123709. * for VirtualJoystick
  123710. */
  123711. interface VirtualJoystickCustomizations {
  123712. /**
  123713. * Size of the joystick's puck
  123714. */
  123715. puckSize: number;
  123716. /**
  123717. * Size of the joystick's container
  123718. */
  123719. containerSize: number;
  123720. /**
  123721. * Color of the joystick && puck
  123722. */
  123723. color: string;
  123724. /**
  123725. * Image URL for the joystick's puck
  123726. */
  123727. puckImage?: string;
  123728. /**
  123729. * Image URL for the joystick's container
  123730. */
  123731. containerImage?: string;
  123732. /**
  123733. * Defines the unmoving position of the joystick container
  123734. */
  123735. position?: {
  123736. x: number;
  123737. y: number;
  123738. };
  123739. /**
  123740. * Defines whether or not the joystick container is always visible
  123741. */
  123742. alwaysVisible: boolean;
  123743. /**
  123744. * Defines whether or not to limit the movement of the puck to the joystick's container
  123745. */
  123746. limitToContainer: boolean;
  123747. }
  123748. /**
  123749. * Class used to define virtual joystick (used in touch mode)
  123750. */
  123751. export class VirtualJoystick {
  123752. /**
  123753. * Gets or sets a boolean indicating that left and right values must be inverted
  123754. */
  123755. reverseLeftRight: boolean;
  123756. /**
  123757. * Gets or sets a boolean indicating that up and down values must be inverted
  123758. */
  123759. reverseUpDown: boolean;
  123760. /**
  123761. * Gets the offset value for the position (ie. the change of the position value)
  123762. */
  123763. deltaPosition: Vector3;
  123764. /**
  123765. * Gets a boolean indicating if the virtual joystick was pressed
  123766. */
  123767. pressed: boolean;
  123768. /**
  123769. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123770. */
  123771. static Canvas: Nullable<HTMLCanvasElement>;
  123772. /**
  123773. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123774. */
  123775. limitToContainer: boolean;
  123776. private static _globalJoystickIndex;
  123777. private static _alwaysVisibleSticks;
  123778. private static vjCanvasContext;
  123779. private static vjCanvasWidth;
  123780. private static vjCanvasHeight;
  123781. private static halfWidth;
  123782. private static _GetDefaultOptions;
  123783. private _action;
  123784. private _axisTargetedByLeftAndRight;
  123785. private _axisTargetedByUpAndDown;
  123786. private _joystickSensibility;
  123787. private _inversedSensibility;
  123788. private _joystickPointerID;
  123789. private _joystickColor;
  123790. private _joystickPointerPos;
  123791. private _joystickPreviousPointerPos;
  123792. private _joystickPointerStartPos;
  123793. private _deltaJoystickVector;
  123794. private _leftJoystick;
  123795. private _touches;
  123796. private _joystickPosition;
  123797. private _alwaysVisible;
  123798. private _puckImage;
  123799. private _containerImage;
  123800. private _joystickPuckSize;
  123801. private _joystickContainerSize;
  123802. private _clearPuckSize;
  123803. private _clearContainerSize;
  123804. private _clearPuckSizeOffset;
  123805. private _clearContainerSizeOffset;
  123806. private _onPointerDownHandlerRef;
  123807. private _onPointerMoveHandlerRef;
  123808. private _onPointerUpHandlerRef;
  123809. private _onResize;
  123810. /**
  123811. * Creates a new virtual joystick
  123812. * @param leftJoystick defines that the joystick is for left hand (false by default)
  123813. * @param customizations Defines the options we want to customize the VirtualJoystick
  123814. */
  123815. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  123816. /**
  123817. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  123818. * @param newJoystickSensibility defines the new sensibility
  123819. */
  123820. setJoystickSensibility(newJoystickSensibility: number): void;
  123821. private _onPointerDown;
  123822. private _onPointerMove;
  123823. private _onPointerUp;
  123824. /**
  123825. * Change the color of the virtual joystick
  123826. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  123827. */
  123828. setJoystickColor(newColor: string): void;
  123829. /**
  123830. * Size of the joystick's container
  123831. */
  123832. set containerSize(newSize: number);
  123833. get containerSize(): number;
  123834. /**
  123835. * Size of the joystick's puck
  123836. */
  123837. set puckSize(newSize: number);
  123838. get puckSize(): number;
  123839. /**
  123840. * Clears the set position of the joystick
  123841. */
  123842. clearPosition(): void;
  123843. /**
  123844. * Defines whether or not the joystick container is always visible
  123845. */
  123846. set alwaysVisible(value: boolean);
  123847. get alwaysVisible(): boolean;
  123848. /**
  123849. * Sets the constant position of the Joystick container
  123850. * @param x X axis coordinate
  123851. * @param y Y axis coordinate
  123852. */
  123853. setPosition(x: number, y: number): void;
  123854. /**
  123855. * Defines a callback to call when the joystick is touched
  123856. * @param action defines the callback
  123857. */
  123858. setActionOnTouch(action: () => any): void;
  123859. /**
  123860. * Defines which axis you'd like to control for left & right
  123861. * @param axis defines the axis to use
  123862. */
  123863. setAxisForLeftRight(axis: JoystickAxis): void;
  123864. /**
  123865. * Defines which axis you'd like to control for up & down
  123866. * @param axis defines the axis to use
  123867. */
  123868. setAxisForUpDown(axis: JoystickAxis): void;
  123869. /**
  123870. * Clears the canvas from the previous puck / container draw
  123871. */
  123872. private _clearPreviousDraw;
  123873. /**
  123874. * Loads `urlPath` to be used for the container's image
  123875. * @param urlPath defines the urlPath of an image to use
  123876. */
  123877. setContainerImage(urlPath: string): void;
  123878. /**
  123879. * Loads `urlPath` to be used for the puck's image
  123880. * @param urlPath defines the urlPath of an image to use
  123881. */
  123882. setPuckImage(urlPath: string): void;
  123883. /**
  123884. * Draws the Virtual Joystick's container
  123885. */
  123886. private _drawContainer;
  123887. /**
  123888. * Draws the Virtual Joystick's puck
  123889. */
  123890. private _drawPuck;
  123891. private _drawVirtualJoystick;
  123892. /**
  123893. * Release internal HTML canvas
  123894. */
  123895. releaseCanvas(): void;
  123896. }
  123897. }
  123898. declare module BABYLON {
  123899. interface FreeCameraInputsManager {
  123900. /**
  123901. * Add virtual joystick input support to the input manager.
  123902. * @returns the current input manager
  123903. */
  123904. addVirtualJoystick(): FreeCameraInputsManager;
  123905. }
  123906. /**
  123907. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  123908. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123909. */
  123910. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  123911. /**
  123912. * Defines the camera the input is attached to.
  123913. */
  123914. camera: FreeCamera;
  123915. private _leftjoystick;
  123916. private _rightjoystick;
  123917. /**
  123918. * Gets the left stick of the virtual joystick.
  123919. * @returns The virtual Joystick
  123920. */
  123921. getLeftJoystick(): VirtualJoystick;
  123922. /**
  123923. * Gets the right stick of the virtual joystick.
  123924. * @returns The virtual Joystick
  123925. */
  123926. getRightJoystick(): VirtualJoystick;
  123927. /**
  123928. * Update the current camera state depending on the inputs that have been used this frame.
  123929. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123930. */
  123931. checkInputs(): void;
  123932. /**
  123933. * Attach the input controls to a specific dom element to get the input from.
  123934. * @param element Defines the element the controls should be listened from
  123935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123936. */
  123937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123938. /**
  123939. * Detach the current controls from the specified dom element.
  123940. * @param element Defines the element to stop listening the inputs from
  123941. */
  123942. detachControl(element: Nullable<HTMLElement>): void;
  123943. /**
  123944. * Gets the class name of the current intput.
  123945. * @returns the class name
  123946. */
  123947. getClassName(): string;
  123948. /**
  123949. * Get the friendly name associated with the input class.
  123950. * @returns the input friendly name
  123951. */
  123952. getSimpleName(): string;
  123953. }
  123954. }
  123955. declare module BABYLON {
  123956. /**
  123957. * This represents a FPS type of camera controlled by touch.
  123958. * This is like a universal camera minus the Gamepad controls.
  123959. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123960. */
  123961. export class TouchCamera extends FreeCamera {
  123962. /**
  123963. * Defines the touch sensibility for rotation.
  123964. * The higher the faster.
  123965. */
  123966. get touchAngularSensibility(): number;
  123967. set touchAngularSensibility(value: number);
  123968. /**
  123969. * Defines the touch sensibility for move.
  123970. * The higher the faster.
  123971. */
  123972. get touchMoveSensibility(): number;
  123973. set touchMoveSensibility(value: number);
  123974. /**
  123975. * Instantiates a new touch camera.
  123976. * This represents a FPS type of camera controlled by touch.
  123977. * This is like a universal camera minus the Gamepad controls.
  123978. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123979. * @param name Define the name of the camera in the scene
  123980. * @param position Define the start position of the camera in the scene
  123981. * @param scene Define the scene the camera belongs to
  123982. */
  123983. constructor(name: string, position: Vector3, scene: Scene);
  123984. /**
  123985. * Gets the current object class name.
  123986. * @return the class name
  123987. */
  123988. getClassName(): string;
  123989. /** @hidden */
  123990. _setupInputs(): void;
  123991. }
  123992. }
  123993. declare module BABYLON {
  123994. /**
  123995. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  123996. * being tilted forward or back and left or right.
  123997. */
  123998. export class DeviceOrientationCamera extends FreeCamera {
  123999. private _initialQuaternion;
  124000. private _quaternionCache;
  124001. private _tmpDragQuaternion;
  124002. private _disablePointerInputWhenUsingDeviceOrientation;
  124003. /**
  124004. * Creates a new device orientation camera
  124005. * @param name The name of the camera
  124006. * @param position The start position camera
  124007. * @param scene The scene the camera belongs to
  124008. */
  124009. constructor(name: string, position: Vector3, scene: Scene);
  124010. /**
  124011. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124012. */
  124013. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124014. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124015. private _dragFactor;
  124016. /**
  124017. * Enabled turning on the y axis when the orientation sensor is active
  124018. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124019. */
  124020. enableHorizontalDragging(dragFactor?: number): void;
  124021. /**
  124022. * Gets the current instance class name ("DeviceOrientationCamera").
  124023. * This helps avoiding instanceof at run time.
  124024. * @returns the class name
  124025. */
  124026. getClassName(): string;
  124027. /**
  124028. * @hidden
  124029. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124030. */
  124031. _checkInputs(): void;
  124032. /**
  124033. * Reset the camera to its default orientation on the specified axis only.
  124034. * @param axis The axis to reset
  124035. */
  124036. resetToCurrentRotation(axis?: Axis): void;
  124037. }
  124038. }
  124039. declare module BABYLON {
  124040. /**
  124041. * Defines supported buttons for XBox360 compatible gamepads
  124042. */
  124043. export enum Xbox360Button {
  124044. /** A */
  124045. A = 0,
  124046. /** B */
  124047. B = 1,
  124048. /** X */
  124049. X = 2,
  124050. /** Y */
  124051. Y = 3,
  124052. /** Left button */
  124053. LB = 4,
  124054. /** Right button */
  124055. RB = 5,
  124056. /** Back */
  124057. Back = 8,
  124058. /** Start */
  124059. Start = 9,
  124060. /** Left stick */
  124061. LeftStick = 10,
  124062. /** Right stick */
  124063. RightStick = 11
  124064. }
  124065. /** Defines values for XBox360 DPad */
  124066. export enum Xbox360Dpad {
  124067. /** Up */
  124068. Up = 12,
  124069. /** Down */
  124070. Down = 13,
  124071. /** Left */
  124072. Left = 14,
  124073. /** Right */
  124074. Right = 15
  124075. }
  124076. /**
  124077. * Defines a XBox360 gamepad
  124078. */
  124079. export class Xbox360Pad extends Gamepad {
  124080. private _leftTrigger;
  124081. private _rightTrigger;
  124082. private _onlefttriggerchanged;
  124083. private _onrighttriggerchanged;
  124084. private _onbuttondown;
  124085. private _onbuttonup;
  124086. private _ondpaddown;
  124087. private _ondpadup;
  124088. /** Observable raised when a button is pressed */
  124089. onButtonDownObservable: Observable<Xbox360Button>;
  124090. /** Observable raised when a button is released */
  124091. onButtonUpObservable: Observable<Xbox360Button>;
  124092. /** Observable raised when a pad is pressed */
  124093. onPadDownObservable: Observable<Xbox360Dpad>;
  124094. /** Observable raised when a pad is released */
  124095. onPadUpObservable: Observable<Xbox360Dpad>;
  124096. private _buttonA;
  124097. private _buttonB;
  124098. private _buttonX;
  124099. private _buttonY;
  124100. private _buttonBack;
  124101. private _buttonStart;
  124102. private _buttonLB;
  124103. private _buttonRB;
  124104. private _buttonLeftStick;
  124105. private _buttonRightStick;
  124106. private _dPadUp;
  124107. private _dPadDown;
  124108. private _dPadLeft;
  124109. private _dPadRight;
  124110. private _isXboxOnePad;
  124111. /**
  124112. * Creates a new XBox360 gamepad object
  124113. * @param id defines the id of this gamepad
  124114. * @param index defines its index
  124115. * @param gamepad defines the internal HTML gamepad object
  124116. * @param xboxOne defines if it is a XBox One gamepad
  124117. */
  124118. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124119. /**
  124120. * Defines the callback to call when left trigger is pressed
  124121. * @param callback defines the callback to use
  124122. */
  124123. onlefttriggerchanged(callback: (value: number) => void): void;
  124124. /**
  124125. * Defines the callback to call when right trigger is pressed
  124126. * @param callback defines the callback to use
  124127. */
  124128. onrighttriggerchanged(callback: (value: number) => void): void;
  124129. /**
  124130. * Gets the left trigger value
  124131. */
  124132. get leftTrigger(): number;
  124133. /**
  124134. * Sets the left trigger value
  124135. */
  124136. set leftTrigger(newValue: number);
  124137. /**
  124138. * Gets the right trigger value
  124139. */
  124140. get rightTrigger(): number;
  124141. /**
  124142. * Sets the right trigger value
  124143. */
  124144. set rightTrigger(newValue: number);
  124145. /**
  124146. * Defines the callback to call when a button is pressed
  124147. * @param callback defines the callback to use
  124148. */
  124149. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124150. /**
  124151. * Defines the callback to call when a button is released
  124152. * @param callback defines the callback to use
  124153. */
  124154. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124155. /**
  124156. * Defines the callback to call when a pad is pressed
  124157. * @param callback defines the callback to use
  124158. */
  124159. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124160. /**
  124161. * Defines the callback to call when a pad is released
  124162. * @param callback defines the callback to use
  124163. */
  124164. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124165. private _setButtonValue;
  124166. private _setDPadValue;
  124167. /**
  124168. * Gets the value of the `A` button
  124169. */
  124170. get buttonA(): number;
  124171. /**
  124172. * Sets the value of the `A` button
  124173. */
  124174. set buttonA(value: number);
  124175. /**
  124176. * Gets the value of the `B` button
  124177. */
  124178. get buttonB(): number;
  124179. /**
  124180. * Sets the value of the `B` button
  124181. */
  124182. set buttonB(value: number);
  124183. /**
  124184. * Gets the value of the `X` button
  124185. */
  124186. get buttonX(): number;
  124187. /**
  124188. * Sets the value of the `X` button
  124189. */
  124190. set buttonX(value: number);
  124191. /**
  124192. * Gets the value of the `Y` button
  124193. */
  124194. get buttonY(): number;
  124195. /**
  124196. * Sets the value of the `Y` button
  124197. */
  124198. set buttonY(value: number);
  124199. /**
  124200. * Gets the value of the `Start` button
  124201. */
  124202. get buttonStart(): number;
  124203. /**
  124204. * Sets the value of the `Start` button
  124205. */
  124206. set buttonStart(value: number);
  124207. /**
  124208. * Gets the value of the `Back` button
  124209. */
  124210. get buttonBack(): number;
  124211. /**
  124212. * Sets the value of the `Back` button
  124213. */
  124214. set buttonBack(value: number);
  124215. /**
  124216. * Gets the value of the `Left` button
  124217. */
  124218. get buttonLB(): number;
  124219. /**
  124220. * Sets the value of the `Left` button
  124221. */
  124222. set buttonLB(value: number);
  124223. /**
  124224. * Gets the value of the `Right` button
  124225. */
  124226. get buttonRB(): number;
  124227. /**
  124228. * Sets the value of the `Right` button
  124229. */
  124230. set buttonRB(value: number);
  124231. /**
  124232. * Gets the value of the Left joystick
  124233. */
  124234. get buttonLeftStick(): number;
  124235. /**
  124236. * Sets the value of the Left joystick
  124237. */
  124238. set buttonLeftStick(value: number);
  124239. /**
  124240. * Gets the value of the Right joystick
  124241. */
  124242. get buttonRightStick(): number;
  124243. /**
  124244. * Sets the value of the Right joystick
  124245. */
  124246. set buttonRightStick(value: number);
  124247. /**
  124248. * Gets the value of D-pad up
  124249. */
  124250. get dPadUp(): number;
  124251. /**
  124252. * Sets the value of D-pad up
  124253. */
  124254. set dPadUp(value: number);
  124255. /**
  124256. * Gets the value of D-pad down
  124257. */
  124258. get dPadDown(): number;
  124259. /**
  124260. * Sets the value of D-pad down
  124261. */
  124262. set dPadDown(value: number);
  124263. /**
  124264. * Gets the value of D-pad left
  124265. */
  124266. get dPadLeft(): number;
  124267. /**
  124268. * Sets the value of D-pad left
  124269. */
  124270. set dPadLeft(value: number);
  124271. /**
  124272. * Gets the value of D-pad right
  124273. */
  124274. get dPadRight(): number;
  124275. /**
  124276. * Sets the value of D-pad right
  124277. */
  124278. set dPadRight(value: number);
  124279. /**
  124280. * Force the gamepad to synchronize with device values
  124281. */
  124282. update(): void;
  124283. /**
  124284. * Disposes the gamepad
  124285. */
  124286. dispose(): void;
  124287. }
  124288. }
  124289. declare module BABYLON {
  124290. /**
  124291. * Defines supported buttons for DualShock compatible gamepads
  124292. */
  124293. export enum DualShockButton {
  124294. /** Cross */
  124295. Cross = 0,
  124296. /** Circle */
  124297. Circle = 1,
  124298. /** Square */
  124299. Square = 2,
  124300. /** Triangle */
  124301. Triangle = 3,
  124302. /** L1 */
  124303. L1 = 4,
  124304. /** R1 */
  124305. R1 = 5,
  124306. /** Share */
  124307. Share = 8,
  124308. /** Options */
  124309. Options = 9,
  124310. /** Left stick */
  124311. LeftStick = 10,
  124312. /** Right stick */
  124313. RightStick = 11
  124314. }
  124315. /** Defines values for DualShock DPad */
  124316. export enum DualShockDpad {
  124317. /** Up */
  124318. Up = 12,
  124319. /** Down */
  124320. Down = 13,
  124321. /** Left */
  124322. Left = 14,
  124323. /** Right */
  124324. Right = 15
  124325. }
  124326. /**
  124327. * Defines a DualShock gamepad
  124328. */
  124329. export class DualShockPad extends Gamepad {
  124330. private _leftTrigger;
  124331. private _rightTrigger;
  124332. private _onlefttriggerchanged;
  124333. private _onrighttriggerchanged;
  124334. private _onbuttondown;
  124335. private _onbuttonup;
  124336. private _ondpaddown;
  124337. private _ondpadup;
  124338. /** Observable raised when a button is pressed */
  124339. onButtonDownObservable: Observable<DualShockButton>;
  124340. /** Observable raised when a button is released */
  124341. onButtonUpObservable: Observable<DualShockButton>;
  124342. /** Observable raised when a pad is pressed */
  124343. onPadDownObservable: Observable<DualShockDpad>;
  124344. /** Observable raised when a pad is released */
  124345. onPadUpObservable: Observable<DualShockDpad>;
  124346. private _buttonCross;
  124347. private _buttonCircle;
  124348. private _buttonSquare;
  124349. private _buttonTriangle;
  124350. private _buttonShare;
  124351. private _buttonOptions;
  124352. private _buttonL1;
  124353. private _buttonR1;
  124354. private _buttonLeftStick;
  124355. private _buttonRightStick;
  124356. private _dPadUp;
  124357. private _dPadDown;
  124358. private _dPadLeft;
  124359. private _dPadRight;
  124360. /**
  124361. * Creates a new DualShock gamepad object
  124362. * @param id defines the id of this gamepad
  124363. * @param index defines its index
  124364. * @param gamepad defines the internal HTML gamepad object
  124365. */
  124366. constructor(id: string, index: number, gamepad: any);
  124367. /**
  124368. * Defines the callback to call when left trigger is pressed
  124369. * @param callback defines the callback to use
  124370. */
  124371. onlefttriggerchanged(callback: (value: number) => void): void;
  124372. /**
  124373. * Defines the callback to call when right trigger is pressed
  124374. * @param callback defines the callback to use
  124375. */
  124376. onrighttriggerchanged(callback: (value: number) => void): void;
  124377. /**
  124378. * Gets the left trigger value
  124379. */
  124380. get leftTrigger(): number;
  124381. /**
  124382. * Sets the left trigger value
  124383. */
  124384. set leftTrigger(newValue: number);
  124385. /**
  124386. * Gets the right trigger value
  124387. */
  124388. get rightTrigger(): number;
  124389. /**
  124390. * Sets the right trigger value
  124391. */
  124392. set rightTrigger(newValue: number);
  124393. /**
  124394. * Defines the callback to call when a button is pressed
  124395. * @param callback defines the callback to use
  124396. */
  124397. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124398. /**
  124399. * Defines the callback to call when a button is released
  124400. * @param callback defines the callback to use
  124401. */
  124402. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124403. /**
  124404. * Defines the callback to call when a pad is pressed
  124405. * @param callback defines the callback to use
  124406. */
  124407. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124408. /**
  124409. * Defines the callback to call when a pad is released
  124410. * @param callback defines the callback to use
  124411. */
  124412. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124413. private _setButtonValue;
  124414. private _setDPadValue;
  124415. /**
  124416. * Gets the value of the `Cross` button
  124417. */
  124418. get buttonCross(): number;
  124419. /**
  124420. * Sets the value of the `Cross` button
  124421. */
  124422. set buttonCross(value: number);
  124423. /**
  124424. * Gets the value of the `Circle` button
  124425. */
  124426. get buttonCircle(): number;
  124427. /**
  124428. * Sets the value of the `Circle` button
  124429. */
  124430. set buttonCircle(value: number);
  124431. /**
  124432. * Gets the value of the `Square` button
  124433. */
  124434. get buttonSquare(): number;
  124435. /**
  124436. * Sets the value of the `Square` button
  124437. */
  124438. set buttonSquare(value: number);
  124439. /**
  124440. * Gets the value of the `Triangle` button
  124441. */
  124442. get buttonTriangle(): number;
  124443. /**
  124444. * Sets the value of the `Triangle` button
  124445. */
  124446. set buttonTriangle(value: number);
  124447. /**
  124448. * Gets the value of the `Options` button
  124449. */
  124450. get buttonOptions(): number;
  124451. /**
  124452. * Sets the value of the `Options` button
  124453. */
  124454. set buttonOptions(value: number);
  124455. /**
  124456. * Gets the value of the `Share` button
  124457. */
  124458. get buttonShare(): number;
  124459. /**
  124460. * Sets the value of the `Share` button
  124461. */
  124462. set buttonShare(value: number);
  124463. /**
  124464. * Gets the value of the `L1` button
  124465. */
  124466. get buttonL1(): number;
  124467. /**
  124468. * Sets the value of the `L1` button
  124469. */
  124470. set buttonL1(value: number);
  124471. /**
  124472. * Gets the value of the `R1` button
  124473. */
  124474. get buttonR1(): number;
  124475. /**
  124476. * Sets the value of the `R1` button
  124477. */
  124478. set buttonR1(value: number);
  124479. /**
  124480. * Gets the value of the Left joystick
  124481. */
  124482. get buttonLeftStick(): number;
  124483. /**
  124484. * Sets the value of the Left joystick
  124485. */
  124486. set buttonLeftStick(value: number);
  124487. /**
  124488. * Gets the value of the Right joystick
  124489. */
  124490. get buttonRightStick(): number;
  124491. /**
  124492. * Sets the value of the Right joystick
  124493. */
  124494. set buttonRightStick(value: number);
  124495. /**
  124496. * Gets the value of D-pad up
  124497. */
  124498. get dPadUp(): number;
  124499. /**
  124500. * Sets the value of D-pad up
  124501. */
  124502. set dPadUp(value: number);
  124503. /**
  124504. * Gets the value of D-pad down
  124505. */
  124506. get dPadDown(): number;
  124507. /**
  124508. * Sets the value of D-pad down
  124509. */
  124510. set dPadDown(value: number);
  124511. /**
  124512. * Gets the value of D-pad left
  124513. */
  124514. get dPadLeft(): number;
  124515. /**
  124516. * Sets the value of D-pad left
  124517. */
  124518. set dPadLeft(value: number);
  124519. /**
  124520. * Gets the value of D-pad right
  124521. */
  124522. get dPadRight(): number;
  124523. /**
  124524. * Sets the value of D-pad right
  124525. */
  124526. set dPadRight(value: number);
  124527. /**
  124528. * Force the gamepad to synchronize with device values
  124529. */
  124530. update(): void;
  124531. /**
  124532. * Disposes the gamepad
  124533. */
  124534. dispose(): void;
  124535. }
  124536. }
  124537. declare module BABYLON {
  124538. /**
  124539. * Manager for handling gamepads
  124540. */
  124541. export class GamepadManager {
  124542. private _scene?;
  124543. private _babylonGamepads;
  124544. private _oneGamepadConnected;
  124545. /** @hidden */
  124546. _isMonitoring: boolean;
  124547. private _gamepadEventSupported;
  124548. private _gamepadSupport?;
  124549. /**
  124550. * observable to be triggered when the gamepad controller has been connected
  124551. */
  124552. onGamepadConnectedObservable: Observable<Gamepad>;
  124553. /**
  124554. * observable to be triggered when the gamepad controller has been disconnected
  124555. */
  124556. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124557. private _onGamepadConnectedEvent;
  124558. private _onGamepadDisconnectedEvent;
  124559. /**
  124560. * Initializes the gamepad manager
  124561. * @param _scene BabylonJS scene
  124562. */
  124563. constructor(_scene?: Scene | undefined);
  124564. /**
  124565. * The gamepads in the game pad manager
  124566. */
  124567. get gamepads(): Gamepad[];
  124568. /**
  124569. * Get the gamepad controllers based on type
  124570. * @param type The type of gamepad controller
  124571. * @returns Nullable gamepad
  124572. */
  124573. getGamepadByType(type?: number): Nullable<Gamepad>;
  124574. /**
  124575. * Disposes the gamepad manager
  124576. */
  124577. dispose(): void;
  124578. private _addNewGamepad;
  124579. private _startMonitoringGamepads;
  124580. private _stopMonitoringGamepads;
  124581. /** @hidden */
  124582. _checkGamepadsStatus(): void;
  124583. private _updateGamepadObjects;
  124584. }
  124585. }
  124586. declare module BABYLON {
  124587. interface Scene {
  124588. /** @hidden */
  124589. _gamepadManager: Nullable<GamepadManager>;
  124590. /**
  124591. * Gets the gamepad manager associated with the scene
  124592. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124593. */
  124594. gamepadManager: GamepadManager;
  124595. }
  124596. /**
  124597. * Interface representing a free camera inputs manager
  124598. */
  124599. interface FreeCameraInputsManager {
  124600. /**
  124601. * Adds gamepad input support to the FreeCameraInputsManager.
  124602. * @returns the FreeCameraInputsManager
  124603. */
  124604. addGamepad(): FreeCameraInputsManager;
  124605. }
  124606. /**
  124607. * Interface representing an arc rotate camera inputs manager
  124608. */
  124609. interface ArcRotateCameraInputsManager {
  124610. /**
  124611. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124612. * @returns the camera inputs manager
  124613. */
  124614. addGamepad(): ArcRotateCameraInputsManager;
  124615. }
  124616. /**
  124617. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124618. */
  124619. export class GamepadSystemSceneComponent implements ISceneComponent {
  124620. /**
  124621. * The component name helpfull to identify the component in the list of scene components.
  124622. */
  124623. readonly name: string;
  124624. /**
  124625. * The scene the component belongs to.
  124626. */
  124627. scene: Scene;
  124628. /**
  124629. * Creates a new instance of the component for the given scene
  124630. * @param scene Defines the scene to register the component in
  124631. */
  124632. constructor(scene: Scene);
  124633. /**
  124634. * Registers the component in a given scene
  124635. */
  124636. register(): void;
  124637. /**
  124638. * Rebuilds the elements related to this component in case of
  124639. * context lost for instance.
  124640. */
  124641. rebuild(): void;
  124642. /**
  124643. * Disposes the component and the associated ressources
  124644. */
  124645. dispose(): void;
  124646. private _beforeCameraUpdate;
  124647. }
  124648. }
  124649. declare module BABYLON {
  124650. /**
  124651. * 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,
  124652. * which still works and will still be found in many Playgrounds.
  124653. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124654. */
  124655. export class UniversalCamera extends TouchCamera {
  124656. /**
  124657. * Defines the gamepad rotation sensiblity.
  124658. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124659. */
  124660. get gamepadAngularSensibility(): number;
  124661. set gamepadAngularSensibility(value: number);
  124662. /**
  124663. * Defines the gamepad move sensiblity.
  124664. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124665. */
  124666. get gamepadMoveSensibility(): number;
  124667. set gamepadMoveSensibility(value: number);
  124668. /**
  124669. * 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,
  124670. * which still works and will still be found in many Playgrounds.
  124671. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124672. * @param name Define the name of the camera in the scene
  124673. * @param position Define the start position of the camera in the scene
  124674. * @param scene Define the scene the camera belongs to
  124675. */
  124676. constructor(name: string, position: Vector3, scene: Scene);
  124677. /**
  124678. * Gets the current object class name.
  124679. * @return the class name
  124680. */
  124681. getClassName(): string;
  124682. }
  124683. }
  124684. declare module BABYLON {
  124685. /**
  124686. * This represents a FPS type of camera. This is only here for back compat purpose.
  124687. * Please use the UniversalCamera instead as both are identical.
  124688. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124689. */
  124690. export class GamepadCamera extends UniversalCamera {
  124691. /**
  124692. * Instantiates a new Gamepad Camera
  124693. * This represents a FPS type of camera. This is only here for back compat purpose.
  124694. * Please use the UniversalCamera instead as both are identical.
  124695. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124696. * @param name Define the name of the camera in the scene
  124697. * @param position Define the start position of the camera in the scene
  124698. * @param scene Define the scene the camera belongs to
  124699. */
  124700. constructor(name: string, position: Vector3, scene: Scene);
  124701. /**
  124702. * Gets the current object class name.
  124703. * @return the class name
  124704. */
  124705. getClassName(): string;
  124706. }
  124707. }
  124708. declare module BABYLON {
  124709. /** @hidden */
  124710. export var passPixelShader: {
  124711. name: string;
  124712. shader: string;
  124713. };
  124714. }
  124715. declare module BABYLON {
  124716. /** @hidden */
  124717. export var passCubePixelShader: {
  124718. name: string;
  124719. shader: string;
  124720. };
  124721. }
  124722. declare module BABYLON {
  124723. /**
  124724. * PassPostProcess which produces an output the same as it's input
  124725. */
  124726. export class PassPostProcess extends PostProcess {
  124727. /**
  124728. * Creates the PassPostProcess
  124729. * @param name The name of the effect.
  124730. * @param options The required width/height ratio to downsize to before computing the render pass.
  124731. * @param camera The camera to apply the render pass to.
  124732. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124733. * @param engine The engine which the post process will be applied. (default: current engine)
  124734. * @param reusable If the post process can be reused on the same frame. (default: false)
  124735. * @param textureType The type of texture to be used when performing the post processing.
  124736. * @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)
  124737. */
  124738. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124739. }
  124740. /**
  124741. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124742. */
  124743. export class PassCubePostProcess extends PostProcess {
  124744. private _face;
  124745. /**
  124746. * Gets or sets the cube face to display.
  124747. * * 0 is +X
  124748. * * 1 is -X
  124749. * * 2 is +Y
  124750. * * 3 is -Y
  124751. * * 4 is +Z
  124752. * * 5 is -Z
  124753. */
  124754. get face(): number;
  124755. set face(value: number);
  124756. /**
  124757. * Creates the PassCubePostProcess
  124758. * @param name The name of the effect.
  124759. * @param options The required width/height ratio to downsize to before computing the render pass.
  124760. * @param camera The camera to apply the render pass to.
  124761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124762. * @param engine The engine which the post process will be applied. (default: current engine)
  124763. * @param reusable If the post process can be reused on the same frame. (default: false)
  124764. * @param textureType The type of texture to be used when performing the post processing.
  124765. * @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)
  124766. */
  124767. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124768. }
  124769. }
  124770. declare module BABYLON {
  124771. /** @hidden */
  124772. export var anaglyphPixelShader: {
  124773. name: string;
  124774. shader: string;
  124775. };
  124776. }
  124777. declare module BABYLON {
  124778. /**
  124779. * Postprocess used to generate anaglyphic rendering
  124780. */
  124781. export class AnaglyphPostProcess extends PostProcess {
  124782. private _passedProcess;
  124783. /**
  124784. * Creates a new AnaglyphPostProcess
  124785. * @param name defines postprocess name
  124786. * @param options defines creation options or target ratio scale
  124787. * @param rigCameras defines cameras using this postprocess
  124788. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124789. * @param engine defines hosting engine
  124790. * @param reusable defines if the postprocess will be reused multiple times per frame
  124791. */
  124792. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124793. }
  124794. }
  124795. declare module BABYLON {
  124796. /**
  124797. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  124798. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124799. */
  124800. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  124801. /**
  124802. * Creates a new AnaglyphArcRotateCamera
  124803. * @param name defines camera name
  124804. * @param alpha defines alpha angle (in radians)
  124805. * @param beta defines beta angle (in radians)
  124806. * @param radius defines radius
  124807. * @param target defines camera target
  124808. * @param interaxialDistance defines distance between each color axis
  124809. * @param scene defines the hosting scene
  124810. */
  124811. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  124812. /**
  124813. * Gets camera class name
  124814. * @returns AnaglyphArcRotateCamera
  124815. */
  124816. getClassName(): string;
  124817. }
  124818. }
  124819. declare module BABYLON {
  124820. /**
  124821. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  124822. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124823. */
  124824. export class AnaglyphFreeCamera extends FreeCamera {
  124825. /**
  124826. * Creates a new AnaglyphFreeCamera
  124827. * @param name defines camera name
  124828. * @param position defines initial position
  124829. * @param interaxialDistance defines distance between each color axis
  124830. * @param scene defines the hosting scene
  124831. */
  124832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124833. /**
  124834. * Gets camera class name
  124835. * @returns AnaglyphFreeCamera
  124836. */
  124837. getClassName(): string;
  124838. }
  124839. }
  124840. declare module BABYLON {
  124841. /**
  124842. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  124843. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124844. */
  124845. export class AnaglyphGamepadCamera extends GamepadCamera {
  124846. /**
  124847. * Creates a new AnaglyphGamepadCamera
  124848. * @param name defines camera name
  124849. * @param position defines initial position
  124850. * @param interaxialDistance defines distance between each color axis
  124851. * @param scene defines the hosting scene
  124852. */
  124853. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124854. /**
  124855. * Gets camera class name
  124856. * @returns AnaglyphGamepadCamera
  124857. */
  124858. getClassName(): string;
  124859. }
  124860. }
  124861. declare module BABYLON {
  124862. /**
  124863. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  124864. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124865. */
  124866. export class AnaglyphUniversalCamera extends UniversalCamera {
  124867. /**
  124868. * Creates a new AnaglyphUniversalCamera
  124869. * @param name defines camera name
  124870. * @param position defines initial position
  124871. * @param interaxialDistance defines distance between each color axis
  124872. * @param scene defines the hosting scene
  124873. */
  124874. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124875. /**
  124876. * Gets camera class name
  124877. * @returns AnaglyphUniversalCamera
  124878. */
  124879. getClassName(): string;
  124880. }
  124881. }
  124882. declare module BABYLON {
  124883. /**
  124884. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  124885. * @see https://doc.babylonjs.com/features/cameras
  124886. */
  124887. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  124888. /**
  124889. * Creates a new StereoscopicArcRotateCamera
  124890. * @param name defines camera name
  124891. * @param alpha defines alpha angle (in radians)
  124892. * @param beta defines beta angle (in radians)
  124893. * @param radius defines radius
  124894. * @param target defines camera target
  124895. * @param interaxialDistance defines distance between each color axis
  124896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124897. * @param scene defines the hosting scene
  124898. */
  124899. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124900. /**
  124901. * Gets camera class name
  124902. * @returns StereoscopicArcRotateCamera
  124903. */
  124904. getClassName(): string;
  124905. }
  124906. }
  124907. declare module BABYLON {
  124908. /**
  124909. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  124910. * @see https://doc.babylonjs.com/features/cameras
  124911. */
  124912. export class StereoscopicFreeCamera extends FreeCamera {
  124913. /**
  124914. * Creates a new StereoscopicFreeCamera
  124915. * @param name defines camera name
  124916. * @param position defines initial position
  124917. * @param interaxialDistance defines distance between each color axis
  124918. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124919. * @param scene defines the hosting scene
  124920. */
  124921. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124922. /**
  124923. * Gets camera class name
  124924. * @returns StereoscopicFreeCamera
  124925. */
  124926. getClassName(): string;
  124927. }
  124928. }
  124929. declare module BABYLON {
  124930. /**
  124931. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  124932. * @see https://doc.babylonjs.com/features/cameras
  124933. */
  124934. export class StereoscopicGamepadCamera extends GamepadCamera {
  124935. /**
  124936. * Creates a new StereoscopicGamepadCamera
  124937. * @param name defines camera name
  124938. * @param position defines initial position
  124939. * @param interaxialDistance defines distance between each color axis
  124940. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124941. * @param scene defines the hosting scene
  124942. */
  124943. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124944. /**
  124945. * Gets camera class name
  124946. * @returns StereoscopicGamepadCamera
  124947. */
  124948. getClassName(): string;
  124949. }
  124950. }
  124951. declare module BABYLON {
  124952. /**
  124953. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  124954. * @see https://doc.babylonjs.com/features/cameras
  124955. */
  124956. export class StereoscopicUniversalCamera extends UniversalCamera {
  124957. /**
  124958. * Creates a new StereoscopicUniversalCamera
  124959. * @param name defines camera name
  124960. * @param position defines initial position
  124961. * @param interaxialDistance defines distance between each color axis
  124962. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124963. * @param scene defines the hosting scene
  124964. */
  124965. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124966. /**
  124967. * Gets camera class name
  124968. * @returns StereoscopicUniversalCamera
  124969. */
  124970. getClassName(): string;
  124971. }
  124972. }
  124973. declare module BABYLON {
  124974. /**
  124975. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  124976. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124977. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124978. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124979. */
  124980. export class VirtualJoysticksCamera extends FreeCamera {
  124981. /**
  124982. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  124983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  124984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  124985. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  124986. * @param name Define the name of the camera in the scene
  124987. * @param position Define the start position of the camera in the scene
  124988. * @param scene Define the scene the camera belongs to
  124989. */
  124990. constructor(name: string, position: Vector3, scene: Scene);
  124991. /**
  124992. * Gets the current object class name.
  124993. * @return the class name
  124994. */
  124995. getClassName(): string;
  124996. }
  124997. }
  124998. declare module BABYLON {
  124999. /**
  125000. * This represents all the required metrics to create a VR camera.
  125001. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125002. */
  125003. export class VRCameraMetrics {
  125004. /**
  125005. * Define the horizontal resolution off the screen.
  125006. */
  125007. hResolution: number;
  125008. /**
  125009. * Define the vertical resolution off the screen.
  125010. */
  125011. vResolution: number;
  125012. /**
  125013. * Define the horizontal screen size.
  125014. */
  125015. hScreenSize: number;
  125016. /**
  125017. * Define the vertical screen size.
  125018. */
  125019. vScreenSize: number;
  125020. /**
  125021. * Define the vertical screen center position.
  125022. */
  125023. vScreenCenter: number;
  125024. /**
  125025. * Define the distance of the eyes to the screen.
  125026. */
  125027. eyeToScreenDistance: number;
  125028. /**
  125029. * Define the distance between both lenses
  125030. */
  125031. lensSeparationDistance: number;
  125032. /**
  125033. * Define the distance between both viewer's eyes.
  125034. */
  125035. interpupillaryDistance: number;
  125036. /**
  125037. * Define the distortion factor of the VR postprocess.
  125038. * Please, touch with care.
  125039. */
  125040. distortionK: number[];
  125041. /**
  125042. * Define the chromatic aberration correction factors for the VR post process.
  125043. */
  125044. chromaAbCorrection: number[];
  125045. /**
  125046. * Define the scale factor of the post process.
  125047. * The smaller the better but the slower.
  125048. */
  125049. postProcessScaleFactor: number;
  125050. /**
  125051. * Define an offset for the lens center.
  125052. */
  125053. lensCenterOffset: number;
  125054. /**
  125055. * Define if the current vr camera should compensate the distortion of the lense or not.
  125056. */
  125057. compensateDistortion: boolean;
  125058. /**
  125059. * Defines if multiview should be enabled when rendering (Default: false)
  125060. */
  125061. multiviewEnabled: boolean;
  125062. /**
  125063. * Gets the rendering aspect ratio based on the provided resolutions.
  125064. */
  125065. get aspectRatio(): number;
  125066. /**
  125067. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125068. */
  125069. get aspectRatioFov(): number;
  125070. /**
  125071. * @hidden
  125072. */
  125073. get leftHMatrix(): Matrix;
  125074. /**
  125075. * @hidden
  125076. */
  125077. get rightHMatrix(): Matrix;
  125078. /**
  125079. * @hidden
  125080. */
  125081. get leftPreViewMatrix(): Matrix;
  125082. /**
  125083. * @hidden
  125084. */
  125085. get rightPreViewMatrix(): Matrix;
  125086. /**
  125087. * Get the default VRMetrics based on the most generic setup.
  125088. * @returns the default vr metrics
  125089. */
  125090. static GetDefault(): VRCameraMetrics;
  125091. }
  125092. }
  125093. declare module BABYLON {
  125094. /** @hidden */
  125095. export var vrDistortionCorrectionPixelShader: {
  125096. name: string;
  125097. shader: string;
  125098. };
  125099. }
  125100. declare module BABYLON {
  125101. /**
  125102. * VRDistortionCorrectionPostProcess used for mobile VR
  125103. */
  125104. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125105. private _isRightEye;
  125106. private _distortionFactors;
  125107. private _postProcessScaleFactor;
  125108. private _lensCenterOffset;
  125109. private _scaleIn;
  125110. private _scaleFactor;
  125111. private _lensCenter;
  125112. /**
  125113. * Initializes the VRDistortionCorrectionPostProcess
  125114. * @param name The name of the effect.
  125115. * @param camera The camera to apply the render pass to.
  125116. * @param isRightEye If this is for the right eye distortion
  125117. * @param vrMetrics All the required metrics for the VR camera
  125118. */
  125119. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125120. }
  125121. }
  125122. declare module BABYLON {
  125123. /**
  125124. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125125. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125126. */
  125127. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125128. /**
  125129. * Creates a new VRDeviceOrientationArcRotateCamera
  125130. * @param name defines camera name
  125131. * @param alpha defines the camera rotation along the logitudinal axis
  125132. * @param beta defines the camera rotation along the latitudinal axis
  125133. * @param radius defines the camera distance from its target
  125134. * @param target defines the camera target
  125135. * @param scene defines the scene the camera belongs to
  125136. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125137. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125138. */
  125139. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125140. /**
  125141. * Gets camera class name
  125142. * @returns VRDeviceOrientationArcRotateCamera
  125143. */
  125144. getClassName(): string;
  125145. }
  125146. }
  125147. declare module BABYLON {
  125148. /**
  125149. * Camera used to simulate VR rendering (based on FreeCamera)
  125150. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125151. */
  125152. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125153. /**
  125154. * Creates a new VRDeviceOrientationFreeCamera
  125155. * @param name defines camera name
  125156. * @param position defines the start position of the camera
  125157. * @param scene defines the scene the camera belongs to
  125158. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125159. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125160. */
  125161. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125162. /**
  125163. * Gets camera class name
  125164. * @returns VRDeviceOrientationFreeCamera
  125165. */
  125166. getClassName(): string;
  125167. }
  125168. }
  125169. declare module BABYLON {
  125170. /**
  125171. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125172. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125173. */
  125174. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125175. /**
  125176. * Creates a new VRDeviceOrientationGamepadCamera
  125177. * @param name defines camera name
  125178. * @param position defines the start position of the camera
  125179. * @param scene defines the scene the camera belongs to
  125180. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125181. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125182. */
  125183. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125184. /**
  125185. * Gets camera class name
  125186. * @returns VRDeviceOrientationGamepadCamera
  125187. */
  125188. getClassName(): string;
  125189. }
  125190. }
  125191. declare module BABYLON {
  125192. /**
  125193. * A class extending Texture allowing drawing on a texture
  125194. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125195. */
  125196. export class DynamicTexture extends Texture {
  125197. private _generateMipMaps;
  125198. private _canvas;
  125199. private _context;
  125200. /**
  125201. * Creates a DynamicTexture
  125202. * @param name defines the name of the texture
  125203. * @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
  125204. * @param scene defines the scene where you want the texture
  125205. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125206. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125207. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125208. */
  125209. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125210. /**
  125211. * Get the current class name of the texture useful for serialization or dynamic coding.
  125212. * @returns "DynamicTexture"
  125213. */
  125214. getClassName(): string;
  125215. /**
  125216. * Gets the current state of canRescale
  125217. */
  125218. get canRescale(): boolean;
  125219. private _recreate;
  125220. /**
  125221. * Scales the texture
  125222. * @param ratio the scale factor to apply to both width and height
  125223. */
  125224. scale(ratio: number): void;
  125225. /**
  125226. * Resizes the texture
  125227. * @param width the new width
  125228. * @param height the new height
  125229. */
  125230. scaleTo(width: number, height: number): void;
  125231. /**
  125232. * Gets the context of the canvas used by the texture
  125233. * @returns the canvas context of the dynamic texture
  125234. */
  125235. getContext(): CanvasRenderingContext2D;
  125236. /**
  125237. * Clears the texture
  125238. */
  125239. clear(): void;
  125240. /**
  125241. * Updates the texture
  125242. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125243. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125244. */
  125245. update(invertY?: boolean, premulAlpha?: boolean): void;
  125246. /**
  125247. * Draws text onto the texture
  125248. * @param text defines the text to be drawn
  125249. * @param x defines the placement of the text from the left
  125250. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125251. * @param font defines the font to be used with font-style, font-size, font-name
  125252. * @param color defines the color used for the text
  125253. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125254. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125255. * @param update defines whether texture is immediately update (default is true)
  125256. */
  125257. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125258. /**
  125259. * Clones the texture
  125260. * @returns the clone of the texture.
  125261. */
  125262. clone(): DynamicTexture;
  125263. /**
  125264. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125265. * @returns a serialized dynamic texture object
  125266. */
  125267. serialize(): any;
  125268. private _IsCanvasElement;
  125269. /** @hidden */
  125270. _rebuild(): void;
  125271. }
  125272. }
  125273. declare module BABYLON {
  125274. /**
  125275. * Class containing static functions to help procedurally build meshes
  125276. */
  125277. export class GroundBuilder {
  125278. /**
  125279. * Creates a ground mesh
  125280. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125281. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125283. * @param name defines the name of the mesh
  125284. * @param options defines the options used to create the mesh
  125285. * @param scene defines the hosting scene
  125286. * @returns the ground mesh
  125287. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125288. */
  125289. static CreateGround(name: string, options: {
  125290. width?: number;
  125291. height?: number;
  125292. subdivisions?: number;
  125293. subdivisionsX?: number;
  125294. subdivisionsY?: number;
  125295. updatable?: boolean;
  125296. }, scene: any): Mesh;
  125297. /**
  125298. * Creates a tiled ground mesh
  125299. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125300. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125301. * * 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
  125302. * * 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
  125303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125304. * @param name defines the name of the mesh
  125305. * @param options defines the options used to create the mesh
  125306. * @param scene defines the hosting scene
  125307. * @returns the tiled ground mesh
  125308. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125309. */
  125310. static CreateTiledGround(name: string, options: {
  125311. xmin: number;
  125312. zmin: number;
  125313. xmax: number;
  125314. zmax: number;
  125315. subdivisions?: {
  125316. w: number;
  125317. h: number;
  125318. };
  125319. precision?: {
  125320. w: number;
  125321. h: number;
  125322. };
  125323. updatable?: boolean;
  125324. }, scene?: Nullable<Scene>): Mesh;
  125325. /**
  125326. * Creates a ground mesh from a height map
  125327. * * The parameter `url` sets the URL of the height map image resource.
  125328. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125329. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125330. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125331. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125332. * * 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.
  125333. * * 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).
  125334. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125336. * @param name defines the name of the mesh
  125337. * @param url defines the url to the height map
  125338. * @param options defines the options used to create the mesh
  125339. * @param scene defines the hosting scene
  125340. * @returns the ground mesh
  125341. * @see https://doc.babylonjs.com/babylon101/height_map
  125342. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125343. */
  125344. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125345. width?: number;
  125346. height?: number;
  125347. subdivisions?: number;
  125348. minHeight?: number;
  125349. maxHeight?: number;
  125350. colorFilter?: Color3;
  125351. alphaFilter?: number;
  125352. updatable?: boolean;
  125353. onReady?: (mesh: GroundMesh) => void;
  125354. }, scene?: Nullable<Scene>): GroundMesh;
  125355. }
  125356. }
  125357. declare module BABYLON {
  125358. /**
  125359. * Class containing static functions to help procedurally build meshes
  125360. */
  125361. export class TorusBuilder {
  125362. /**
  125363. * Creates a torus mesh
  125364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125370. * @param name defines the name of the mesh
  125371. * @param options defines the options used to create the mesh
  125372. * @param scene defines the hosting scene
  125373. * @returns the torus mesh
  125374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125375. */
  125376. static CreateTorus(name: string, options: {
  125377. diameter?: number;
  125378. thickness?: number;
  125379. tessellation?: number;
  125380. updatable?: boolean;
  125381. sideOrientation?: number;
  125382. frontUVs?: Vector4;
  125383. backUVs?: Vector4;
  125384. }, scene: any): Mesh;
  125385. }
  125386. }
  125387. declare module BABYLON {
  125388. /**
  125389. * Class containing static functions to help procedurally build meshes
  125390. */
  125391. export class CylinderBuilder {
  125392. /**
  125393. * Creates a cylinder or a cone mesh
  125394. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125395. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125396. * * 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.
  125397. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125398. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125399. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125400. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125401. * * 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).
  125402. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125403. * * 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).
  125404. * * 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
  125405. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125406. * * 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
  125407. * * 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.
  125408. * * If `enclose` is false, a ring surface is one element.
  125409. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125410. * * 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
  125411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125414. * @param name defines the name of the mesh
  125415. * @param options defines the options used to create the mesh
  125416. * @param scene defines the hosting scene
  125417. * @returns the cylinder mesh
  125418. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125419. */
  125420. static CreateCylinder(name: string, options: {
  125421. height?: number;
  125422. diameterTop?: number;
  125423. diameterBottom?: number;
  125424. diameter?: number;
  125425. tessellation?: number;
  125426. subdivisions?: number;
  125427. arc?: number;
  125428. faceColors?: Color4[];
  125429. faceUV?: Vector4[];
  125430. updatable?: boolean;
  125431. hasRings?: boolean;
  125432. enclose?: boolean;
  125433. cap?: number;
  125434. sideOrientation?: number;
  125435. frontUVs?: Vector4;
  125436. backUVs?: Vector4;
  125437. }, scene: any): Mesh;
  125438. }
  125439. }
  125440. declare module BABYLON {
  125441. /**
  125442. * States of the webXR experience
  125443. */
  125444. export enum WebXRState {
  125445. /**
  125446. * Transitioning to being in XR mode
  125447. */
  125448. ENTERING_XR = 0,
  125449. /**
  125450. * Transitioning to non XR mode
  125451. */
  125452. EXITING_XR = 1,
  125453. /**
  125454. * In XR mode and presenting
  125455. */
  125456. IN_XR = 2,
  125457. /**
  125458. * Not entered XR mode
  125459. */
  125460. NOT_IN_XR = 3
  125461. }
  125462. /**
  125463. * Abstraction of the XR render target
  125464. */
  125465. export interface WebXRRenderTarget extends IDisposable {
  125466. /**
  125467. * xrpresent context of the canvas which can be used to display/mirror xr content
  125468. */
  125469. canvasContext: WebGLRenderingContext;
  125470. /**
  125471. * xr layer for the canvas
  125472. */
  125473. xrLayer: Nullable<XRWebGLLayer>;
  125474. /**
  125475. * Initializes the xr layer for the session
  125476. * @param xrSession xr session
  125477. * @returns a promise that will resolve once the XR Layer has been created
  125478. */
  125479. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125480. }
  125481. }
  125482. declare module BABYLON {
  125483. /**
  125484. * COnfiguration object for WebXR output canvas
  125485. */
  125486. export class WebXRManagedOutputCanvasOptions {
  125487. /**
  125488. * An optional canvas in case you wish to create it yourself and provide it here.
  125489. * If not provided, a new canvas will be created
  125490. */
  125491. canvasElement?: HTMLCanvasElement;
  125492. /**
  125493. * Options for this XR Layer output
  125494. */
  125495. canvasOptions?: XRWebGLLayerOptions;
  125496. /**
  125497. * CSS styling for a newly created canvas (if not provided)
  125498. */
  125499. newCanvasCssStyle?: string;
  125500. /**
  125501. * Get the default values of the configuration object
  125502. * @returns default values of this configuration object
  125503. */
  125504. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125505. }
  125506. /**
  125507. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125508. */
  125509. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125510. private _options;
  125511. private _canvas;
  125512. private _engine;
  125513. private _originalCanvasSize;
  125514. /**
  125515. * Rendering context of the canvas which can be used to display/mirror xr content
  125516. */
  125517. canvasContext: WebGLRenderingContext;
  125518. /**
  125519. * xr layer for the canvas
  125520. */
  125521. xrLayer: Nullable<XRWebGLLayer>;
  125522. /**
  125523. * Obseervers registered here will be triggered when the xr layer was initialized
  125524. */
  125525. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125526. /**
  125527. * Initializes the canvas to be added/removed upon entering/exiting xr
  125528. * @param _xrSessionManager The XR Session manager
  125529. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125530. */
  125531. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125532. /**
  125533. * Disposes of the object
  125534. */
  125535. dispose(): void;
  125536. /**
  125537. * Initializes the xr layer for the session
  125538. * @param xrSession xr session
  125539. * @returns a promise that will resolve once the XR Layer has been created
  125540. */
  125541. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125542. private _addCanvas;
  125543. private _removeCanvas;
  125544. private _setCanvasSize;
  125545. private _setManagedOutputCanvas;
  125546. }
  125547. }
  125548. declare module BABYLON {
  125549. /**
  125550. * Manages an XRSession to work with Babylon's engine
  125551. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125552. */
  125553. export class WebXRSessionManager implements IDisposable {
  125554. /** The scene which the session should be created for */
  125555. scene: Scene;
  125556. private _referenceSpace;
  125557. private _rttProvider;
  125558. private _sessionEnded;
  125559. private _xrNavigator;
  125560. private baseLayer;
  125561. /**
  125562. * The base reference space from which the session started. good if you want to reset your
  125563. * reference space
  125564. */
  125565. baseReferenceSpace: XRReferenceSpace;
  125566. /**
  125567. * Current XR frame
  125568. */
  125569. currentFrame: Nullable<XRFrame>;
  125570. /** WebXR timestamp updated every frame */
  125571. currentTimestamp: number;
  125572. /**
  125573. * Used just in case of a failure to initialize an immersive session.
  125574. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125575. */
  125576. defaultHeightCompensation: number;
  125577. /**
  125578. * Fires every time a new xrFrame arrives which can be used to update the camera
  125579. */
  125580. onXRFrameObservable: Observable<XRFrame>;
  125581. /**
  125582. * Fires when the reference space changed
  125583. */
  125584. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125585. /**
  125586. * Fires when the xr session is ended either by the device or manually done
  125587. */
  125588. onXRSessionEnded: Observable<any>;
  125589. /**
  125590. * Fires when the xr session is ended either by the device or manually done
  125591. */
  125592. onXRSessionInit: Observable<XRSession>;
  125593. /**
  125594. * Underlying xr session
  125595. */
  125596. session: XRSession;
  125597. /**
  125598. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125599. * or get the offset the player is currently at.
  125600. */
  125601. viewerReferenceSpace: XRReferenceSpace;
  125602. /**
  125603. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125604. * @param scene The scene which the session should be created for
  125605. */
  125606. constructor(
  125607. /** The scene which the session should be created for */
  125608. scene: Scene);
  125609. /**
  125610. * The current reference space used in this session. This reference space can constantly change!
  125611. * It is mainly used to offset the camera's position.
  125612. */
  125613. get referenceSpace(): XRReferenceSpace;
  125614. /**
  125615. * Set a new reference space and triggers the observable
  125616. */
  125617. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125618. /**
  125619. * Disposes of the session manager
  125620. */
  125621. dispose(): void;
  125622. /**
  125623. * Stops the xrSession and restores the render loop
  125624. * @returns Promise which resolves after it exits XR
  125625. */
  125626. exitXRAsync(): Promise<void>;
  125627. /**
  125628. * Gets the correct render target texture to be rendered this frame for this eye
  125629. * @param eye the eye for which to get the render target
  125630. * @returns the render target for the specified eye
  125631. */
  125632. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125633. /**
  125634. * Creates a WebXRRenderTarget object for the XR session
  125635. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125636. * @param options optional options to provide when creating a new render target
  125637. * @returns a WebXR render target to which the session can render
  125638. */
  125639. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125640. /**
  125641. * Initializes the manager
  125642. * After initialization enterXR can be called to start an XR session
  125643. * @returns Promise which resolves after it is initialized
  125644. */
  125645. initializeAsync(): Promise<void>;
  125646. /**
  125647. * Initializes an xr session
  125648. * @param xrSessionMode mode to initialize
  125649. * @param xrSessionInit defines optional and required values to pass to the session builder
  125650. * @returns a promise which will resolve once the session has been initialized
  125651. */
  125652. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125653. /**
  125654. * Checks if a session would be supported for the creation options specified
  125655. * @param sessionMode session mode to check if supported eg. immersive-vr
  125656. * @returns A Promise that resolves to true if supported and false if not
  125657. */
  125658. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125659. /**
  125660. * Resets the reference space to the one started the session
  125661. */
  125662. resetReferenceSpace(): void;
  125663. /**
  125664. * Starts rendering to the xr layer
  125665. */
  125666. runXRRenderLoop(): void;
  125667. /**
  125668. * Sets the reference space on the xr session
  125669. * @param referenceSpaceType space to set
  125670. * @returns a promise that will resolve once the reference space has been set
  125671. */
  125672. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125673. /**
  125674. * Updates the render state of the session
  125675. * @param state state to set
  125676. * @returns a promise that resolves once the render state has been updated
  125677. */
  125678. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125679. /**
  125680. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125681. * @param sessionMode defines the session to test
  125682. * @returns a promise with boolean as final value
  125683. */
  125684. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125685. private _createRenderTargetTexture;
  125686. }
  125687. }
  125688. declare module BABYLON {
  125689. /**
  125690. * WebXR Camera which holds the views for the xrSession
  125691. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125692. */
  125693. export class WebXRCamera extends FreeCamera {
  125694. private _xrSessionManager;
  125695. private _firstFrame;
  125696. private _referenceQuaternion;
  125697. private _referencedPosition;
  125698. private _xrInvPositionCache;
  125699. private _xrInvQuaternionCache;
  125700. /**
  125701. * Should position compensation execute on first frame.
  125702. * This is used when copying the position from a native (non XR) camera
  125703. */
  125704. compensateOnFirstFrame: boolean;
  125705. /**
  125706. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125707. * @param name the name of the camera
  125708. * @param scene the scene to add the camera to
  125709. * @param _xrSessionManager a constructed xr session manager
  125710. */
  125711. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125712. /**
  125713. * Return the user's height, unrelated to the current ground.
  125714. * This will be the y position of this camera, when ground level is 0.
  125715. */
  125716. get realWorldHeight(): number;
  125717. /** @hidden */
  125718. _updateForDualEyeDebugging(): void;
  125719. /**
  125720. * Sets this camera's transformation based on a non-vr camera
  125721. * @param otherCamera the non-vr camera to copy the transformation from
  125722. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125723. */
  125724. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125725. /**
  125726. * Gets the current instance class name ("WebXRCamera").
  125727. * @returns the class name
  125728. */
  125729. getClassName(): string;
  125730. private _rotate180;
  125731. private _updateFromXRSession;
  125732. private _updateNumberOfRigCameras;
  125733. private _updateReferenceSpace;
  125734. private _updateReferenceSpaceOffset;
  125735. }
  125736. }
  125737. declare module BABYLON {
  125738. /**
  125739. * Defining the interface required for a (webxr) feature
  125740. */
  125741. export interface IWebXRFeature extends IDisposable {
  125742. /**
  125743. * Is this feature attached
  125744. */
  125745. attached: boolean;
  125746. /**
  125747. * Should auto-attach be disabled?
  125748. */
  125749. disableAutoAttach: boolean;
  125750. /**
  125751. * Attach the feature to the session
  125752. * Will usually be called by the features manager
  125753. *
  125754. * @param force should attachment be forced (even when already attached)
  125755. * @returns true if successful.
  125756. */
  125757. attach(force?: boolean): boolean;
  125758. /**
  125759. * Detach the feature from the session
  125760. * Will usually be called by the features manager
  125761. *
  125762. * @returns true if successful.
  125763. */
  125764. detach(): boolean;
  125765. /**
  125766. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125767. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125768. *
  125769. * @returns whether or not the feature is compatible in this environment
  125770. */
  125771. isCompatible(): boolean;
  125772. /**
  125773. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125774. */
  125775. xrNativeFeatureName?: string;
  125776. }
  125777. /**
  125778. * A list of the currently available features without referencing them
  125779. */
  125780. export class WebXRFeatureName {
  125781. /**
  125782. * The name of the anchor system feature
  125783. */
  125784. static ANCHOR_SYSTEM: string;
  125785. /**
  125786. * The name of the background remover feature
  125787. */
  125788. static BACKGROUND_REMOVER: string;
  125789. /**
  125790. * The name of the hit test feature
  125791. */
  125792. static HIT_TEST: string;
  125793. /**
  125794. * physics impostors for xr controllers feature
  125795. */
  125796. static PHYSICS_CONTROLLERS: string;
  125797. /**
  125798. * The name of the plane detection feature
  125799. */
  125800. static PLANE_DETECTION: string;
  125801. /**
  125802. * The name of the pointer selection feature
  125803. */
  125804. static POINTER_SELECTION: string;
  125805. /**
  125806. * The name of the teleportation feature
  125807. */
  125808. static TELEPORTATION: string;
  125809. }
  125810. /**
  125811. * Defining the constructor of a feature. Used to register the modules.
  125812. */
  125813. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  125814. /**
  125815. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  125816. * It is mainly used in AR sessions.
  125817. *
  125818. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  125819. */
  125820. export class WebXRFeaturesManager implements IDisposable {
  125821. private _xrSessionManager;
  125822. private static readonly _AvailableFeatures;
  125823. private _features;
  125824. /**
  125825. * constructs a new features manages.
  125826. *
  125827. * @param _xrSessionManager an instance of WebXRSessionManager
  125828. */
  125829. constructor(_xrSessionManager: WebXRSessionManager);
  125830. /**
  125831. * Used to register a module. After calling this function a developer can use this feature in the scene.
  125832. * Mainly used internally.
  125833. *
  125834. * @param featureName the name of the feature to register
  125835. * @param constructorFunction the function used to construct the module
  125836. * @param version the (babylon) version of the module
  125837. * @param stable is that a stable version of this module
  125838. */
  125839. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  125840. /**
  125841. * Returns a constructor of a specific feature.
  125842. *
  125843. * @param featureName the name of the feature to construct
  125844. * @param version the version of the feature to load
  125845. * @param xrSessionManager the xrSessionManager. Used to construct the module
  125846. * @param options optional options provided to the module.
  125847. * @returns a function that, when called, will return a new instance of this feature
  125848. */
  125849. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  125850. /**
  125851. * Can be used to return the list of features currently registered
  125852. *
  125853. * @returns an Array of available features
  125854. */
  125855. static GetAvailableFeatures(): string[];
  125856. /**
  125857. * Gets the versions available for a specific feature
  125858. * @param featureName the name of the feature
  125859. * @returns an array with the available versions
  125860. */
  125861. static GetAvailableVersions(featureName: string): string[];
  125862. /**
  125863. * Return the latest unstable version of this feature
  125864. * @param featureName the name of the feature to search
  125865. * @returns the version number. if not found will return -1
  125866. */
  125867. static GetLatestVersionOfFeature(featureName: string): number;
  125868. /**
  125869. * Return the latest stable version of this feature
  125870. * @param featureName the name of the feature to search
  125871. * @returns the version number. if not found will return -1
  125872. */
  125873. static GetStableVersionOfFeature(featureName: string): number;
  125874. /**
  125875. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  125876. * Can be used during a session to start a feature
  125877. * @param featureName the name of feature to attach
  125878. */
  125879. attachFeature(featureName: string): void;
  125880. /**
  125881. * Can be used inside a session or when the session ends to detach a specific feature
  125882. * @param featureName the name of the feature to detach
  125883. */
  125884. detachFeature(featureName: string): void;
  125885. /**
  125886. * Used to disable an already-enabled feature
  125887. * The feature will be disposed and will be recreated once enabled.
  125888. * @param featureName the feature to disable
  125889. * @returns true if disable was successful
  125890. */
  125891. disableFeature(featureName: string | {
  125892. Name: string;
  125893. }): boolean;
  125894. /**
  125895. * dispose this features manager
  125896. */
  125897. dispose(): void;
  125898. /**
  125899. * 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.
  125900. * 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.
  125901. *
  125902. * @param featureName the name of the feature to load or the class of the feature
  125903. * @param version optional version to load. if not provided the latest version will be enabled
  125904. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  125905. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  125906. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  125907. * @returns a new constructed feature or throws an error if feature not found.
  125908. */
  125909. enableFeature(featureName: string | {
  125910. Name: string;
  125911. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  125912. /**
  125913. * get the implementation of an enabled feature.
  125914. * @param featureName the name of the feature to load
  125915. * @returns the feature class, if found
  125916. */
  125917. getEnabledFeature(featureName: string): IWebXRFeature;
  125918. /**
  125919. * Get the list of enabled features
  125920. * @returns an array of enabled features
  125921. */
  125922. getEnabledFeatures(): string[];
  125923. /**
  125924. * This function will exten the session creation configuration object with enabled features.
  125925. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  125926. * according to the defined "required" variable, provided during enableFeature call
  125927. * @param xrSessionInit the xr Session init object to extend
  125928. *
  125929. * @returns an extended XRSessionInit object
  125930. */
  125931. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  125932. }
  125933. }
  125934. declare module BABYLON {
  125935. /**
  125936. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  125937. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  125938. */
  125939. export class WebXRExperienceHelper implements IDisposable {
  125940. private scene;
  125941. private _nonVRCamera;
  125942. private _originalSceneAutoClear;
  125943. private _supported;
  125944. /**
  125945. * Camera used to render xr content
  125946. */
  125947. camera: WebXRCamera;
  125948. /** A features manager for this xr session */
  125949. featuresManager: WebXRFeaturesManager;
  125950. /**
  125951. * Observers registered here will be triggered after the camera's initial transformation is set
  125952. * This can be used to set a different ground level or an extra rotation.
  125953. *
  125954. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  125955. * to the position set after this observable is done executing.
  125956. */
  125957. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  125958. /**
  125959. * Fires when the state of the experience helper has changed
  125960. */
  125961. onStateChangedObservable: Observable<WebXRState>;
  125962. /** Session manager used to keep track of xr session */
  125963. sessionManager: WebXRSessionManager;
  125964. /**
  125965. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  125966. */
  125967. state: WebXRState;
  125968. /**
  125969. * Creates a WebXRExperienceHelper
  125970. * @param scene The scene the helper should be created in
  125971. */
  125972. private constructor();
  125973. /**
  125974. * Creates the experience helper
  125975. * @param scene the scene to attach the experience helper to
  125976. * @returns a promise for the experience helper
  125977. */
  125978. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  125979. /**
  125980. * Disposes of the experience helper
  125981. */
  125982. dispose(): void;
  125983. /**
  125984. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  125985. * @param sessionMode options for the XR session
  125986. * @param referenceSpaceType frame of reference of the XR session
  125987. * @param renderTarget the output canvas that will be used to enter XR mode
  125988. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  125989. * @returns promise that resolves after xr mode has entered
  125990. */
  125991. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  125992. /**
  125993. * Exits XR mode and returns the scene to its original state
  125994. * @returns promise that resolves after xr mode has exited
  125995. */
  125996. exitXRAsync(): Promise<void>;
  125997. private _nonXRToXRCamera;
  125998. private _setState;
  125999. }
  126000. }
  126001. declare module BABYLON {
  126002. /**
  126003. * X-Y values for axes in WebXR
  126004. */
  126005. export interface IWebXRMotionControllerAxesValue {
  126006. /**
  126007. * The value of the x axis
  126008. */
  126009. x: number;
  126010. /**
  126011. * The value of the y-axis
  126012. */
  126013. y: number;
  126014. }
  126015. /**
  126016. * changed / previous values for the values of this component
  126017. */
  126018. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126019. /**
  126020. * current (this frame) value
  126021. */
  126022. current: T;
  126023. /**
  126024. * previous (last change) value
  126025. */
  126026. previous: T;
  126027. }
  126028. /**
  126029. * Represents changes in the component between current frame and last values recorded
  126030. */
  126031. export interface IWebXRMotionControllerComponentChanges {
  126032. /**
  126033. * will be populated with previous and current values if axes changed
  126034. */
  126035. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126036. /**
  126037. * will be populated with previous and current values if pressed changed
  126038. */
  126039. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126040. /**
  126041. * will be populated with previous and current values if touched changed
  126042. */
  126043. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126044. /**
  126045. * will be populated with previous and current values if value changed
  126046. */
  126047. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126048. }
  126049. /**
  126050. * This class represents a single component (for example button or thumbstick) of a motion controller
  126051. */
  126052. export class WebXRControllerComponent implements IDisposable {
  126053. /**
  126054. * the id of this component
  126055. */
  126056. id: string;
  126057. /**
  126058. * the type of the component
  126059. */
  126060. type: MotionControllerComponentType;
  126061. private _buttonIndex;
  126062. private _axesIndices;
  126063. private _axes;
  126064. private _changes;
  126065. private _currentValue;
  126066. private _hasChanges;
  126067. private _pressed;
  126068. private _touched;
  126069. /**
  126070. * button component type
  126071. */
  126072. static BUTTON_TYPE: MotionControllerComponentType;
  126073. /**
  126074. * squeeze component type
  126075. */
  126076. static SQUEEZE_TYPE: MotionControllerComponentType;
  126077. /**
  126078. * Thumbstick component type
  126079. */
  126080. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126081. /**
  126082. * Touchpad component type
  126083. */
  126084. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126085. /**
  126086. * trigger component type
  126087. */
  126088. static TRIGGER_TYPE: MotionControllerComponentType;
  126089. /**
  126090. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126091. * the axes data changes
  126092. */
  126093. onAxisValueChangedObservable: Observable<{
  126094. x: number;
  126095. y: number;
  126096. }>;
  126097. /**
  126098. * Observers registered here will be triggered when the state of a button changes
  126099. * State change is either pressed / touched / value
  126100. */
  126101. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126102. /**
  126103. * Creates a new component for a motion controller.
  126104. * It is created by the motion controller itself
  126105. *
  126106. * @param id the id of this component
  126107. * @param type the type of the component
  126108. * @param _buttonIndex index in the buttons array of the gamepad
  126109. * @param _axesIndices indices of the values in the axes array of the gamepad
  126110. */
  126111. constructor(
  126112. /**
  126113. * the id of this component
  126114. */
  126115. id: string,
  126116. /**
  126117. * the type of the component
  126118. */
  126119. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126120. /**
  126121. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126122. */
  126123. get axes(): IWebXRMotionControllerAxesValue;
  126124. /**
  126125. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126126. */
  126127. get changes(): IWebXRMotionControllerComponentChanges;
  126128. /**
  126129. * Return whether or not the component changed the last frame
  126130. */
  126131. get hasChanges(): boolean;
  126132. /**
  126133. * is the button currently pressed
  126134. */
  126135. get pressed(): boolean;
  126136. /**
  126137. * is the button currently touched
  126138. */
  126139. get touched(): boolean;
  126140. /**
  126141. * Get the current value of this component
  126142. */
  126143. get value(): number;
  126144. /**
  126145. * Dispose this component
  126146. */
  126147. dispose(): void;
  126148. /**
  126149. * Are there axes correlating to this component
  126150. * @return true is axes data is available
  126151. */
  126152. isAxes(): boolean;
  126153. /**
  126154. * Is this component a button (hence - pressable)
  126155. * @returns true if can be pressed
  126156. */
  126157. isButton(): boolean;
  126158. /**
  126159. * update this component using the gamepad object it is in. Called on every frame
  126160. * @param nativeController the native gamepad controller object
  126161. */
  126162. update(nativeController: IMinimalMotionControllerObject): void;
  126163. }
  126164. }
  126165. declare module BABYLON {
  126166. /**
  126167. * Interface used to represent data loading progression
  126168. */
  126169. export interface ISceneLoaderProgressEvent {
  126170. /**
  126171. * Defines if data length to load can be evaluated
  126172. */
  126173. readonly lengthComputable: boolean;
  126174. /**
  126175. * Defines the loaded data length
  126176. */
  126177. readonly loaded: number;
  126178. /**
  126179. * Defines the data length to load
  126180. */
  126181. readonly total: number;
  126182. }
  126183. /**
  126184. * Interface used by SceneLoader plugins to define supported file extensions
  126185. */
  126186. export interface ISceneLoaderPluginExtensions {
  126187. /**
  126188. * Defines the list of supported extensions
  126189. */
  126190. [extension: string]: {
  126191. isBinary: boolean;
  126192. };
  126193. }
  126194. /**
  126195. * Interface used by SceneLoader plugin factory
  126196. */
  126197. export interface ISceneLoaderPluginFactory {
  126198. /**
  126199. * Defines the name of the factory
  126200. */
  126201. name: string;
  126202. /**
  126203. * Function called to create a new plugin
  126204. * @return the new plugin
  126205. */
  126206. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126207. /**
  126208. * The callback that returns true if the data can be directly loaded.
  126209. * @param data string containing the file data
  126210. * @returns if the data can be loaded directly
  126211. */
  126212. canDirectLoad?(data: string): boolean;
  126213. }
  126214. /**
  126215. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126216. */
  126217. export interface ISceneLoaderPluginBase {
  126218. /**
  126219. * The friendly name of this plugin.
  126220. */
  126221. name: string;
  126222. /**
  126223. * The file extensions supported by this plugin.
  126224. */
  126225. extensions: string | ISceneLoaderPluginExtensions;
  126226. /**
  126227. * The callback called when loading from a url.
  126228. * @param scene scene loading this url
  126229. * @param url url to load
  126230. * @param onSuccess callback called when the file successfully loads
  126231. * @param onProgress callback called while file is loading (if the server supports this mode)
  126232. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126233. * @param onError callback called when the file fails to load
  126234. * @returns a file request object
  126235. */
  126236. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126237. /**
  126238. * The callback called when loading from a file object.
  126239. * @param scene scene loading this file
  126240. * @param file defines the file to load
  126241. * @param onSuccess defines the callback to call when data is loaded
  126242. * @param onProgress defines the callback to call during loading process
  126243. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126244. * @param onError defines the callback to call when an error occurs
  126245. * @returns a file request object
  126246. */
  126247. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126248. /**
  126249. * The callback that returns true if the data can be directly loaded.
  126250. * @param data string containing the file data
  126251. * @returns if the data can be loaded directly
  126252. */
  126253. canDirectLoad?(data: string): boolean;
  126254. /**
  126255. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126256. * @param scene scene loading this data
  126257. * @param data string containing the data
  126258. * @returns data to pass to the plugin
  126259. */
  126260. directLoad?(scene: Scene, data: string): any;
  126261. /**
  126262. * The callback that allows custom handling of the root url based on the response url.
  126263. * @param rootUrl the original root url
  126264. * @param responseURL the response url if available
  126265. * @returns the new root url
  126266. */
  126267. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126268. }
  126269. /**
  126270. * Interface used to define a SceneLoader plugin
  126271. */
  126272. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126273. /**
  126274. * Import meshes into a scene.
  126275. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126276. * @param scene The scene to import into
  126277. * @param data The data to import
  126278. * @param rootUrl The root url for scene and resources
  126279. * @param meshes The meshes array to import into
  126280. * @param particleSystems The particle systems array to import into
  126281. * @param skeletons The skeletons array to import into
  126282. * @param onError The callback when import fails
  126283. * @returns True if successful or false otherwise
  126284. */
  126285. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126286. /**
  126287. * Load into a scene.
  126288. * @param scene The scene to load into
  126289. * @param data The data to import
  126290. * @param rootUrl The root url for scene and resources
  126291. * @param onError The callback when import fails
  126292. * @returns True if successful or false otherwise
  126293. */
  126294. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126295. /**
  126296. * Load into an asset container.
  126297. * @param scene The scene to load into
  126298. * @param data The data to import
  126299. * @param rootUrl The root url for scene and resources
  126300. * @param onError The callback when import fails
  126301. * @returns The loaded asset container
  126302. */
  126303. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126304. }
  126305. /**
  126306. * Interface used to define an async SceneLoader plugin
  126307. */
  126308. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126309. /**
  126310. * Import meshes into a scene.
  126311. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126312. * @param scene The scene to import into
  126313. * @param data The data to import
  126314. * @param rootUrl The root url for scene and resources
  126315. * @param onProgress The callback when the load progresses
  126316. * @param fileName Defines the name of the file to load
  126317. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126318. */
  126319. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126320. meshes: AbstractMesh[];
  126321. particleSystems: IParticleSystem[];
  126322. skeletons: Skeleton[];
  126323. animationGroups: AnimationGroup[];
  126324. }>;
  126325. /**
  126326. * Load into a scene.
  126327. * @param scene The scene to load into
  126328. * @param data The data to import
  126329. * @param rootUrl The root url for scene and resources
  126330. * @param onProgress The callback when the load progresses
  126331. * @param fileName Defines the name of the file to load
  126332. * @returns Nothing
  126333. */
  126334. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126335. /**
  126336. * Load into an asset container.
  126337. * @param scene The scene to load into
  126338. * @param data The data to import
  126339. * @param rootUrl The root url for scene and resources
  126340. * @param onProgress The callback when the load progresses
  126341. * @param fileName Defines the name of the file to load
  126342. * @returns The loaded asset container
  126343. */
  126344. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126345. }
  126346. /**
  126347. * Mode that determines how to handle old animation groups before loading new ones.
  126348. */
  126349. export enum SceneLoaderAnimationGroupLoadingMode {
  126350. /**
  126351. * Reset all old animations to initial state then dispose them.
  126352. */
  126353. Clean = 0,
  126354. /**
  126355. * Stop all old animations.
  126356. */
  126357. Stop = 1,
  126358. /**
  126359. * Restart old animations from first frame.
  126360. */
  126361. Sync = 2,
  126362. /**
  126363. * Old animations remains untouched.
  126364. */
  126365. NoSync = 3
  126366. }
  126367. /**
  126368. * Defines a plugin registered by the SceneLoader
  126369. */
  126370. interface IRegisteredPlugin {
  126371. /**
  126372. * Defines the plugin to use
  126373. */
  126374. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126375. /**
  126376. * Defines if the plugin supports binary data
  126377. */
  126378. isBinary: boolean;
  126379. }
  126380. /**
  126381. * Class used to load scene from various file formats using registered plugins
  126382. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126383. */
  126384. export class SceneLoader {
  126385. /**
  126386. * No logging while loading
  126387. */
  126388. static readonly NO_LOGGING: number;
  126389. /**
  126390. * Minimal logging while loading
  126391. */
  126392. static readonly MINIMAL_LOGGING: number;
  126393. /**
  126394. * Summary logging while loading
  126395. */
  126396. static readonly SUMMARY_LOGGING: number;
  126397. /**
  126398. * Detailled logging while loading
  126399. */
  126400. static readonly DETAILED_LOGGING: number;
  126401. /**
  126402. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126403. */
  126404. static get ForceFullSceneLoadingForIncremental(): boolean;
  126405. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126406. /**
  126407. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126408. */
  126409. static get ShowLoadingScreen(): boolean;
  126410. static set ShowLoadingScreen(value: boolean);
  126411. /**
  126412. * Defines the current logging level (while loading the scene)
  126413. * @ignorenaming
  126414. */
  126415. static get loggingLevel(): number;
  126416. static set loggingLevel(value: number);
  126417. /**
  126418. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126419. */
  126420. static get CleanBoneMatrixWeights(): boolean;
  126421. static set CleanBoneMatrixWeights(value: boolean);
  126422. /**
  126423. * Event raised when a plugin is used to load a scene
  126424. */
  126425. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126426. private static _registeredPlugins;
  126427. private static _showingLoadingScreen;
  126428. /**
  126429. * Gets the default plugin (used to load Babylon files)
  126430. * @returns the .babylon plugin
  126431. */
  126432. static GetDefaultPlugin(): IRegisteredPlugin;
  126433. private static _GetPluginForExtension;
  126434. private static _GetPluginForDirectLoad;
  126435. private static _GetPluginForFilename;
  126436. private static _GetDirectLoad;
  126437. private static _LoadData;
  126438. private static _GetFileInfo;
  126439. /**
  126440. * Gets a plugin that can load the given extension
  126441. * @param extension defines the extension to load
  126442. * @returns a plugin or null if none works
  126443. */
  126444. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126445. /**
  126446. * Gets a boolean indicating that the given extension can be loaded
  126447. * @param extension defines the extension to load
  126448. * @returns true if the extension is supported
  126449. */
  126450. static IsPluginForExtensionAvailable(extension: string): boolean;
  126451. /**
  126452. * Adds a new plugin to the list of registered plugins
  126453. * @param plugin defines the plugin to add
  126454. */
  126455. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126456. /**
  126457. * Import meshes into a scene
  126458. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126459. * @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)
  126460. * @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)
  126461. * @param scene the instance of BABYLON.Scene to append to
  126462. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126463. * @param onProgress a callback with a progress event for each file being loaded
  126464. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126465. * @param pluginExtension the extension used to determine the plugin
  126466. * @returns The loaded plugin
  126467. */
  126468. 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>;
  126469. /**
  126470. * Import meshes into a scene
  126471. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126472. * @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)
  126473. * @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)
  126474. * @param scene the instance of BABYLON.Scene to append to
  126475. * @param onProgress a callback with a progress event for each file being loaded
  126476. * @param pluginExtension the extension used to determine the plugin
  126477. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126478. */
  126479. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126480. meshes: AbstractMesh[];
  126481. particleSystems: IParticleSystem[];
  126482. skeletons: Skeleton[];
  126483. animationGroups: AnimationGroup[];
  126484. }>;
  126485. /**
  126486. * Load a scene
  126487. * @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)
  126488. * @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)
  126489. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126490. * @param onSuccess a callback with the scene when import succeeds
  126491. * @param onProgress a callback with a progress event for each file being loaded
  126492. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126493. * @param pluginExtension the extension used to determine the plugin
  126494. * @returns The loaded plugin
  126495. */
  126496. 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>;
  126497. /**
  126498. * Load a scene
  126499. * @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)
  126500. * @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)
  126501. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126502. * @param onProgress a callback with a progress event for each file being loaded
  126503. * @param pluginExtension the extension used to determine the plugin
  126504. * @returns The loaded scene
  126505. */
  126506. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126507. /**
  126508. * Append a scene
  126509. * @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)
  126510. * @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)
  126511. * @param scene is the instance of BABYLON.Scene to append to
  126512. * @param onSuccess a callback with the scene when import succeeds
  126513. * @param onProgress a callback with a progress event for each file being loaded
  126514. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126515. * @param pluginExtension the extension used to determine the plugin
  126516. * @returns The loaded plugin
  126517. */
  126518. 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>;
  126519. /**
  126520. * Append a scene
  126521. * @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)
  126522. * @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)
  126523. * @param scene is the instance of BABYLON.Scene to append to
  126524. * @param onProgress a callback with a progress event for each file being loaded
  126525. * @param pluginExtension the extension used to determine the plugin
  126526. * @returns The given scene
  126527. */
  126528. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126529. /**
  126530. * Load a scene into an asset container
  126531. * @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)
  126532. * @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)
  126533. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126534. * @param onSuccess a callback with the scene when import succeeds
  126535. * @param onProgress a callback with a progress event for each file being loaded
  126536. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126537. * @param pluginExtension the extension used to determine the plugin
  126538. * @returns The loaded plugin
  126539. */
  126540. 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>;
  126541. /**
  126542. * Load a scene into an asset container
  126543. * @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)
  126544. * @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)
  126545. * @param scene is the instance of Scene to append to
  126546. * @param onProgress a callback with a progress event for each file being loaded
  126547. * @param pluginExtension the extension used to determine the plugin
  126548. * @returns The loaded asset container
  126549. */
  126550. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126551. /**
  126552. * Import animations from a file into a scene
  126553. * @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)
  126554. * @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)
  126555. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126556. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126557. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126558. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126559. * @param onSuccess a callback with the scene when import succeeds
  126560. * @param onProgress a callback with a progress event for each file being loaded
  126561. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126562. * @param pluginExtension the extension used to determine the plugin
  126563. */
  126564. 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;
  126565. /**
  126566. * Import animations from a file into a scene
  126567. * @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)
  126568. * @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)
  126569. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126570. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126571. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126572. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126573. * @param onSuccess a callback with the scene when import succeeds
  126574. * @param onProgress a callback with a progress event for each file being loaded
  126575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126576. * @param pluginExtension the extension used to determine the plugin
  126577. * @returns the updated scene with imported animations
  126578. */
  126579. 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>;
  126580. }
  126581. }
  126582. declare module BABYLON {
  126583. /**
  126584. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126585. */
  126586. export type MotionControllerHandedness = "none" | "left" | "right";
  126587. /**
  126588. * The type of components available in motion controllers.
  126589. * This is not the name of the component.
  126590. */
  126591. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126592. /**
  126593. * The state of a controller component
  126594. */
  126595. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126596. /**
  126597. * The schema of motion controller layout.
  126598. * No object will be initialized using this interface
  126599. * This is used just to define the profile.
  126600. */
  126601. export interface IMotionControllerLayout {
  126602. /**
  126603. * Path to load the assets. Usually relative to the base path
  126604. */
  126605. assetPath: string;
  126606. /**
  126607. * Available components (unsorted)
  126608. */
  126609. components: {
  126610. /**
  126611. * A map of component Ids
  126612. */
  126613. [componentId: string]: {
  126614. /**
  126615. * The type of input the component outputs
  126616. */
  126617. type: MotionControllerComponentType;
  126618. /**
  126619. * The indices of this component in the gamepad object
  126620. */
  126621. gamepadIndices: {
  126622. /**
  126623. * Index of button
  126624. */
  126625. button?: number;
  126626. /**
  126627. * If available, index of x-axis
  126628. */
  126629. xAxis?: number;
  126630. /**
  126631. * If available, index of y-axis
  126632. */
  126633. yAxis?: number;
  126634. };
  126635. /**
  126636. * The mesh's root node name
  126637. */
  126638. rootNodeName: string;
  126639. /**
  126640. * Animation definitions for this model
  126641. */
  126642. visualResponses: {
  126643. [stateKey: string]: {
  126644. /**
  126645. * What property will be animated
  126646. */
  126647. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126648. /**
  126649. * What states influence this visual response
  126650. */
  126651. states: MotionControllerComponentStateType[];
  126652. /**
  126653. * Type of animation - movement or visibility
  126654. */
  126655. valueNodeProperty: "transform" | "visibility";
  126656. /**
  126657. * Base node name to move. Its position will be calculated according to the min and max nodes
  126658. */
  126659. valueNodeName?: string;
  126660. /**
  126661. * Minimum movement node
  126662. */
  126663. minNodeName?: string;
  126664. /**
  126665. * Max movement node
  126666. */
  126667. maxNodeName?: string;
  126668. };
  126669. };
  126670. /**
  126671. * If touch enabled, what is the name of node to display user feedback
  126672. */
  126673. touchPointNodeName?: string;
  126674. };
  126675. };
  126676. /**
  126677. * Is it xr standard mapping or not
  126678. */
  126679. gamepadMapping: "" | "xr-standard";
  126680. /**
  126681. * Base root node of this entire model
  126682. */
  126683. rootNodeName: string;
  126684. /**
  126685. * Defines the main button component id
  126686. */
  126687. selectComponentId: string;
  126688. }
  126689. /**
  126690. * A definition for the layout map in the input profile
  126691. */
  126692. export interface IMotionControllerLayoutMap {
  126693. /**
  126694. * Layouts with handedness type as a key
  126695. */
  126696. [handedness: string]: IMotionControllerLayout;
  126697. }
  126698. /**
  126699. * The XR Input profile schema
  126700. * Profiles can be found here:
  126701. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126702. */
  126703. export interface IMotionControllerProfile {
  126704. /**
  126705. * fallback profiles for this profileId
  126706. */
  126707. fallbackProfileIds: string[];
  126708. /**
  126709. * The layout map, with handedness as key
  126710. */
  126711. layouts: IMotionControllerLayoutMap;
  126712. /**
  126713. * The id of this profile
  126714. * correlates to the profile(s) in the xrInput.profiles array
  126715. */
  126716. profileId: string;
  126717. }
  126718. /**
  126719. * A helper-interface for the 3 meshes needed for controller button animation
  126720. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126721. */
  126722. export interface IMotionControllerButtonMeshMap {
  126723. /**
  126724. * the mesh that defines the pressed value mesh position.
  126725. * This is used to find the max-position of this button
  126726. */
  126727. pressedMesh: AbstractMesh;
  126728. /**
  126729. * the mesh that defines the unpressed value mesh position.
  126730. * This is used to find the min (or initial) position of this button
  126731. */
  126732. unpressedMesh: AbstractMesh;
  126733. /**
  126734. * The mesh that will be changed when value changes
  126735. */
  126736. valueMesh: AbstractMesh;
  126737. }
  126738. /**
  126739. * A helper-interface for the 3 meshes needed for controller axis animation.
  126740. * This will be expanded when touchpad animations are fully supported
  126741. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126742. */
  126743. export interface IMotionControllerMeshMap {
  126744. /**
  126745. * the mesh that defines the maximum value mesh position.
  126746. */
  126747. maxMesh?: AbstractMesh;
  126748. /**
  126749. * the mesh that defines the minimum value mesh position.
  126750. */
  126751. minMesh?: AbstractMesh;
  126752. /**
  126753. * The mesh that will be changed when axis value changes
  126754. */
  126755. valueMesh: AbstractMesh;
  126756. }
  126757. /**
  126758. * The elements needed for change-detection of the gamepad objects in motion controllers
  126759. */
  126760. export interface IMinimalMotionControllerObject {
  126761. /**
  126762. * Available axes of this controller
  126763. */
  126764. axes: number[];
  126765. /**
  126766. * An array of available buttons
  126767. */
  126768. buttons: Array<{
  126769. /**
  126770. * Value of the button/trigger
  126771. */
  126772. value: number;
  126773. /**
  126774. * If the button/trigger is currently touched
  126775. */
  126776. touched: boolean;
  126777. /**
  126778. * If the button/trigger is currently pressed
  126779. */
  126780. pressed: boolean;
  126781. }>;
  126782. /**
  126783. * EXPERIMENTAL haptic support.
  126784. */
  126785. hapticActuators?: Array<{
  126786. pulse: (value: number, duration: number) => Promise<boolean>;
  126787. }>;
  126788. }
  126789. /**
  126790. * An Abstract Motion controller
  126791. * This class receives an xrInput and a profile layout and uses those to initialize the components
  126792. * Each component has an observable to check for changes in value and state
  126793. */
  126794. export abstract class WebXRAbstractMotionController implements IDisposable {
  126795. protected scene: Scene;
  126796. protected layout: IMotionControllerLayout;
  126797. /**
  126798. * The gamepad object correlating to this controller
  126799. */
  126800. gamepadObject: IMinimalMotionControllerObject;
  126801. /**
  126802. * handedness (left/right/none) of this controller
  126803. */
  126804. handedness: MotionControllerHandedness;
  126805. private _initComponent;
  126806. private _modelReady;
  126807. /**
  126808. * A map of components (WebXRControllerComponent) in this motion controller
  126809. * Components have a ComponentType and can also have both button and axis definitions
  126810. */
  126811. readonly components: {
  126812. [id: string]: WebXRControllerComponent;
  126813. };
  126814. /**
  126815. * Disable the model's animation. Can be set at any time.
  126816. */
  126817. disableAnimation: boolean;
  126818. /**
  126819. * Observers registered here will be triggered when the model of this controller is done loading
  126820. */
  126821. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  126822. /**
  126823. * The profile id of this motion controller
  126824. */
  126825. abstract profileId: string;
  126826. /**
  126827. * The root mesh of the model. It is null if the model was not yet initialized
  126828. */
  126829. rootMesh: Nullable<AbstractMesh>;
  126830. /**
  126831. * constructs a new abstract motion controller
  126832. * @param scene the scene to which the model of the controller will be added
  126833. * @param layout The profile layout to load
  126834. * @param gamepadObject The gamepad object correlating to this controller
  126835. * @param handedness handedness (left/right/none) of this controller
  126836. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  126837. */
  126838. constructor(scene: Scene, layout: IMotionControllerLayout,
  126839. /**
  126840. * The gamepad object correlating to this controller
  126841. */
  126842. gamepadObject: IMinimalMotionControllerObject,
  126843. /**
  126844. * handedness (left/right/none) of this controller
  126845. */
  126846. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  126847. /**
  126848. * Dispose this controller, the model mesh and all its components
  126849. */
  126850. dispose(): void;
  126851. /**
  126852. * Returns all components of specific type
  126853. * @param type the type to search for
  126854. * @return an array of components with this type
  126855. */
  126856. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  126857. /**
  126858. * get a component based an its component id as defined in layout.components
  126859. * @param id the id of the component
  126860. * @returns the component correlates to the id or undefined if not found
  126861. */
  126862. getComponent(id: string): WebXRControllerComponent;
  126863. /**
  126864. * Get the list of components available in this motion controller
  126865. * @returns an array of strings correlating to available components
  126866. */
  126867. getComponentIds(): string[];
  126868. /**
  126869. * Get the first component of specific type
  126870. * @param type type of component to find
  126871. * @return a controller component or null if not found
  126872. */
  126873. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  126874. /**
  126875. * Get the main (Select) component of this controller as defined in the layout
  126876. * @returns the main component of this controller
  126877. */
  126878. getMainComponent(): WebXRControllerComponent;
  126879. /**
  126880. * Loads the model correlating to this controller
  126881. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  126882. * @returns A promise fulfilled with the result of the model loading
  126883. */
  126884. loadModel(): Promise<boolean>;
  126885. /**
  126886. * Update this model using the current XRFrame
  126887. * @param xrFrame the current xr frame to use and update the model
  126888. */
  126889. updateFromXRFrame(xrFrame: XRFrame): void;
  126890. /**
  126891. * Backwards compatibility due to a deeply-integrated typo
  126892. */
  126893. get handness(): XREye;
  126894. /**
  126895. * Pulse (vibrate) this controller
  126896. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  126897. * Consecutive calls to this function will cancel the last pulse call
  126898. *
  126899. * @param value the strength of the pulse in 0.0...1.0 range
  126900. * @param duration Duration of the pulse in milliseconds
  126901. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  126902. * @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
  126903. */
  126904. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  126905. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126906. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  126907. /**
  126908. * Moves the axis on the controller mesh based on its current state
  126909. * @param axis the index of the axis
  126910. * @param axisValue the value of the axis which determines the meshes new position
  126911. * @hidden
  126912. */
  126913. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  126914. /**
  126915. * Update the model itself with the current frame data
  126916. * @param xrFrame the frame to use for updating the model mesh
  126917. */
  126918. protected updateModel(xrFrame: XRFrame): void;
  126919. /**
  126920. * Get the filename and path for this controller's model
  126921. * @returns a map of filename and path
  126922. */
  126923. protected abstract _getFilenameAndPath(): {
  126924. filename: string;
  126925. path: string;
  126926. };
  126927. /**
  126928. * This function is called before the mesh is loaded. It checks for loading constraints.
  126929. * For example, this function can check if the GLB loader is available
  126930. * If this function returns false, the generic controller will be loaded instead
  126931. * @returns Is the client ready to load the mesh
  126932. */
  126933. protected abstract _getModelLoadingConstraints(): boolean;
  126934. /**
  126935. * This function will be called after the model was successfully loaded and can be used
  126936. * for mesh transformations before it is available for the user
  126937. * @param meshes the loaded meshes
  126938. */
  126939. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  126940. /**
  126941. * Set the root mesh for this controller. Important for the WebXR controller class
  126942. * @param meshes the loaded meshes
  126943. */
  126944. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  126945. /**
  126946. * A function executed each frame that updates the mesh (if needed)
  126947. * @param xrFrame the current xrFrame
  126948. */
  126949. protected abstract _updateModel(xrFrame: XRFrame): void;
  126950. private _getGenericFilenameAndPath;
  126951. private _getGenericParentMesh;
  126952. }
  126953. }
  126954. declare module BABYLON {
  126955. /**
  126956. * A generic trigger-only motion controller for WebXR
  126957. */
  126958. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  126959. /**
  126960. * Static version of the profile id of this controller
  126961. */
  126962. static ProfileId: string;
  126963. profileId: string;
  126964. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  126965. protected _getFilenameAndPath(): {
  126966. filename: string;
  126967. path: string;
  126968. };
  126969. protected _getModelLoadingConstraints(): boolean;
  126970. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  126971. protected _setRootMesh(meshes: AbstractMesh[]): void;
  126972. protected _updateModel(): void;
  126973. }
  126974. }
  126975. declare module BABYLON {
  126976. /**
  126977. * Class containing static functions to help procedurally build meshes
  126978. */
  126979. export class SphereBuilder {
  126980. /**
  126981. * Creates a sphere mesh
  126982. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126983. * * 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`)
  126984. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126985. * * 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
  126986. * * 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)
  126987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126990. * @param name defines the name of the mesh
  126991. * @param options defines the options used to create the mesh
  126992. * @param scene defines the hosting scene
  126993. * @returns the sphere mesh
  126994. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126995. */
  126996. static CreateSphere(name: string, options: {
  126997. segments?: number;
  126998. diameter?: number;
  126999. diameterX?: number;
  127000. diameterY?: number;
  127001. diameterZ?: number;
  127002. arc?: number;
  127003. slice?: number;
  127004. sideOrientation?: number;
  127005. frontUVs?: Vector4;
  127006. backUVs?: Vector4;
  127007. updatable?: boolean;
  127008. }, scene?: Nullable<Scene>): Mesh;
  127009. }
  127010. }
  127011. declare module BABYLON {
  127012. /**
  127013. * A profiled motion controller has its profile loaded from an online repository.
  127014. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127015. */
  127016. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127017. private _repositoryUrl;
  127018. private _buttonMeshMapping;
  127019. private _touchDots;
  127020. /**
  127021. * The profile ID of this controller. Will be populated when the controller initializes.
  127022. */
  127023. profileId: string;
  127024. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127025. dispose(): void;
  127026. protected _getFilenameAndPath(): {
  127027. filename: string;
  127028. path: string;
  127029. };
  127030. protected _getModelLoadingConstraints(): boolean;
  127031. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127032. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127033. protected _updateModel(_xrFrame: XRFrame): void;
  127034. }
  127035. }
  127036. declare module BABYLON {
  127037. /**
  127038. * A construction function type to create a new controller based on an xrInput object
  127039. */
  127040. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127041. /**
  127042. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127043. *
  127044. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127045. * it should be replaced with auto-loaded controllers.
  127046. *
  127047. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127048. */
  127049. export class WebXRMotionControllerManager {
  127050. private static _AvailableControllers;
  127051. private static _Fallbacks;
  127052. private static _ProfileLoadingPromises;
  127053. private static _ProfilesList;
  127054. /**
  127055. * The base URL of the online controller repository. Can be changed at any time.
  127056. */
  127057. static BaseRepositoryUrl: string;
  127058. /**
  127059. * Which repository gets priority - local or online
  127060. */
  127061. static PrioritizeOnlineRepository: boolean;
  127062. /**
  127063. * Use the online repository, or use only locally-defined controllers
  127064. */
  127065. static UseOnlineRepository: boolean;
  127066. /**
  127067. * Clear the cache used for profile loading and reload when requested again
  127068. */
  127069. static ClearProfilesCache(): void;
  127070. /**
  127071. * Register the default fallbacks.
  127072. * This function is called automatically when this file is imported.
  127073. */
  127074. static DefaultFallbacks(): void;
  127075. /**
  127076. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127077. * @param profileId the profile to which a fallback needs to be found
  127078. * @return an array with corresponding fallback profiles
  127079. */
  127080. static FindFallbackWithProfileId(profileId: string): string[];
  127081. /**
  127082. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127083. * The order of search:
  127084. *
  127085. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127086. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127087. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127088. * 4) return the generic trigger controller if none were found
  127089. *
  127090. * @param xrInput the xrInput to which a new controller is initialized
  127091. * @param scene the scene to which the model will be added
  127092. * @param forceProfile force a certain profile for this controller
  127093. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127094. */
  127095. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127096. /**
  127097. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127098. *
  127099. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127100. *
  127101. * @param type the profile type to register
  127102. * @param constructFunction the function to be called when loading this profile
  127103. */
  127104. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127105. /**
  127106. * Register a fallback to a specific profile.
  127107. * @param profileId the profileId that will receive the fallbacks
  127108. * @param fallbacks A list of fallback profiles
  127109. */
  127110. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127111. /**
  127112. * Will update the list of profiles available in the repository
  127113. * @return a promise that resolves to a map of profiles available online
  127114. */
  127115. static UpdateProfilesList(): Promise<{
  127116. [profile: string]: string;
  127117. }>;
  127118. private static _LoadProfileFromRepository;
  127119. private static _LoadProfilesFromAvailableControllers;
  127120. }
  127121. }
  127122. declare module BABYLON {
  127123. /**
  127124. * Configuration options for the WebXR controller creation
  127125. */
  127126. export interface IWebXRControllerOptions {
  127127. /**
  127128. * Should the controller mesh be animated when a user interacts with it
  127129. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127130. */
  127131. disableMotionControllerAnimation?: boolean;
  127132. /**
  127133. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127134. */
  127135. doNotLoadControllerMesh?: boolean;
  127136. /**
  127137. * Force a specific controller type for this controller.
  127138. * This can be used when creating your own profile or when testing different controllers
  127139. */
  127140. forceControllerProfile?: string;
  127141. /**
  127142. * Defines a rendering group ID for meshes that will be loaded.
  127143. * This is for the default controllers only.
  127144. */
  127145. renderingGroupId?: number;
  127146. }
  127147. /**
  127148. * Represents an XR controller
  127149. */
  127150. export class WebXRInputSource {
  127151. private _scene;
  127152. /** The underlying input source for the controller */
  127153. inputSource: XRInputSource;
  127154. private _options;
  127155. private _tmpVector;
  127156. private _uniqueId;
  127157. /**
  127158. * 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
  127159. */
  127160. grip?: AbstractMesh;
  127161. /**
  127162. * If available, this is the gamepad object related to this controller.
  127163. * Using this object it is possible to get click events and trackpad changes of the
  127164. * webxr controller that is currently being used.
  127165. */
  127166. motionController?: WebXRAbstractMotionController;
  127167. /**
  127168. * Event that fires when the controller is removed/disposed.
  127169. * The object provided as event data is this controller, after associated assets were disposed.
  127170. * uniqueId is still available.
  127171. */
  127172. onDisposeObservable: Observable<WebXRInputSource>;
  127173. /**
  127174. * Will be triggered when the mesh associated with the motion controller is done loading.
  127175. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127176. * A shortened version of controller -> motion controller -> on mesh loaded.
  127177. */
  127178. onMeshLoadedObservable: Observable<AbstractMesh>;
  127179. /**
  127180. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127181. */
  127182. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127183. /**
  127184. * Pointer which can be used to select objects or attach a visible laser to
  127185. */
  127186. pointer: AbstractMesh;
  127187. /**
  127188. * Creates the input source object
  127189. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127190. * @param _scene the scene which the controller should be associated to
  127191. * @param inputSource the underlying input source for the controller
  127192. * @param _options options for this controller creation
  127193. */
  127194. constructor(_scene: Scene,
  127195. /** The underlying input source for the controller */
  127196. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127197. /**
  127198. * Get this controllers unique id
  127199. */
  127200. get uniqueId(): string;
  127201. /**
  127202. * Disposes of the object
  127203. */
  127204. dispose(): void;
  127205. /**
  127206. * Gets a world space ray coming from the pointer or grip
  127207. * @param result the resulting ray
  127208. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127209. */
  127210. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127211. /**
  127212. * Updates the controller pose based on the given XRFrame
  127213. * @param xrFrame xr frame to update the pose with
  127214. * @param referenceSpace reference space to use
  127215. */
  127216. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127217. }
  127218. }
  127219. declare module BABYLON {
  127220. /**
  127221. * The schema for initialization options of the XR Input class
  127222. */
  127223. export interface IWebXRInputOptions {
  127224. /**
  127225. * If set to true no model will be automatically loaded
  127226. */
  127227. doNotLoadControllerMeshes?: boolean;
  127228. /**
  127229. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127230. * If not found, the xr input profile data will be used.
  127231. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127232. */
  127233. forceInputProfile?: string;
  127234. /**
  127235. * Do not send a request to the controller repository to load the profile.
  127236. *
  127237. * Instead, use the controllers available in babylon itself.
  127238. */
  127239. disableOnlineControllerRepository?: boolean;
  127240. /**
  127241. * A custom URL for the controllers repository
  127242. */
  127243. customControllersRepositoryURL?: string;
  127244. /**
  127245. * Should the controller model's components not move according to the user input
  127246. */
  127247. disableControllerAnimation?: boolean;
  127248. /**
  127249. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127250. */
  127251. controllerOptions?: IWebXRControllerOptions;
  127252. }
  127253. /**
  127254. * XR input used to track XR inputs such as controllers/rays
  127255. */
  127256. export class WebXRInput implements IDisposable {
  127257. /**
  127258. * the xr session manager for this session
  127259. */
  127260. xrSessionManager: WebXRSessionManager;
  127261. /**
  127262. * the WebXR camera for this session. Mainly used for teleportation
  127263. */
  127264. xrCamera: WebXRCamera;
  127265. private readonly options;
  127266. /**
  127267. * XR controllers being tracked
  127268. */
  127269. controllers: Array<WebXRInputSource>;
  127270. private _frameObserver;
  127271. private _sessionEndedObserver;
  127272. private _sessionInitObserver;
  127273. /**
  127274. * Event when a controller has been connected/added
  127275. */
  127276. onControllerAddedObservable: Observable<WebXRInputSource>;
  127277. /**
  127278. * Event when a controller has been removed/disconnected
  127279. */
  127280. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127281. /**
  127282. * Initializes the WebXRInput
  127283. * @param xrSessionManager the xr session manager for this session
  127284. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127285. * @param options = initialization options for this xr input
  127286. */
  127287. constructor(
  127288. /**
  127289. * the xr session manager for this session
  127290. */
  127291. xrSessionManager: WebXRSessionManager,
  127292. /**
  127293. * the WebXR camera for this session. Mainly used for teleportation
  127294. */
  127295. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127296. private _onInputSourcesChange;
  127297. private _addAndRemoveControllers;
  127298. /**
  127299. * Disposes of the object
  127300. */
  127301. dispose(): void;
  127302. }
  127303. }
  127304. declare module BABYLON {
  127305. /**
  127306. * This is the base class for all WebXR features.
  127307. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127308. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127309. */
  127310. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127311. protected _xrSessionManager: WebXRSessionManager;
  127312. private _attached;
  127313. private _removeOnDetach;
  127314. /**
  127315. * Should auto-attach be disabled?
  127316. */
  127317. disableAutoAttach: boolean;
  127318. /**
  127319. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127320. */
  127321. xrNativeFeatureName: string;
  127322. /**
  127323. * Construct a new (abstract) WebXR feature
  127324. * @param _xrSessionManager the xr session manager for this feature
  127325. */
  127326. constructor(_xrSessionManager: WebXRSessionManager);
  127327. /**
  127328. * Is this feature attached
  127329. */
  127330. get attached(): boolean;
  127331. /**
  127332. * attach this feature
  127333. *
  127334. * @param force should attachment be forced (even when already attached)
  127335. * @returns true if successful, false is failed or already attached
  127336. */
  127337. attach(force?: boolean): boolean;
  127338. /**
  127339. * detach this feature.
  127340. *
  127341. * @returns true if successful, false if failed or already detached
  127342. */
  127343. detach(): boolean;
  127344. /**
  127345. * Dispose this feature and all of the resources attached
  127346. */
  127347. dispose(): void;
  127348. /**
  127349. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127350. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127351. *
  127352. * @returns whether or not the feature is compatible in this environment
  127353. */
  127354. isCompatible(): boolean;
  127355. /**
  127356. * This is used to register callbacks that will automatically be removed when detach is called.
  127357. * @param observable the observable to which the observer will be attached
  127358. * @param callback the callback to register
  127359. */
  127360. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127361. /**
  127362. * Code in this function will be executed on each xrFrame received from the browser.
  127363. * This function will not execute after the feature is detached.
  127364. * @param _xrFrame the current frame
  127365. */
  127366. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127367. }
  127368. }
  127369. declare module BABYLON {
  127370. /**
  127371. * Renders a layer on top of an existing scene
  127372. */
  127373. export class UtilityLayerRenderer implements IDisposable {
  127374. /** the original scene that will be rendered on top of */
  127375. originalScene: Scene;
  127376. private _pointerCaptures;
  127377. private _lastPointerEvents;
  127378. private static _DefaultUtilityLayer;
  127379. private static _DefaultKeepDepthUtilityLayer;
  127380. private _sharedGizmoLight;
  127381. private _renderCamera;
  127382. /**
  127383. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127384. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127385. * @returns the camera that is used when rendering the utility layer
  127386. */
  127387. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127388. /**
  127389. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127390. * @param cam the camera that should be used when rendering the utility layer
  127391. */
  127392. setRenderCamera(cam: Nullable<Camera>): void;
  127393. /**
  127394. * @hidden
  127395. * Light which used by gizmos to get light shading
  127396. */
  127397. _getSharedGizmoLight(): HemisphericLight;
  127398. /**
  127399. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127400. */
  127401. pickUtilitySceneFirst: boolean;
  127402. /**
  127403. * 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)
  127404. */
  127405. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127406. /**
  127407. * 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)
  127408. */
  127409. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127410. /**
  127411. * The scene that is rendered on top of the original scene
  127412. */
  127413. utilityLayerScene: Scene;
  127414. /**
  127415. * If the utility layer should automatically be rendered on top of existing scene
  127416. */
  127417. shouldRender: boolean;
  127418. /**
  127419. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127420. */
  127421. onlyCheckPointerDownEvents: boolean;
  127422. /**
  127423. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127424. */
  127425. processAllEvents: boolean;
  127426. /**
  127427. * Observable raised when the pointer move from the utility layer scene to the main scene
  127428. */
  127429. onPointerOutObservable: Observable<number>;
  127430. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127431. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127432. private _afterRenderObserver;
  127433. private _sceneDisposeObserver;
  127434. private _originalPointerObserver;
  127435. /**
  127436. * Instantiates a UtilityLayerRenderer
  127437. * @param originalScene the original scene that will be rendered on top of
  127438. * @param handleEvents boolean indicating if the utility layer should handle events
  127439. */
  127440. constructor(
  127441. /** the original scene that will be rendered on top of */
  127442. originalScene: Scene, handleEvents?: boolean);
  127443. private _notifyObservers;
  127444. /**
  127445. * Renders the utility layers scene on top of the original scene
  127446. */
  127447. render(): void;
  127448. /**
  127449. * Disposes of the renderer
  127450. */
  127451. dispose(): void;
  127452. private _updateCamera;
  127453. }
  127454. }
  127455. declare module BABYLON {
  127456. /**
  127457. * Options interface for the pointer selection module
  127458. */
  127459. export interface IWebXRControllerPointerSelectionOptions {
  127460. /**
  127461. * if provided, this scene will be used to render meshes.
  127462. */
  127463. customUtilityLayerScene?: Scene;
  127464. /**
  127465. * 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)
  127466. * If not disabled, the last picked point will be used to execute a pointer up event
  127467. * If disabled, pointer up event will be triggered right after the pointer down event.
  127468. * Used in screen and gaze target ray mode only
  127469. */
  127470. disablePointerUpOnTouchOut: boolean;
  127471. /**
  127472. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127473. */
  127474. forceGazeMode: boolean;
  127475. /**
  127476. * 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
  127477. * to start a new countdown to the pointer down event.
  127478. * Defaults to 1.
  127479. */
  127480. gazeModePointerMovedFactor?: number;
  127481. /**
  127482. * Different button type to use instead of the main component
  127483. */
  127484. overrideButtonId?: string;
  127485. /**
  127486. * use this rendering group id for the meshes (optional)
  127487. */
  127488. renderingGroupId?: number;
  127489. /**
  127490. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127491. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127492. * 3000 means 3 seconds between pointing at something and selecting it
  127493. */
  127494. timeToSelect?: number;
  127495. /**
  127496. * Should meshes created here be added to a utility layer or the main scene
  127497. */
  127498. useUtilityLayer?: boolean;
  127499. /**
  127500. * Optional WebXR camera to be used for gaze selection
  127501. */
  127502. gazeCamera?: WebXRCamera;
  127503. /**
  127504. * the xr input to use with this pointer selection
  127505. */
  127506. xrInput: WebXRInput;
  127507. }
  127508. /**
  127509. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127510. */
  127511. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127512. private readonly _options;
  127513. private static _idCounter;
  127514. private _attachController;
  127515. private _controllers;
  127516. private _scene;
  127517. private _tmpVectorForPickCompare;
  127518. /**
  127519. * The module's name
  127520. */
  127521. static readonly Name: string;
  127522. /**
  127523. * The (Babylon) version of this module.
  127524. * This is an integer representing the implementation version.
  127525. * This number does not correspond to the WebXR specs version
  127526. */
  127527. static readonly Version: number;
  127528. /**
  127529. * Disable lighting on the laser pointer (so it will always be visible)
  127530. */
  127531. disablePointerLighting: boolean;
  127532. /**
  127533. * Disable lighting on the selection mesh (so it will always be visible)
  127534. */
  127535. disableSelectionMeshLighting: boolean;
  127536. /**
  127537. * Should the laser pointer be displayed
  127538. */
  127539. displayLaserPointer: boolean;
  127540. /**
  127541. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127542. */
  127543. displaySelectionMesh: boolean;
  127544. /**
  127545. * This color will be set to the laser pointer when selection is triggered
  127546. */
  127547. laserPointerPickedColor: Color3;
  127548. /**
  127549. * Default color of the laser pointer
  127550. */
  127551. laserPointerDefaultColor: Color3;
  127552. /**
  127553. * default color of the selection ring
  127554. */
  127555. selectionMeshDefaultColor: Color3;
  127556. /**
  127557. * This color will be applied to the selection ring when selection is triggered
  127558. */
  127559. selectionMeshPickedColor: Color3;
  127560. /**
  127561. * Optional filter to be used for ray selection. This predicate shares behavior with
  127562. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127563. */
  127564. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127565. /**
  127566. * constructs a new background remover module
  127567. * @param _xrSessionManager the session manager for this module
  127568. * @param _options read-only options to be used in this module
  127569. */
  127570. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127571. /**
  127572. * attach this feature
  127573. * Will usually be called by the features manager
  127574. *
  127575. * @returns true if successful.
  127576. */
  127577. attach(): boolean;
  127578. /**
  127579. * detach this feature.
  127580. * Will usually be called by the features manager
  127581. *
  127582. * @returns true if successful.
  127583. */
  127584. detach(): boolean;
  127585. /**
  127586. * Will get the mesh under a specific pointer.
  127587. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127588. * @param controllerId the controllerId to check
  127589. * @returns The mesh under pointer or null if no mesh is under the pointer
  127590. */
  127591. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127592. /**
  127593. * Get the xr controller that correlates to the pointer id in the pointer event
  127594. *
  127595. * @param id the pointer id to search for
  127596. * @returns the controller that correlates to this id or null if not found
  127597. */
  127598. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127599. protected _onXRFrame(_xrFrame: XRFrame): void;
  127600. private _attachGazeMode;
  127601. private _attachScreenRayMode;
  127602. private _attachTrackedPointerRayMode;
  127603. private _convertNormalToDirectionOfRay;
  127604. private _detachController;
  127605. private _generateNewMeshPair;
  127606. private _pickingMoved;
  127607. private _updatePointerDistance;
  127608. /** @hidden */
  127609. get lasterPointerDefaultColor(): Color3;
  127610. }
  127611. }
  127612. declare module BABYLON {
  127613. /**
  127614. * Button which can be used to enter a different mode of XR
  127615. */
  127616. export class WebXREnterExitUIButton {
  127617. /** button element */
  127618. element: HTMLElement;
  127619. /** XR initialization options for the button */
  127620. sessionMode: XRSessionMode;
  127621. /** Reference space type */
  127622. referenceSpaceType: XRReferenceSpaceType;
  127623. /**
  127624. * Creates a WebXREnterExitUIButton
  127625. * @param element button element
  127626. * @param sessionMode XR initialization session mode
  127627. * @param referenceSpaceType the type of reference space to be used
  127628. */
  127629. constructor(
  127630. /** button element */
  127631. element: HTMLElement,
  127632. /** XR initialization options for the button */
  127633. sessionMode: XRSessionMode,
  127634. /** Reference space type */
  127635. referenceSpaceType: XRReferenceSpaceType);
  127636. /**
  127637. * Extendable function which can be used to update the button's visuals when the state changes
  127638. * @param activeButton the current active button in the UI
  127639. */
  127640. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127641. }
  127642. /**
  127643. * Options to create the webXR UI
  127644. */
  127645. export class WebXREnterExitUIOptions {
  127646. /**
  127647. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127648. */
  127649. customButtons?: Array<WebXREnterExitUIButton>;
  127650. /**
  127651. * A reference space type to use when creating the default button.
  127652. * Default is local-floor
  127653. */
  127654. referenceSpaceType?: XRReferenceSpaceType;
  127655. /**
  127656. * Context to enter xr with
  127657. */
  127658. renderTarget?: Nullable<WebXRRenderTarget>;
  127659. /**
  127660. * A session mode to use when creating the default button.
  127661. * Default is immersive-vr
  127662. */
  127663. sessionMode?: XRSessionMode;
  127664. /**
  127665. * A list of optional features to init the session with
  127666. */
  127667. optionalFeatures?: string[];
  127668. /**
  127669. * A list of optional features to init the session with
  127670. */
  127671. requiredFeatures?: string[];
  127672. }
  127673. /**
  127674. * UI to allow the user to enter/exit XR mode
  127675. */
  127676. export class WebXREnterExitUI implements IDisposable {
  127677. private scene;
  127678. /** version of the options passed to this UI */
  127679. options: WebXREnterExitUIOptions;
  127680. private _activeButton;
  127681. private _buttons;
  127682. private _overlay;
  127683. /**
  127684. * Fired every time the active button is changed.
  127685. *
  127686. * When xr is entered via a button that launches xr that button will be the callback parameter
  127687. *
  127688. * When exiting xr the callback parameter will be null)
  127689. */
  127690. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127691. /**
  127692. *
  127693. * @param scene babylon scene object to use
  127694. * @param options (read-only) version of the options passed to this UI
  127695. */
  127696. private constructor();
  127697. /**
  127698. * Creates UI to allow the user to enter/exit XR mode
  127699. * @param scene the scene to add the ui to
  127700. * @param helper the xr experience helper to enter/exit xr with
  127701. * @param options options to configure the UI
  127702. * @returns the created ui
  127703. */
  127704. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127705. /**
  127706. * Disposes of the XR UI component
  127707. */
  127708. dispose(): void;
  127709. private _updateButtons;
  127710. }
  127711. }
  127712. declare module BABYLON {
  127713. /**
  127714. * Class containing static functions to help procedurally build meshes
  127715. */
  127716. export class LinesBuilder {
  127717. /**
  127718. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127719. * * 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
  127720. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127721. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127722. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127723. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127724. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127725. * * 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
  127726. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127729. * @param name defines the name of the new line system
  127730. * @param options defines the options used to create the line system
  127731. * @param scene defines the hosting scene
  127732. * @returns a new line system mesh
  127733. */
  127734. static CreateLineSystem(name: string, options: {
  127735. lines: Vector3[][];
  127736. updatable?: boolean;
  127737. instance?: Nullable<LinesMesh>;
  127738. colors?: Nullable<Color4[][]>;
  127739. useVertexAlpha?: boolean;
  127740. }, scene: Nullable<Scene>): LinesMesh;
  127741. /**
  127742. * Creates a line mesh
  127743. * 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
  127744. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127745. * * The parameter `points` is an array successive Vector3
  127746. * * 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
  127747. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127748. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127749. * * When updating an instance, remember that only point positions can change, not the number of points
  127750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127752. * @param name defines the name of the new line system
  127753. * @param options defines the options used to create the line system
  127754. * @param scene defines the hosting scene
  127755. * @returns a new line mesh
  127756. */
  127757. static CreateLines(name: string, options: {
  127758. points: Vector3[];
  127759. updatable?: boolean;
  127760. instance?: Nullable<LinesMesh>;
  127761. colors?: Color4[];
  127762. useVertexAlpha?: boolean;
  127763. }, scene?: Nullable<Scene>): LinesMesh;
  127764. /**
  127765. * Creates a dashed line mesh
  127766. * * 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
  127767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127768. * * The parameter `points` is an array successive Vector3
  127769. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127770. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127771. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127772. * * 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
  127773. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127774. * * When updating an instance, remember that only point positions can change, not the number of points
  127775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127776. * @param name defines the name of the mesh
  127777. * @param options defines the options used to create the mesh
  127778. * @param scene defines the hosting scene
  127779. * @returns the dashed line mesh
  127780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127781. */
  127782. static CreateDashedLines(name: string, options: {
  127783. points: Vector3[];
  127784. dashSize?: number;
  127785. gapSize?: number;
  127786. dashNb?: number;
  127787. updatable?: boolean;
  127788. instance?: LinesMesh;
  127789. useVertexAlpha?: boolean;
  127790. }, scene?: Nullable<Scene>): LinesMesh;
  127791. }
  127792. }
  127793. declare module BABYLON {
  127794. /**
  127795. * Construction options for a timer
  127796. */
  127797. export interface ITimerOptions<T> {
  127798. /**
  127799. * Time-to-end
  127800. */
  127801. timeout: number;
  127802. /**
  127803. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  127804. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  127805. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  127806. */
  127807. contextObservable: Observable<T>;
  127808. /**
  127809. * Optional parameters when adding an observer to the observable
  127810. */
  127811. observableParameters?: {
  127812. mask?: number;
  127813. insertFirst?: boolean;
  127814. scope?: any;
  127815. };
  127816. /**
  127817. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  127818. */
  127819. breakCondition?: (data?: ITimerData<T>) => boolean;
  127820. /**
  127821. * Will be triggered when the time condition has met
  127822. */
  127823. onEnded?: (data: ITimerData<any>) => void;
  127824. /**
  127825. * Will be triggered when the break condition has met (prematurely ended)
  127826. */
  127827. onAborted?: (data: ITimerData<any>) => void;
  127828. /**
  127829. * Optional function to execute on each tick (or count)
  127830. */
  127831. onTick?: (data: ITimerData<any>) => void;
  127832. }
  127833. /**
  127834. * An interface defining the data sent by the timer
  127835. */
  127836. export interface ITimerData<T> {
  127837. /**
  127838. * When did it start
  127839. */
  127840. startTime: number;
  127841. /**
  127842. * Time now
  127843. */
  127844. currentTime: number;
  127845. /**
  127846. * Time passed since started
  127847. */
  127848. deltaTime: number;
  127849. /**
  127850. * How much is completed, in [0.0...1.0].
  127851. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  127852. */
  127853. completeRate: number;
  127854. /**
  127855. * What the registered observable sent in the last count
  127856. */
  127857. payload: T;
  127858. }
  127859. /**
  127860. * The current state of the timer
  127861. */
  127862. export enum TimerState {
  127863. /**
  127864. * Timer initialized, not yet started
  127865. */
  127866. INIT = 0,
  127867. /**
  127868. * Timer started and counting
  127869. */
  127870. STARTED = 1,
  127871. /**
  127872. * Timer ended (whether aborted or time reached)
  127873. */
  127874. ENDED = 2
  127875. }
  127876. /**
  127877. * A simple version of the timer. Will take options and start the timer immediately after calling it
  127878. *
  127879. * @param options options with which to initialize this timer
  127880. */
  127881. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  127882. /**
  127883. * An advanced implementation of a timer class
  127884. */
  127885. export class AdvancedTimer<T = any> implements IDisposable {
  127886. /**
  127887. * Will notify each time the timer calculates the remaining time
  127888. */
  127889. onEachCountObservable: Observable<ITimerData<T>>;
  127890. /**
  127891. * Will trigger when the timer was aborted due to the break condition
  127892. */
  127893. onTimerAbortedObservable: Observable<ITimerData<T>>;
  127894. /**
  127895. * Will trigger when the timer ended successfully
  127896. */
  127897. onTimerEndedObservable: Observable<ITimerData<T>>;
  127898. /**
  127899. * Will trigger when the timer state has changed
  127900. */
  127901. onStateChangedObservable: Observable<TimerState>;
  127902. private _observer;
  127903. private _contextObservable;
  127904. private _observableParameters;
  127905. private _startTime;
  127906. private _timer;
  127907. private _state;
  127908. private _breakCondition;
  127909. private _timeToEnd;
  127910. private _breakOnNextTick;
  127911. /**
  127912. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  127913. * @param options construction options for this advanced timer
  127914. */
  127915. constructor(options: ITimerOptions<T>);
  127916. /**
  127917. * set a breaking condition for this timer. Default is to never break during count
  127918. * @param predicate the new break condition. Returns true to break, false otherwise
  127919. */
  127920. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  127921. /**
  127922. * Reset ALL associated observables in this advanced timer
  127923. */
  127924. clearObservables(): void;
  127925. /**
  127926. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  127927. *
  127928. * @param timeToEnd how much time to measure until timer ended
  127929. */
  127930. start(timeToEnd?: number): void;
  127931. /**
  127932. * Will force a stop on the next tick.
  127933. */
  127934. stop(): void;
  127935. /**
  127936. * Dispose this timer, clearing all resources
  127937. */
  127938. dispose(): void;
  127939. private _setState;
  127940. private _tick;
  127941. private _stop;
  127942. }
  127943. }
  127944. declare module BABYLON {
  127945. /**
  127946. * The options container for the teleportation module
  127947. */
  127948. export interface IWebXRTeleportationOptions {
  127949. /**
  127950. * if provided, this scene will be used to render meshes.
  127951. */
  127952. customUtilityLayerScene?: Scene;
  127953. /**
  127954. * Values to configure the default target mesh
  127955. */
  127956. defaultTargetMeshOptions?: {
  127957. /**
  127958. * Fill color of the teleportation area
  127959. */
  127960. teleportationFillColor?: string;
  127961. /**
  127962. * Border color for the teleportation area
  127963. */
  127964. teleportationBorderColor?: string;
  127965. /**
  127966. * Disable the mesh's animation sequence
  127967. */
  127968. disableAnimation?: boolean;
  127969. /**
  127970. * Disable lighting on the material or the ring and arrow
  127971. */
  127972. disableLighting?: boolean;
  127973. /**
  127974. * Override the default material of the torus and arrow
  127975. */
  127976. torusArrowMaterial?: Material;
  127977. };
  127978. /**
  127979. * A list of meshes to use as floor meshes.
  127980. * Meshes can be added and removed after initializing the feature using the
  127981. * addFloorMesh and removeFloorMesh functions
  127982. * If empty, rotation will still work
  127983. */
  127984. floorMeshes?: AbstractMesh[];
  127985. /**
  127986. * use this rendering group id for the meshes (optional)
  127987. */
  127988. renderingGroupId?: number;
  127989. /**
  127990. * Should teleportation move only to snap points
  127991. */
  127992. snapPointsOnly?: boolean;
  127993. /**
  127994. * An array of points to which the teleportation will snap to.
  127995. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  127996. */
  127997. snapPositions?: Vector3[];
  127998. /**
  127999. * How close should the teleportation ray be in order to snap to position.
  128000. * Default to 0.8 units (meters)
  128001. */
  128002. snapToPositionRadius?: number;
  128003. /**
  128004. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128005. * If you want to support rotation, make sure your mesh has a direction indicator.
  128006. *
  128007. * When left untouched, the default mesh will be initialized.
  128008. */
  128009. teleportationTargetMesh?: AbstractMesh;
  128010. /**
  128011. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128012. */
  128013. timeToTeleport?: number;
  128014. /**
  128015. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128016. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128017. */
  128018. useMainComponentOnly?: boolean;
  128019. /**
  128020. * Should meshes created here be added to a utility layer or the main scene
  128021. */
  128022. useUtilityLayer?: boolean;
  128023. /**
  128024. * Babylon XR Input class for controller
  128025. */
  128026. xrInput: WebXRInput;
  128027. }
  128028. /**
  128029. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128030. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128031. * the input of the attached controllers.
  128032. */
  128033. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128034. private _options;
  128035. private _controllers;
  128036. private _currentTeleportationControllerId;
  128037. private _floorMeshes;
  128038. private _quadraticBezierCurve;
  128039. private _selectionFeature;
  128040. private _snapToPositions;
  128041. private _snappedToPoint;
  128042. private _teleportationRingMaterial?;
  128043. private _tmpRay;
  128044. private _tmpVector;
  128045. /**
  128046. * The module's name
  128047. */
  128048. static readonly Name: string;
  128049. /**
  128050. * The (Babylon) version of this module.
  128051. * This is an integer representing the implementation version.
  128052. * This number does not correspond to the webxr specs version
  128053. */
  128054. static readonly Version: number;
  128055. /**
  128056. * Is movement backwards enabled
  128057. */
  128058. backwardsMovementEnabled: boolean;
  128059. /**
  128060. * Distance to travel when moving backwards
  128061. */
  128062. backwardsTeleportationDistance: number;
  128063. /**
  128064. * The distance from the user to the inspection point in the direction of the controller
  128065. * A higher number will allow the user to move further
  128066. * defaults to 5 (meters, in xr units)
  128067. */
  128068. parabolicCheckRadius: number;
  128069. /**
  128070. * Should the module support parabolic ray on top of direct ray
  128071. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128072. * Very helpful when moving between floors / different heights
  128073. */
  128074. parabolicRayEnabled: boolean;
  128075. /**
  128076. * How much rotation should be applied when rotating right and left
  128077. */
  128078. rotationAngle: number;
  128079. /**
  128080. * Is rotation enabled when moving forward?
  128081. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128082. */
  128083. rotationEnabled: boolean;
  128084. /**
  128085. * constructs a new anchor system
  128086. * @param _xrSessionManager an instance of WebXRSessionManager
  128087. * @param _options configuration object for this feature
  128088. */
  128089. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128090. /**
  128091. * Get the snapPointsOnly flag
  128092. */
  128093. get snapPointsOnly(): boolean;
  128094. /**
  128095. * Sets the snapPointsOnly flag
  128096. * @param snapToPoints should teleportation be exclusively to snap points
  128097. */
  128098. set snapPointsOnly(snapToPoints: boolean);
  128099. /**
  128100. * Add a new mesh to the floor meshes array
  128101. * @param mesh the mesh to use as floor mesh
  128102. */
  128103. addFloorMesh(mesh: AbstractMesh): void;
  128104. /**
  128105. * Add a new snap-to point to fix teleportation to this position
  128106. * @param newSnapPoint The new Snap-To point
  128107. */
  128108. addSnapPoint(newSnapPoint: Vector3): void;
  128109. attach(): boolean;
  128110. detach(): boolean;
  128111. dispose(): void;
  128112. /**
  128113. * Remove a mesh from the floor meshes array
  128114. * @param mesh the mesh to remove
  128115. */
  128116. removeFloorMesh(mesh: AbstractMesh): void;
  128117. /**
  128118. * Remove a mesh from the floor meshes array using its name
  128119. * @param name the mesh name to remove
  128120. */
  128121. removeFloorMeshByName(name: string): void;
  128122. /**
  128123. * 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
  128124. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128125. * @returns was the point found and removed or not
  128126. */
  128127. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128128. /**
  128129. * This function sets a selection feature that will be disabled when
  128130. * the forward ray is shown and will be reattached when hidden.
  128131. * This is used to remove the selection rays when moving.
  128132. * @param selectionFeature the feature to disable when forward movement is enabled
  128133. */
  128134. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128135. protected _onXRFrame(_xrFrame: XRFrame): void;
  128136. private _attachController;
  128137. private _createDefaultTargetMesh;
  128138. private _detachController;
  128139. private _findClosestSnapPointWithRadius;
  128140. private _setTargetMeshPosition;
  128141. private _setTargetMeshVisibility;
  128142. private _showParabolicPath;
  128143. private _teleportForward;
  128144. }
  128145. }
  128146. declare module BABYLON {
  128147. /**
  128148. * Options for the default xr helper
  128149. */
  128150. export class WebXRDefaultExperienceOptions {
  128151. /**
  128152. * Enable or disable default UI to enter XR
  128153. */
  128154. disableDefaultUI?: boolean;
  128155. /**
  128156. * Should teleportation not initialize. defaults to false.
  128157. */
  128158. disableTeleportation?: boolean;
  128159. /**
  128160. * Floor meshes that will be used for teleport
  128161. */
  128162. floorMeshes?: Array<AbstractMesh>;
  128163. /**
  128164. * If set to true, the first frame will not be used to reset position
  128165. * The first frame is mainly used when copying transformation from the old camera
  128166. * Mainly used in AR
  128167. */
  128168. ignoreNativeCameraTransformation?: boolean;
  128169. /**
  128170. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128171. */
  128172. inputOptions?: IWebXRInputOptions;
  128173. /**
  128174. * optional configuration for the output canvas
  128175. */
  128176. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128177. /**
  128178. * optional UI options. This can be used among other to change session mode and reference space type
  128179. */
  128180. uiOptions?: WebXREnterExitUIOptions;
  128181. /**
  128182. * When loading teleportation and pointer select, use stable versions instead of latest.
  128183. */
  128184. useStablePlugins?: boolean;
  128185. /**
  128186. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128187. */
  128188. renderingGroupId?: number;
  128189. /**
  128190. * A list of optional features to init the session with
  128191. * If set to true, all features we support will be added
  128192. */
  128193. optionalFeatures?: boolean | string[];
  128194. }
  128195. /**
  128196. * Default experience which provides a similar setup to the previous webVRExperience
  128197. */
  128198. export class WebXRDefaultExperience {
  128199. /**
  128200. * Base experience
  128201. */
  128202. baseExperience: WebXRExperienceHelper;
  128203. /**
  128204. * Enables ui for entering/exiting xr
  128205. */
  128206. enterExitUI: WebXREnterExitUI;
  128207. /**
  128208. * Input experience extension
  128209. */
  128210. input: WebXRInput;
  128211. /**
  128212. * Enables laser pointer and selection
  128213. */
  128214. pointerSelection: WebXRControllerPointerSelection;
  128215. /**
  128216. * Default target xr should render to
  128217. */
  128218. renderTarget: WebXRRenderTarget;
  128219. /**
  128220. * Enables teleportation
  128221. */
  128222. teleportation: WebXRMotionControllerTeleportation;
  128223. private constructor();
  128224. /**
  128225. * Creates the default xr experience
  128226. * @param scene scene
  128227. * @param options options for basic configuration
  128228. * @returns resulting WebXRDefaultExperience
  128229. */
  128230. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128231. /**
  128232. * DIsposes of the experience helper
  128233. */
  128234. dispose(): void;
  128235. }
  128236. }
  128237. declare module BABYLON {
  128238. /**
  128239. * Options to modify the vr teleportation behavior.
  128240. */
  128241. export interface VRTeleportationOptions {
  128242. /**
  128243. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128244. */
  128245. floorMeshName?: string;
  128246. /**
  128247. * A list of meshes to be used as the teleportation floor. (default: empty)
  128248. */
  128249. floorMeshes?: Mesh[];
  128250. /**
  128251. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128252. */
  128253. teleportationMode?: number;
  128254. /**
  128255. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128256. */
  128257. teleportationTime?: number;
  128258. /**
  128259. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128260. */
  128261. teleportationSpeed?: number;
  128262. /**
  128263. * The easing function used in the animation or null for Linear. (default CircleEase)
  128264. */
  128265. easingFunction?: EasingFunction;
  128266. }
  128267. /**
  128268. * Options to modify the vr experience helper's behavior.
  128269. */
  128270. export interface VRExperienceHelperOptions extends WebVROptions {
  128271. /**
  128272. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128273. */
  128274. createDeviceOrientationCamera?: boolean;
  128275. /**
  128276. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128277. */
  128278. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128279. /**
  128280. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128281. */
  128282. laserToggle?: boolean;
  128283. /**
  128284. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128285. */
  128286. floorMeshes?: Mesh[];
  128287. /**
  128288. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128289. */
  128290. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128291. /**
  128292. * Defines if WebXR should be used instead of WebVR (if available)
  128293. */
  128294. useXR?: boolean;
  128295. }
  128296. /**
  128297. * Event containing information after VR has been entered
  128298. */
  128299. export class OnAfterEnteringVRObservableEvent {
  128300. /**
  128301. * If entering vr was successful
  128302. */
  128303. success: boolean;
  128304. }
  128305. /**
  128306. * Helps to quickly add VR support to an existing scene.
  128307. * See https://doc.babylonjs.com/how_to/webvr_helper
  128308. */
  128309. export class VRExperienceHelper {
  128310. /** Options to modify the vr experience helper's behavior. */
  128311. webVROptions: VRExperienceHelperOptions;
  128312. private _scene;
  128313. private _position;
  128314. private _btnVR;
  128315. private _btnVRDisplayed;
  128316. private _webVRsupported;
  128317. private _webVRready;
  128318. private _webVRrequesting;
  128319. private _webVRpresenting;
  128320. private _hasEnteredVR;
  128321. private _fullscreenVRpresenting;
  128322. private _inputElement;
  128323. private _webVRCamera;
  128324. private _vrDeviceOrientationCamera;
  128325. private _deviceOrientationCamera;
  128326. private _existingCamera;
  128327. private _onKeyDown;
  128328. private _onVrDisplayPresentChange;
  128329. private _onVRDisplayChanged;
  128330. private _onVRRequestPresentStart;
  128331. private _onVRRequestPresentComplete;
  128332. /**
  128333. * 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)
  128334. */
  128335. enableGazeEvenWhenNoPointerLock: boolean;
  128336. /**
  128337. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128338. */
  128339. exitVROnDoubleTap: boolean;
  128340. /**
  128341. * Observable raised right before entering VR.
  128342. */
  128343. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128344. /**
  128345. * Observable raised when entering VR has completed.
  128346. */
  128347. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128348. /**
  128349. * Observable raised when exiting VR.
  128350. */
  128351. onExitingVRObservable: Observable<VRExperienceHelper>;
  128352. /**
  128353. * Observable raised when controller mesh is loaded.
  128354. */
  128355. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128356. /** Return this.onEnteringVRObservable
  128357. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128358. */
  128359. get onEnteringVR(): Observable<VRExperienceHelper>;
  128360. /** Return this.onExitingVRObservable
  128361. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128362. */
  128363. get onExitingVR(): Observable<VRExperienceHelper>;
  128364. /** Return this.onControllerMeshLoadedObservable
  128365. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128366. */
  128367. get onControllerMeshLoaded(): Observable<WebVRController>;
  128368. private _rayLength;
  128369. private _useCustomVRButton;
  128370. private _teleportationRequested;
  128371. private _teleportActive;
  128372. private _floorMeshName;
  128373. private _floorMeshesCollection;
  128374. private _teleportationMode;
  128375. private _teleportationTime;
  128376. private _teleportationSpeed;
  128377. private _teleportationEasing;
  128378. private _rotationAllowed;
  128379. private _teleportBackwardsVector;
  128380. private _teleportationTarget;
  128381. private _isDefaultTeleportationTarget;
  128382. private _postProcessMove;
  128383. private _teleportationFillColor;
  128384. private _teleportationBorderColor;
  128385. private _rotationAngle;
  128386. private _haloCenter;
  128387. private _cameraGazer;
  128388. private _padSensibilityUp;
  128389. private _padSensibilityDown;
  128390. private _leftController;
  128391. private _rightController;
  128392. private _gazeColor;
  128393. private _laserColor;
  128394. private _pickedLaserColor;
  128395. private _pickedGazeColor;
  128396. /**
  128397. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128398. */
  128399. onNewMeshSelected: Observable<AbstractMesh>;
  128400. /**
  128401. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128402. * This observable will provide the mesh and the controller used to select the mesh
  128403. */
  128404. onMeshSelectedWithController: Observable<{
  128405. mesh: AbstractMesh;
  128406. controller: WebVRController;
  128407. }>;
  128408. /**
  128409. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128410. */
  128411. onNewMeshPicked: Observable<PickingInfo>;
  128412. private _circleEase;
  128413. /**
  128414. * Observable raised before camera teleportation
  128415. */
  128416. onBeforeCameraTeleport: Observable<Vector3>;
  128417. /**
  128418. * Observable raised after camera teleportation
  128419. */
  128420. onAfterCameraTeleport: Observable<Vector3>;
  128421. /**
  128422. * Observable raised when current selected mesh gets unselected
  128423. */
  128424. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128425. private _raySelectionPredicate;
  128426. /**
  128427. * To be optionaly changed by user to define custom ray selection
  128428. */
  128429. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128430. /**
  128431. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128432. */
  128433. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128434. /**
  128435. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128436. */
  128437. teleportationEnabled: boolean;
  128438. private _defaultHeight;
  128439. private _teleportationInitialized;
  128440. private _interactionsEnabled;
  128441. private _interactionsRequested;
  128442. private _displayGaze;
  128443. private _displayLaserPointer;
  128444. /**
  128445. * The mesh used to display where the user is going to teleport.
  128446. */
  128447. get teleportationTarget(): Mesh;
  128448. /**
  128449. * Sets the mesh to be used to display where the user is going to teleport.
  128450. */
  128451. set teleportationTarget(value: Mesh);
  128452. /**
  128453. * 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
  128454. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128455. * See https://doc.babylonjs.com/resources/baking_transformations
  128456. */
  128457. get gazeTrackerMesh(): Mesh;
  128458. set gazeTrackerMesh(value: Mesh);
  128459. /**
  128460. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128461. */
  128462. updateGazeTrackerScale: boolean;
  128463. /**
  128464. * If the gaze trackers color should be updated when selecting meshes
  128465. */
  128466. updateGazeTrackerColor: boolean;
  128467. /**
  128468. * If the controller laser color should be updated when selecting meshes
  128469. */
  128470. updateControllerLaserColor: boolean;
  128471. /**
  128472. * The gaze tracking mesh corresponding to the left controller
  128473. */
  128474. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128475. /**
  128476. * The gaze tracking mesh corresponding to the right controller
  128477. */
  128478. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128479. /**
  128480. * If the ray of the gaze should be displayed.
  128481. */
  128482. get displayGaze(): boolean;
  128483. /**
  128484. * Sets if the ray of the gaze should be displayed.
  128485. */
  128486. set displayGaze(value: boolean);
  128487. /**
  128488. * If the ray of the LaserPointer should be displayed.
  128489. */
  128490. get displayLaserPointer(): boolean;
  128491. /**
  128492. * Sets if the ray of the LaserPointer should be displayed.
  128493. */
  128494. set displayLaserPointer(value: boolean);
  128495. /**
  128496. * The deviceOrientationCamera used as the camera when not in VR.
  128497. */
  128498. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128499. /**
  128500. * Based on the current WebVR support, returns the current VR camera used.
  128501. */
  128502. get currentVRCamera(): Nullable<Camera>;
  128503. /**
  128504. * The webVRCamera which is used when in VR.
  128505. */
  128506. get webVRCamera(): WebVRFreeCamera;
  128507. /**
  128508. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128509. */
  128510. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128511. /**
  128512. * The html button that is used to trigger entering into VR.
  128513. */
  128514. get vrButton(): Nullable<HTMLButtonElement>;
  128515. private get _teleportationRequestInitiated();
  128516. /**
  128517. * Defines whether or not Pointer lock should be requested when switching to
  128518. * full screen.
  128519. */
  128520. requestPointerLockOnFullScreen: boolean;
  128521. /**
  128522. * If asking to force XR, this will be populated with the default xr experience
  128523. */
  128524. xr: WebXRDefaultExperience;
  128525. /**
  128526. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128527. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128528. */
  128529. xrTestDone: boolean;
  128530. /**
  128531. * Instantiates a VRExperienceHelper.
  128532. * Helps to quickly add VR support to an existing scene.
  128533. * @param scene The scene the VRExperienceHelper belongs to.
  128534. * @param webVROptions Options to modify the vr experience helper's behavior.
  128535. */
  128536. constructor(scene: Scene,
  128537. /** Options to modify the vr experience helper's behavior. */
  128538. webVROptions?: VRExperienceHelperOptions);
  128539. private completeVRInit;
  128540. private _onDefaultMeshLoaded;
  128541. private _onResize;
  128542. private _onFullscreenChange;
  128543. /**
  128544. * Gets a value indicating if we are currently in VR mode.
  128545. */
  128546. get isInVRMode(): boolean;
  128547. private onVrDisplayPresentChange;
  128548. private onVRDisplayChanged;
  128549. private moveButtonToBottomRight;
  128550. private displayVRButton;
  128551. private updateButtonVisibility;
  128552. private _cachedAngularSensibility;
  128553. /**
  128554. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128555. * Otherwise, will use the fullscreen API.
  128556. */
  128557. enterVR(): void;
  128558. /**
  128559. * Attempt to exit VR, or fullscreen.
  128560. */
  128561. exitVR(): void;
  128562. /**
  128563. * The position of the vr experience helper.
  128564. */
  128565. get position(): Vector3;
  128566. /**
  128567. * Sets the position of the vr experience helper.
  128568. */
  128569. set position(value: Vector3);
  128570. /**
  128571. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128572. */
  128573. enableInteractions(): void;
  128574. private get _noControllerIsActive();
  128575. private beforeRender;
  128576. private _isTeleportationFloor;
  128577. /**
  128578. * Adds a floor mesh to be used for teleportation.
  128579. * @param floorMesh the mesh to be used for teleportation.
  128580. */
  128581. addFloorMesh(floorMesh: Mesh): void;
  128582. /**
  128583. * Removes a floor mesh from being used for teleportation.
  128584. * @param floorMesh the mesh to be removed.
  128585. */
  128586. removeFloorMesh(floorMesh: Mesh): void;
  128587. /**
  128588. * Enables interactions and teleportation using the VR controllers and gaze.
  128589. * @param vrTeleportationOptions options to modify teleportation behavior.
  128590. */
  128591. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128592. private _onNewGamepadConnected;
  128593. private _tryEnableInteractionOnController;
  128594. private _onNewGamepadDisconnected;
  128595. private _enableInteractionOnController;
  128596. private _checkTeleportWithRay;
  128597. private _checkRotate;
  128598. private _checkTeleportBackwards;
  128599. private _enableTeleportationOnController;
  128600. private _createTeleportationCircles;
  128601. private _displayTeleportationTarget;
  128602. private _hideTeleportationTarget;
  128603. private _rotateCamera;
  128604. private _moveTeleportationSelectorTo;
  128605. private _workingVector;
  128606. private _workingQuaternion;
  128607. private _workingMatrix;
  128608. /**
  128609. * Time Constant Teleportation Mode
  128610. */
  128611. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128612. /**
  128613. * Speed Constant Teleportation Mode
  128614. */
  128615. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128616. /**
  128617. * Teleports the users feet to the desired location
  128618. * @param location The location where the user's feet should be placed
  128619. */
  128620. teleportCamera(location: Vector3): void;
  128621. private _convertNormalToDirectionOfRay;
  128622. private _castRayAndSelectObject;
  128623. private _notifySelectedMeshUnselected;
  128624. /**
  128625. * Permanently set new colors for the laser pointer
  128626. * @param color the new laser color
  128627. * @param pickedColor the new laser color when picked mesh detected
  128628. */
  128629. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128630. /**
  128631. * Set lighting enabled / disabled on the laser pointer of both controllers
  128632. * @param enabled should the lighting be enabled on the laser pointer
  128633. */
  128634. setLaserLightingState(enabled?: boolean): void;
  128635. /**
  128636. * Permanently set new colors for the gaze pointer
  128637. * @param color the new gaze color
  128638. * @param pickedColor the new gaze color when picked mesh detected
  128639. */
  128640. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128641. /**
  128642. * Sets the color of the laser ray from the vr controllers.
  128643. * @param color new color for the ray.
  128644. */
  128645. changeLaserColor(color: Color3): void;
  128646. /**
  128647. * Sets the color of the ray from the vr headsets gaze.
  128648. * @param color new color for the ray.
  128649. */
  128650. changeGazeColor(color: Color3): void;
  128651. /**
  128652. * Exits VR and disposes of the vr experience helper
  128653. */
  128654. dispose(): void;
  128655. /**
  128656. * Gets the name of the VRExperienceHelper class
  128657. * @returns "VRExperienceHelper"
  128658. */
  128659. getClassName(): string;
  128660. }
  128661. }
  128662. declare module BABYLON {
  128663. /**
  128664. * Contains an array of blocks representing the octree
  128665. */
  128666. export interface IOctreeContainer<T> {
  128667. /**
  128668. * Blocks within the octree
  128669. */
  128670. blocks: Array<OctreeBlock<T>>;
  128671. }
  128672. /**
  128673. * Class used to store a cell in an octree
  128674. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128675. */
  128676. export class OctreeBlock<T> {
  128677. /**
  128678. * Gets the content of the current block
  128679. */
  128680. entries: T[];
  128681. /**
  128682. * Gets the list of block children
  128683. */
  128684. blocks: Array<OctreeBlock<T>>;
  128685. private _depth;
  128686. private _maxDepth;
  128687. private _capacity;
  128688. private _minPoint;
  128689. private _maxPoint;
  128690. private _boundingVectors;
  128691. private _creationFunc;
  128692. /**
  128693. * Creates a new block
  128694. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128695. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128696. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128697. * @param depth defines the current depth of this block in the octree
  128698. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128699. * @param creationFunc defines a callback to call when an element is added to the block
  128700. */
  128701. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128702. /**
  128703. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128704. */
  128705. get capacity(): number;
  128706. /**
  128707. * Gets the minimum vector (in world space) of the block's bounding box
  128708. */
  128709. get minPoint(): Vector3;
  128710. /**
  128711. * Gets the maximum vector (in world space) of the block's bounding box
  128712. */
  128713. get maxPoint(): Vector3;
  128714. /**
  128715. * Add a new element to this block
  128716. * @param entry defines the element to add
  128717. */
  128718. addEntry(entry: T): void;
  128719. /**
  128720. * Remove an element from this block
  128721. * @param entry defines the element to remove
  128722. */
  128723. removeEntry(entry: T): void;
  128724. /**
  128725. * Add an array of elements to this block
  128726. * @param entries defines the array of elements to add
  128727. */
  128728. addEntries(entries: T[]): void;
  128729. /**
  128730. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128731. * @param frustumPlanes defines the frustum planes to test
  128732. * @param selection defines the array to store current content if selection is positive
  128733. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128734. */
  128735. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128736. /**
  128737. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128738. * @param sphereCenter defines the bounding sphere center
  128739. * @param sphereRadius defines the bounding sphere radius
  128740. * @param selection defines the array to store current content if selection is positive
  128741. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128742. */
  128743. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128744. /**
  128745. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128746. * @param ray defines the ray to test with
  128747. * @param selection defines the array to store current content if selection is positive
  128748. */
  128749. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128750. /**
  128751. * Subdivide the content into child blocks (this block will then be empty)
  128752. */
  128753. createInnerBlocks(): void;
  128754. /**
  128755. * @hidden
  128756. */
  128757. 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;
  128758. }
  128759. }
  128760. declare module BABYLON {
  128761. /**
  128762. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128763. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128764. */
  128765. export class Octree<T> {
  128766. /** 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.) */
  128767. maxDepth: number;
  128768. /**
  128769. * Blocks within the octree containing objects
  128770. */
  128771. blocks: Array<OctreeBlock<T>>;
  128772. /**
  128773. * Content stored in the octree
  128774. */
  128775. dynamicContent: T[];
  128776. private _maxBlockCapacity;
  128777. private _selectionContent;
  128778. private _creationFunc;
  128779. /**
  128780. * Creates a octree
  128781. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128782. * @param creationFunc function to be used to instatiate the octree
  128783. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128784. * @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.)
  128785. */
  128786. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128787. /** 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.) */
  128788. maxDepth?: number);
  128789. /**
  128790. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  128791. * @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);
  128792. * @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);
  128793. * @param entries meshes to be added to the octree blocks
  128794. */
  128795. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  128796. /**
  128797. * Adds a mesh to the octree
  128798. * @param entry Mesh to add to the octree
  128799. */
  128800. addMesh(entry: T): void;
  128801. /**
  128802. * Remove an element from the octree
  128803. * @param entry defines the element to remove
  128804. */
  128805. removeMesh(entry: T): void;
  128806. /**
  128807. * Selects an array of meshes within the frustum
  128808. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  128809. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  128810. * @returns array of meshes within the frustum
  128811. */
  128812. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  128813. /**
  128814. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  128815. * @param sphereCenter defines the bounding sphere center
  128816. * @param sphereRadius defines the bounding sphere radius
  128817. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128818. * @returns an array of objects that intersect the sphere
  128819. */
  128820. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  128821. /**
  128822. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  128823. * @param ray defines the ray to test with
  128824. * @returns array of intersected objects
  128825. */
  128826. intersectsRay(ray: Ray): SmartArray<T>;
  128827. /**
  128828. * Adds a mesh into the octree block if it intersects the block
  128829. */
  128830. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  128831. /**
  128832. * Adds a submesh into the octree block if it intersects the block
  128833. */
  128834. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  128835. }
  128836. }
  128837. declare module BABYLON {
  128838. interface Scene {
  128839. /**
  128840. * @hidden
  128841. * Backing Filed
  128842. */
  128843. _selectionOctree: Octree<AbstractMesh>;
  128844. /**
  128845. * Gets the octree used to boost mesh selection (picking)
  128846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128847. */
  128848. selectionOctree: Octree<AbstractMesh>;
  128849. /**
  128850. * Creates or updates the octree used to boost selection (picking)
  128851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128852. * @param maxCapacity defines the maximum capacity per leaf
  128853. * @param maxDepth defines the maximum depth of the octree
  128854. * @returns an octree of AbstractMesh
  128855. */
  128856. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  128857. }
  128858. interface AbstractMesh {
  128859. /**
  128860. * @hidden
  128861. * Backing Field
  128862. */
  128863. _submeshesOctree: Octree<SubMesh>;
  128864. /**
  128865. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  128866. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  128867. * @param maxCapacity defines the maximum size of each block (64 by default)
  128868. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  128869. * @returns the new octree
  128870. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  128871. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128872. */
  128873. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  128874. }
  128875. /**
  128876. * Defines the octree scene component responsible to manage any octrees
  128877. * in a given scene.
  128878. */
  128879. export class OctreeSceneComponent {
  128880. /**
  128881. * The component name help to identify the component in the list of scene components.
  128882. */
  128883. readonly name: string;
  128884. /**
  128885. * The scene the component belongs to.
  128886. */
  128887. scene: Scene;
  128888. /**
  128889. * Indicates if the meshes have been checked to make sure they are isEnabled()
  128890. */
  128891. readonly checksIsEnabled: boolean;
  128892. /**
  128893. * Creates a new instance of the component for the given scene
  128894. * @param scene Defines the scene to register the component in
  128895. */
  128896. constructor(scene: Scene);
  128897. /**
  128898. * Registers the component in a given scene
  128899. */
  128900. register(): void;
  128901. /**
  128902. * Return the list of active meshes
  128903. * @returns the list of active meshes
  128904. */
  128905. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  128906. /**
  128907. * Return the list of active sub meshes
  128908. * @param mesh The mesh to get the candidates sub meshes from
  128909. * @returns the list of active sub meshes
  128910. */
  128911. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  128912. private _tempRay;
  128913. /**
  128914. * Return the list of sub meshes intersecting with a given local ray
  128915. * @param mesh defines the mesh to find the submesh for
  128916. * @param localRay defines the ray in local space
  128917. * @returns the list of intersecting sub meshes
  128918. */
  128919. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  128920. /**
  128921. * Return the list of sub meshes colliding with a collider
  128922. * @param mesh defines the mesh to find the submesh for
  128923. * @param collider defines the collider to evaluate the collision against
  128924. * @returns the list of colliding sub meshes
  128925. */
  128926. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  128927. /**
  128928. * Rebuilds the elements related to this component in case of
  128929. * context lost for instance.
  128930. */
  128931. rebuild(): void;
  128932. /**
  128933. * Disposes the component and the associated ressources.
  128934. */
  128935. dispose(): void;
  128936. }
  128937. }
  128938. declare module BABYLON {
  128939. /**
  128940. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  128941. */
  128942. export class Gizmo implements IDisposable {
  128943. /** The utility layer the gizmo will be added to */
  128944. gizmoLayer: UtilityLayerRenderer;
  128945. /**
  128946. * The root mesh of the gizmo
  128947. */
  128948. _rootMesh: Mesh;
  128949. private _attachedMesh;
  128950. private _attachedNode;
  128951. /**
  128952. * Ratio for the scale of the gizmo (Default: 1)
  128953. */
  128954. scaleRatio: number;
  128955. /**
  128956. * If a custom mesh has been set (Default: false)
  128957. */
  128958. protected _customMeshSet: boolean;
  128959. /**
  128960. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  128961. * * When set, interactions will be enabled
  128962. */
  128963. get attachedMesh(): Nullable<AbstractMesh>;
  128964. set attachedMesh(value: Nullable<AbstractMesh>);
  128965. /**
  128966. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  128967. * * When set, interactions will be enabled
  128968. */
  128969. get attachedNode(): Nullable<Node>;
  128970. set attachedNode(value: Nullable<Node>);
  128971. /**
  128972. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  128973. * @param mesh The mesh to replace the default mesh of the gizmo
  128974. */
  128975. setCustomMesh(mesh: Mesh): void;
  128976. /**
  128977. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  128978. */
  128979. updateGizmoRotationToMatchAttachedMesh: boolean;
  128980. /**
  128981. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  128982. */
  128983. updateGizmoPositionToMatchAttachedMesh: boolean;
  128984. /**
  128985. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  128986. */
  128987. updateScale: boolean;
  128988. protected _interactionsEnabled: boolean;
  128989. protected _attachedNodeChanged(value: Nullable<Node>): void;
  128990. private _beforeRenderObserver;
  128991. private _tempVector;
  128992. /**
  128993. * Creates a gizmo
  128994. * @param gizmoLayer The utility layer the gizmo will be added to
  128995. */
  128996. constructor(
  128997. /** The utility layer the gizmo will be added to */
  128998. gizmoLayer?: UtilityLayerRenderer);
  128999. /**
  129000. * Updates the gizmo to match the attached mesh's position/rotation
  129001. */
  129002. protected _update(): void;
  129003. /**
  129004. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129005. * @param value Node, TransformNode or mesh
  129006. */
  129007. protected _matrixChanged(): void;
  129008. /**
  129009. * Disposes of the gizmo
  129010. */
  129011. dispose(): void;
  129012. }
  129013. }
  129014. declare module BABYLON {
  129015. /**
  129016. * Single plane drag gizmo
  129017. */
  129018. export class PlaneDragGizmo extends Gizmo {
  129019. /**
  129020. * Drag behavior responsible for the gizmos dragging interactions
  129021. */
  129022. dragBehavior: PointerDragBehavior;
  129023. private _pointerObserver;
  129024. /**
  129025. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129026. */
  129027. snapDistance: number;
  129028. /**
  129029. * Event that fires each time the gizmo snaps to a new location.
  129030. * * snapDistance is the the change in distance
  129031. */
  129032. onSnapObservable: Observable<{
  129033. snapDistance: number;
  129034. }>;
  129035. private _plane;
  129036. private _coloredMaterial;
  129037. private _hoverMaterial;
  129038. private _isEnabled;
  129039. private _parent;
  129040. /** @hidden */
  129041. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129042. /** @hidden */
  129043. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129044. /**
  129045. * Creates a PlaneDragGizmo
  129046. * @param gizmoLayer The utility layer the gizmo will be added to
  129047. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129048. * @param color The color of the gizmo
  129049. */
  129050. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129051. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129052. /**
  129053. * If the gizmo is enabled
  129054. */
  129055. set isEnabled(value: boolean);
  129056. get isEnabled(): boolean;
  129057. /**
  129058. * Disposes of the gizmo
  129059. */
  129060. dispose(): void;
  129061. }
  129062. }
  129063. declare module BABYLON {
  129064. /**
  129065. * Gizmo that enables dragging a mesh along 3 axis
  129066. */
  129067. export class PositionGizmo extends Gizmo {
  129068. /**
  129069. * Internal gizmo used for interactions on the x axis
  129070. */
  129071. xGizmo: AxisDragGizmo;
  129072. /**
  129073. * Internal gizmo used for interactions on the y axis
  129074. */
  129075. yGizmo: AxisDragGizmo;
  129076. /**
  129077. * Internal gizmo used for interactions on the z axis
  129078. */
  129079. zGizmo: AxisDragGizmo;
  129080. /**
  129081. * Internal gizmo used for interactions on the yz plane
  129082. */
  129083. xPlaneGizmo: PlaneDragGizmo;
  129084. /**
  129085. * Internal gizmo used for interactions on the xz plane
  129086. */
  129087. yPlaneGizmo: PlaneDragGizmo;
  129088. /**
  129089. * Internal gizmo used for interactions on the xy plane
  129090. */
  129091. zPlaneGizmo: PlaneDragGizmo;
  129092. /**
  129093. * private variables
  129094. */
  129095. private _meshAttached;
  129096. private _nodeAttached;
  129097. private _updateGizmoRotationToMatchAttachedMesh;
  129098. private _snapDistance;
  129099. private _scaleRatio;
  129100. /** Fires an event when any of it's sub gizmos are dragged */
  129101. onDragStartObservable: Observable<unknown>;
  129102. /** Fires an event when any of it's sub gizmos are released from dragging */
  129103. onDragEndObservable: Observable<unknown>;
  129104. /**
  129105. * If set to true, planar drag is enabled
  129106. */
  129107. private _planarGizmoEnabled;
  129108. get attachedMesh(): Nullable<AbstractMesh>;
  129109. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129110. get attachedNode(): Nullable<Node>;
  129111. set attachedNode(node: Nullable<Node>);
  129112. /**
  129113. * Creates a PositionGizmo
  129114. * @param gizmoLayer The utility layer the gizmo will be added to
  129115. @param thickness display gizmo axis thickness
  129116. */
  129117. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129118. /**
  129119. * If the planar drag gizmo is enabled
  129120. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129121. */
  129122. set planarGizmoEnabled(value: boolean);
  129123. get planarGizmoEnabled(): boolean;
  129124. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129125. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129126. /**
  129127. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129128. */
  129129. set snapDistance(value: number);
  129130. get snapDistance(): number;
  129131. /**
  129132. * Ratio for the scale of the gizmo (Default: 1)
  129133. */
  129134. set scaleRatio(value: number);
  129135. get scaleRatio(): number;
  129136. /**
  129137. * Disposes of the gizmo
  129138. */
  129139. dispose(): void;
  129140. /**
  129141. * CustomMeshes are not supported by this gizmo
  129142. * @param mesh The mesh to replace the default mesh of the gizmo
  129143. */
  129144. setCustomMesh(mesh: Mesh): void;
  129145. }
  129146. }
  129147. declare module BABYLON {
  129148. /**
  129149. * Single axis drag gizmo
  129150. */
  129151. export class AxisDragGizmo extends Gizmo {
  129152. /**
  129153. * Drag behavior responsible for the gizmos dragging interactions
  129154. */
  129155. dragBehavior: PointerDragBehavior;
  129156. private _pointerObserver;
  129157. /**
  129158. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129159. */
  129160. snapDistance: number;
  129161. /**
  129162. * Event that fires each time the gizmo snaps to a new location.
  129163. * * snapDistance is the the change in distance
  129164. */
  129165. onSnapObservable: Observable<{
  129166. snapDistance: number;
  129167. }>;
  129168. private _isEnabled;
  129169. private _parent;
  129170. private _arrow;
  129171. private _coloredMaterial;
  129172. private _hoverMaterial;
  129173. /** @hidden */
  129174. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129175. /** @hidden */
  129176. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129177. /**
  129178. * Creates an AxisDragGizmo
  129179. * @param gizmoLayer The utility layer the gizmo will be added to
  129180. * @param dragAxis The axis which the gizmo will be able to drag on
  129181. * @param color The color of the gizmo
  129182. * @param thickness display gizmo axis thickness
  129183. */
  129184. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129185. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129186. /**
  129187. * If the gizmo is enabled
  129188. */
  129189. set isEnabled(value: boolean);
  129190. get isEnabled(): boolean;
  129191. /**
  129192. * Disposes of the gizmo
  129193. */
  129194. dispose(): void;
  129195. }
  129196. }
  129197. declare module BABYLON.Debug {
  129198. /**
  129199. * The Axes viewer will show 3 axes in a specific point in space
  129200. */
  129201. export class AxesViewer {
  129202. private _xAxis;
  129203. private _yAxis;
  129204. private _zAxis;
  129205. private _scaleLinesFactor;
  129206. private _instanced;
  129207. /**
  129208. * Gets the hosting scene
  129209. */
  129210. scene: Scene;
  129211. /**
  129212. * Gets or sets a number used to scale line length
  129213. */
  129214. scaleLines: number;
  129215. /** Gets the node hierarchy used to render x-axis */
  129216. get xAxis(): TransformNode;
  129217. /** Gets the node hierarchy used to render y-axis */
  129218. get yAxis(): TransformNode;
  129219. /** Gets the node hierarchy used to render z-axis */
  129220. get zAxis(): TransformNode;
  129221. /**
  129222. * Creates a new AxesViewer
  129223. * @param scene defines the hosting scene
  129224. * @param scaleLines defines a number used to scale line length (1 by default)
  129225. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129226. * @param xAxis defines the node hierarchy used to render the x-axis
  129227. * @param yAxis defines the node hierarchy used to render the y-axis
  129228. * @param zAxis defines the node hierarchy used to render the z-axis
  129229. */
  129230. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129231. /**
  129232. * Force the viewer to update
  129233. * @param position defines the position of the viewer
  129234. * @param xaxis defines the x axis of the viewer
  129235. * @param yaxis defines the y axis of the viewer
  129236. * @param zaxis defines the z axis of the viewer
  129237. */
  129238. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129239. /**
  129240. * Creates an instance of this axes viewer.
  129241. * @returns a new axes viewer with instanced meshes
  129242. */
  129243. createInstance(): AxesViewer;
  129244. /** Releases resources */
  129245. dispose(): void;
  129246. private static _SetRenderingGroupId;
  129247. }
  129248. }
  129249. declare module BABYLON.Debug {
  129250. /**
  129251. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129252. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129253. */
  129254. export class BoneAxesViewer extends AxesViewer {
  129255. /**
  129256. * Gets or sets the target mesh where to display the axes viewer
  129257. */
  129258. mesh: Nullable<Mesh>;
  129259. /**
  129260. * Gets or sets the target bone where to display the axes viewer
  129261. */
  129262. bone: Nullable<Bone>;
  129263. /** Gets current position */
  129264. pos: Vector3;
  129265. /** Gets direction of X axis */
  129266. xaxis: Vector3;
  129267. /** Gets direction of Y axis */
  129268. yaxis: Vector3;
  129269. /** Gets direction of Z axis */
  129270. zaxis: Vector3;
  129271. /**
  129272. * Creates a new BoneAxesViewer
  129273. * @param scene defines the hosting scene
  129274. * @param bone defines the target bone
  129275. * @param mesh defines the target mesh
  129276. * @param scaleLines defines a scaling factor for line length (1 by default)
  129277. */
  129278. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129279. /**
  129280. * Force the viewer to update
  129281. */
  129282. update(): void;
  129283. /** Releases resources */
  129284. dispose(): void;
  129285. }
  129286. }
  129287. declare module BABYLON {
  129288. /**
  129289. * Interface used to define scene explorer extensibility option
  129290. */
  129291. export interface IExplorerExtensibilityOption {
  129292. /**
  129293. * Define the option label
  129294. */
  129295. label: string;
  129296. /**
  129297. * Defines the action to execute on click
  129298. */
  129299. action: (entity: any) => void;
  129300. }
  129301. /**
  129302. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129303. */
  129304. export interface IExplorerExtensibilityGroup {
  129305. /**
  129306. * Defines a predicate to test if a given type mut be extended
  129307. */
  129308. predicate: (entity: any) => boolean;
  129309. /**
  129310. * Gets the list of options added to a type
  129311. */
  129312. entries: IExplorerExtensibilityOption[];
  129313. }
  129314. /**
  129315. * Interface used to define the options to use to create the Inspector
  129316. */
  129317. export interface IInspectorOptions {
  129318. /**
  129319. * Display in overlay mode (default: false)
  129320. */
  129321. overlay?: boolean;
  129322. /**
  129323. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129324. */
  129325. globalRoot?: HTMLElement;
  129326. /**
  129327. * Display the Scene explorer
  129328. */
  129329. showExplorer?: boolean;
  129330. /**
  129331. * Display the property inspector
  129332. */
  129333. showInspector?: boolean;
  129334. /**
  129335. * Display in embed mode (both panes on the right)
  129336. */
  129337. embedMode?: boolean;
  129338. /**
  129339. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129340. */
  129341. handleResize?: boolean;
  129342. /**
  129343. * Allow the panes to popup (default: true)
  129344. */
  129345. enablePopup?: boolean;
  129346. /**
  129347. * Allow the panes to be closed by users (default: true)
  129348. */
  129349. enableClose?: boolean;
  129350. /**
  129351. * Optional list of extensibility entries
  129352. */
  129353. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129354. /**
  129355. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129356. */
  129357. inspectorURL?: string;
  129358. /**
  129359. * Optional initial tab (default to DebugLayerTab.Properties)
  129360. */
  129361. initialTab?: DebugLayerTab;
  129362. }
  129363. interface Scene {
  129364. /**
  129365. * @hidden
  129366. * Backing field
  129367. */
  129368. _debugLayer: DebugLayer;
  129369. /**
  129370. * Gets the debug layer (aka Inspector) associated with the scene
  129371. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129372. */
  129373. debugLayer: DebugLayer;
  129374. }
  129375. /**
  129376. * Enum of inspector action tab
  129377. */
  129378. export enum DebugLayerTab {
  129379. /**
  129380. * Properties tag (default)
  129381. */
  129382. Properties = 0,
  129383. /**
  129384. * Debug tab
  129385. */
  129386. Debug = 1,
  129387. /**
  129388. * Statistics tab
  129389. */
  129390. Statistics = 2,
  129391. /**
  129392. * Tools tab
  129393. */
  129394. Tools = 3,
  129395. /**
  129396. * Settings tab
  129397. */
  129398. Settings = 4
  129399. }
  129400. /**
  129401. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129402. * what is happening in your scene
  129403. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129404. */
  129405. export class DebugLayer {
  129406. /**
  129407. * Define the url to get the inspector script from.
  129408. * By default it uses the babylonjs CDN.
  129409. * @ignoreNaming
  129410. */
  129411. static InspectorURL: string;
  129412. private _scene;
  129413. private BJSINSPECTOR;
  129414. private _onPropertyChangedObservable?;
  129415. /**
  129416. * Observable triggered when a property is changed through the inspector.
  129417. */
  129418. get onPropertyChangedObservable(): any;
  129419. /**
  129420. * Instantiates a new debug layer.
  129421. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129422. * what is happening in your scene
  129423. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129424. * @param scene Defines the scene to inspect
  129425. */
  129426. constructor(scene: Scene);
  129427. /** Creates the inspector window. */
  129428. private _createInspector;
  129429. /**
  129430. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129431. * @param entity defines the entity to select
  129432. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129433. */
  129434. select(entity: any, lineContainerTitles?: string | string[]): void;
  129435. /** Get the inspector from bundle or global */
  129436. private _getGlobalInspector;
  129437. /**
  129438. * Get if the inspector is visible or not.
  129439. * @returns true if visible otherwise, false
  129440. */
  129441. isVisible(): boolean;
  129442. /**
  129443. * Hide the inspector and close its window.
  129444. */
  129445. hide(): void;
  129446. /**
  129447. * Update the scene in the inspector
  129448. */
  129449. setAsActiveScene(): void;
  129450. /**
  129451. * Launch the debugLayer.
  129452. * @param config Define the configuration of the inspector
  129453. * @return a promise fulfilled when the debug layer is visible
  129454. */
  129455. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129456. }
  129457. }
  129458. declare module BABYLON {
  129459. /**
  129460. * Class containing static functions to help procedurally build meshes
  129461. */
  129462. export class BoxBuilder {
  129463. /**
  129464. * Creates a box mesh
  129465. * * The parameter `size` sets the size (float) of each box side (default 1)
  129466. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129467. * * 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)
  129468. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129472. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129473. * @param name defines the name of the mesh
  129474. * @param options defines the options used to create the mesh
  129475. * @param scene defines the hosting scene
  129476. * @returns the box mesh
  129477. */
  129478. static CreateBox(name: string, options: {
  129479. size?: number;
  129480. width?: number;
  129481. height?: number;
  129482. depth?: number;
  129483. faceUV?: Vector4[];
  129484. faceColors?: Color4[];
  129485. sideOrientation?: number;
  129486. frontUVs?: Vector4;
  129487. backUVs?: Vector4;
  129488. wrap?: boolean;
  129489. topBaseAt?: number;
  129490. bottomBaseAt?: number;
  129491. updatable?: boolean;
  129492. }, scene?: Nullable<Scene>): Mesh;
  129493. }
  129494. }
  129495. declare module BABYLON.Debug {
  129496. /**
  129497. * Used to show the physics impostor around the specific mesh
  129498. */
  129499. export class PhysicsViewer {
  129500. /** @hidden */
  129501. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129502. /** @hidden */
  129503. protected _meshes: Array<Nullable<AbstractMesh>>;
  129504. /** @hidden */
  129505. protected _scene: Nullable<Scene>;
  129506. /** @hidden */
  129507. protected _numMeshes: number;
  129508. /** @hidden */
  129509. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129510. private _renderFunction;
  129511. private _utilityLayer;
  129512. private _debugBoxMesh;
  129513. private _debugSphereMesh;
  129514. private _debugCylinderMesh;
  129515. private _debugMaterial;
  129516. private _debugMeshMeshes;
  129517. /**
  129518. * Creates a new PhysicsViewer
  129519. * @param scene defines the hosting scene
  129520. */
  129521. constructor(scene: Scene);
  129522. /** @hidden */
  129523. protected _updateDebugMeshes(): void;
  129524. /**
  129525. * Renders a specified physic impostor
  129526. * @param impostor defines the impostor to render
  129527. * @param targetMesh defines the mesh represented by the impostor
  129528. * @returns the new debug mesh used to render the impostor
  129529. */
  129530. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129531. /**
  129532. * Hides a specified physic impostor
  129533. * @param impostor defines the impostor to hide
  129534. */
  129535. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129536. private _getDebugMaterial;
  129537. private _getDebugBoxMesh;
  129538. private _getDebugSphereMesh;
  129539. private _getDebugCylinderMesh;
  129540. private _getDebugMeshMesh;
  129541. private _getDebugMesh;
  129542. /** Releases all resources */
  129543. dispose(): void;
  129544. }
  129545. }
  129546. declare module BABYLON {
  129547. /**
  129548. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129549. * in order to better appreciate the issue one might have.
  129550. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129551. */
  129552. export class RayHelper {
  129553. /**
  129554. * Defines the ray we are currently tryin to visualize.
  129555. */
  129556. ray: Nullable<Ray>;
  129557. private _renderPoints;
  129558. private _renderLine;
  129559. private _renderFunction;
  129560. private _scene;
  129561. private _updateToMeshFunction;
  129562. private _attachedToMesh;
  129563. private _meshSpaceDirection;
  129564. private _meshSpaceOrigin;
  129565. /**
  129566. * Helper function to create a colored helper in a scene in one line.
  129567. * @param ray Defines the ray we are currently tryin to visualize
  129568. * @param scene Defines the scene the ray is used in
  129569. * @param color Defines the color we want to see the ray in
  129570. * @returns The newly created ray helper.
  129571. */
  129572. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129573. /**
  129574. * Instantiate a new ray helper.
  129575. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129576. * in order to better appreciate the issue one might have.
  129577. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129578. * @param ray Defines the ray we are currently tryin to visualize
  129579. */
  129580. constructor(ray: Ray);
  129581. /**
  129582. * Shows the ray we are willing to debug.
  129583. * @param scene Defines the scene the ray needs to be rendered in
  129584. * @param color Defines the color the ray needs to be rendered in
  129585. */
  129586. show(scene: Scene, color?: Color3): void;
  129587. /**
  129588. * Hides the ray we are debugging.
  129589. */
  129590. hide(): void;
  129591. private _render;
  129592. /**
  129593. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129594. * @param mesh Defines the mesh we want the helper attached to
  129595. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129596. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129597. * @param length Defines the length of the ray
  129598. */
  129599. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129600. /**
  129601. * Detach the ray helper from the mesh it has previously been attached to.
  129602. */
  129603. detachFromMesh(): void;
  129604. private _updateToMesh;
  129605. /**
  129606. * Dispose the helper and release its associated resources.
  129607. */
  129608. dispose(): void;
  129609. }
  129610. }
  129611. declare module BABYLON {
  129612. /**
  129613. * Defines the options associated with the creation of a SkeletonViewer.
  129614. */
  129615. export interface ISkeletonViewerOptions {
  129616. /** Should the system pause animations before building the Viewer? */
  129617. pauseAnimations: boolean;
  129618. /** Should the system return the skeleton to rest before building? */
  129619. returnToRest: boolean;
  129620. /** public Display Mode of the Viewer */
  129621. displayMode: number;
  129622. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129623. displayOptions: ISkeletonViewerDisplayOptions;
  129624. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129625. computeBonesUsingShaders: boolean;
  129626. }
  129627. /**
  129628. * Defines how to display the various bone meshes for the viewer.
  129629. */
  129630. export interface ISkeletonViewerDisplayOptions {
  129631. /** How far down to start tapering the bone spurs */
  129632. midStep?: number;
  129633. /** How big is the midStep? */
  129634. midStepFactor?: number;
  129635. /** Base for the Sphere Size */
  129636. sphereBaseSize?: number;
  129637. /** The ratio of the sphere to the longest bone in units */
  129638. sphereScaleUnit?: number;
  129639. /** Ratio for the Sphere Size */
  129640. sphereFactor?: number;
  129641. }
  129642. }
  129643. declare module BABYLON {
  129644. /**
  129645. * Class containing static functions to help procedurally build meshes
  129646. */
  129647. export class RibbonBuilder {
  129648. /**
  129649. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129650. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129651. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129652. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129653. * * 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
  129654. * * 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
  129655. * * 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
  129656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129659. * * 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
  129660. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129661. * * 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
  129662. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129664. * @param name defines the name of the mesh
  129665. * @param options defines the options used to create the mesh
  129666. * @param scene defines the hosting scene
  129667. * @returns the ribbon mesh
  129668. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129670. */
  129671. static CreateRibbon(name: string, options: {
  129672. pathArray: Vector3[][];
  129673. closeArray?: boolean;
  129674. closePath?: boolean;
  129675. offset?: number;
  129676. updatable?: boolean;
  129677. sideOrientation?: number;
  129678. frontUVs?: Vector4;
  129679. backUVs?: Vector4;
  129680. instance?: Mesh;
  129681. invertUV?: boolean;
  129682. uvs?: Vector2[];
  129683. colors?: Color4[];
  129684. }, scene?: Nullable<Scene>): Mesh;
  129685. }
  129686. }
  129687. declare module BABYLON {
  129688. /**
  129689. * Class containing static functions to help procedurally build meshes
  129690. */
  129691. export class ShapeBuilder {
  129692. /**
  129693. * 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.
  129694. * * 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.
  129695. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129696. * * 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.
  129697. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129698. * * 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
  129699. * * 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
  129700. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129705. * @param name defines the name of the mesh
  129706. * @param options defines the options used to create the mesh
  129707. * @param scene defines the hosting scene
  129708. * @returns the extruded shape mesh
  129709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129711. */
  129712. static ExtrudeShape(name: string, options: {
  129713. shape: Vector3[];
  129714. path: Vector3[];
  129715. scale?: number;
  129716. rotation?: number;
  129717. cap?: number;
  129718. updatable?: boolean;
  129719. sideOrientation?: number;
  129720. frontUVs?: Vector4;
  129721. backUVs?: Vector4;
  129722. instance?: Mesh;
  129723. invertUV?: boolean;
  129724. }, scene?: Nullable<Scene>): Mesh;
  129725. /**
  129726. * Creates an custom extruded shape mesh.
  129727. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129728. * * 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.
  129729. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129730. * * 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
  129731. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129732. * * 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
  129733. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129734. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129735. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129736. * * 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
  129737. * * 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
  129738. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129743. * @param name defines the name of the mesh
  129744. * @param options defines the options used to create the mesh
  129745. * @param scene defines the hosting scene
  129746. * @returns the custom extruded shape mesh
  129747. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129748. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129749. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129750. */
  129751. static ExtrudeShapeCustom(name: string, options: {
  129752. shape: Vector3[];
  129753. path: Vector3[];
  129754. scaleFunction?: any;
  129755. rotationFunction?: any;
  129756. ribbonCloseArray?: boolean;
  129757. ribbonClosePath?: boolean;
  129758. cap?: number;
  129759. updatable?: boolean;
  129760. sideOrientation?: number;
  129761. frontUVs?: Vector4;
  129762. backUVs?: Vector4;
  129763. instance?: Mesh;
  129764. invertUV?: boolean;
  129765. }, scene?: Nullable<Scene>): Mesh;
  129766. private static _ExtrudeShapeGeneric;
  129767. }
  129768. }
  129769. declare module BABYLON.Debug {
  129770. /**
  129771. * Class used to render a debug view of a given skeleton
  129772. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129773. */
  129774. export class SkeletonViewer {
  129775. /** defines the skeleton to render */
  129776. skeleton: Skeleton;
  129777. /** defines the mesh attached to the skeleton */
  129778. mesh: AbstractMesh;
  129779. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129780. autoUpdateBonesMatrices: boolean;
  129781. /** defines the rendering group id to use with the viewer */
  129782. renderingGroupId: number;
  129783. /** is the options for the viewer */
  129784. options: Partial<ISkeletonViewerOptions>;
  129785. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  129786. static readonly DISPLAY_LINES: number;
  129787. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  129788. static readonly DISPLAY_SPHERES: number;
  129789. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  129790. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  129791. /** If SkeletonViewer scene scope. */
  129792. private _scene;
  129793. /** Gets or sets the color used to render the skeleton */
  129794. color: Color3;
  129795. /** Array of the points of the skeleton fo the line view. */
  129796. private _debugLines;
  129797. /** The SkeletonViewers Mesh. */
  129798. private _debugMesh;
  129799. /** If SkeletonViewer is enabled. */
  129800. private _isEnabled;
  129801. /** If SkeletonViewer is ready. */
  129802. private _ready;
  129803. /** SkeletonViewer render observable. */
  129804. private _obs;
  129805. /** The Utility Layer to render the gizmos in. */
  129806. private _utilityLayer;
  129807. /** Gets the Scene. */
  129808. get scene(): Scene;
  129809. /** Gets the utilityLayer. */
  129810. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  129811. /** Checks Ready Status. */
  129812. get isReady(): Boolean;
  129813. /** Sets Ready Status. */
  129814. set ready(value: boolean);
  129815. /** Gets the debugMesh */
  129816. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  129817. /** Sets the debugMesh */
  129818. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  129819. /** Gets the material */
  129820. get material(): StandardMaterial;
  129821. /** Sets the material */
  129822. set material(value: StandardMaterial);
  129823. /**
  129824. * Creates a new SkeletonViewer
  129825. * @param skeleton defines the skeleton to render
  129826. * @param mesh defines the mesh attached to the skeleton
  129827. * @param scene defines the hosting scene
  129828. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  129829. * @param renderingGroupId defines the rendering group id to use with the viewer
  129830. * @param options All of the extra constructor options for the SkeletonViewer
  129831. */
  129832. constructor(
  129833. /** defines the skeleton to render */
  129834. skeleton: Skeleton,
  129835. /** defines the mesh attached to the skeleton */
  129836. mesh: AbstractMesh,
  129837. /** The Scene scope*/
  129838. scene: Scene,
  129839. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129840. autoUpdateBonesMatrices?: boolean,
  129841. /** defines the rendering group id to use with the viewer */
  129842. renderingGroupId?: number,
  129843. /** is the options for the viewer */
  129844. options?: Partial<ISkeletonViewerOptions>);
  129845. /** The Dynamic bindings for the update functions */
  129846. private _bindObs;
  129847. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  129848. update(): void;
  129849. /** Gets or sets a boolean indicating if the viewer is enabled */
  129850. set isEnabled(value: boolean);
  129851. get isEnabled(): boolean;
  129852. private _getBonePosition;
  129853. private _getLinesForBonesWithLength;
  129854. private _getLinesForBonesNoLength;
  129855. /** function to revert the mesh and scene back to the initial state. */
  129856. private _revert;
  129857. /** function to build and bind sphere joint points and spur bone representations. */
  129858. private _buildSpheresAndSpurs;
  129859. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  129860. private _displayLinesUpdate;
  129861. /** Release associated resources */
  129862. dispose(): void;
  129863. }
  129864. }
  129865. declare module BABYLON {
  129866. /**
  129867. * Enum for Device Types
  129868. */
  129869. export enum DeviceType {
  129870. /** Generic */
  129871. Generic = 0,
  129872. /** Keyboard */
  129873. Keyboard = 1,
  129874. /** Mouse */
  129875. Mouse = 2,
  129876. /** Touch Pointers */
  129877. Touch = 3,
  129878. /** PS4 Dual Shock */
  129879. DualShock = 4,
  129880. /** Xbox */
  129881. Xbox = 5,
  129882. /** Switch Controller */
  129883. Switch = 6
  129884. }
  129885. /**
  129886. * Enum for All Pointers (Touch/Mouse)
  129887. */
  129888. export enum PointerInput {
  129889. /** Horizontal Axis */
  129890. Horizontal = 0,
  129891. /** Vertical Axis */
  129892. Vertical = 1,
  129893. /** Left Click or Touch */
  129894. LeftClick = 2,
  129895. /** Middle Click */
  129896. MiddleClick = 3,
  129897. /** Right Click */
  129898. RightClick = 4,
  129899. /** Browser Back */
  129900. BrowserBack = 5,
  129901. /** Browser Forward */
  129902. BrowserForward = 6
  129903. }
  129904. /**
  129905. * Enum for Dual Shock Gamepad
  129906. */
  129907. export enum DualShockInput {
  129908. /** Cross */
  129909. Cross = 0,
  129910. /** Circle */
  129911. Circle = 1,
  129912. /** Square */
  129913. Square = 2,
  129914. /** Triangle */
  129915. Triangle = 3,
  129916. /** L1 */
  129917. L1 = 4,
  129918. /** R1 */
  129919. R1 = 5,
  129920. /** L2 */
  129921. L2 = 6,
  129922. /** R2 */
  129923. R2 = 7,
  129924. /** Share */
  129925. Share = 8,
  129926. /** Options */
  129927. Options = 9,
  129928. /** L3 */
  129929. L3 = 10,
  129930. /** R3 */
  129931. R3 = 11,
  129932. /** DPadUp */
  129933. DPadUp = 12,
  129934. /** DPadDown */
  129935. DPadDown = 13,
  129936. /** DPadLeft */
  129937. DPadLeft = 14,
  129938. /** DRight */
  129939. DPadRight = 15,
  129940. /** Home */
  129941. Home = 16,
  129942. /** TouchPad */
  129943. TouchPad = 17,
  129944. /** LStickXAxis */
  129945. LStickXAxis = 18,
  129946. /** LStickYAxis */
  129947. LStickYAxis = 19,
  129948. /** RStickXAxis */
  129949. RStickXAxis = 20,
  129950. /** RStickYAxis */
  129951. RStickYAxis = 21
  129952. }
  129953. /**
  129954. * Enum for Xbox Gamepad
  129955. */
  129956. export enum XboxInput {
  129957. /** A */
  129958. A = 0,
  129959. /** B */
  129960. B = 1,
  129961. /** X */
  129962. X = 2,
  129963. /** Y */
  129964. Y = 3,
  129965. /** LB */
  129966. LB = 4,
  129967. /** RB */
  129968. RB = 5,
  129969. /** LT */
  129970. LT = 6,
  129971. /** RT */
  129972. RT = 7,
  129973. /** Back */
  129974. Back = 8,
  129975. /** Start */
  129976. Start = 9,
  129977. /** LS */
  129978. LS = 10,
  129979. /** RS */
  129980. RS = 11,
  129981. /** DPadUp */
  129982. DPadUp = 12,
  129983. /** DPadDown */
  129984. DPadDown = 13,
  129985. /** DPadLeft */
  129986. DPadLeft = 14,
  129987. /** DRight */
  129988. DPadRight = 15,
  129989. /** Home */
  129990. Home = 16,
  129991. /** LStickXAxis */
  129992. LStickXAxis = 17,
  129993. /** LStickYAxis */
  129994. LStickYAxis = 18,
  129995. /** RStickXAxis */
  129996. RStickXAxis = 19,
  129997. /** RStickYAxis */
  129998. RStickYAxis = 20
  129999. }
  130000. /**
  130001. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130002. */
  130003. export enum SwitchInput {
  130004. /** B */
  130005. B = 0,
  130006. /** A */
  130007. A = 1,
  130008. /** Y */
  130009. Y = 2,
  130010. /** X */
  130011. X = 3,
  130012. /** L */
  130013. L = 4,
  130014. /** R */
  130015. R = 5,
  130016. /** ZL */
  130017. ZL = 6,
  130018. /** ZR */
  130019. ZR = 7,
  130020. /** Minus */
  130021. Minus = 8,
  130022. /** Plus */
  130023. Plus = 9,
  130024. /** LS */
  130025. LS = 10,
  130026. /** RS */
  130027. RS = 11,
  130028. /** DPadUp */
  130029. DPadUp = 12,
  130030. /** DPadDown */
  130031. DPadDown = 13,
  130032. /** DPadLeft */
  130033. DPadLeft = 14,
  130034. /** DRight */
  130035. DPadRight = 15,
  130036. /** Home */
  130037. Home = 16,
  130038. /** Capture */
  130039. Capture = 17,
  130040. /** LStickXAxis */
  130041. LStickXAxis = 18,
  130042. /** LStickYAxis */
  130043. LStickYAxis = 19,
  130044. /** RStickXAxis */
  130045. RStickXAxis = 20,
  130046. /** RStickYAxis */
  130047. RStickYAxis = 21
  130048. }
  130049. }
  130050. declare module BABYLON {
  130051. /**
  130052. * This class will take all inputs from Keyboard, Pointer, and
  130053. * any Gamepads and provide a polling system that all devices
  130054. * will use. This class assumes that there will only be one
  130055. * pointer device and one keyboard.
  130056. */
  130057. export class DeviceInputSystem implements IDisposable {
  130058. /**
  130059. * Callback to be triggered when a device is connected
  130060. */
  130061. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130062. /**
  130063. * Callback to be triggered when a device is disconnected
  130064. */
  130065. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130066. /**
  130067. * Callback to be triggered when event driven input is updated
  130068. */
  130069. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130070. private _inputs;
  130071. private _gamepads;
  130072. private _keyboardActive;
  130073. private _pointerActive;
  130074. private _elementToAttachTo;
  130075. private _keyboardDownEvent;
  130076. private _keyboardUpEvent;
  130077. private _pointerMoveEvent;
  130078. private _pointerDownEvent;
  130079. private _pointerUpEvent;
  130080. private _gamepadConnectedEvent;
  130081. private _gamepadDisconnectedEvent;
  130082. private static _MAX_KEYCODES;
  130083. private static _MAX_POINTER_INPUTS;
  130084. private constructor();
  130085. /**
  130086. * Creates a new DeviceInputSystem instance
  130087. * @param engine Engine to pull input element from
  130088. * @returns The new instance
  130089. */
  130090. static Create(engine: Engine): DeviceInputSystem;
  130091. /**
  130092. * Checks for current device input value, given an id and input index
  130093. * @param deviceName Id of connected device
  130094. * @param inputIndex Index of device input
  130095. * @returns Current value of input
  130096. */
  130097. /**
  130098. * Checks for current device input value, given an id and input index
  130099. * @param deviceType Enum specifiying device type
  130100. * @param deviceSlot "Slot" or index that device is referenced in
  130101. * @param inputIndex Id of input to be checked
  130102. * @returns Current value of input
  130103. */
  130104. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130105. /**
  130106. * Dispose of all the eventlisteners
  130107. */
  130108. dispose(): void;
  130109. /**
  130110. * Add device and inputs to device array
  130111. * @param deviceType Enum specifiying device type
  130112. * @param deviceSlot "Slot" or index that device is referenced in
  130113. * @param numberOfInputs Number of input entries to create for given device
  130114. */
  130115. private _registerDevice;
  130116. /**
  130117. * Given a specific device name, remove that device from the device map
  130118. * @param deviceType Enum specifiying device type
  130119. * @param deviceSlot "Slot" or index that device is referenced in
  130120. */
  130121. private _unregisterDevice;
  130122. /**
  130123. * Handle all actions that come from keyboard interaction
  130124. */
  130125. private _handleKeyActions;
  130126. /**
  130127. * Handle all actions that come from pointer interaction
  130128. */
  130129. private _handlePointerActions;
  130130. /**
  130131. * Handle all actions that come from gamepad interaction
  130132. */
  130133. private _handleGamepadActions;
  130134. /**
  130135. * Update all non-event based devices with each frame
  130136. * @param deviceType Enum specifiying device type
  130137. * @param deviceSlot "Slot" or index that device is referenced in
  130138. * @param inputIndex Id of input to be checked
  130139. */
  130140. private _updateDevice;
  130141. /**
  130142. * Gets DeviceType from the device name
  130143. * @param deviceName Name of Device from DeviceInputSystem
  130144. * @returns DeviceType enum value
  130145. */
  130146. private _getGamepadDeviceType;
  130147. }
  130148. }
  130149. declare module BABYLON {
  130150. /**
  130151. * Type to handle enforcement of inputs
  130152. */
  130153. 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;
  130154. }
  130155. declare module BABYLON {
  130156. /**
  130157. * Class that handles all input for a specific device
  130158. */
  130159. export class DeviceSource<T extends DeviceType> {
  130160. /** Type of device */
  130161. readonly deviceType: DeviceType;
  130162. /** "Slot" or index that device is referenced in */
  130163. readonly deviceSlot: number;
  130164. /**
  130165. * Observable to handle device input changes per device
  130166. */
  130167. readonly onInputChangedObservable: Observable<{
  130168. inputIndex: DeviceInput<T>;
  130169. previousState: Nullable<number>;
  130170. currentState: Nullable<number>;
  130171. }>;
  130172. private readonly _deviceInputSystem;
  130173. /**
  130174. * Default Constructor
  130175. * @param deviceInputSystem Reference to DeviceInputSystem
  130176. * @param deviceType Type of device
  130177. * @param deviceSlot "Slot" or index that device is referenced in
  130178. */
  130179. constructor(deviceInputSystem: DeviceInputSystem,
  130180. /** Type of device */
  130181. deviceType: DeviceType,
  130182. /** "Slot" or index that device is referenced in */
  130183. deviceSlot?: number);
  130184. /**
  130185. * Get input for specific input
  130186. * @param inputIndex index of specific input on device
  130187. * @returns Input value from DeviceInputSystem
  130188. */
  130189. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130190. }
  130191. /**
  130192. * Class to keep track of devices
  130193. */
  130194. export class DeviceSourceManager implements IDisposable {
  130195. /**
  130196. * Observable to be triggered when before a device is connected
  130197. */
  130198. readonly onBeforeDeviceConnectedObservable: Observable<{
  130199. deviceType: DeviceType;
  130200. deviceSlot: number;
  130201. }>;
  130202. /**
  130203. * Observable to be triggered when before a device is disconnected
  130204. */
  130205. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130206. deviceType: DeviceType;
  130207. deviceSlot: number;
  130208. }>;
  130209. /**
  130210. * Observable to be triggered when after a device is connected
  130211. */
  130212. readonly onAfterDeviceConnectedObservable: Observable<{
  130213. deviceType: DeviceType;
  130214. deviceSlot: number;
  130215. }>;
  130216. /**
  130217. * Observable to be triggered when after a device is disconnected
  130218. */
  130219. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130220. deviceType: DeviceType;
  130221. deviceSlot: number;
  130222. }>;
  130223. private readonly _devices;
  130224. private readonly _firstDevice;
  130225. private readonly _deviceInputSystem;
  130226. /**
  130227. * Default Constructor
  130228. * @param engine engine to pull input element from
  130229. */
  130230. constructor(engine: Engine);
  130231. /**
  130232. * Gets a DeviceSource, given a type and slot
  130233. * @param deviceType Enum specifying device type
  130234. * @param deviceSlot "Slot" or index that device is referenced in
  130235. * @returns DeviceSource object
  130236. */
  130237. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130238. /**
  130239. * Gets an array of DeviceSource objects for a given device type
  130240. * @param deviceType Enum specifying device type
  130241. * @returns Array of DeviceSource objects
  130242. */
  130243. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130244. /**
  130245. * Dispose of DeviceInputSystem and other parts
  130246. */
  130247. dispose(): void;
  130248. /**
  130249. * Function to add device name to device list
  130250. * @param deviceType Enum specifying device type
  130251. * @param deviceSlot "Slot" or index that device is referenced in
  130252. */
  130253. private _addDevice;
  130254. /**
  130255. * Function to remove device name to device list
  130256. * @param deviceType Enum specifying device type
  130257. * @param deviceSlot "Slot" or index that device is referenced in
  130258. */
  130259. private _removeDevice;
  130260. /**
  130261. * Updates array storing first connected device of each type
  130262. * @param type Type of Device
  130263. */
  130264. private _updateFirstDevices;
  130265. }
  130266. }
  130267. declare module BABYLON {
  130268. /**
  130269. * Options to create the null engine
  130270. */
  130271. export class NullEngineOptions {
  130272. /**
  130273. * Render width (Default: 512)
  130274. */
  130275. renderWidth: number;
  130276. /**
  130277. * Render height (Default: 256)
  130278. */
  130279. renderHeight: number;
  130280. /**
  130281. * Texture size (Default: 512)
  130282. */
  130283. textureSize: number;
  130284. /**
  130285. * If delta time between frames should be constant
  130286. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130287. */
  130288. deterministicLockstep: boolean;
  130289. /**
  130290. * Maximum about of steps between frames (Default: 4)
  130291. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130292. */
  130293. lockstepMaxSteps: number;
  130294. /**
  130295. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130296. */
  130297. useHighPrecisionMatrix?: boolean;
  130298. }
  130299. /**
  130300. * The null engine class provides support for headless version of babylon.js.
  130301. * This can be used in server side scenario or for testing purposes
  130302. */
  130303. export class NullEngine extends Engine {
  130304. private _options;
  130305. /**
  130306. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130308. * @returns true if engine is in deterministic lock step mode
  130309. */
  130310. isDeterministicLockStep(): boolean;
  130311. /**
  130312. * Gets the max steps when engine is running in deterministic lock step
  130313. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130314. * @returns the max steps
  130315. */
  130316. getLockstepMaxSteps(): number;
  130317. /**
  130318. * Gets the current hardware scaling level.
  130319. * By default the hardware scaling level is computed from the window device ratio.
  130320. * 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.
  130321. * @returns a number indicating the current hardware scaling level
  130322. */
  130323. getHardwareScalingLevel(): number;
  130324. constructor(options?: NullEngineOptions);
  130325. /**
  130326. * Creates a vertex buffer
  130327. * @param vertices the data for the vertex buffer
  130328. * @returns the new WebGL static buffer
  130329. */
  130330. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130331. /**
  130332. * Creates a new index buffer
  130333. * @param indices defines the content of the index buffer
  130334. * @param updatable defines if the index buffer must be updatable
  130335. * @returns a new webGL buffer
  130336. */
  130337. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130338. /**
  130339. * Clear the current render buffer or the current render target (if any is set up)
  130340. * @param color defines the color to use
  130341. * @param backBuffer defines if the back buffer must be cleared
  130342. * @param depth defines if the depth buffer must be cleared
  130343. * @param stencil defines if the stencil buffer must be cleared
  130344. */
  130345. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130346. /**
  130347. * Gets the current render width
  130348. * @param useScreen defines if screen size must be used (or the current render target if any)
  130349. * @returns a number defining the current render width
  130350. */
  130351. getRenderWidth(useScreen?: boolean): number;
  130352. /**
  130353. * Gets the current render height
  130354. * @param useScreen defines if screen size must be used (or the current render target if any)
  130355. * @returns a number defining the current render height
  130356. */
  130357. getRenderHeight(useScreen?: boolean): number;
  130358. /**
  130359. * Set the WebGL's viewport
  130360. * @param viewport defines the viewport element to be used
  130361. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130362. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130363. */
  130364. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130365. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130366. /**
  130367. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130368. * @param pipelineContext defines the pipeline context to use
  130369. * @param uniformsNames defines the list of uniform names
  130370. * @returns an array of webGL uniform locations
  130371. */
  130372. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130373. /**
  130374. * Gets the lsit of active attributes for a given webGL program
  130375. * @param pipelineContext defines the pipeline context to use
  130376. * @param attributesNames defines the list of attribute names to get
  130377. * @returns an array of indices indicating the offset of each attribute
  130378. */
  130379. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130380. /**
  130381. * Binds an effect to the webGL context
  130382. * @param effect defines the effect to bind
  130383. */
  130384. bindSamplers(effect: Effect): void;
  130385. /**
  130386. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130387. * @param effect defines the effect to activate
  130388. */
  130389. enableEffect(effect: Effect): void;
  130390. /**
  130391. * Set various states to the webGL context
  130392. * @param culling defines backface culling state
  130393. * @param zOffset defines the value to apply to zOffset (0 by default)
  130394. * @param force defines if states must be applied even if cache is up to date
  130395. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130396. */
  130397. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130398. /**
  130399. * Set the value of an uniform to an array of int32
  130400. * @param uniform defines the webGL uniform location where to store the value
  130401. * @param array defines the array of int32 to store
  130402. */
  130403. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130404. /**
  130405. * Set the value of an uniform to an array of int32 (stored as vec2)
  130406. * @param uniform defines the webGL uniform location where to store the value
  130407. * @param array defines the array of int32 to store
  130408. */
  130409. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130410. /**
  130411. * Set the value of an uniform to an array of int32 (stored as vec3)
  130412. * @param uniform defines the webGL uniform location where to store the value
  130413. * @param array defines the array of int32 to store
  130414. */
  130415. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130416. /**
  130417. * Set the value of an uniform to an array of int32 (stored as vec4)
  130418. * @param uniform defines the webGL uniform location where to store the value
  130419. * @param array defines the array of int32 to store
  130420. */
  130421. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130422. /**
  130423. * Set the value of an uniform to an array of float32
  130424. * @param uniform defines the webGL uniform location where to store the value
  130425. * @param array defines the array of float32 to store
  130426. */
  130427. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130428. /**
  130429. * Set the value of an uniform to an array of float32 (stored as vec2)
  130430. * @param uniform defines the webGL uniform location where to store the value
  130431. * @param array defines the array of float32 to store
  130432. */
  130433. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130434. /**
  130435. * Set the value of an uniform to an array of float32 (stored as vec3)
  130436. * @param uniform defines the webGL uniform location where to store the value
  130437. * @param array defines the array of float32 to store
  130438. */
  130439. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130440. /**
  130441. * Set the value of an uniform to an array of float32 (stored as vec4)
  130442. * @param uniform defines the webGL uniform location where to store the value
  130443. * @param array defines the array of float32 to store
  130444. */
  130445. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130446. /**
  130447. * Set the value of an uniform to an array of number
  130448. * @param uniform defines the webGL uniform location where to store the value
  130449. * @param array defines the array of number to store
  130450. */
  130451. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130452. /**
  130453. * Set the value of an uniform to an array of number (stored as vec2)
  130454. * @param uniform defines the webGL uniform location where to store the value
  130455. * @param array defines the array of number to store
  130456. */
  130457. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130458. /**
  130459. * Set the value of an uniform to an array of number (stored as vec3)
  130460. * @param uniform defines the webGL uniform location where to store the value
  130461. * @param array defines the array of number to store
  130462. */
  130463. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130464. /**
  130465. * Set the value of an uniform to an array of number (stored as vec4)
  130466. * @param uniform defines the webGL uniform location where to store the value
  130467. * @param array defines the array of number to store
  130468. */
  130469. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130470. /**
  130471. * Set the value of an uniform to an array of float32 (stored as matrices)
  130472. * @param uniform defines the webGL uniform location where to store the value
  130473. * @param matrices defines the array of float32 to store
  130474. */
  130475. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130476. /**
  130477. * Set the value of an uniform to a matrix (3x3)
  130478. * @param uniform defines the webGL uniform location where to store the value
  130479. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130480. */
  130481. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130482. /**
  130483. * Set the value of an uniform to a matrix (2x2)
  130484. * @param uniform defines the webGL uniform location where to store the value
  130485. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130486. */
  130487. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130488. /**
  130489. * Set the value of an uniform to a number (float)
  130490. * @param uniform defines the webGL uniform location where to store the value
  130491. * @param value defines the float number to store
  130492. */
  130493. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130494. /**
  130495. * Set the value of an uniform to a vec2
  130496. * @param uniform defines the webGL uniform location where to store the value
  130497. * @param x defines the 1st component of the value
  130498. * @param y defines the 2nd component of the value
  130499. */
  130500. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130501. /**
  130502. * Set the value of an uniform to a vec3
  130503. * @param uniform defines the webGL uniform location where to store the value
  130504. * @param x defines the 1st component of the value
  130505. * @param y defines the 2nd component of the value
  130506. * @param z defines the 3rd component of the value
  130507. */
  130508. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130509. /**
  130510. * Set the value of an uniform to a boolean
  130511. * @param uniform defines the webGL uniform location where to store the value
  130512. * @param bool defines the boolean to store
  130513. */
  130514. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130515. /**
  130516. * Set the value of an uniform to a vec4
  130517. * @param uniform defines the webGL uniform location where to store the value
  130518. * @param x defines the 1st component of the value
  130519. * @param y defines the 2nd component of the value
  130520. * @param z defines the 3rd component of the value
  130521. * @param w defines the 4th component of the value
  130522. */
  130523. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130524. /**
  130525. * Sets the current alpha mode
  130526. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130527. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130528. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130529. */
  130530. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130531. /**
  130532. * Bind webGl buffers directly to the webGL context
  130533. * @param vertexBuffers defines the vertex buffer to bind
  130534. * @param indexBuffer defines the index buffer to bind
  130535. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130536. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130537. * @param effect defines the effect associated with the vertex buffer
  130538. */
  130539. bindBuffers(vertexBuffers: {
  130540. [key: string]: VertexBuffer;
  130541. }, indexBuffer: DataBuffer, effect: Effect): void;
  130542. /**
  130543. * Force the entire cache to be cleared
  130544. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130545. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130546. */
  130547. wipeCaches(bruteForce?: boolean): void;
  130548. /**
  130549. * Send a draw order
  130550. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130551. * @param indexStart defines the starting index
  130552. * @param indexCount defines the number of index to draw
  130553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130554. */
  130555. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130556. /**
  130557. * Draw a list of indexed primitives
  130558. * @param fillMode defines the primitive to use
  130559. * @param indexStart defines the starting index
  130560. * @param indexCount defines the number of index to draw
  130561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130562. */
  130563. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130564. /**
  130565. * Draw a list of unindexed primitives
  130566. * @param fillMode defines the primitive to use
  130567. * @param verticesStart defines the index of first vertex to draw
  130568. * @param verticesCount defines the count of vertices to draw
  130569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130570. */
  130571. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130572. /** @hidden */
  130573. _createTexture(): WebGLTexture;
  130574. /** @hidden */
  130575. _releaseTexture(texture: InternalTexture): void;
  130576. /**
  130577. * Usually called from Texture.ts.
  130578. * Passed information to create a WebGLTexture
  130579. * @param urlArg defines a value which contains one of the following:
  130580. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130581. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130582. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130583. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130584. * @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)
  130585. * @param scene needed for loading to the correct scene
  130586. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130587. * @param onLoad optional callback to be called upon successful completion
  130588. * @param onError optional callback to be called upon failure
  130589. * @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
  130590. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130591. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130592. * @param forcedExtension defines the extension to use to pick the right loader
  130593. * @param mimeType defines an optional mime type
  130594. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130595. */
  130596. 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;
  130597. /**
  130598. * Creates a new render target texture
  130599. * @param size defines the size of the texture
  130600. * @param options defines the options used to create the texture
  130601. * @returns a new render target texture stored in an InternalTexture
  130602. */
  130603. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130604. /**
  130605. * Update the sampling mode of a given texture
  130606. * @param samplingMode defines the required sampling mode
  130607. * @param texture defines the texture to update
  130608. */
  130609. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130610. /**
  130611. * Binds the frame buffer to the specified texture.
  130612. * @param texture The texture to render to or null for the default canvas
  130613. * @param faceIndex The face of the texture to render to in case of cube texture
  130614. * @param requiredWidth The width of the target to render to
  130615. * @param requiredHeight The height of the target to render to
  130616. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130617. * @param lodLevel defines le lod level to bind to the frame buffer
  130618. */
  130619. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130620. /**
  130621. * Unbind the current render target texture from the webGL context
  130622. * @param texture defines the render target texture to unbind
  130623. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130624. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130625. */
  130626. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130627. /**
  130628. * Creates a dynamic vertex buffer
  130629. * @param vertices the data for the dynamic vertex buffer
  130630. * @returns the new WebGL dynamic buffer
  130631. */
  130632. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130633. /**
  130634. * Update the content of a dynamic texture
  130635. * @param texture defines the texture to update
  130636. * @param canvas defines the canvas containing the source
  130637. * @param invertY defines if data must be stored with Y axis inverted
  130638. * @param premulAlpha defines if alpha is stored as premultiplied
  130639. * @param format defines the format of the data
  130640. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130641. */
  130642. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130643. /**
  130644. * Gets a boolean indicating if all created effects are ready
  130645. * @returns true if all effects are ready
  130646. */
  130647. areAllEffectsReady(): boolean;
  130648. /**
  130649. * @hidden
  130650. * Get the current error code of the webGL context
  130651. * @returns the error code
  130652. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130653. */
  130654. getError(): number;
  130655. /** @hidden */
  130656. _getUnpackAlignement(): number;
  130657. /** @hidden */
  130658. _unpackFlipY(value: boolean): void;
  130659. /**
  130660. * Update a dynamic index buffer
  130661. * @param indexBuffer defines the target index buffer
  130662. * @param indices defines the data to update
  130663. * @param offset defines the offset in the target index buffer where update should start
  130664. */
  130665. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130666. /**
  130667. * Updates a dynamic vertex buffer.
  130668. * @param vertexBuffer the vertex buffer to update
  130669. * @param vertices the data used to update the vertex buffer
  130670. * @param byteOffset the byte offset of the data (optional)
  130671. * @param byteLength the byte length of the data (optional)
  130672. */
  130673. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130674. /** @hidden */
  130675. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130676. /** @hidden */
  130677. _bindTexture(channel: number, texture: InternalTexture): void;
  130678. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130679. /**
  130680. * 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
  130681. */
  130682. releaseEffects(): void;
  130683. displayLoadingUI(): void;
  130684. hideLoadingUI(): void;
  130685. /** @hidden */
  130686. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130687. /** @hidden */
  130688. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130689. /** @hidden */
  130690. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130691. /** @hidden */
  130692. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130693. }
  130694. }
  130695. declare module BABYLON {
  130696. /**
  130697. * @hidden
  130698. **/
  130699. export class _TimeToken {
  130700. _startTimeQuery: Nullable<WebGLQuery>;
  130701. _endTimeQuery: Nullable<WebGLQuery>;
  130702. _timeElapsedQuery: Nullable<WebGLQuery>;
  130703. _timeElapsedQueryEnded: boolean;
  130704. }
  130705. }
  130706. declare module BABYLON {
  130707. /** @hidden */
  130708. export class _OcclusionDataStorage {
  130709. /** @hidden */
  130710. occlusionInternalRetryCounter: number;
  130711. /** @hidden */
  130712. isOcclusionQueryInProgress: boolean;
  130713. /** @hidden */
  130714. isOccluded: boolean;
  130715. /** @hidden */
  130716. occlusionRetryCount: number;
  130717. /** @hidden */
  130718. occlusionType: number;
  130719. /** @hidden */
  130720. occlusionQueryAlgorithmType: number;
  130721. }
  130722. interface Engine {
  130723. /**
  130724. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130725. * @return the new query
  130726. */
  130727. createQuery(): WebGLQuery;
  130728. /**
  130729. * Delete and release a webGL query
  130730. * @param query defines the query to delete
  130731. * @return the current engine
  130732. */
  130733. deleteQuery(query: WebGLQuery): Engine;
  130734. /**
  130735. * Check if a given query has resolved and got its value
  130736. * @param query defines the query to check
  130737. * @returns true if the query got its value
  130738. */
  130739. isQueryResultAvailable(query: WebGLQuery): boolean;
  130740. /**
  130741. * Gets the value of a given query
  130742. * @param query defines the query to check
  130743. * @returns the value of the query
  130744. */
  130745. getQueryResult(query: WebGLQuery): number;
  130746. /**
  130747. * Initiates an occlusion query
  130748. * @param algorithmType defines the algorithm to use
  130749. * @param query defines the query to use
  130750. * @returns the current engine
  130751. * @see https://doc.babylonjs.com/features/occlusionquery
  130752. */
  130753. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130754. /**
  130755. * Ends an occlusion query
  130756. * @see https://doc.babylonjs.com/features/occlusionquery
  130757. * @param algorithmType defines the algorithm to use
  130758. * @returns the current engine
  130759. */
  130760. endOcclusionQuery(algorithmType: number): Engine;
  130761. /**
  130762. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130763. * Please note that only one query can be issued at a time
  130764. * @returns a time token used to track the time span
  130765. */
  130766. startTimeQuery(): Nullable<_TimeToken>;
  130767. /**
  130768. * Ends a time query
  130769. * @param token defines the token used to measure the time span
  130770. * @returns the time spent (in ns)
  130771. */
  130772. endTimeQuery(token: _TimeToken): int;
  130773. /** @hidden */
  130774. _currentNonTimestampToken: Nullable<_TimeToken>;
  130775. /** @hidden */
  130776. _createTimeQuery(): WebGLQuery;
  130777. /** @hidden */
  130778. _deleteTimeQuery(query: WebGLQuery): void;
  130779. /** @hidden */
  130780. _getGlAlgorithmType(algorithmType: number): number;
  130781. /** @hidden */
  130782. _getTimeQueryResult(query: WebGLQuery): any;
  130783. /** @hidden */
  130784. _getTimeQueryAvailability(query: WebGLQuery): any;
  130785. }
  130786. interface AbstractMesh {
  130787. /**
  130788. * Backing filed
  130789. * @hidden
  130790. */
  130791. __occlusionDataStorage: _OcclusionDataStorage;
  130792. /**
  130793. * Access property
  130794. * @hidden
  130795. */
  130796. _occlusionDataStorage: _OcclusionDataStorage;
  130797. /**
  130798. * 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.
  130799. * The default value is -1 which means don't break the query and wait till the result
  130800. * @see https://doc.babylonjs.com/features/occlusionquery
  130801. */
  130802. occlusionRetryCount: number;
  130803. /**
  130804. * 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:
  130805. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  130806. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  130807. * * 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.
  130808. * @see https://doc.babylonjs.com/features/occlusionquery
  130809. */
  130810. occlusionType: number;
  130811. /**
  130812. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  130813. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  130814. * * 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.
  130815. * @see https://doc.babylonjs.com/features/occlusionquery
  130816. */
  130817. occlusionQueryAlgorithmType: number;
  130818. /**
  130819. * 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
  130820. * @see https://doc.babylonjs.com/features/occlusionquery
  130821. */
  130822. isOccluded: boolean;
  130823. /**
  130824. * Flag to check the progress status of the query
  130825. * @see https://doc.babylonjs.com/features/occlusionquery
  130826. */
  130827. isOcclusionQueryInProgress: boolean;
  130828. }
  130829. }
  130830. declare module BABYLON {
  130831. /** @hidden */
  130832. export var _forceTransformFeedbackToBundle: boolean;
  130833. interface Engine {
  130834. /**
  130835. * Creates a webGL transform feedback object
  130836. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  130837. * @returns the webGL transform feedback object
  130838. */
  130839. createTransformFeedback(): WebGLTransformFeedback;
  130840. /**
  130841. * Delete a webGL transform feedback object
  130842. * @param value defines the webGL transform feedback object to delete
  130843. */
  130844. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  130845. /**
  130846. * Bind a webGL transform feedback object to the webgl context
  130847. * @param value defines the webGL transform feedback object to bind
  130848. */
  130849. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  130850. /**
  130851. * Begins a transform feedback operation
  130852. * @param usePoints defines if points or triangles must be used
  130853. */
  130854. beginTransformFeedback(usePoints: boolean): void;
  130855. /**
  130856. * Ends a transform feedback operation
  130857. */
  130858. endTransformFeedback(): void;
  130859. /**
  130860. * Specify the varyings to use with transform feedback
  130861. * @param program defines the associated webGL program
  130862. * @param value defines the list of strings representing the varying names
  130863. */
  130864. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  130865. /**
  130866. * Bind a webGL buffer for a transform feedback operation
  130867. * @param value defines the webGL buffer to bind
  130868. */
  130869. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  130870. }
  130871. }
  130872. declare module BABYLON {
  130873. /**
  130874. * Class used to define an additional view for the engine
  130875. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130876. */
  130877. export class EngineView {
  130878. /** Defines the canvas where to render the view */
  130879. target: HTMLCanvasElement;
  130880. /** Defines an optional camera used to render the view (will use active camera else) */
  130881. camera?: Camera;
  130882. }
  130883. interface Engine {
  130884. /**
  130885. * Gets or sets the HTML element to use for attaching events
  130886. */
  130887. inputElement: Nullable<HTMLElement>;
  130888. /**
  130889. * Gets the current engine view
  130890. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130891. */
  130892. activeView: Nullable<EngineView>;
  130893. /** Gets or sets the list of views */
  130894. views: EngineView[];
  130895. /**
  130896. * Register a new child canvas
  130897. * @param canvas defines the canvas to register
  130898. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  130899. * @returns the associated view
  130900. */
  130901. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  130902. /**
  130903. * Remove a registered child canvas
  130904. * @param canvas defines the canvas to remove
  130905. * @returns the current engine
  130906. */
  130907. unRegisterView(canvas: HTMLCanvasElement): Engine;
  130908. }
  130909. }
  130910. declare module BABYLON {
  130911. interface Engine {
  130912. /** @hidden */
  130913. _excludedCompressedTextures: string[];
  130914. /** @hidden */
  130915. _textureFormatInUse: string;
  130916. /**
  130917. * Gets the list of texture formats supported
  130918. */
  130919. readonly texturesSupported: Array<string>;
  130920. /**
  130921. * Gets the texture format in use
  130922. */
  130923. readonly textureFormatInUse: Nullable<string>;
  130924. /**
  130925. * Set the compressed texture extensions or file names to skip.
  130926. *
  130927. * @param skippedFiles defines the list of those texture files you want to skip
  130928. * Example: [".dds", ".env", "myfile.png"]
  130929. */
  130930. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  130931. /**
  130932. * Set the compressed texture format to use, based on the formats you have, and the formats
  130933. * supported by the hardware / browser.
  130934. *
  130935. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  130936. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  130937. * to API arguments needed to compressed textures. This puts the burden on the container
  130938. * generator to house the arcane code for determining these for current & future formats.
  130939. *
  130940. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  130941. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  130942. *
  130943. * Note: The result of this call is not taken into account when a texture is base64.
  130944. *
  130945. * @param formatsAvailable defines the list of those format families you have created
  130946. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  130947. *
  130948. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  130949. * @returns The extension selected.
  130950. */
  130951. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  130952. }
  130953. }
  130954. declare module BABYLON {
  130955. /**
  130956. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  130957. */
  130958. export interface CubeMapInfo {
  130959. /**
  130960. * The pixel array for the front face.
  130961. * This is stored in format, left to right, up to down format.
  130962. */
  130963. front: Nullable<ArrayBufferView>;
  130964. /**
  130965. * The pixel array for the back face.
  130966. * This is stored in format, left to right, up to down format.
  130967. */
  130968. back: Nullable<ArrayBufferView>;
  130969. /**
  130970. * The pixel array for the left face.
  130971. * This is stored in format, left to right, up to down format.
  130972. */
  130973. left: Nullable<ArrayBufferView>;
  130974. /**
  130975. * The pixel array for the right face.
  130976. * This is stored in format, left to right, up to down format.
  130977. */
  130978. right: Nullable<ArrayBufferView>;
  130979. /**
  130980. * The pixel array for the up face.
  130981. * This is stored in format, left to right, up to down format.
  130982. */
  130983. up: Nullable<ArrayBufferView>;
  130984. /**
  130985. * The pixel array for the down face.
  130986. * This is stored in format, left to right, up to down format.
  130987. */
  130988. down: Nullable<ArrayBufferView>;
  130989. /**
  130990. * The size of the cubemap stored.
  130991. *
  130992. * Each faces will be size * size pixels.
  130993. */
  130994. size: number;
  130995. /**
  130996. * The format of the texture.
  130997. *
  130998. * RGBA, RGB.
  130999. */
  131000. format: number;
  131001. /**
  131002. * The type of the texture data.
  131003. *
  131004. * UNSIGNED_INT, FLOAT.
  131005. */
  131006. type: number;
  131007. /**
  131008. * Specifies whether the texture is in gamma space.
  131009. */
  131010. gammaSpace: boolean;
  131011. }
  131012. /**
  131013. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131014. */
  131015. export class PanoramaToCubeMapTools {
  131016. private static FACE_LEFT;
  131017. private static FACE_RIGHT;
  131018. private static FACE_FRONT;
  131019. private static FACE_BACK;
  131020. private static FACE_DOWN;
  131021. private static FACE_UP;
  131022. /**
  131023. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131024. *
  131025. * @param float32Array The source data.
  131026. * @param inputWidth The width of the input panorama.
  131027. * @param inputHeight The height of the input panorama.
  131028. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131029. * @return The cubemap data
  131030. */
  131031. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131032. private static CreateCubemapTexture;
  131033. private static CalcProjectionSpherical;
  131034. }
  131035. }
  131036. declare module BABYLON {
  131037. /**
  131038. * Helper class dealing with the extraction of spherical polynomial dataArray
  131039. * from a cube map.
  131040. */
  131041. export class CubeMapToSphericalPolynomialTools {
  131042. private static FileFaces;
  131043. /**
  131044. * Converts a texture to the according Spherical Polynomial data.
  131045. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131046. *
  131047. * @param texture The texture to extract the information from.
  131048. * @return The Spherical Polynomial data.
  131049. */
  131050. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131051. /**
  131052. * Converts a cubemap to the according Spherical Polynomial data.
  131053. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131054. *
  131055. * @param cubeInfo The Cube map to extract the information from.
  131056. * @return The Spherical Polynomial data.
  131057. */
  131058. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131059. }
  131060. }
  131061. declare module BABYLON {
  131062. interface BaseTexture {
  131063. /**
  131064. * Get the polynomial representation of the texture data.
  131065. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131066. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131067. */
  131068. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131069. }
  131070. }
  131071. declare module BABYLON {
  131072. /** @hidden */
  131073. export var rgbdEncodePixelShader: {
  131074. name: string;
  131075. shader: string;
  131076. };
  131077. }
  131078. declare module BABYLON {
  131079. /** @hidden */
  131080. export var rgbdDecodePixelShader: {
  131081. name: string;
  131082. shader: string;
  131083. };
  131084. }
  131085. declare module BABYLON {
  131086. /**
  131087. * Raw texture data and descriptor sufficient for WebGL texture upload
  131088. */
  131089. export interface EnvironmentTextureInfo {
  131090. /**
  131091. * Version of the environment map
  131092. */
  131093. version: number;
  131094. /**
  131095. * Width of image
  131096. */
  131097. width: number;
  131098. /**
  131099. * Irradiance information stored in the file.
  131100. */
  131101. irradiance: any;
  131102. /**
  131103. * Specular information stored in the file.
  131104. */
  131105. specular: any;
  131106. }
  131107. /**
  131108. * Defines One Image in the file. It requires only the position in the file
  131109. * as well as the length.
  131110. */
  131111. interface BufferImageData {
  131112. /**
  131113. * Length of the image data.
  131114. */
  131115. length: number;
  131116. /**
  131117. * Position of the data from the null terminator delimiting the end of the JSON.
  131118. */
  131119. position: number;
  131120. }
  131121. /**
  131122. * Defines the specular data enclosed in the file.
  131123. * This corresponds to the version 1 of the data.
  131124. */
  131125. export interface EnvironmentTextureSpecularInfoV1 {
  131126. /**
  131127. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131128. */
  131129. specularDataPosition?: number;
  131130. /**
  131131. * This contains all the images data needed to reconstruct the cubemap.
  131132. */
  131133. mipmaps: Array<BufferImageData>;
  131134. /**
  131135. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131136. */
  131137. lodGenerationScale: number;
  131138. }
  131139. /**
  131140. * Sets of helpers addressing the serialization and deserialization of environment texture
  131141. * stored in a BabylonJS env file.
  131142. * Those files are usually stored as .env files.
  131143. */
  131144. export class EnvironmentTextureTools {
  131145. /**
  131146. * Magic number identifying the env file.
  131147. */
  131148. private static _MagicBytes;
  131149. /**
  131150. * Gets the environment info from an env file.
  131151. * @param data The array buffer containing the .env bytes.
  131152. * @returns the environment file info (the json header) if successfully parsed.
  131153. */
  131154. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131155. /**
  131156. * Creates an environment texture from a loaded cube texture.
  131157. * @param texture defines the cube texture to convert in env file
  131158. * @return a promise containing the environment data if succesfull.
  131159. */
  131160. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131161. /**
  131162. * Creates a JSON representation of the spherical data.
  131163. * @param texture defines the texture containing the polynomials
  131164. * @return the JSON representation of the spherical info
  131165. */
  131166. private static _CreateEnvTextureIrradiance;
  131167. /**
  131168. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131169. * @param data the image data
  131170. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131171. * @return the views described by info providing access to the underlying buffer
  131172. */
  131173. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131174. /**
  131175. * Uploads the texture info contained in the env file to the GPU.
  131176. * @param texture defines the internal texture to upload to
  131177. * @param data defines the data to load
  131178. * @param info defines the texture info retrieved through the GetEnvInfo method
  131179. * @returns a promise
  131180. */
  131181. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131182. private static _OnImageReadyAsync;
  131183. /**
  131184. * Uploads the levels of image data to the GPU.
  131185. * @param texture defines the internal texture to upload to
  131186. * @param imageData defines the array buffer views of image data [mipmap][face]
  131187. * @returns a promise
  131188. */
  131189. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131190. /**
  131191. * Uploads spherical polynomials information to the texture.
  131192. * @param texture defines the texture we are trying to upload the information to
  131193. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131194. */
  131195. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131196. /** @hidden */
  131197. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131198. }
  131199. }
  131200. declare module BABYLON {
  131201. /**
  131202. * Class used to inline functions in shader code
  131203. */
  131204. export class ShaderCodeInliner {
  131205. private static readonly _RegexpFindFunctionNameAndType;
  131206. private _sourceCode;
  131207. private _functionDescr;
  131208. private _numMaxIterations;
  131209. /** Gets or sets the token used to mark the functions to inline */
  131210. inlineToken: string;
  131211. /** Gets or sets the debug mode */
  131212. debug: boolean;
  131213. /** Gets the code after the inlining process */
  131214. get code(): string;
  131215. /**
  131216. * Initializes the inliner
  131217. * @param sourceCode shader code source to inline
  131218. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131219. */
  131220. constructor(sourceCode: string, numMaxIterations?: number);
  131221. /**
  131222. * Start the processing of the shader code
  131223. */
  131224. processCode(): void;
  131225. private _collectFunctions;
  131226. private _processInlining;
  131227. private _extractBetweenMarkers;
  131228. private _skipWhitespaces;
  131229. private _removeComments;
  131230. private _replaceFunctionCallsByCode;
  131231. private _findBackward;
  131232. private _escapeRegExp;
  131233. private _replaceNames;
  131234. }
  131235. }
  131236. declare module BABYLON {
  131237. /**
  131238. * Container for accessors for natively-stored mesh data buffers.
  131239. */
  131240. class NativeDataBuffer extends DataBuffer {
  131241. /**
  131242. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131243. */
  131244. nativeIndexBuffer?: any;
  131245. /**
  131246. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131247. */
  131248. nativeVertexBuffer?: any;
  131249. }
  131250. /** @hidden */
  131251. class NativeTexture extends InternalTexture {
  131252. getInternalTexture(): InternalTexture;
  131253. getViewCount(): number;
  131254. }
  131255. /** @hidden */
  131256. export class NativeEngine extends Engine {
  131257. private readonly _native;
  131258. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131259. private readonly INVALID_HANDLE;
  131260. getHardwareScalingLevel(): number;
  131261. constructor();
  131262. dispose(): void;
  131263. /**
  131264. * Can be used to override the current requestAnimationFrame requester.
  131265. * @hidden
  131266. */
  131267. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131268. /**
  131269. * Override default engine behavior.
  131270. * @param color
  131271. * @param backBuffer
  131272. * @param depth
  131273. * @param stencil
  131274. */
  131275. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131276. /**
  131277. * Gets host document
  131278. * @returns the host document object
  131279. */
  131280. getHostDocument(): Nullable<Document>;
  131281. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131282. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131283. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131284. recordVertexArrayObject(vertexBuffers: {
  131285. [key: string]: VertexBuffer;
  131286. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131287. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131288. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131289. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131290. /**
  131291. * Draw a list of indexed primitives
  131292. * @param fillMode defines the primitive to use
  131293. * @param indexStart defines the starting index
  131294. * @param indexCount defines the number of index to draw
  131295. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131296. */
  131297. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131298. /**
  131299. * Draw a list of unindexed primitives
  131300. * @param fillMode defines the primitive to use
  131301. * @param verticesStart defines the index of first vertex to draw
  131302. * @param verticesCount defines the count of vertices to draw
  131303. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131304. */
  131305. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131306. createPipelineContext(): IPipelineContext;
  131307. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131308. /** @hidden */
  131309. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131310. /** @hidden */
  131311. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131312. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131313. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131314. protected _setProgram(program: WebGLProgram): void;
  131315. _releaseEffect(effect: Effect): void;
  131316. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131317. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131318. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131319. bindSamplers(effect: Effect): void;
  131320. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131321. getRenderWidth(useScreen?: boolean): number;
  131322. getRenderHeight(useScreen?: boolean): number;
  131323. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131324. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131325. /**
  131326. * Set the z offset to apply to current rendering
  131327. * @param value defines the offset to apply
  131328. */
  131329. setZOffset(value: number): void;
  131330. /**
  131331. * Gets the current value of the zOffset
  131332. * @returns the current zOffset state
  131333. */
  131334. getZOffset(): number;
  131335. /**
  131336. * Enable or disable depth buffering
  131337. * @param enable defines the state to set
  131338. */
  131339. setDepthBuffer(enable: boolean): void;
  131340. /**
  131341. * Gets a boolean indicating if depth writing is enabled
  131342. * @returns the current depth writing state
  131343. */
  131344. getDepthWrite(): boolean;
  131345. /**
  131346. * Enable or disable depth writing
  131347. * @param enable defines the state to set
  131348. */
  131349. setDepthWrite(enable: boolean): void;
  131350. /**
  131351. * Enable or disable color writing
  131352. * @param enable defines the state to set
  131353. */
  131354. setColorWrite(enable: boolean): void;
  131355. /**
  131356. * Gets a boolean indicating if color writing is enabled
  131357. * @returns the current color writing state
  131358. */
  131359. getColorWrite(): boolean;
  131360. /**
  131361. * Sets alpha constants used by some alpha blending modes
  131362. * @param r defines the red component
  131363. * @param g defines the green component
  131364. * @param b defines the blue component
  131365. * @param a defines the alpha component
  131366. */
  131367. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131368. /**
  131369. * Sets the current alpha mode
  131370. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131371. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131372. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131373. */
  131374. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131375. /**
  131376. * Gets the current alpha mode
  131377. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131378. * @returns the current alpha mode
  131379. */
  131380. getAlphaMode(): number;
  131381. setInt(uniform: WebGLUniformLocation, int: number): void;
  131382. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131383. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131384. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131385. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131386. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131387. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131388. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131389. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131390. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131391. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131392. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131393. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131394. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131395. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131396. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131397. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131398. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131399. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131400. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131401. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131402. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131403. wipeCaches(bruteForce?: boolean): void;
  131404. _createTexture(): WebGLTexture;
  131405. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131406. /**
  131407. * Usually called from Texture.ts.
  131408. * Passed information to create a WebGLTexture
  131409. * @param url defines a value which contains one of the following:
  131410. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131411. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131412. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131413. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131414. * @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)
  131415. * @param scene needed for loading to the correct scene
  131416. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131417. * @param onLoad optional callback to be called upon successful completion
  131418. * @param onError optional callback to be called upon failure
  131419. * @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
  131420. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131421. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131422. * @param forcedExtension defines the extension to use to pick the right loader
  131423. * @param mimeType defines an optional mime type
  131424. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131425. */
  131426. 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;
  131427. /**
  131428. * Creates a cube texture
  131429. * @param rootUrl defines the url where the files to load is located
  131430. * @param scene defines the current scene
  131431. * @param files defines the list of files to load (1 per face)
  131432. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131433. * @param onLoad defines an optional callback raised when the texture is loaded
  131434. * @param onError defines an optional callback raised if there is an issue to load the texture
  131435. * @param format defines the format of the data
  131436. * @param forcedExtension defines the extension to use to pick the right loader
  131437. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131438. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131439. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131440. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131441. * @returns the cube texture as an InternalTexture
  131442. */
  131443. 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;
  131444. private _getSamplingFilter;
  131445. private static _GetNativeTextureFormat;
  131446. createRenderTargetTexture(size: number | {
  131447. width: number;
  131448. height: number;
  131449. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131450. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131451. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131452. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131453. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131454. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131455. /**
  131456. * Updates a dynamic vertex buffer.
  131457. * @param vertexBuffer the vertex buffer to update
  131458. * @param data the data used to update the vertex buffer
  131459. * @param byteOffset the byte offset of the data (optional)
  131460. * @param byteLength the byte length of the data (optional)
  131461. */
  131462. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131463. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131464. private _updateAnisotropicLevel;
  131465. private _getAddressMode;
  131466. /** @hidden */
  131467. _bindTexture(channel: number, texture: InternalTexture): void;
  131468. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131469. releaseEffects(): void;
  131470. /** @hidden */
  131471. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131472. /** @hidden */
  131473. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131474. /** @hidden */
  131475. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131476. /** @hidden */
  131477. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131478. }
  131479. }
  131480. declare module BABYLON {
  131481. /**
  131482. * Gather the list of clipboard event types as constants.
  131483. */
  131484. export class ClipboardEventTypes {
  131485. /**
  131486. * The clipboard event is fired when a copy command is active (pressed).
  131487. */
  131488. static readonly COPY: number;
  131489. /**
  131490. * The clipboard event is fired when a cut command is active (pressed).
  131491. */
  131492. static readonly CUT: number;
  131493. /**
  131494. * The clipboard event is fired when a paste command is active (pressed).
  131495. */
  131496. static readonly PASTE: number;
  131497. }
  131498. /**
  131499. * This class is used to store clipboard related info for the onClipboardObservable event.
  131500. */
  131501. export class ClipboardInfo {
  131502. /**
  131503. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131504. */
  131505. type: number;
  131506. /**
  131507. * Defines the related dom event
  131508. */
  131509. event: ClipboardEvent;
  131510. /**
  131511. *Creates an instance of ClipboardInfo.
  131512. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131513. * @param event Defines the related dom event
  131514. */
  131515. constructor(
  131516. /**
  131517. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131518. */
  131519. type: number,
  131520. /**
  131521. * Defines the related dom event
  131522. */
  131523. event: ClipboardEvent);
  131524. /**
  131525. * Get the clipboard event's type from the keycode.
  131526. * @param keyCode Defines the keyCode for the current keyboard event.
  131527. * @return {number}
  131528. */
  131529. static GetTypeFromCharacter(keyCode: number): number;
  131530. }
  131531. }
  131532. declare module BABYLON {
  131533. /**
  131534. * Google Daydream controller
  131535. */
  131536. export class DaydreamController extends WebVRController {
  131537. /**
  131538. * Base Url for the controller model.
  131539. */
  131540. static MODEL_BASE_URL: string;
  131541. /**
  131542. * File name for the controller model.
  131543. */
  131544. static MODEL_FILENAME: string;
  131545. /**
  131546. * Gamepad Id prefix used to identify Daydream Controller.
  131547. */
  131548. static readonly GAMEPAD_ID_PREFIX: string;
  131549. /**
  131550. * Creates a new DaydreamController from a gamepad
  131551. * @param vrGamepad the gamepad that the controller should be created from
  131552. */
  131553. constructor(vrGamepad: any);
  131554. /**
  131555. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131556. * @param scene scene in which to add meshes
  131557. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131558. */
  131559. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131560. /**
  131561. * Called once for each button that changed state since the last frame
  131562. * @param buttonIdx Which button index changed
  131563. * @param state New state of the button
  131564. * @param changes Which properties on the state changed since last frame
  131565. */
  131566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131567. }
  131568. }
  131569. declare module BABYLON {
  131570. /**
  131571. * Gear VR Controller
  131572. */
  131573. export class GearVRController extends WebVRController {
  131574. /**
  131575. * Base Url for the controller model.
  131576. */
  131577. static MODEL_BASE_URL: string;
  131578. /**
  131579. * File name for the controller model.
  131580. */
  131581. static MODEL_FILENAME: string;
  131582. /**
  131583. * Gamepad Id prefix used to identify this controller.
  131584. */
  131585. static readonly GAMEPAD_ID_PREFIX: string;
  131586. private readonly _buttonIndexToObservableNameMap;
  131587. /**
  131588. * Creates a new GearVRController from a gamepad
  131589. * @param vrGamepad the gamepad that the controller should be created from
  131590. */
  131591. constructor(vrGamepad: any);
  131592. /**
  131593. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131594. * @param scene scene in which to add meshes
  131595. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131596. */
  131597. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131598. /**
  131599. * Called once for each button that changed state since the last frame
  131600. * @param buttonIdx Which button index changed
  131601. * @param state New state of the button
  131602. * @param changes Which properties on the state changed since last frame
  131603. */
  131604. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131605. }
  131606. }
  131607. declare module BABYLON {
  131608. /**
  131609. * Generic Controller
  131610. */
  131611. export class GenericController extends WebVRController {
  131612. /**
  131613. * Base Url for the controller model.
  131614. */
  131615. static readonly MODEL_BASE_URL: string;
  131616. /**
  131617. * File name for the controller model.
  131618. */
  131619. static readonly MODEL_FILENAME: string;
  131620. /**
  131621. * Creates a new GenericController from a gamepad
  131622. * @param vrGamepad the gamepad that the controller should be created from
  131623. */
  131624. constructor(vrGamepad: any);
  131625. /**
  131626. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131627. * @param scene scene in which to add meshes
  131628. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131629. */
  131630. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131631. /**
  131632. * Called once for each button that changed state since the last frame
  131633. * @param buttonIdx Which button index changed
  131634. * @param state New state of the button
  131635. * @param changes Which properties on the state changed since last frame
  131636. */
  131637. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131638. }
  131639. }
  131640. declare module BABYLON {
  131641. /**
  131642. * Oculus Touch Controller
  131643. */
  131644. export class OculusTouchController extends WebVRController {
  131645. /**
  131646. * Base Url for the controller model.
  131647. */
  131648. static MODEL_BASE_URL: string;
  131649. /**
  131650. * File name for the left controller model.
  131651. */
  131652. static MODEL_LEFT_FILENAME: string;
  131653. /**
  131654. * File name for the right controller model.
  131655. */
  131656. static MODEL_RIGHT_FILENAME: string;
  131657. /**
  131658. * Base Url for the Quest controller model.
  131659. */
  131660. static QUEST_MODEL_BASE_URL: string;
  131661. /**
  131662. * @hidden
  131663. * If the controllers are running on a device that needs the updated Quest controller models
  131664. */
  131665. static _IsQuest: boolean;
  131666. /**
  131667. * Fired when the secondary trigger on this controller is modified
  131668. */
  131669. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131670. /**
  131671. * Fired when the thumb rest on this controller is modified
  131672. */
  131673. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131674. /**
  131675. * Creates a new OculusTouchController from a gamepad
  131676. * @param vrGamepad the gamepad that the controller should be created from
  131677. */
  131678. constructor(vrGamepad: any);
  131679. /**
  131680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131681. * @param scene scene in which to add meshes
  131682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131683. */
  131684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131685. /**
  131686. * Fired when the A button on this controller is modified
  131687. */
  131688. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131689. /**
  131690. * Fired when the B button on this controller is modified
  131691. */
  131692. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131693. /**
  131694. * Fired when the X button on this controller is modified
  131695. */
  131696. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131697. /**
  131698. * Fired when the Y button on this controller is modified
  131699. */
  131700. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131701. /**
  131702. * Called once for each button that changed state since the last frame
  131703. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131704. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131705. * 2) secondary trigger (same)
  131706. * 3) A (right) X (left), touch, pressed = value
  131707. * 4) B / Y
  131708. * 5) thumb rest
  131709. * @param buttonIdx Which button index changed
  131710. * @param state New state of the button
  131711. * @param changes Which properties on the state changed since last frame
  131712. */
  131713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131714. }
  131715. }
  131716. declare module BABYLON {
  131717. /**
  131718. * Vive Controller
  131719. */
  131720. export class ViveController extends WebVRController {
  131721. /**
  131722. * Base Url for the controller model.
  131723. */
  131724. static MODEL_BASE_URL: string;
  131725. /**
  131726. * File name for the controller model.
  131727. */
  131728. static MODEL_FILENAME: string;
  131729. /**
  131730. * Creates a new ViveController from a gamepad
  131731. * @param vrGamepad the gamepad that the controller should be created from
  131732. */
  131733. constructor(vrGamepad: any);
  131734. /**
  131735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131736. * @param scene scene in which to add meshes
  131737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131738. */
  131739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131740. /**
  131741. * Fired when the left button on this controller is modified
  131742. */
  131743. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131744. /**
  131745. * Fired when the right button on this controller is modified
  131746. */
  131747. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131748. /**
  131749. * Fired when the menu button on this controller is modified
  131750. */
  131751. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131752. /**
  131753. * Called once for each button that changed state since the last frame
  131754. * Vive mapping:
  131755. * 0: touchpad
  131756. * 1: trigger
  131757. * 2: left AND right buttons
  131758. * 3: menu button
  131759. * @param buttonIdx Which button index changed
  131760. * @param state New state of the button
  131761. * @param changes Which properties on the state changed since last frame
  131762. */
  131763. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131764. }
  131765. }
  131766. declare module BABYLON {
  131767. /**
  131768. * Defines the WindowsMotionController object that the state of the windows motion controller
  131769. */
  131770. export class WindowsMotionController extends WebVRController {
  131771. /**
  131772. * The base url used to load the left and right controller models
  131773. */
  131774. static MODEL_BASE_URL: string;
  131775. /**
  131776. * The name of the left controller model file
  131777. */
  131778. static MODEL_LEFT_FILENAME: string;
  131779. /**
  131780. * The name of the right controller model file
  131781. */
  131782. static MODEL_RIGHT_FILENAME: string;
  131783. /**
  131784. * The controller name prefix for this controller type
  131785. */
  131786. static readonly GAMEPAD_ID_PREFIX: string;
  131787. /**
  131788. * The controller id pattern for this controller type
  131789. */
  131790. private static readonly GAMEPAD_ID_PATTERN;
  131791. private _loadedMeshInfo;
  131792. protected readonly _mapping: {
  131793. buttons: string[];
  131794. buttonMeshNames: {
  131795. trigger: string;
  131796. menu: string;
  131797. grip: string;
  131798. thumbstick: string;
  131799. trackpad: string;
  131800. };
  131801. buttonObservableNames: {
  131802. trigger: string;
  131803. menu: string;
  131804. grip: string;
  131805. thumbstick: string;
  131806. trackpad: string;
  131807. };
  131808. axisMeshNames: string[];
  131809. pointingPoseMeshName: string;
  131810. };
  131811. /**
  131812. * Fired when the trackpad on this controller is clicked
  131813. */
  131814. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131815. /**
  131816. * Fired when the trackpad on this controller is modified
  131817. */
  131818. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131819. /**
  131820. * The current x and y values of this controller's trackpad
  131821. */
  131822. trackpad: StickValues;
  131823. /**
  131824. * Creates a new WindowsMotionController from a gamepad
  131825. * @param vrGamepad the gamepad that the controller should be created from
  131826. */
  131827. constructor(vrGamepad: any);
  131828. /**
  131829. * Fired when the trigger on this controller is modified
  131830. */
  131831. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131832. /**
  131833. * Fired when the menu button on this controller is modified
  131834. */
  131835. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131836. /**
  131837. * Fired when the grip button on this controller is modified
  131838. */
  131839. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131840. /**
  131841. * Fired when the thumbstick button on this controller is modified
  131842. */
  131843. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131844. /**
  131845. * Fired when the touchpad button on this controller is modified
  131846. */
  131847. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131848. /**
  131849. * Fired when the touchpad values on this controller are modified
  131850. */
  131851. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  131852. protected _updateTrackpad(): void;
  131853. /**
  131854. * Called once per frame by the engine.
  131855. */
  131856. update(): void;
  131857. /**
  131858. * Called once for each button that changed state since the last frame
  131859. * @param buttonIdx Which button index changed
  131860. * @param state New state of the button
  131861. * @param changes Which properties on the state changed since last frame
  131862. */
  131863. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131864. /**
  131865. * Moves the buttons on the controller mesh based on their current state
  131866. * @param buttonName the name of the button to move
  131867. * @param buttonValue the value of the button which determines the buttons new position
  131868. */
  131869. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  131870. /**
  131871. * Moves the axis on the controller mesh based on its current state
  131872. * @param axis the index of the axis
  131873. * @param axisValue the value of the axis which determines the meshes new position
  131874. * @hidden
  131875. */
  131876. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  131877. /**
  131878. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131879. * @param scene scene in which to add meshes
  131880. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131881. */
  131882. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  131883. /**
  131884. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  131885. * can be transformed by button presses and axes values, based on this._mapping.
  131886. *
  131887. * @param scene scene in which the meshes exist
  131888. * @param meshes list of meshes that make up the controller model to process
  131889. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  131890. */
  131891. private processModel;
  131892. private createMeshInfo;
  131893. /**
  131894. * Gets the ray of the controller in the direction the controller is pointing
  131895. * @param length the length the resulting ray should be
  131896. * @returns a ray in the direction the controller is pointing
  131897. */
  131898. getForwardRay(length?: number): Ray;
  131899. /**
  131900. * Disposes of the controller
  131901. */
  131902. dispose(): void;
  131903. }
  131904. /**
  131905. * This class represents a new windows motion controller in XR.
  131906. */
  131907. export class XRWindowsMotionController extends WindowsMotionController {
  131908. /**
  131909. * Changing the original WIndowsMotionController mapping to fir the new mapping
  131910. */
  131911. protected readonly _mapping: {
  131912. buttons: string[];
  131913. buttonMeshNames: {
  131914. trigger: string;
  131915. menu: string;
  131916. grip: string;
  131917. thumbstick: string;
  131918. trackpad: string;
  131919. };
  131920. buttonObservableNames: {
  131921. trigger: string;
  131922. menu: string;
  131923. grip: string;
  131924. thumbstick: string;
  131925. trackpad: string;
  131926. };
  131927. axisMeshNames: string[];
  131928. pointingPoseMeshName: string;
  131929. };
  131930. /**
  131931. * Construct a new XR-Based windows motion controller
  131932. *
  131933. * @param gamepadInfo the gamepad object from the browser
  131934. */
  131935. constructor(gamepadInfo: any);
  131936. /**
  131937. * holds the thumbstick values (X,Y)
  131938. */
  131939. thumbstickValues: StickValues;
  131940. /**
  131941. * Fired when the thumbstick on this controller is clicked
  131942. */
  131943. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  131944. /**
  131945. * Fired when the thumbstick on this controller is modified
  131946. */
  131947. onThumbstickValuesChangedObservable: Observable<StickValues>;
  131948. /**
  131949. * Fired when the touchpad button on this controller is modified
  131950. */
  131951. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131952. /**
  131953. * Fired when the touchpad values on this controller are modified
  131954. */
  131955. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131956. /**
  131957. * Fired when the thumbstick button on this controller is modified
  131958. * here to prevent breaking changes
  131959. */
  131960. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131961. /**
  131962. * updating the thumbstick(!) and not the trackpad.
  131963. * This is named this way due to the difference between WebVR and XR and to avoid
  131964. * changing the parent class.
  131965. */
  131966. protected _updateTrackpad(): void;
  131967. /**
  131968. * Disposes the class with joy
  131969. */
  131970. dispose(): void;
  131971. }
  131972. }
  131973. declare module BABYLON {
  131974. /**
  131975. * Class containing static functions to help procedurally build meshes
  131976. */
  131977. export class PolyhedronBuilder {
  131978. /**
  131979. * Creates a polyhedron mesh
  131980. * * 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
  131981. * * The parameter `size` (positive float, default 1) sets the polygon size
  131982. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  131983. * * 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`
  131984. * * 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
  131985. * * 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)`)
  131986. * * 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
  131987. * * 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
  131988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131991. * @param name defines the name of the mesh
  131992. * @param options defines the options used to create the mesh
  131993. * @param scene defines the hosting scene
  131994. * @returns the polyhedron mesh
  131995. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  131996. */
  131997. static CreatePolyhedron(name: string, options: {
  131998. type?: number;
  131999. size?: number;
  132000. sizeX?: number;
  132001. sizeY?: number;
  132002. sizeZ?: number;
  132003. custom?: any;
  132004. faceUV?: Vector4[];
  132005. faceColors?: Color4[];
  132006. flat?: boolean;
  132007. updatable?: boolean;
  132008. sideOrientation?: number;
  132009. frontUVs?: Vector4;
  132010. backUVs?: Vector4;
  132011. }, scene?: Nullable<Scene>): Mesh;
  132012. }
  132013. }
  132014. declare module BABYLON {
  132015. /**
  132016. * Gizmo that enables scaling a mesh along 3 axis
  132017. */
  132018. export class ScaleGizmo extends Gizmo {
  132019. /**
  132020. * Internal gizmo used for interactions on the x axis
  132021. */
  132022. xGizmo: AxisScaleGizmo;
  132023. /**
  132024. * Internal gizmo used for interactions on the y axis
  132025. */
  132026. yGizmo: AxisScaleGizmo;
  132027. /**
  132028. * Internal gizmo used for interactions on the z axis
  132029. */
  132030. zGizmo: AxisScaleGizmo;
  132031. /**
  132032. * Internal gizmo used to scale all axis equally
  132033. */
  132034. uniformScaleGizmo: AxisScaleGizmo;
  132035. private _meshAttached;
  132036. private _nodeAttached;
  132037. private _updateGizmoRotationToMatchAttachedMesh;
  132038. private _snapDistance;
  132039. private _scaleRatio;
  132040. private _uniformScalingMesh;
  132041. private _octahedron;
  132042. private _sensitivity;
  132043. /** Fires an event when any of it's sub gizmos are dragged */
  132044. onDragStartObservable: Observable<unknown>;
  132045. /** Fires an event when any of it's sub gizmos are released from dragging */
  132046. onDragEndObservable: Observable<unknown>;
  132047. get attachedMesh(): Nullable<AbstractMesh>;
  132048. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132049. get attachedNode(): Nullable<Node>;
  132050. set attachedNode(node: Nullable<Node>);
  132051. /**
  132052. * Creates a ScaleGizmo
  132053. * @param gizmoLayer The utility layer the gizmo will be added to
  132054. * @param thickness display gizmo axis thickness
  132055. */
  132056. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132057. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132058. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132059. /**
  132060. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132061. */
  132062. set snapDistance(value: number);
  132063. get snapDistance(): number;
  132064. /**
  132065. * Ratio for the scale of the gizmo (Default: 1)
  132066. */
  132067. set scaleRatio(value: number);
  132068. get scaleRatio(): number;
  132069. /**
  132070. * Sensitivity factor for dragging (Default: 1)
  132071. */
  132072. set sensitivity(value: number);
  132073. get sensitivity(): number;
  132074. /**
  132075. * Disposes of the gizmo
  132076. */
  132077. dispose(): void;
  132078. }
  132079. }
  132080. declare module BABYLON {
  132081. /**
  132082. * Single axis scale gizmo
  132083. */
  132084. export class AxisScaleGizmo extends Gizmo {
  132085. /**
  132086. * Drag behavior responsible for the gizmos dragging interactions
  132087. */
  132088. dragBehavior: PointerDragBehavior;
  132089. private _pointerObserver;
  132090. /**
  132091. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132092. */
  132093. snapDistance: number;
  132094. /**
  132095. * Event that fires each time the gizmo snaps to a new location.
  132096. * * snapDistance is the the change in distance
  132097. */
  132098. onSnapObservable: Observable<{
  132099. snapDistance: number;
  132100. }>;
  132101. /**
  132102. * If the scaling operation should be done on all axis (default: false)
  132103. */
  132104. uniformScaling: boolean;
  132105. /**
  132106. * Custom sensitivity value for the drag strength
  132107. */
  132108. sensitivity: number;
  132109. private _isEnabled;
  132110. private _parent;
  132111. private _arrow;
  132112. private _coloredMaterial;
  132113. private _hoverMaterial;
  132114. /**
  132115. * Creates an AxisScaleGizmo
  132116. * @param gizmoLayer The utility layer the gizmo will be added to
  132117. * @param dragAxis The axis which the gizmo will be able to scale on
  132118. * @param color The color of the gizmo
  132119. * @param thickness display gizmo axis thickness
  132120. */
  132121. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132122. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132123. /**
  132124. * If the gizmo is enabled
  132125. */
  132126. set isEnabled(value: boolean);
  132127. get isEnabled(): boolean;
  132128. /**
  132129. * Disposes of the gizmo
  132130. */
  132131. dispose(): void;
  132132. /**
  132133. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132134. * @param mesh The mesh to replace the default mesh of the gizmo
  132135. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132136. */
  132137. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132138. }
  132139. }
  132140. declare module BABYLON {
  132141. /**
  132142. * Bounding box gizmo
  132143. */
  132144. export class BoundingBoxGizmo extends Gizmo {
  132145. private _lineBoundingBox;
  132146. private _rotateSpheresParent;
  132147. private _scaleBoxesParent;
  132148. private _boundingDimensions;
  132149. private _renderObserver;
  132150. private _pointerObserver;
  132151. private _scaleDragSpeed;
  132152. private _tmpQuaternion;
  132153. private _tmpVector;
  132154. private _tmpRotationMatrix;
  132155. /**
  132156. * 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)
  132157. */
  132158. ignoreChildren: boolean;
  132159. /**
  132160. * 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)
  132161. */
  132162. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132163. /**
  132164. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132165. */
  132166. rotationSphereSize: number;
  132167. /**
  132168. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132169. */
  132170. scaleBoxSize: number;
  132171. /**
  132172. * 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)
  132173. */
  132174. fixedDragMeshScreenSize: boolean;
  132175. /**
  132176. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132177. */
  132178. fixedDragMeshScreenSizeDistanceFactor: number;
  132179. /**
  132180. * Fired when a rotation sphere or scale box is dragged
  132181. */
  132182. onDragStartObservable: Observable<{}>;
  132183. /**
  132184. * Fired when a scale box is dragged
  132185. */
  132186. onScaleBoxDragObservable: Observable<{}>;
  132187. /**
  132188. * Fired when a scale box drag is ended
  132189. */
  132190. onScaleBoxDragEndObservable: Observable<{}>;
  132191. /**
  132192. * Fired when a rotation sphere is dragged
  132193. */
  132194. onRotationSphereDragObservable: Observable<{}>;
  132195. /**
  132196. * Fired when a rotation sphere drag is ended
  132197. */
  132198. onRotationSphereDragEndObservable: Observable<{}>;
  132199. /**
  132200. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  132201. */
  132202. scalePivot: Nullable<Vector3>;
  132203. /**
  132204. * Mesh used as a pivot to rotate the attached node
  132205. */
  132206. private _anchorMesh;
  132207. private _existingMeshScale;
  132208. private _dragMesh;
  132209. private pointerDragBehavior;
  132210. private coloredMaterial;
  132211. private hoverColoredMaterial;
  132212. /**
  132213. * Sets the color of the bounding box gizmo
  132214. * @param color the color to set
  132215. */
  132216. setColor(color: Color3): void;
  132217. /**
  132218. * Creates an BoundingBoxGizmo
  132219. * @param gizmoLayer The utility layer the gizmo will be added to
  132220. * @param color The color of the gizmo
  132221. */
  132222. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132223. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132224. private _selectNode;
  132225. /**
  132226. * Updates the bounding box information for the Gizmo
  132227. */
  132228. updateBoundingBox(): void;
  132229. private _updateRotationSpheres;
  132230. private _updateScaleBoxes;
  132231. /**
  132232. * Enables rotation on the specified axis and disables rotation on the others
  132233. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132234. */
  132235. setEnabledRotationAxis(axis: string): void;
  132236. /**
  132237. * Enables/disables scaling
  132238. * @param enable if scaling should be enabled
  132239. * @param homogeneousScaling defines if scaling should only be homogeneous
  132240. */
  132241. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132242. private _updateDummy;
  132243. /**
  132244. * Enables a pointer drag behavior on the bounding box of the gizmo
  132245. */
  132246. enableDragBehavior(): void;
  132247. /**
  132248. * Disposes of the gizmo
  132249. */
  132250. dispose(): void;
  132251. /**
  132252. * 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)
  132253. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132254. * @returns the bounding box mesh with the passed in mesh as a child
  132255. */
  132256. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132257. /**
  132258. * CustomMeshes are not supported by this gizmo
  132259. * @param mesh The mesh to replace the default mesh of the gizmo
  132260. */
  132261. setCustomMesh(mesh: Mesh): void;
  132262. }
  132263. }
  132264. declare module BABYLON {
  132265. /**
  132266. * Single plane rotation gizmo
  132267. */
  132268. export class PlaneRotationGizmo extends Gizmo {
  132269. /**
  132270. * Drag behavior responsible for the gizmos dragging interactions
  132271. */
  132272. dragBehavior: PointerDragBehavior;
  132273. private _pointerObserver;
  132274. /**
  132275. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132276. */
  132277. snapDistance: number;
  132278. /**
  132279. * Event that fires each time the gizmo snaps to a new location.
  132280. * * snapDistance is the the change in distance
  132281. */
  132282. onSnapObservable: Observable<{
  132283. snapDistance: number;
  132284. }>;
  132285. private _isEnabled;
  132286. private _parent;
  132287. /**
  132288. * Creates a PlaneRotationGizmo
  132289. * @param gizmoLayer The utility layer the gizmo will be added to
  132290. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132291. * @param color The color of the gizmo
  132292. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132293. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132294. * @param thickness display gizmo axis thickness
  132295. */
  132296. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132297. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132298. /**
  132299. * If the gizmo is enabled
  132300. */
  132301. set isEnabled(value: boolean);
  132302. get isEnabled(): boolean;
  132303. /**
  132304. * Disposes of the gizmo
  132305. */
  132306. dispose(): void;
  132307. }
  132308. }
  132309. declare module BABYLON {
  132310. /**
  132311. * Gizmo that enables rotating a mesh along 3 axis
  132312. */
  132313. export class RotationGizmo extends Gizmo {
  132314. /**
  132315. * Internal gizmo used for interactions on the x axis
  132316. */
  132317. xGizmo: PlaneRotationGizmo;
  132318. /**
  132319. * Internal gizmo used for interactions on the y axis
  132320. */
  132321. yGizmo: PlaneRotationGizmo;
  132322. /**
  132323. * Internal gizmo used for interactions on the z axis
  132324. */
  132325. zGizmo: PlaneRotationGizmo;
  132326. /** Fires an event when any of it's sub gizmos are dragged */
  132327. onDragStartObservable: Observable<unknown>;
  132328. /** Fires an event when any of it's sub gizmos are released from dragging */
  132329. onDragEndObservable: Observable<unknown>;
  132330. private _meshAttached;
  132331. private _nodeAttached;
  132332. get attachedMesh(): Nullable<AbstractMesh>;
  132333. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132334. get attachedNode(): Nullable<Node>;
  132335. set attachedNode(node: Nullable<Node>);
  132336. /**
  132337. * Creates a RotationGizmo
  132338. * @param gizmoLayer The utility layer the gizmo will be added to
  132339. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132340. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132341. * @param thickness display gizmo axis thickness
  132342. */
  132343. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132344. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132345. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132346. /**
  132347. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132348. */
  132349. set snapDistance(value: number);
  132350. get snapDistance(): number;
  132351. /**
  132352. * Ratio for the scale of the gizmo (Default: 1)
  132353. */
  132354. set scaleRatio(value: number);
  132355. get scaleRatio(): number;
  132356. /**
  132357. * Disposes of the gizmo
  132358. */
  132359. dispose(): void;
  132360. /**
  132361. * CustomMeshes are not supported by this gizmo
  132362. * @param mesh The mesh to replace the default mesh of the gizmo
  132363. */
  132364. setCustomMesh(mesh: Mesh): void;
  132365. }
  132366. }
  132367. declare module BABYLON {
  132368. /**
  132369. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  132370. */
  132371. export class GizmoManager implements IDisposable {
  132372. private scene;
  132373. /**
  132374. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132375. */
  132376. gizmos: {
  132377. positionGizmo: Nullable<PositionGizmo>;
  132378. rotationGizmo: Nullable<RotationGizmo>;
  132379. scaleGizmo: Nullable<ScaleGizmo>;
  132380. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132381. };
  132382. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132383. clearGizmoOnEmptyPointerEvent: boolean;
  132384. /** Fires an event when the manager is attached to a mesh */
  132385. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132386. private _gizmosEnabled;
  132387. private _pointerObserver;
  132388. private _attachedMesh;
  132389. private _boundingBoxColor;
  132390. private _defaultUtilityLayer;
  132391. private _defaultKeepDepthUtilityLayer;
  132392. private _thickness;
  132393. /**
  132394. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132395. */
  132396. boundingBoxDragBehavior: SixDofDragBehavior;
  132397. /**
  132398. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132399. */
  132400. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132401. /**
  132402. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  132403. */
  132404. usePointerToAttachGizmos: boolean;
  132405. /**
  132406. * Utility layer that the bounding box gizmo belongs to
  132407. */
  132408. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132409. /**
  132410. * Utility layer that all gizmos besides bounding box belong to
  132411. */
  132412. get utilityLayer(): UtilityLayerRenderer;
  132413. /**
  132414. * Instatiates a gizmo manager
  132415. * @param scene the scene to overlay the gizmos on top of
  132416. * @param thickness display gizmo axis thickness
  132417. */
  132418. constructor(scene: Scene, thickness?: number);
  132419. /**
  132420. * Attaches a set of gizmos to the specified mesh
  132421. * @param mesh The mesh the gizmo's should be attached to
  132422. */
  132423. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132424. /**
  132425. * If the position gizmo is enabled
  132426. */
  132427. set positionGizmoEnabled(value: boolean);
  132428. get positionGizmoEnabled(): boolean;
  132429. /**
  132430. * If the rotation gizmo is enabled
  132431. */
  132432. set rotationGizmoEnabled(value: boolean);
  132433. get rotationGizmoEnabled(): boolean;
  132434. /**
  132435. * If the scale gizmo is enabled
  132436. */
  132437. set scaleGizmoEnabled(value: boolean);
  132438. get scaleGizmoEnabled(): boolean;
  132439. /**
  132440. * If the boundingBox gizmo is enabled
  132441. */
  132442. set boundingBoxGizmoEnabled(value: boolean);
  132443. get boundingBoxGizmoEnabled(): boolean;
  132444. /**
  132445. * Disposes of the gizmo manager
  132446. */
  132447. dispose(): void;
  132448. }
  132449. }
  132450. declare module BABYLON {
  132451. /**
  132452. * A directional light is defined by a direction (what a surprise!).
  132453. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132454. * 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.
  132455. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132456. */
  132457. export class DirectionalLight extends ShadowLight {
  132458. private _shadowFrustumSize;
  132459. /**
  132460. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132461. */
  132462. get shadowFrustumSize(): number;
  132463. /**
  132464. * Specifies a fix frustum size for the shadow generation.
  132465. */
  132466. set shadowFrustumSize(value: number);
  132467. private _shadowOrthoScale;
  132468. /**
  132469. * Gets the shadow projection scale against the optimal computed one.
  132470. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132471. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132472. */
  132473. get shadowOrthoScale(): number;
  132474. /**
  132475. * Sets the shadow projection scale against the optimal computed one.
  132476. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132477. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132478. */
  132479. set shadowOrthoScale(value: number);
  132480. /**
  132481. * Automatically compute the projection matrix to best fit (including all the casters)
  132482. * on each frame.
  132483. */
  132484. autoUpdateExtends: boolean;
  132485. /**
  132486. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132487. * on each frame. autoUpdateExtends must be set to true for this to work
  132488. */
  132489. autoCalcShadowZBounds: boolean;
  132490. private _orthoLeft;
  132491. private _orthoRight;
  132492. private _orthoTop;
  132493. private _orthoBottom;
  132494. /**
  132495. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132496. * The directional light is emitted from everywhere in the given direction.
  132497. * It can cast shadows.
  132498. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132499. * @param name The friendly name of the light
  132500. * @param direction The direction of the light
  132501. * @param scene The scene the light belongs to
  132502. */
  132503. constructor(name: string, direction: Vector3, scene: Scene);
  132504. /**
  132505. * Returns the string "DirectionalLight".
  132506. * @return The class name
  132507. */
  132508. getClassName(): string;
  132509. /**
  132510. * Returns the integer 1.
  132511. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132512. */
  132513. getTypeID(): number;
  132514. /**
  132515. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  132516. * Returns the DirectionalLight Shadow projection matrix.
  132517. */
  132518. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132519. /**
  132520. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132521. * Returns the DirectionalLight Shadow projection matrix.
  132522. */
  132523. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132524. /**
  132525. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132526. * Returns the DirectionalLight Shadow projection matrix.
  132527. */
  132528. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132529. protected _buildUniformLayout(): void;
  132530. /**
  132531. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132532. * @param effect The effect to update
  132533. * @param lightIndex The index of the light in the effect to update
  132534. * @returns The directional light
  132535. */
  132536. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132537. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132538. /**
  132539. * Gets the minZ used for shadow according to both the scene and the light.
  132540. *
  132541. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132542. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132543. * @param activeCamera The camera we are returning the min for
  132544. * @returns the depth min z
  132545. */
  132546. getDepthMinZ(activeCamera: Camera): number;
  132547. /**
  132548. * Gets the maxZ used for shadow according to both the scene and the light.
  132549. *
  132550. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132551. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132552. * @param activeCamera The camera we are returning the max for
  132553. * @returns the depth max z
  132554. */
  132555. getDepthMaxZ(activeCamera: Camera): number;
  132556. /**
  132557. * Prepares the list of defines specific to the light type.
  132558. * @param defines the list of defines
  132559. * @param lightIndex defines the index of the light for the effect
  132560. */
  132561. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132562. }
  132563. }
  132564. declare module BABYLON {
  132565. /**
  132566. * Class containing static functions to help procedurally build meshes
  132567. */
  132568. export class HemisphereBuilder {
  132569. /**
  132570. * Creates a hemisphere mesh
  132571. * @param name defines the name of the mesh
  132572. * @param options defines the options used to create the mesh
  132573. * @param scene defines the hosting scene
  132574. * @returns the hemisphere mesh
  132575. */
  132576. static CreateHemisphere(name: string, options: {
  132577. segments?: number;
  132578. diameter?: number;
  132579. sideOrientation?: number;
  132580. }, scene: any): Mesh;
  132581. }
  132582. }
  132583. declare module BABYLON {
  132584. /**
  132585. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132586. * These values define a cone of light starting from the position, emitting toward the direction.
  132587. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132588. * and the exponent defines the speed of the decay of the light with distance (reach).
  132589. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132590. */
  132591. export class SpotLight extends ShadowLight {
  132592. private _angle;
  132593. private _innerAngle;
  132594. private _cosHalfAngle;
  132595. private _lightAngleScale;
  132596. private _lightAngleOffset;
  132597. /**
  132598. * Gets the cone angle of the spot light in Radians.
  132599. */
  132600. get angle(): number;
  132601. /**
  132602. * Sets the cone angle of the spot light in Radians.
  132603. */
  132604. set angle(value: number);
  132605. /**
  132606. * Only used in gltf falloff mode, this defines the angle where
  132607. * the directional falloff will start before cutting at angle which could be seen
  132608. * as outer angle.
  132609. */
  132610. get innerAngle(): number;
  132611. /**
  132612. * Only used in gltf falloff mode, this defines the angle where
  132613. * the directional falloff will start before cutting at angle which could be seen
  132614. * as outer angle.
  132615. */
  132616. set innerAngle(value: number);
  132617. private _shadowAngleScale;
  132618. /**
  132619. * Allows scaling the angle of the light for shadow generation only.
  132620. */
  132621. get shadowAngleScale(): number;
  132622. /**
  132623. * Allows scaling the angle of the light for shadow generation only.
  132624. */
  132625. set shadowAngleScale(value: number);
  132626. /**
  132627. * The light decay speed with the distance from the emission spot.
  132628. */
  132629. exponent: number;
  132630. private _projectionTextureMatrix;
  132631. /**
  132632. * Allows reading the projecton texture
  132633. */
  132634. get projectionTextureMatrix(): Matrix;
  132635. protected _projectionTextureLightNear: number;
  132636. /**
  132637. * Gets the near clip of the Spotlight for texture projection.
  132638. */
  132639. get projectionTextureLightNear(): number;
  132640. /**
  132641. * Sets the near clip of the Spotlight for texture projection.
  132642. */
  132643. set projectionTextureLightNear(value: number);
  132644. protected _projectionTextureLightFar: number;
  132645. /**
  132646. * Gets the far clip of the Spotlight for texture projection.
  132647. */
  132648. get projectionTextureLightFar(): number;
  132649. /**
  132650. * Sets the far clip of the Spotlight for texture projection.
  132651. */
  132652. set projectionTextureLightFar(value: number);
  132653. protected _projectionTextureUpDirection: Vector3;
  132654. /**
  132655. * Gets the Up vector of the Spotlight for texture projection.
  132656. */
  132657. get projectionTextureUpDirection(): Vector3;
  132658. /**
  132659. * Sets the Up vector of the Spotlight for texture projection.
  132660. */
  132661. set projectionTextureUpDirection(value: Vector3);
  132662. private _projectionTexture;
  132663. /**
  132664. * Gets the projection texture of the light.
  132665. */
  132666. get projectionTexture(): Nullable<BaseTexture>;
  132667. /**
  132668. * Sets the projection texture of the light.
  132669. */
  132670. set projectionTexture(value: Nullable<BaseTexture>);
  132671. private _projectionTextureViewLightDirty;
  132672. private _projectionTextureProjectionLightDirty;
  132673. private _projectionTextureDirty;
  132674. private _projectionTextureViewTargetVector;
  132675. private _projectionTextureViewLightMatrix;
  132676. private _projectionTextureProjectionLightMatrix;
  132677. private _projectionTextureScalingMatrix;
  132678. /**
  132679. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132680. * It can cast shadows.
  132681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132682. * @param name The light friendly name
  132683. * @param position The position of the spot light in the scene
  132684. * @param direction The direction of the light in the scene
  132685. * @param angle The cone angle of the light in Radians
  132686. * @param exponent The light decay speed with the distance from the emission spot
  132687. * @param scene The scene the lights belongs to
  132688. */
  132689. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132690. /**
  132691. * Returns the string "SpotLight".
  132692. * @returns the class name
  132693. */
  132694. getClassName(): string;
  132695. /**
  132696. * Returns the integer 2.
  132697. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132698. */
  132699. getTypeID(): number;
  132700. /**
  132701. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132702. */
  132703. protected _setDirection(value: Vector3): void;
  132704. /**
  132705. * Overrides the position setter to recompute the projection texture view light Matrix.
  132706. */
  132707. protected _setPosition(value: Vector3): void;
  132708. /**
  132709. * 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.
  132710. * Returns the SpotLight.
  132711. */
  132712. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132713. protected _computeProjectionTextureViewLightMatrix(): void;
  132714. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132715. /**
  132716. * Main function for light texture projection matrix computing.
  132717. */
  132718. protected _computeProjectionTextureMatrix(): void;
  132719. protected _buildUniformLayout(): void;
  132720. private _computeAngleValues;
  132721. /**
  132722. * Sets the passed Effect "effect" with the Light textures.
  132723. * @param effect The effect to update
  132724. * @param lightIndex The index of the light in the effect to update
  132725. * @returns The light
  132726. */
  132727. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132728. /**
  132729. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132730. * @param effect The effect to update
  132731. * @param lightIndex The index of the light in the effect to update
  132732. * @returns The spot light
  132733. */
  132734. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132735. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132736. /**
  132737. * Disposes the light and the associated resources.
  132738. */
  132739. dispose(): void;
  132740. /**
  132741. * Prepares the list of defines specific to the light type.
  132742. * @param defines the list of defines
  132743. * @param lightIndex defines the index of the light for the effect
  132744. */
  132745. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132746. }
  132747. }
  132748. declare module BABYLON {
  132749. /**
  132750. * Gizmo that enables viewing a light
  132751. */
  132752. export class LightGizmo extends Gizmo {
  132753. private _lightMesh;
  132754. private _material;
  132755. private _cachedPosition;
  132756. private _cachedForward;
  132757. private _attachedMeshParent;
  132758. /**
  132759. * Creates a LightGizmo
  132760. * @param gizmoLayer The utility layer the gizmo will be added to
  132761. */
  132762. constructor(gizmoLayer?: UtilityLayerRenderer);
  132763. private _light;
  132764. /**
  132765. * The light that the gizmo is attached to
  132766. */
  132767. set light(light: Nullable<Light>);
  132768. get light(): Nullable<Light>;
  132769. /**
  132770. * Gets the material used to render the light gizmo
  132771. */
  132772. get material(): StandardMaterial;
  132773. /**
  132774. * @hidden
  132775. * Updates the gizmo to match the attached mesh's position/rotation
  132776. */
  132777. protected _update(): void;
  132778. private static _Scale;
  132779. /**
  132780. * Creates the lines for a light mesh
  132781. */
  132782. private static _CreateLightLines;
  132783. /**
  132784. * Disposes of the light gizmo
  132785. */
  132786. dispose(): void;
  132787. private static _CreateHemisphericLightMesh;
  132788. private static _CreatePointLightMesh;
  132789. private static _CreateSpotLightMesh;
  132790. private static _CreateDirectionalLightMesh;
  132791. }
  132792. }
  132793. declare module BABYLON {
  132794. /** @hidden */
  132795. export var backgroundFragmentDeclaration: {
  132796. name: string;
  132797. shader: string;
  132798. };
  132799. }
  132800. declare module BABYLON {
  132801. /** @hidden */
  132802. export var backgroundUboDeclaration: {
  132803. name: string;
  132804. shader: string;
  132805. };
  132806. }
  132807. declare module BABYLON {
  132808. /** @hidden */
  132809. export var backgroundPixelShader: {
  132810. name: string;
  132811. shader: string;
  132812. };
  132813. }
  132814. declare module BABYLON {
  132815. /** @hidden */
  132816. export var backgroundVertexDeclaration: {
  132817. name: string;
  132818. shader: string;
  132819. };
  132820. }
  132821. declare module BABYLON {
  132822. /** @hidden */
  132823. export var backgroundVertexShader: {
  132824. name: string;
  132825. shader: string;
  132826. };
  132827. }
  132828. declare module BABYLON {
  132829. /**
  132830. * Background material used to create an efficient environement around your scene.
  132831. */
  132832. export class BackgroundMaterial extends PushMaterial {
  132833. /**
  132834. * Standard reflectance value at parallel view angle.
  132835. */
  132836. static StandardReflectance0: number;
  132837. /**
  132838. * Standard reflectance value at grazing angle.
  132839. */
  132840. static StandardReflectance90: number;
  132841. protected _primaryColor: Color3;
  132842. /**
  132843. * Key light Color (multiply against the environement texture)
  132844. */
  132845. primaryColor: Color3;
  132846. protected __perceptualColor: Nullable<Color3>;
  132847. /**
  132848. * Experimental Internal Use Only.
  132849. *
  132850. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  132851. * This acts as a helper to set the primary color to a more "human friendly" value.
  132852. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  132853. * output color as close as possible from the chosen value.
  132854. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  132855. * part of lighting setup.)
  132856. */
  132857. get _perceptualColor(): Nullable<Color3>;
  132858. set _perceptualColor(value: Nullable<Color3>);
  132859. protected _primaryColorShadowLevel: float;
  132860. /**
  132861. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  132862. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  132863. */
  132864. get primaryColorShadowLevel(): float;
  132865. set primaryColorShadowLevel(value: float);
  132866. protected _primaryColorHighlightLevel: float;
  132867. /**
  132868. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  132869. * The primary color is used at the level chosen to define what the white area would look.
  132870. */
  132871. get primaryColorHighlightLevel(): float;
  132872. set primaryColorHighlightLevel(value: float);
  132873. protected _reflectionTexture: Nullable<BaseTexture>;
  132874. /**
  132875. * Reflection Texture used in the material.
  132876. * Should be author in a specific way for the best result (refer to the documentation).
  132877. */
  132878. reflectionTexture: Nullable<BaseTexture>;
  132879. protected _reflectionBlur: float;
  132880. /**
  132881. * Reflection Texture level of blur.
  132882. *
  132883. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  132884. * texture twice.
  132885. */
  132886. reflectionBlur: float;
  132887. protected _diffuseTexture: Nullable<BaseTexture>;
  132888. /**
  132889. * Diffuse Texture used in the material.
  132890. * Should be author in a specific way for the best result (refer to the documentation).
  132891. */
  132892. diffuseTexture: Nullable<BaseTexture>;
  132893. protected _shadowLights: Nullable<IShadowLight[]>;
  132894. /**
  132895. * Specify the list of lights casting shadow on the material.
  132896. * All scene shadow lights will be included if null.
  132897. */
  132898. shadowLights: Nullable<IShadowLight[]>;
  132899. protected _shadowLevel: float;
  132900. /**
  132901. * Helps adjusting the shadow to a softer level if required.
  132902. * 0 means black shadows and 1 means no shadows.
  132903. */
  132904. shadowLevel: float;
  132905. protected _sceneCenter: Vector3;
  132906. /**
  132907. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  132908. * It is usually zero but might be interesting to modify according to your setup.
  132909. */
  132910. sceneCenter: Vector3;
  132911. protected _opacityFresnel: boolean;
  132912. /**
  132913. * This helps specifying that the material is falling off to the sky box at grazing angle.
  132914. * This helps ensuring a nice transition when the camera goes under the ground.
  132915. */
  132916. opacityFresnel: boolean;
  132917. protected _reflectionFresnel: boolean;
  132918. /**
  132919. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  132920. * This helps adding a mirror texture on the ground.
  132921. */
  132922. reflectionFresnel: boolean;
  132923. protected _reflectionFalloffDistance: number;
  132924. /**
  132925. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  132926. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  132927. */
  132928. reflectionFalloffDistance: number;
  132929. protected _reflectionAmount: number;
  132930. /**
  132931. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  132932. */
  132933. reflectionAmount: number;
  132934. protected _reflectionReflectance0: number;
  132935. /**
  132936. * This specifies the weight of the reflection at grazing angle.
  132937. */
  132938. reflectionReflectance0: number;
  132939. protected _reflectionReflectance90: number;
  132940. /**
  132941. * This specifies the weight of the reflection at a perpendicular point of view.
  132942. */
  132943. reflectionReflectance90: number;
  132944. /**
  132945. * Sets the reflection reflectance fresnel values according to the default standard
  132946. * empirically know to work well :-)
  132947. */
  132948. set reflectionStandardFresnelWeight(value: number);
  132949. protected _useRGBColor: boolean;
  132950. /**
  132951. * Helps to directly use the maps channels instead of their level.
  132952. */
  132953. useRGBColor: boolean;
  132954. protected _enableNoise: boolean;
  132955. /**
  132956. * This helps reducing the banding effect that could occur on the background.
  132957. */
  132958. enableNoise: boolean;
  132959. /**
  132960. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132961. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  132962. * Recommended to be keep at 1.0 except for special cases.
  132963. */
  132964. get fovMultiplier(): number;
  132965. set fovMultiplier(value: number);
  132966. private _fovMultiplier;
  132967. /**
  132968. * Enable the FOV adjustment feature controlled by fovMultiplier.
  132969. */
  132970. useEquirectangularFOV: boolean;
  132971. private _maxSimultaneousLights;
  132972. /**
  132973. * Number of Simultaneous lights allowed on the material.
  132974. */
  132975. maxSimultaneousLights: int;
  132976. private _shadowOnly;
  132977. /**
  132978. * Make the material only render shadows
  132979. */
  132980. shadowOnly: boolean;
  132981. /**
  132982. * Default configuration related to image processing available in the Background Material.
  132983. */
  132984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132985. /**
  132986. * Keep track of the image processing observer to allow dispose and replace.
  132987. */
  132988. private _imageProcessingObserver;
  132989. /**
  132990. * Attaches a new image processing configuration to the PBR Material.
  132991. * @param configuration (if null the scene configuration will be use)
  132992. */
  132993. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132994. /**
  132995. * Gets the image processing configuration used either in this material.
  132996. */
  132997. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  132998. /**
  132999. * Sets the Default image processing configuration used either in the this material.
  133000. *
  133001. * If sets to null, the scene one is in use.
  133002. */
  133003. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133004. /**
  133005. * Gets wether the color curves effect is enabled.
  133006. */
  133007. get cameraColorCurvesEnabled(): boolean;
  133008. /**
  133009. * Sets wether the color curves effect is enabled.
  133010. */
  133011. set cameraColorCurvesEnabled(value: boolean);
  133012. /**
  133013. * Gets wether the color grading effect is enabled.
  133014. */
  133015. get cameraColorGradingEnabled(): boolean;
  133016. /**
  133017. * Gets wether the color grading effect is enabled.
  133018. */
  133019. set cameraColorGradingEnabled(value: boolean);
  133020. /**
  133021. * Gets wether tonemapping is enabled or not.
  133022. */
  133023. get cameraToneMappingEnabled(): boolean;
  133024. /**
  133025. * Sets wether tonemapping is enabled or not
  133026. */
  133027. set cameraToneMappingEnabled(value: boolean);
  133028. /**
  133029. * The camera exposure used on this material.
  133030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133031. * This corresponds to a photographic exposure.
  133032. */
  133033. get cameraExposure(): float;
  133034. /**
  133035. * The camera exposure used on this material.
  133036. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133037. * This corresponds to a photographic exposure.
  133038. */
  133039. set cameraExposure(value: float);
  133040. /**
  133041. * Gets The camera contrast used on this material.
  133042. */
  133043. get cameraContrast(): float;
  133044. /**
  133045. * Sets The camera contrast used on this material.
  133046. */
  133047. set cameraContrast(value: float);
  133048. /**
  133049. * Gets the Color Grading 2D Lookup Texture.
  133050. */
  133051. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133052. /**
  133053. * Sets the Color Grading 2D Lookup Texture.
  133054. */
  133055. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133056. /**
  133057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133059. * 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;
  133060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133061. */
  133062. get cameraColorCurves(): Nullable<ColorCurves>;
  133063. /**
  133064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133066. * 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;
  133067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133068. */
  133069. set cameraColorCurves(value: Nullable<ColorCurves>);
  133070. /**
  133071. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133072. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133073. */
  133074. switchToBGR: boolean;
  133075. private _renderTargets;
  133076. private _reflectionControls;
  133077. private _white;
  133078. private _primaryShadowColor;
  133079. private _primaryHighlightColor;
  133080. /**
  133081. * Instantiates a Background Material in the given scene
  133082. * @param name The friendly name of the material
  133083. * @param scene The scene to add the material to
  133084. */
  133085. constructor(name: string, scene: Scene);
  133086. /**
  133087. * Gets a boolean indicating that current material needs to register RTT
  133088. */
  133089. get hasRenderTargetTextures(): boolean;
  133090. /**
  133091. * The entire material has been created in order to prevent overdraw.
  133092. * @returns false
  133093. */
  133094. needAlphaTesting(): boolean;
  133095. /**
  133096. * The entire material has been created in order to prevent overdraw.
  133097. * @returns true if blending is enable
  133098. */
  133099. needAlphaBlending(): boolean;
  133100. /**
  133101. * Checks wether the material is ready to be rendered for a given mesh.
  133102. * @param mesh The mesh to render
  133103. * @param subMesh The submesh to check against
  133104. * @param useInstances Specify wether or not the material is used with instances
  133105. * @returns true if all the dependencies are ready (Textures, Effects...)
  133106. */
  133107. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133108. /**
  133109. * Compute the primary color according to the chosen perceptual color.
  133110. */
  133111. private _computePrimaryColorFromPerceptualColor;
  133112. /**
  133113. * Compute the highlights and shadow colors according to their chosen levels.
  133114. */
  133115. private _computePrimaryColors;
  133116. /**
  133117. * Build the uniform buffer used in the material.
  133118. */
  133119. buildUniformLayout(): void;
  133120. /**
  133121. * Unbind the material.
  133122. */
  133123. unbind(): void;
  133124. /**
  133125. * Bind only the world matrix to the material.
  133126. * @param world The world matrix to bind.
  133127. */
  133128. bindOnlyWorldMatrix(world: Matrix): void;
  133129. /**
  133130. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133131. * @param world The world matrix to bind.
  133132. * @param subMesh The submesh to bind for.
  133133. */
  133134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133135. /**
  133136. * Checks to see if a texture is used in the material.
  133137. * @param texture - Base texture to use.
  133138. * @returns - Boolean specifying if a texture is used in the material.
  133139. */
  133140. hasTexture(texture: BaseTexture): boolean;
  133141. /**
  133142. * Dispose the material.
  133143. * @param forceDisposeEffect Force disposal of the associated effect.
  133144. * @param forceDisposeTextures Force disposal of the associated textures.
  133145. */
  133146. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133147. /**
  133148. * Clones the material.
  133149. * @param name The cloned name.
  133150. * @returns The cloned material.
  133151. */
  133152. clone(name: string): BackgroundMaterial;
  133153. /**
  133154. * Serializes the current material to its JSON representation.
  133155. * @returns The JSON representation.
  133156. */
  133157. serialize(): any;
  133158. /**
  133159. * Gets the class name of the material
  133160. * @returns "BackgroundMaterial"
  133161. */
  133162. getClassName(): string;
  133163. /**
  133164. * Parse a JSON input to create back a background material.
  133165. * @param source The JSON data to parse
  133166. * @param scene The scene to create the parsed material in
  133167. * @param rootUrl The root url of the assets the material depends upon
  133168. * @returns the instantiated BackgroundMaterial.
  133169. */
  133170. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133171. }
  133172. }
  133173. declare module BABYLON {
  133174. /**
  133175. * Represents the different options available during the creation of
  133176. * a Environment helper.
  133177. *
  133178. * This can control the default ground, skybox and image processing setup of your scene.
  133179. */
  133180. export interface IEnvironmentHelperOptions {
  133181. /**
  133182. * Specifies whether or not to create a ground.
  133183. * True by default.
  133184. */
  133185. createGround: boolean;
  133186. /**
  133187. * Specifies the ground size.
  133188. * 15 by default.
  133189. */
  133190. groundSize: number;
  133191. /**
  133192. * The texture used on the ground for the main color.
  133193. * Comes from the BabylonJS CDN by default.
  133194. *
  133195. * Remarks: Can be either a texture or a url.
  133196. */
  133197. groundTexture: string | BaseTexture;
  133198. /**
  133199. * The color mixed in the ground texture by default.
  133200. * BabylonJS clearColor by default.
  133201. */
  133202. groundColor: Color3;
  133203. /**
  133204. * Specifies the ground opacity.
  133205. * 1 by default.
  133206. */
  133207. groundOpacity: number;
  133208. /**
  133209. * Enables the ground to receive shadows.
  133210. * True by default.
  133211. */
  133212. enableGroundShadow: boolean;
  133213. /**
  133214. * Helps preventing the shadow to be fully black on the ground.
  133215. * 0.5 by default.
  133216. */
  133217. groundShadowLevel: number;
  133218. /**
  133219. * Creates a mirror texture attach to the ground.
  133220. * false by default.
  133221. */
  133222. enableGroundMirror: boolean;
  133223. /**
  133224. * Specifies the ground mirror size ratio.
  133225. * 0.3 by default as the default kernel is 64.
  133226. */
  133227. groundMirrorSizeRatio: number;
  133228. /**
  133229. * Specifies the ground mirror blur kernel size.
  133230. * 64 by default.
  133231. */
  133232. groundMirrorBlurKernel: number;
  133233. /**
  133234. * Specifies the ground mirror visibility amount.
  133235. * 1 by default
  133236. */
  133237. groundMirrorAmount: number;
  133238. /**
  133239. * Specifies the ground mirror reflectance weight.
  133240. * This uses the standard weight of the background material to setup the fresnel effect
  133241. * of the mirror.
  133242. * 1 by default.
  133243. */
  133244. groundMirrorFresnelWeight: number;
  133245. /**
  133246. * Specifies the ground mirror Falloff distance.
  133247. * This can helps reducing the size of the reflection.
  133248. * 0 by Default.
  133249. */
  133250. groundMirrorFallOffDistance: number;
  133251. /**
  133252. * Specifies the ground mirror texture type.
  133253. * Unsigned Int by Default.
  133254. */
  133255. groundMirrorTextureType: number;
  133256. /**
  133257. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133258. * the shown objects.
  133259. */
  133260. groundYBias: number;
  133261. /**
  133262. * Specifies whether or not to create a skybox.
  133263. * True by default.
  133264. */
  133265. createSkybox: boolean;
  133266. /**
  133267. * Specifies the skybox size.
  133268. * 20 by default.
  133269. */
  133270. skyboxSize: number;
  133271. /**
  133272. * The texture used on the skybox for the main color.
  133273. * Comes from the BabylonJS CDN by default.
  133274. *
  133275. * Remarks: Can be either a texture or a url.
  133276. */
  133277. skyboxTexture: string | BaseTexture;
  133278. /**
  133279. * The color mixed in the skybox texture by default.
  133280. * BabylonJS clearColor by default.
  133281. */
  133282. skyboxColor: Color3;
  133283. /**
  133284. * The background rotation around the Y axis of the scene.
  133285. * This helps aligning the key lights of your scene with the background.
  133286. * 0 by default.
  133287. */
  133288. backgroundYRotation: number;
  133289. /**
  133290. * Compute automatically the size of the elements to best fit with the scene.
  133291. */
  133292. sizeAuto: boolean;
  133293. /**
  133294. * Default position of the rootMesh if autoSize is not true.
  133295. */
  133296. rootPosition: Vector3;
  133297. /**
  133298. * Sets up the image processing in the scene.
  133299. * true by default.
  133300. */
  133301. setupImageProcessing: boolean;
  133302. /**
  133303. * The texture used as your environment texture in the scene.
  133304. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133305. *
  133306. * Remarks: Can be either a texture or a url.
  133307. */
  133308. environmentTexture: string | BaseTexture;
  133309. /**
  133310. * The value of the exposure to apply to the scene.
  133311. * 0.6 by default if setupImageProcessing is true.
  133312. */
  133313. cameraExposure: number;
  133314. /**
  133315. * The value of the contrast to apply to the scene.
  133316. * 1.6 by default if setupImageProcessing is true.
  133317. */
  133318. cameraContrast: number;
  133319. /**
  133320. * Specifies whether or not tonemapping should be enabled in the scene.
  133321. * true by default if setupImageProcessing is true.
  133322. */
  133323. toneMappingEnabled: boolean;
  133324. }
  133325. /**
  133326. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133327. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133328. * It also helps with the default setup of your imageProcessing configuration.
  133329. */
  133330. export class EnvironmentHelper {
  133331. /**
  133332. * Default ground texture URL.
  133333. */
  133334. private static _groundTextureCDNUrl;
  133335. /**
  133336. * Default skybox texture URL.
  133337. */
  133338. private static _skyboxTextureCDNUrl;
  133339. /**
  133340. * Default environment texture URL.
  133341. */
  133342. private static _environmentTextureCDNUrl;
  133343. /**
  133344. * Creates the default options for the helper.
  133345. */
  133346. private static _getDefaultOptions;
  133347. private _rootMesh;
  133348. /**
  133349. * Gets the root mesh created by the helper.
  133350. */
  133351. get rootMesh(): Mesh;
  133352. private _skybox;
  133353. /**
  133354. * Gets the skybox created by the helper.
  133355. */
  133356. get skybox(): Nullable<Mesh>;
  133357. private _skyboxTexture;
  133358. /**
  133359. * Gets the skybox texture created by the helper.
  133360. */
  133361. get skyboxTexture(): Nullable<BaseTexture>;
  133362. private _skyboxMaterial;
  133363. /**
  133364. * Gets the skybox material created by the helper.
  133365. */
  133366. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133367. private _ground;
  133368. /**
  133369. * Gets the ground mesh created by the helper.
  133370. */
  133371. get ground(): Nullable<Mesh>;
  133372. private _groundTexture;
  133373. /**
  133374. * Gets the ground texture created by the helper.
  133375. */
  133376. get groundTexture(): Nullable<BaseTexture>;
  133377. private _groundMirror;
  133378. /**
  133379. * Gets the ground mirror created by the helper.
  133380. */
  133381. get groundMirror(): Nullable<MirrorTexture>;
  133382. /**
  133383. * Gets the ground mirror render list to helps pushing the meshes
  133384. * you wish in the ground reflection.
  133385. */
  133386. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  133387. private _groundMaterial;
  133388. /**
  133389. * Gets the ground material created by the helper.
  133390. */
  133391. get groundMaterial(): Nullable<BackgroundMaterial>;
  133392. /**
  133393. * Stores the creation options.
  133394. */
  133395. private readonly _scene;
  133396. private _options;
  133397. /**
  133398. * This observable will be notified with any error during the creation of the environment,
  133399. * mainly texture creation errors.
  133400. */
  133401. onErrorObservable: Observable<{
  133402. message?: string;
  133403. exception?: any;
  133404. }>;
  133405. /**
  133406. * constructor
  133407. * @param options Defines the options we want to customize the helper
  133408. * @param scene The scene to add the material to
  133409. */
  133410. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133411. /**
  133412. * Updates the background according to the new options
  133413. * @param options
  133414. */
  133415. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133416. /**
  133417. * Sets the primary color of all the available elements.
  133418. * @param color the main color to affect to the ground and the background
  133419. */
  133420. setMainColor(color: Color3): void;
  133421. /**
  133422. * Setup the image processing according to the specified options.
  133423. */
  133424. private _setupImageProcessing;
  133425. /**
  133426. * Setup the environment texture according to the specified options.
  133427. */
  133428. private _setupEnvironmentTexture;
  133429. /**
  133430. * Setup the background according to the specified options.
  133431. */
  133432. private _setupBackground;
  133433. /**
  133434. * Get the scene sizes according to the setup.
  133435. */
  133436. private _getSceneSize;
  133437. /**
  133438. * Setup the ground according to the specified options.
  133439. */
  133440. private _setupGround;
  133441. /**
  133442. * Setup the ground material according to the specified options.
  133443. */
  133444. private _setupGroundMaterial;
  133445. /**
  133446. * Setup the ground diffuse texture according to the specified options.
  133447. */
  133448. private _setupGroundDiffuseTexture;
  133449. /**
  133450. * Setup the ground mirror texture according to the specified options.
  133451. */
  133452. private _setupGroundMirrorTexture;
  133453. /**
  133454. * Setup the ground to receive the mirror texture.
  133455. */
  133456. private _setupMirrorInGroundMaterial;
  133457. /**
  133458. * Setup the skybox according to the specified options.
  133459. */
  133460. private _setupSkybox;
  133461. /**
  133462. * Setup the skybox material according to the specified options.
  133463. */
  133464. private _setupSkyboxMaterial;
  133465. /**
  133466. * Setup the skybox reflection texture according to the specified options.
  133467. */
  133468. private _setupSkyboxReflectionTexture;
  133469. private _errorHandler;
  133470. /**
  133471. * Dispose all the elements created by the Helper.
  133472. */
  133473. dispose(): void;
  133474. }
  133475. }
  133476. declare module BABYLON {
  133477. /**
  133478. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133479. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133480. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133481. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133482. */
  133483. export class PhotoDome extends TransformNode {
  133484. /**
  133485. * Define the image as a Monoscopic panoramic 360 image.
  133486. */
  133487. static readonly MODE_MONOSCOPIC: number;
  133488. /**
  133489. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133490. */
  133491. static readonly MODE_TOPBOTTOM: number;
  133492. /**
  133493. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133494. */
  133495. static readonly MODE_SIDEBYSIDE: number;
  133496. private _useDirectMapping;
  133497. /**
  133498. * The texture being displayed on the sphere
  133499. */
  133500. protected _photoTexture: Texture;
  133501. /**
  133502. * Gets or sets the texture being displayed on the sphere
  133503. */
  133504. get photoTexture(): Texture;
  133505. set photoTexture(value: Texture);
  133506. /**
  133507. * Observable raised when an error occured while loading the 360 image
  133508. */
  133509. onLoadErrorObservable: Observable<string>;
  133510. /**
  133511. * The skybox material
  133512. */
  133513. protected _material: BackgroundMaterial;
  133514. /**
  133515. * The surface used for the skybox
  133516. */
  133517. protected _mesh: Mesh;
  133518. /**
  133519. * Gets the mesh used for the skybox.
  133520. */
  133521. get mesh(): Mesh;
  133522. /**
  133523. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133524. * Also see the options.resolution property.
  133525. */
  133526. get fovMultiplier(): number;
  133527. set fovMultiplier(value: number);
  133528. private _imageMode;
  133529. /**
  133530. * Gets or set the current video mode for the video. It can be:
  133531. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133532. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133533. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133534. */
  133535. get imageMode(): number;
  133536. set imageMode(value: number);
  133537. /**
  133538. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133539. * @param name Element's name, child elements will append suffixes for their own names.
  133540. * @param urlsOfPhoto defines the url of the photo to display
  133541. * @param options defines an object containing optional or exposed sub element properties
  133542. * @param onError defines a callback called when an error occured while loading the texture
  133543. */
  133544. constructor(name: string, urlOfPhoto: string, options: {
  133545. resolution?: number;
  133546. size?: number;
  133547. useDirectMapping?: boolean;
  133548. faceForward?: boolean;
  133549. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133550. private _onBeforeCameraRenderObserver;
  133551. private _changeImageMode;
  133552. /**
  133553. * Releases resources associated with this node.
  133554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133556. */
  133557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133558. }
  133559. }
  133560. declare module BABYLON {
  133561. /**
  133562. * Class used to host RGBD texture specific utilities
  133563. */
  133564. export class RGBDTextureTools {
  133565. /**
  133566. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133567. * @param texture the texture to expand.
  133568. */
  133569. static ExpandRGBDTexture(texture: Texture): void;
  133570. }
  133571. }
  133572. declare module BABYLON {
  133573. /**
  133574. * Class used to host texture specific utilities
  133575. */
  133576. export class BRDFTextureTools {
  133577. /**
  133578. * Prevents texture cache collision
  133579. */
  133580. private static _instanceNumber;
  133581. /**
  133582. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133583. * @param scene defines the hosting scene
  133584. * @returns the environment BRDF texture
  133585. */
  133586. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133587. private static _environmentBRDFBase64Texture;
  133588. }
  133589. }
  133590. declare module BABYLON {
  133591. /**
  133592. * @hidden
  133593. */
  133594. export interface IMaterialClearCoatDefines {
  133595. CLEARCOAT: boolean;
  133596. CLEARCOAT_DEFAULTIOR: boolean;
  133597. CLEARCOAT_TEXTURE: boolean;
  133598. CLEARCOAT_TEXTUREDIRECTUV: number;
  133599. CLEARCOAT_BUMP: boolean;
  133600. CLEARCOAT_BUMPDIRECTUV: number;
  133601. CLEARCOAT_TINT: boolean;
  133602. CLEARCOAT_TINT_TEXTURE: boolean;
  133603. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133604. /** @hidden */
  133605. _areTexturesDirty: boolean;
  133606. }
  133607. /**
  133608. * Define the code related to the clear coat parameters of the pbr material.
  133609. */
  133610. export class PBRClearCoatConfiguration {
  133611. /**
  133612. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133613. * The default fits with a polyurethane material.
  133614. */
  133615. private static readonly _DefaultIndexOfRefraction;
  133616. private _isEnabled;
  133617. /**
  133618. * Defines if the clear coat is enabled in the material.
  133619. */
  133620. isEnabled: boolean;
  133621. /**
  133622. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133623. */
  133624. intensity: number;
  133625. /**
  133626. * Defines the clear coat layer roughness.
  133627. */
  133628. roughness: number;
  133629. private _indexOfRefraction;
  133630. /**
  133631. * Defines the index of refraction of the clear coat.
  133632. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133633. * The default fits with a polyurethane material.
  133634. * Changing the default value is more performance intensive.
  133635. */
  133636. indexOfRefraction: number;
  133637. private _texture;
  133638. /**
  133639. * Stores the clear coat values in a texture.
  133640. */
  133641. texture: Nullable<BaseTexture>;
  133642. private _bumpTexture;
  133643. /**
  133644. * Define the clear coat specific bump texture.
  133645. */
  133646. bumpTexture: Nullable<BaseTexture>;
  133647. private _isTintEnabled;
  133648. /**
  133649. * Defines if the clear coat tint is enabled in the material.
  133650. */
  133651. isTintEnabled: boolean;
  133652. /**
  133653. * Defines the clear coat tint of the material.
  133654. * This is only use if tint is enabled
  133655. */
  133656. tintColor: Color3;
  133657. /**
  133658. * Defines the distance at which the tint color should be found in the
  133659. * clear coat media.
  133660. * This is only use if tint is enabled
  133661. */
  133662. tintColorAtDistance: number;
  133663. /**
  133664. * Defines the clear coat layer thickness.
  133665. * This is only use if tint is enabled
  133666. */
  133667. tintThickness: number;
  133668. private _tintTexture;
  133669. /**
  133670. * Stores the clear tint values in a texture.
  133671. * rgb is tint
  133672. * a is a thickness factor
  133673. */
  133674. tintTexture: Nullable<BaseTexture>;
  133675. /** @hidden */
  133676. private _internalMarkAllSubMeshesAsTexturesDirty;
  133677. /** @hidden */
  133678. _markAllSubMeshesAsTexturesDirty(): void;
  133679. /**
  133680. * Instantiate a new istance of clear coat configuration.
  133681. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133682. */
  133683. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133684. /**
  133685. * Gets wehter the submesh is ready to be used or not.
  133686. * @param defines the list of "defines" to update.
  133687. * @param scene defines the scene the material belongs to.
  133688. * @param engine defines the engine the material belongs to.
  133689. * @param disableBumpMap defines wether the material disables bump or not.
  133690. * @returns - boolean indicating that the submesh is ready or not.
  133691. */
  133692. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133693. /**
  133694. * Checks to see if a texture is used in the material.
  133695. * @param defines the list of "defines" to update.
  133696. * @param scene defines the scene to the material belongs to.
  133697. */
  133698. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133699. /**
  133700. * Binds the material data.
  133701. * @param uniformBuffer defines the Uniform buffer to fill in.
  133702. * @param scene defines the scene the material belongs to.
  133703. * @param engine defines the engine the material belongs to.
  133704. * @param disableBumpMap defines wether the material disables bump or not.
  133705. * @param isFrozen defines wether the material is frozen or not.
  133706. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133707. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133708. */
  133709. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133710. /**
  133711. * Checks to see if a texture is used in the material.
  133712. * @param texture - Base texture to use.
  133713. * @returns - Boolean specifying if a texture is used in the material.
  133714. */
  133715. hasTexture(texture: BaseTexture): boolean;
  133716. /**
  133717. * Returns an array of the actively used textures.
  133718. * @param activeTextures Array of BaseTextures
  133719. */
  133720. getActiveTextures(activeTextures: BaseTexture[]): void;
  133721. /**
  133722. * Returns the animatable textures.
  133723. * @param animatables Array of animatable textures.
  133724. */
  133725. getAnimatables(animatables: IAnimatable[]): void;
  133726. /**
  133727. * Disposes the resources of the material.
  133728. * @param forceDisposeTextures - Forces the disposal of all textures.
  133729. */
  133730. dispose(forceDisposeTextures?: boolean): void;
  133731. /**
  133732. * Get the current class name of the texture useful for serialization or dynamic coding.
  133733. * @returns "PBRClearCoatConfiguration"
  133734. */
  133735. getClassName(): string;
  133736. /**
  133737. * Add fallbacks to the effect fallbacks list.
  133738. * @param defines defines the Base texture to use.
  133739. * @param fallbacks defines the current fallback list.
  133740. * @param currentRank defines the current fallback rank.
  133741. * @returns the new fallback rank.
  133742. */
  133743. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133744. /**
  133745. * Add the required uniforms to the current list.
  133746. * @param uniforms defines the current uniform list.
  133747. */
  133748. static AddUniforms(uniforms: string[]): void;
  133749. /**
  133750. * Add the required samplers to the current list.
  133751. * @param samplers defines the current sampler list.
  133752. */
  133753. static AddSamplers(samplers: string[]): void;
  133754. /**
  133755. * Add the required uniforms to the current buffer.
  133756. * @param uniformBuffer defines the current uniform buffer.
  133757. */
  133758. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133759. /**
  133760. * Makes a duplicate of the current configuration into another one.
  133761. * @param clearCoatConfiguration define the config where to copy the info
  133762. */
  133763. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133764. /**
  133765. * Serializes this clear coat configuration.
  133766. * @returns - An object with the serialized config.
  133767. */
  133768. serialize(): any;
  133769. /**
  133770. * Parses a anisotropy Configuration from a serialized object.
  133771. * @param source - Serialized object.
  133772. * @param scene Defines the scene we are parsing for
  133773. * @param rootUrl Defines the rootUrl to load from
  133774. */
  133775. parse(source: any, scene: Scene, rootUrl: string): void;
  133776. }
  133777. }
  133778. declare module BABYLON {
  133779. /**
  133780. * @hidden
  133781. */
  133782. export interface IMaterialAnisotropicDefines {
  133783. ANISOTROPIC: boolean;
  133784. ANISOTROPIC_TEXTURE: boolean;
  133785. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133786. MAINUV1: boolean;
  133787. _areTexturesDirty: boolean;
  133788. _needUVs: boolean;
  133789. }
  133790. /**
  133791. * Define the code related to the anisotropic parameters of the pbr material.
  133792. */
  133793. export class PBRAnisotropicConfiguration {
  133794. private _isEnabled;
  133795. /**
  133796. * Defines if the anisotropy is enabled in the material.
  133797. */
  133798. isEnabled: boolean;
  133799. /**
  133800. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  133801. */
  133802. intensity: number;
  133803. /**
  133804. * Defines if the effect is along the tangents, bitangents or in between.
  133805. * By default, the effect is "strectching" the highlights along the tangents.
  133806. */
  133807. direction: Vector2;
  133808. private _texture;
  133809. /**
  133810. * Stores the anisotropy values in a texture.
  133811. * rg is direction (like normal from -1 to 1)
  133812. * b is a intensity
  133813. */
  133814. texture: Nullable<BaseTexture>;
  133815. /** @hidden */
  133816. private _internalMarkAllSubMeshesAsTexturesDirty;
  133817. /** @hidden */
  133818. _markAllSubMeshesAsTexturesDirty(): void;
  133819. /**
  133820. * Instantiate a new istance of anisotropy configuration.
  133821. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133822. */
  133823. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133824. /**
  133825. * Specifies that the submesh is ready to be used.
  133826. * @param defines the list of "defines" to update.
  133827. * @param scene defines the scene the material belongs to.
  133828. * @returns - boolean indicating that the submesh is ready or not.
  133829. */
  133830. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  133831. /**
  133832. * Checks to see if a texture is used in the material.
  133833. * @param defines the list of "defines" to update.
  133834. * @param mesh the mesh we are preparing the defines for.
  133835. * @param scene defines the scene the material belongs to.
  133836. */
  133837. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  133838. /**
  133839. * Binds the material data.
  133840. * @param uniformBuffer defines the Uniform buffer to fill in.
  133841. * @param scene defines the scene the material belongs to.
  133842. * @param isFrozen defines wether the material is frozen or not.
  133843. */
  133844. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133845. /**
  133846. * Checks to see if a texture is used in the material.
  133847. * @param texture - Base texture to use.
  133848. * @returns - Boolean specifying if a texture is used in the material.
  133849. */
  133850. hasTexture(texture: BaseTexture): boolean;
  133851. /**
  133852. * Returns an array of the actively used textures.
  133853. * @param activeTextures Array of BaseTextures
  133854. */
  133855. getActiveTextures(activeTextures: BaseTexture[]): void;
  133856. /**
  133857. * Returns the animatable textures.
  133858. * @param animatables Array of animatable textures.
  133859. */
  133860. getAnimatables(animatables: IAnimatable[]): void;
  133861. /**
  133862. * Disposes the resources of the material.
  133863. * @param forceDisposeTextures - Forces the disposal of all textures.
  133864. */
  133865. dispose(forceDisposeTextures?: boolean): void;
  133866. /**
  133867. * Get the current class name of the texture useful for serialization or dynamic coding.
  133868. * @returns "PBRAnisotropicConfiguration"
  133869. */
  133870. getClassName(): string;
  133871. /**
  133872. * Add fallbacks to the effect fallbacks list.
  133873. * @param defines defines the Base texture to use.
  133874. * @param fallbacks defines the current fallback list.
  133875. * @param currentRank defines the current fallback rank.
  133876. * @returns the new fallback rank.
  133877. */
  133878. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133879. /**
  133880. * Add the required uniforms to the current list.
  133881. * @param uniforms defines the current uniform list.
  133882. */
  133883. static AddUniforms(uniforms: string[]): void;
  133884. /**
  133885. * Add the required uniforms to the current buffer.
  133886. * @param uniformBuffer defines the current uniform buffer.
  133887. */
  133888. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133889. /**
  133890. * Add the required samplers to the current list.
  133891. * @param samplers defines the current sampler list.
  133892. */
  133893. static AddSamplers(samplers: string[]): void;
  133894. /**
  133895. * Makes a duplicate of the current configuration into another one.
  133896. * @param anisotropicConfiguration define the config where to copy the info
  133897. */
  133898. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  133899. /**
  133900. * Serializes this anisotropy configuration.
  133901. * @returns - An object with the serialized config.
  133902. */
  133903. serialize(): any;
  133904. /**
  133905. * Parses a anisotropy Configuration from a serialized object.
  133906. * @param source - Serialized object.
  133907. * @param scene Defines the scene we are parsing for
  133908. * @param rootUrl Defines the rootUrl to load from
  133909. */
  133910. parse(source: any, scene: Scene, rootUrl: string): void;
  133911. }
  133912. }
  133913. declare module BABYLON {
  133914. /**
  133915. * @hidden
  133916. */
  133917. export interface IMaterialBRDFDefines {
  133918. BRDF_V_HEIGHT_CORRELATED: boolean;
  133919. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133920. SPHERICAL_HARMONICS: boolean;
  133921. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133922. /** @hidden */
  133923. _areMiscDirty: boolean;
  133924. }
  133925. /**
  133926. * Define the code related to the BRDF parameters of the pbr material.
  133927. */
  133928. export class PBRBRDFConfiguration {
  133929. /**
  133930. * Default value used for the energy conservation.
  133931. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133932. */
  133933. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  133934. /**
  133935. * Default value used for the Smith Visibility Height Correlated mode.
  133936. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  133937. */
  133938. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  133939. /**
  133940. * Default value used for the IBL diffuse part.
  133941. * This can help switching back to the polynomials mode globally which is a tiny bit
  133942. * less GPU intensive at the drawback of a lower quality.
  133943. */
  133944. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  133945. /**
  133946. * Default value used for activating energy conservation for the specular workflow.
  133947. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133948. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133949. */
  133950. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  133951. private _useEnergyConservation;
  133952. /**
  133953. * Defines if the material uses energy conservation.
  133954. */
  133955. useEnergyConservation: boolean;
  133956. private _useSmithVisibilityHeightCorrelated;
  133957. /**
  133958. * LEGACY Mode set to false
  133959. * Defines if the material uses height smith correlated visibility term.
  133960. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  133961. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  133962. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  133963. * Not relying on height correlated will also disable energy conservation.
  133964. */
  133965. useSmithVisibilityHeightCorrelated: boolean;
  133966. private _useSphericalHarmonics;
  133967. /**
  133968. * LEGACY Mode set to false
  133969. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  133970. * diffuse part of the IBL.
  133971. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  133972. * to the ground truth.
  133973. */
  133974. useSphericalHarmonics: boolean;
  133975. private _useSpecularGlossinessInputEnergyConservation;
  133976. /**
  133977. * Defines if the material uses energy conservation, when the specular workflow is active.
  133978. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  133979. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  133980. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  133981. */
  133982. useSpecularGlossinessInputEnergyConservation: boolean;
  133983. /** @hidden */
  133984. private _internalMarkAllSubMeshesAsMiscDirty;
  133985. /** @hidden */
  133986. _markAllSubMeshesAsMiscDirty(): void;
  133987. /**
  133988. * Instantiate a new istance of clear coat configuration.
  133989. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  133990. */
  133991. constructor(markAllSubMeshesAsMiscDirty: () => void);
  133992. /**
  133993. * Checks to see if a texture is used in the material.
  133994. * @param defines the list of "defines" to update.
  133995. */
  133996. prepareDefines(defines: IMaterialBRDFDefines): void;
  133997. /**
  133998. * Get the current class name of the texture useful for serialization or dynamic coding.
  133999. * @returns "PBRClearCoatConfiguration"
  134000. */
  134001. getClassName(): string;
  134002. /**
  134003. * Makes a duplicate of the current configuration into another one.
  134004. * @param brdfConfiguration define the config where to copy the info
  134005. */
  134006. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134007. /**
  134008. * Serializes this BRDF configuration.
  134009. * @returns - An object with the serialized config.
  134010. */
  134011. serialize(): any;
  134012. /**
  134013. * Parses a anisotropy Configuration from a serialized object.
  134014. * @param source - Serialized object.
  134015. * @param scene Defines the scene we are parsing for
  134016. * @param rootUrl Defines the rootUrl to load from
  134017. */
  134018. parse(source: any, scene: Scene, rootUrl: string): void;
  134019. }
  134020. }
  134021. declare module BABYLON {
  134022. /**
  134023. * @hidden
  134024. */
  134025. export interface IMaterialSheenDefines {
  134026. SHEEN: boolean;
  134027. SHEEN_TEXTURE: boolean;
  134028. SHEEN_TEXTUREDIRECTUV: number;
  134029. SHEEN_LINKWITHALBEDO: boolean;
  134030. SHEEN_ROUGHNESS: boolean;
  134031. SHEEN_ALBEDOSCALING: boolean;
  134032. /** @hidden */
  134033. _areTexturesDirty: boolean;
  134034. }
  134035. /**
  134036. * Define the code related to the Sheen parameters of the pbr material.
  134037. */
  134038. export class PBRSheenConfiguration {
  134039. private _isEnabled;
  134040. /**
  134041. * Defines if the material uses sheen.
  134042. */
  134043. isEnabled: boolean;
  134044. private _linkSheenWithAlbedo;
  134045. /**
  134046. * Defines if the sheen is linked to the sheen color.
  134047. */
  134048. linkSheenWithAlbedo: boolean;
  134049. /**
  134050. * Defines the sheen intensity.
  134051. */
  134052. intensity: number;
  134053. /**
  134054. * Defines the sheen color.
  134055. */
  134056. color: Color3;
  134057. private _texture;
  134058. /**
  134059. * Stores the sheen tint values in a texture.
  134060. * rgb is tint
  134061. * a is a intensity or roughness if roughness has been defined
  134062. */
  134063. texture: Nullable<BaseTexture>;
  134064. private _roughness;
  134065. /**
  134066. * Defines the sheen roughness.
  134067. * It is not taken into account if linkSheenWithAlbedo is true.
  134068. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134069. */
  134070. roughness: Nullable<number>;
  134071. private _albedoScaling;
  134072. /**
  134073. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134074. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134075. * making it easier to setup and tweak the effect
  134076. */
  134077. albedoScaling: boolean;
  134078. /** @hidden */
  134079. private _internalMarkAllSubMeshesAsTexturesDirty;
  134080. /** @hidden */
  134081. _markAllSubMeshesAsTexturesDirty(): void;
  134082. /**
  134083. * Instantiate a new istance of clear coat configuration.
  134084. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134085. */
  134086. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134087. /**
  134088. * Specifies that the submesh is ready to be used.
  134089. * @param defines the list of "defines" to update.
  134090. * @param scene defines the scene the material belongs to.
  134091. * @returns - boolean indicating that the submesh is ready or not.
  134092. */
  134093. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134094. /**
  134095. * Checks to see if a texture is used in the material.
  134096. * @param defines the list of "defines" to update.
  134097. * @param scene defines the scene the material belongs to.
  134098. */
  134099. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134100. /**
  134101. * Binds the material data.
  134102. * @param uniformBuffer defines the Uniform buffer to fill in.
  134103. * @param scene defines the scene the material belongs to.
  134104. * @param isFrozen defines wether the material is frozen or not.
  134105. */
  134106. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134107. /**
  134108. * Checks to see if a texture is used in the material.
  134109. * @param texture - Base texture to use.
  134110. * @returns - Boolean specifying if a texture is used in the material.
  134111. */
  134112. hasTexture(texture: BaseTexture): boolean;
  134113. /**
  134114. * Returns an array of the actively used textures.
  134115. * @param activeTextures Array of BaseTextures
  134116. */
  134117. getActiveTextures(activeTextures: BaseTexture[]): void;
  134118. /**
  134119. * Returns the animatable textures.
  134120. * @param animatables Array of animatable textures.
  134121. */
  134122. getAnimatables(animatables: IAnimatable[]): void;
  134123. /**
  134124. * Disposes the resources of the material.
  134125. * @param forceDisposeTextures - Forces the disposal of all textures.
  134126. */
  134127. dispose(forceDisposeTextures?: boolean): void;
  134128. /**
  134129. * Get the current class name of the texture useful for serialization or dynamic coding.
  134130. * @returns "PBRSheenConfiguration"
  134131. */
  134132. getClassName(): string;
  134133. /**
  134134. * Add fallbacks to the effect fallbacks list.
  134135. * @param defines defines the Base texture to use.
  134136. * @param fallbacks defines the current fallback list.
  134137. * @param currentRank defines the current fallback rank.
  134138. * @returns the new fallback rank.
  134139. */
  134140. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134141. /**
  134142. * Add the required uniforms to the current list.
  134143. * @param uniforms defines the current uniform list.
  134144. */
  134145. static AddUniforms(uniforms: string[]): void;
  134146. /**
  134147. * Add the required uniforms to the current buffer.
  134148. * @param uniformBuffer defines the current uniform buffer.
  134149. */
  134150. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134151. /**
  134152. * Add the required samplers to the current list.
  134153. * @param samplers defines the current sampler list.
  134154. */
  134155. static AddSamplers(samplers: string[]): void;
  134156. /**
  134157. * Makes a duplicate of the current configuration into another one.
  134158. * @param sheenConfiguration define the config where to copy the info
  134159. */
  134160. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134161. /**
  134162. * Serializes this BRDF configuration.
  134163. * @returns - An object with the serialized config.
  134164. */
  134165. serialize(): any;
  134166. /**
  134167. * Parses a anisotropy Configuration from a serialized object.
  134168. * @param source - Serialized object.
  134169. * @param scene Defines the scene we are parsing for
  134170. * @param rootUrl Defines the rootUrl to load from
  134171. */
  134172. parse(source: any, scene: Scene, rootUrl: string): void;
  134173. }
  134174. }
  134175. declare module BABYLON {
  134176. /**
  134177. * @hidden
  134178. */
  134179. export interface IMaterialSubSurfaceDefines {
  134180. SUBSURFACE: boolean;
  134181. SS_REFRACTION: boolean;
  134182. SS_TRANSLUCENCY: boolean;
  134183. SS_SCATTERING: boolean;
  134184. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134185. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134186. SS_REFRACTIONMAP_3D: boolean;
  134187. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134188. SS_LODINREFRACTIONALPHA: boolean;
  134189. SS_GAMMAREFRACTION: boolean;
  134190. SS_RGBDREFRACTION: boolean;
  134191. SS_LINEARSPECULARREFRACTION: boolean;
  134192. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134193. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134194. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134195. /** @hidden */
  134196. _areTexturesDirty: boolean;
  134197. }
  134198. /**
  134199. * Define the code related to the sub surface parameters of the pbr material.
  134200. */
  134201. export class PBRSubSurfaceConfiguration {
  134202. private _isRefractionEnabled;
  134203. /**
  134204. * Defines if the refraction is enabled in the material.
  134205. */
  134206. isRefractionEnabled: boolean;
  134207. private _isTranslucencyEnabled;
  134208. /**
  134209. * Defines if the translucency is enabled in the material.
  134210. */
  134211. isTranslucencyEnabled: boolean;
  134212. private _isScatteringEnabled;
  134213. /**
  134214. * Defines if the sub surface scattering is enabled in the material.
  134215. */
  134216. isScatteringEnabled: boolean;
  134217. private _scatteringDiffusionProfileIndex;
  134218. /**
  134219. * Diffusion profile for subsurface scattering.
  134220. * Useful for better scattering in the skins or foliages.
  134221. */
  134222. get scatteringDiffusionProfile(): Nullable<Color3>;
  134223. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134224. /**
  134225. * Defines the refraction intensity of the material.
  134226. * The refraction when enabled replaces the Diffuse part of the material.
  134227. * The intensity helps transitionning between diffuse and refraction.
  134228. */
  134229. refractionIntensity: number;
  134230. /**
  134231. * Defines the translucency intensity of the material.
  134232. * When translucency has been enabled, this defines how much of the "translucency"
  134233. * is addded to the diffuse part of the material.
  134234. */
  134235. translucencyIntensity: number;
  134236. /**
  134237. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134238. */
  134239. useAlbedoToTintRefraction: boolean;
  134240. private _thicknessTexture;
  134241. /**
  134242. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134243. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134244. * 0 would mean minimumThickness
  134245. * 1 would mean maximumThickness
  134246. * The other channels might be use as a mask to vary the different effects intensity.
  134247. */
  134248. thicknessTexture: Nullable<BaseTexture>;
  134249. private _refractionTexture;
  134250. /**
  134251. * Defines the texture to use for refraction.
  134252. */
  134253. refractionTexture: Nullable<BaseTexture>;
  134254. private _indexOfRefraction;
  134255. /**
  134256. * Index of refraction of the material base layer.
  134257. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134258. *
  134259. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134260. *
  134261. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134262. */
  134263. indexOfRefraction: number;
  134264. private _volumeIndexOfRefraction;
  134265. /**
  134266. * Index of refraction of the material's volume.
  134267. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134268. *
  134269. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134270. * the volume will use the same IOR as the surface.
  134271. */
  134272. get volumeIndexOfRefraction(): number;
  134273. set volumeIndexOfRefraction(value: number);
  134274. private _invertRefractionY;
  134275. /**
  134276. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134277. */
  134278. invertRefractionY: boolean;
  134279. private _linkRefractionWithTransparency;
  134280. /**
  134281. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134282. * Materials half opaque for instance using refraction could benefit from this control.
  134283. */
  134284. linkRefractionWithTransparency: boolean;
  134285. /**
  134286. * Defines the minimum thickness stored in the thickness map.
  134287. * If no thickness map is defined, this value will be used to simulate thickness.
  134288. */
  134289. minimumThickness: number;
  134290. /**
  134291. * Defines the maximum thickness stored in the thickness map.
  134292. */
  134293. maximumThickness: number;
  134294. /**
  134295. * Defines the volume tint of the material.
  134296. * This is used for both translucency and scattering.
  134297. */
  134298. tintColor: Color3;
  134299. /**
  134300. * Defines the distance at which the tint color should be found in the media.
  134301. * This is used for refraction only.
  134302. */
  134303. tintColorAtDistance: number;
  134304. /**
  134305. * Defines how far each channel transmit through the media.
  134306. * It is defined as a color to simplify it selection.
  134307. */
  134308. diffusionDistance: Color3;
  134309. private _useMaskFromThicknessTexture;
  134310. /**
  134311. * Stores the intensity of the different subsurface effects in the thickness texture.
  134312. * * the green channel is the translucency intensity.
  134313. * * the blue channel is the scattering intensity.
  134314. * * the alpha channel is the refraction intensity.
  134315. */
  134316. useMaskFromThicknessTexture: boolean;
  134317. private _scene;
  134318. /** @hidden */
  134319. private _internalMarkAllSubMeshesAsTexturesDirty;
  134320. private _internalMarkScenePrePassDirty;
  134321. /** @hidden */
  134322. _markAllSubMeshesAsTexturesDirty(): void;
  134323. /** @hidden */
  134324. _markScenePrePassDirty(): void;
  134325. /**
  134326. * Instantiate a new istance of sub surface configuration.
  134327. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134328. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134329. * @param scene The scene
  134330. */
  134331. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134332. /**
  134333. * Gets wehter the submesh is ready to be used or not.
  134334. * @param defines the list of "defines" to update.
  134335. * @param scene defines the scene the material belongs to.
  134336. * @returns - boolean indicating that the submesh is ready or not.
  134337. */
  134338. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134339. /**
  134340. * Checks to see if a texture is used in the material.
  134341. * @param defines the list of "defines" to update.
  134342. * @param scene defines the scene to the material belongs to.
  134343. */
  134344. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134345. /**
  134346. * Binds the material data.
  134347. * @param uniformBuffer defines the Uniform buffer to fill in.
  134348. * @param scene defines the scene the material belongs to.
  134349. * @param engine defines the engine the material belongs to.
  134350. * @param isFrozen defines whether the material is frozen or not.
  134351. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134352. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134353. */
  134354. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134355. /**
  134356. * Unbinds the material from the mesh.
  134357. * @param activeEffect defines the effect that should be unbound from.
  134358. * @returns true if unbound, otherwise false
  134359. */
  134360. unbind(activeEffect: Effect): boolean;
  134361. /**
  134362. * Returns the texture used for refraction or null if none is used.
  134363. * @param scene defines the scene the material belongs to.
  134364. * @returns - Refraction texture if present. If no refraction texture and refraction
  134365. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134366. */
  134367. private _getRefractionTexture;
  134368. /**
  134369. * Returns true if alpha blending should be disabled.
  134370. */
  134371. get disableAlphaBlending(): boolean;
  134372. /**
  134373. * Fills the list of render target textures.
  134374. * @param renderTargets the list of render targets to update
  134375. */
  134376. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  134377. /**
  134378. * Checks to see if a texture is used in the material.
  134379. * @param texture - Base texture to use.
  134380. * @returns - Boolean specifying if a texture is used in the material.
  134381. */
  134382. hasTexture(texture: BaseTexture): boolean;
  134383. /**
  134384. * Gets a boolean indicating that current material needs to register RTT
  134385. * @returns true if this uses a render target otherwise false.
  134386. */
  134387. hasRenderTargetTextures(): boolean;
  134388. /**
  134389. * Returns an array of the actively used textures.
  134390. * @param activeTextures Array of BaseTextures
  134391. */
  134392. getActiveTextures(activeTextures: BaseTexture[]): void;
  134393. /**
  134394. * Returns the animatable textures.
  134395. * @param animatables Array of animatable textures.
  134396. */
  134397. getAnimatables(animatables: IAnimatable[]): void;
  134398. /**
  134399. * Disposes the resources of the material.
  134400. * @param forceDisposeTextures - Forces the disposal of all textures.
  134401. */
  134402. dispose(forceDisposeTextures?: boolean): void;
  134403. /**
  134404. * Get the current class name of the texture useful for serialization or dynamic coding.
  134405. * @returns "PBRSubSurfaceConfiguration"
  134406. */
  134407. getClassName(): string;
  134408. /**
  134409. * Add fallbacks to the effect fallbacks list.
  134410. * @param defines defines the Base texture to use.
  134411. * @param fallbacks defines the current fallback list.
  134412. * @param currentRank defines the current fallback rank.
  134413. * @returns the new fallback rank.
  134414. */
  134415. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134416. /**
  134417. * Add the required uniforms to the current list.
  134418. * @param uniforms defines the current uniform list.
  134419. */
  134420. static AddUniforms(uniforms: string[]): void;
  134421. /**
  134422. * Add the required samplers to the current list.
  134423. * @param samplers defines the current sampler list.
  134424. */
  134425. static AddSamplers(samplers: string[]): void;
  134426. /**
  134427. * Add the required uniforms to the current buffer.
  134428. * @param uniformBuffer defines the current uniform buffer.
  134429. */
  134430. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134431. /**
  134432. * Makes a duplicate of the current configuration into another one.
  134433. * @param configuration define the config where to copy the info
  134434. */
  134435. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134436. /**
  134437. * Serializes this Sub Surface configuration.
  134438. * @returns - An object with the serialized config.
  134439. */
  134440. serialize(): any;
  134441. /**
  134442. * Parses a anisotropy Configuration from a serialized object.
  134443. * @param source - Serialized object.
  134444. * @param scene Defines the scene we are parsing for
  134445. * @param rootUrl Defines the rootUrl to load from
  134446. */
  134447. parse(source: any, scene: Scene, rootUrl: string): void;
  134448. }
  134449. }
  134450. declare module BABYLON {
  134451. /** @hidden */
  134452. export var pbrFragmentDeclaration: {
  134453. name: string;
  134454. shader: string;
  134455. };
  134456. }
  134457. declare module BABYLON {
  134458. /** @hidden */
  134459. export var pbrUboDeclaration: {
  134460. name: string;
  134461. shader: string;
  134462. };
  134463. }
  134464. declare module BABYLON {
  134465. /** @hidden */
  134466. export var pbrFragmentExtraDeclaration: {
  134467. name: string;
  134468. shader: string;
  134469. };
  134470. }
  134471. declare module BABYLON {
  134472. /** @hidden */
  134473. export var pbrFragmentSamplersDeclaration: {
  134474. name: string;
  134475. shader: string;
  134476. };
  134477. }
  134478. declare module BABYLON {
  134479. /** @hidden */
  134480. export var importanceSampling: {
  134481. name: string;
  134482. shader: string;
  134483. };
  134484. }
  134485. declare module BABYLON {
  134486. /** @hidden */
  134487. export var pbrHelperFunctions: {
  134488. name: string;
  134489. shader: string;
  134490. };
  134491. }
  134492. declare module BABYLON {
  134493. /** @hidden */
  134494. export var harmonicsFunctions: {
  134495. name: string;
  134496. shader: string;
  134497. };
  134498. }
  134499. declare module BABYLON {
  134500. /** @hidden */
  134501. export var pbrDirectLightingSetupFunctions: {
  134502. name: string;
  134503. shader: string;
  134504. };
  134505. }
  134506. declare module BABYLON {
  134507. /** @hidden */
  134508. export var pbrDirectLightingFalloffFunctions: {
  134509. name: string;
  134510. shader: string;
  134511. };
  134512. }
  134513. declare module BABYLON {
  134514. /** @hidden */
  134515. export var pbrBRDFFunctions: {
  134516. name: string;
  134517. shader: string;
  134518. };
  134519. }
  134520. declare module BABYLON {
  134521. /** @hidden */
  134522. export var hdrFilteringFunctions: {
  134523. name: string;
  134524. shader: string;
  134525. };
  134526. }
  134527. declare module BABYLON {
  134528. /** @hidden */
  134529. export var pbrDirectLightingFunctions: {
  134530. name: string;
  134531. shader: string;
  134532. };
  134533. }
  134534. declare module BABYLON {
  134535. /** @hidden */
  134536. export var pbrIBLFunctions: {
  134537. name: string;
  134538. shader: string;
  134539. };
  134540. }
  134541. declare module BABYLON {
  134542. /** @hidden */
  134543. export var pbrBlockAlbedoOpacity: {
  134544. name: string;
  134545. shader: string;
  134546. };
  134547. }
  134548. declare module BABYLON {
  134549. /** @hidden */
  134550. export var pbrBlockReflectivity: {
  134551. name: string;
  134552. shader: string;
  134553. };
  134554. }
  134555. declare module BABYLON {
  134556. /** @hidden */
  134557. export var pbrBlockAmbientOcclusion: {
  134558. name: string;
  134559. shader: string;
  134560. };
  134561. }
  134562. declare module BABYLON {
  134563. /** @hidden */
  134564. export var pbrBlockAlphaFresnel: {
  134565. name: string;
  134566. shader: string;
  134567. };
  134568. }
  134569. declare module BABYLON {
  134570. /** @hidden */
  134571. export var pbrBlockAnisotropic: {
  134572. name: string;
  134573. shader: string;
  134574. };
  134575. }
  134576. declare module BABYLON {
  134577. /** @hidden */
  134578. export var pbrBlockReflection: {
  134579. name: string;
  134580. shader: string;
  134581. };
  134582. }
  134583. declare module BABYLON {
  134584. /** @hidden */
  134585. export var pbrBlockSheen: {
  134586. name: string;
  134587. shader: string;
  134588. };
  134589. }
  134590. declare module BABYLON {
  134591. /** @hidden */
  134592. export var pbrBlockClearcoat: {
  134593. name: string;
  134594. shader: string;
  134595. };
  134596. }
  134597. declare module BABYLON {
  134598. /** @hidden */
  134599. export var pbrBlockSubSurface: {
  134600. name: string;
  134601. shader: string;
  134602. };
  134603. }
  134604. declare module BABYLON {
  134605. /** @hidden */
  134606. export var pbrBlockNormalGeometric: {
  134607. name: string;
  134608. shader: string;
  134609. };
  134610. }
  134611. declare module BABYLON {
  134612. /** @hidden */
  134613. export var pbrBlockNormalFinal: {
  134614. name: string;
  134615. shader: string;
  134616. };
  134617. }
  134618. declare module BABYLON {
  134619. /** @hidden */
  134620. export var pbrBlockLightmapInit: {
  134621. name: string;
  134622. shader: string;
  134623. };
  134624. }
  134625. declare module BABYLON {
  134626. /** @hidden */
  134627. export var pbrBlockGeometryInfo: {
  134628. name: string;
  134629. shader: string;
  134630. };
  134631. }
  134632. declare module BABYLON {
  134633. /** @hidden */
  134634. export var pbrBlockReflectance0: {
  134635. name: string;
  134636. shader: string;
  134637. };
  134638. }
  134639. declare module BABYLON {
  134640. /** @hidden */
  134641. export var pbrBlockReflectance: {
  134642. name: string;
  134643. shader: string;
  134644. };
  134645. }
  134646. declare module BABYLON {
  134647. /** @hidden */
  134648. export var pbrBlockDirectLighting: {
  134649. name: string;
  134650. shader: string;
  134651. };
  134652. }
  134653. declare module BABYLON {
  134654. /** @hidden */
  134655. export var pbrBlockFinalLitComponents: {
  134656. name: string;
  134657. shader: string;
  134658. };
  134659. }
  134660. declare module BABYLON {
  134661. /** @hidden */
  134662. export var pbrBlockFinalUnlitComponents: {
  134663. name: string;
  134664. shader: string;
  134665. };
  134666. }
  134667. declare module BABYLON {
  134668. /** @hidden */
  134669. export var pbrBlockFinalColorComposition: {
  134670. name: string;
  134671. shader: string;
  134672. };
  134673. }
  134674. declare module BABYLON {
  134675. /** @hidden */
  134676. export var pbrBlockImageProcessing: {
  134677. name: string;
  134678. shader: string;
  134679. };
  134680. }
  134681. declare module BABYLON {
  134682. /** @hidden */
  134683. export var pbrDebug: {
  134684. name: string;
  134685. shader: string;
  134686. };
  134687. }
  134688. declare module BABYLON {
  134689. /** @hidden */
  134690. export var pbrPixelShader: {
  134691. name: string;
  134692. shader: string;
  134693. };
  134694. }
  134695. declare module BABYLON {
  134696. /** @hidden */
  134697. export var pbrVertexDeclaration: {
  134698. name: string;
  134699. shader: string;
  134700. };
  134701. }
  134702. declare module BABYLON {
  134703. /** @hidden */
  134704. export var pbrVertexShader: {
  134705. name: string;
  134706. shader: string;
  134707. };
  134708. }
  134709. declare module BABYLON {
  134710. /**
  134711. * Manages the defines for the PBR Material.
  134712. * @hidden
  134713. */
  134714. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134715. PBR: boolean;
  134716. NUM_SAMPLES: string;
  134717. REALTIME_FILTERING: boolean;
  134718. MAINUV1: boolean;
  134719. MAINUV2: boolean;
  134720. UV1: boolean;
  134721. UV2: boolean;
  134722. ALBEDO: boolean;
  134723. GAMMAALBEDO: boolean;
  134724. ALBEDODIRECTUV: number;
  134725. VERTEXCOLOR: boolean;
  134726. DETAIL: boolean;
  134727. DETAILDIRECTUV: number;
  134728. DETAIL_NORMALBLENDMETHOD: number;
  134729. AMBIENT: boolean;
  134730. AMBIENTDIRECTUV: number;
  134731. AMBIENTINGRAYSCALE: boolean;
  134732. OPACITY: boolean;
  134733. VERTEXALPHA: boolean;
  134734. OPACITYDIRECTUV: number;
  134735. OPACITYRGB: boolean;
  134736. ALPHATEST: boolean;
  134737. DEPTHPREPASS: boolean;
  134738. ALPHABLEND: boolean;
  134739. ALPHAFROMALBEDO: boolean;
  134740. ALPHATESTVALUE: string;
  134741. SPECULAROVERALPHA: boolean;
  134742. RADIANCEOVERALPHA: boolean;
  134743. ALPHAFRESNEL: boolean;
  134744. LINEARALPHAFRESNEL: boolean;
  134745. PREMULTIPLYALPHA: boolean;
  134746. EMISSIVE: boolean;
  134747. EMISSIVEDIRECTUV: number;
  134748. REFLECTIVITY: boolean;
  134749. REFLECTIVITYDIRECTUV: number;
  134750. SPECULARTERM: boolean;
  134751. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134752. MICROSURFACEAUTOMATIC: boolean;
  134753. LODBASEDMICROSFURACE: boolean;
  134754. MICROSURFACEMAP: boolean;
  134755. MICROSURFACEMAPDIRECTUV: number;
  134756. METALLICWORKFLOW: boolean;
  134757. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134758. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134759. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134760. AOSTOREINMETALMAPRED: boolean;
  134761. METALLIC_REFLECTANCE: boolean;
  134762. METALLIC_REFLECTANCEDIRECTUV: number;
  134763. ENVIRONMENTBRDF: boolean;
  134764. ENVIRONMENTBRDF_RGBD: boolean;
  134765. NORMAL: boolean;
  134766. TANGENT: boolean;
  134767. BUMP: boolean;
  134768. BUMPDIRECTUV: number;
  134769. OBJECTSPACE_NORMALMAP: boolean;
  134770. PARALLAX: boolean;
  134771. PARALLAXOCCLUSION: boolean;
  134772. NORMALXYSCALE: boolean;
  134773. LIGHTMAP: boolean;
  134774. LIGHTMAPDIRECTUV: number;
  134775. USELIGHTMAPASSHADOWMAP: boolean;
  134776. GAMMALIGHTMAP: boolean;
  134777. RGBDLIGHTMAP: boolean;
  134778. REFLECTION: boolean;
  134779. REFLECTIONMAP_3D: boolean;
  134780. REFLECTIONMAP_SPHERICAL: boolean;
  134781. REFLECTIONMAP_PLANAR: boolean;
  134782. REFLECTIONMAP_CUBIC: boolean;
  134783. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  134784. REFLECTIONMAP_PROJECTION: boolean;
  134785. REFLECTIONMAP_SKYBOX: boolean;
  134786. REFLECTIONMAP_EXPLICIT: boolean;
  134787. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  134788. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  134789. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  134790. INVERTCUBICMAP: boolean;
  134791. USESPHERICALFROMREFLECTIONMAP: boolean;
  134792. USEIRRADIANCEMAP: boolean;
  134793. SPHERICAL_HARMONICS: boolean;
  134794. USESPHERICALINVERTEX: boolean;
  134795. REFLECTIONMAP_OPPOSITEZ: boolean;
  134796. LODINREFLECTIONALPHA: boolean;
  134797. GAMMAREFLECTION: boolean;
  134798. RGBDREFLECTION: boolean;
  134799. LINEARSPECULARREFLECTION: boolean;
  134800. RADIANCEOCCLUSION: boolean;
  134801. HORIZONOCCLUSION: boolean;
  134802. INSTANCES: boolean;
  134803. THIN_INSTANCES: boolean;
  134804. PREPASS: boolean;
  134805. SCENE_MRT_COUNT: number;
  134806. NUM_BONE_INFLUENCERS: number;
  134807. BonesPerMesh: number;
  134808. BONETEXTURE: boolean;
  134809. NONUNIFORMSCALING: boolean;
  134810. MORPHTARGETS: boolean;
  134811. MORPHTARGETS_NORMAL: boolean;
  134812. MORPHTARGETS_TANGENT: boolean;
  134813. MORPHTARGETS_UV: boolean;
  134814. NUM_MORPH_INFLUENCERS: number;
  134815. IMAGEPROCESSING: boolean;
  134816. VIGNETTE: boolean;
  134817. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134818. VIGNETTEBLENDMODEOPAQUE: boolean;
  134819. TONEMAPPING: boolean;
  134820. TONEMAPPING_ACES: boolean;
  134821. CONTRAST: boolean;
  134822. COLORCURVES: boolean;
  134823. COLORGRADING: boolean;
  134824. COLORGRADING3D: boolean;
  134825. SAMPLER3DGREENDEPTH: boolean;
  134826. SAMPLER3DBGRMAP: boolean;
  134827. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134828. EXPOSURE: boolean;
  134829. MULTIVIEW: boolean;
  134830. USEPHYSICALLIGHTFALLOFF: boolean;
  134831. USEGLTFLIGHTFALLOFF: boolean;
  134832. TWOSIDEDLIGHTING: boolean;
  134833. SHADOWFLOAT: boolean;
  134834. CLIPPLANE: boolean;
  134835. CLIPPLANE2: boolean;
  134836. CLIPPLANE3: boolean;
  134837. CLIPPLANE4: boolean;
  134838. CLIPPLANE5: boolean;
  134839. CLIPPLANE6: boolean;
  134840. POINTSIZE: boolean;
  134841. FOG: boolean;
  134842. LOGARITHMICDEPTH: boolean;
  134843. FORCENORMALFORWARD: boolean;
  134844. SPECULARAA: boolean;
  134845. CLEARCOAT: boolean;
  134846. CLEARCOAT_DEFAULTIOR: boolean;
  134847. CLEARCOAT_TEXTURE: boolean;
  134848. CLEARCOAT_TEXTUREDIRECTUV: number;
  134849. CLEARCOAT_BUMP: boolean;
  134850. CLEARCOAT_BUMPDIRECTUV: number;
  134851. CLEARCOAT_TINT: boolean;
  134852. CLEARCOAT_TINT_TEXTURE: boolean;
  134853. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134854. ANISOTROPIC: boolean;
  134855. ANISOTROPIC_TEXTURE: boolean;
  134856. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134857. BRDF_V_HEIGHT_CORRELATED: boolean;
  134858. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134859. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134860. SHEEN: boolean;
  134861. SHEEN_TEXTURE: boolean;
  134862. SHEEN_TEXTUREDIRECTUV: number;
  134863. SHEEN_LINKWITHALBEDO: boolean;
  134864. SHEEN_ROUGHNESS: boolean;
  134865. SHEEN_ALBEDOSCALING: boolean;
  134866. SUBSURFACE: boolean;
  134867. SS_REFRACTION: boolean;
  134868. SS_TRANSLUCENCY: boolean;
  134869. SS_SCATTERING: boolean;
  134870. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134871. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134872. SS_REFRACTIONMAP_3D: boolean;
  134873. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134874. SS_LODINREFRACTIONALPHA: boolean;
  134875. SS_GAMMAREFRACTION: boolean;
  134876. SS_RGBDREFRACTION: boolean;
  134877. SS_LINEARSPECULARREFRACTION: boolean;
  134878. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134879. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134880. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134881. UNLIT: boolean;
  134882. DEBUGMODE: number;
  134883. /**
  134884. * Initializes the PBR Material defines.
  134885. */
  134886. constructor();
  134887. /**
  134888. * Resets the PBR Material defines.
  134889. */
  134890. reset(): void;
  134891. }
  134892. /**
  134893. * The Physically based material base class of BJS.
  134894. *
  134895. * This offers the main features of a standard PBR material.
  134896. * For more information, please refer to the documentation :
  134897. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134898. */
  134899. export abstract class PBRBaseMaterial extends PushMaterial {
  134900. /**
  134901. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134902. */
  134903. static readonly PBRMATERIAL_OPAQUE: number;
  134904. /**
  134905. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134906. */
  134907. static readonly PBRMATERIAL_ALPHATEST: number;
  134908. /**
  134909. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134910. */
  134911. static readonly PBRMATERIAL_ALPHABLEND: number;
  134912. /**
  134913. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134914. * They are also discarded below the alpha cutoff threshold to improve performances.
  134915. */
  134916. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134917. /**
  134918. * Defines the default value of how much AO map is occluding the analytical lights
  134919. * (point spot...).
  134920. */
  134921. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134922. /**
  134923. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  134924. */
  134925. static readonly LIGHTFALLOFF_PHYSICAL: number;
  134926. /**
  134927. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  134928. * to enhance interoperability with other engines.
  134929. */
  134930. static readonly LIGHTFALLOFF_GLTF: number;
  134931. /**
  134932. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  134933. * to enhance interoperability with other materials.
  134934. */
  134935. static readonly LIGHTFALLOFF_STANDARD: number;
  134936. /**
  134937. * Intensity of the direct lights e.g. the four lights available in your scene.
  134938. * This impacts both the direct diffuse and specular highlights.
  134939. */
  134940. protected _directIntensity: number;
  134941. /**
  134942. * Intensity of the emissive part of the material.
  134943. * This helps controlling the emissive effect without modifying the emissive color.
  134944. */
  134945. protected _emissiveIntensity: number;
  134946. /**
  134947. * Intensity of the environment e.g. how much the environment will light the object
  134948. * either through harmonics for rough material or through the refelction for shiny ones.
  134949. */
  134950. protected _environmentIntensity: number;
  134951. /**
  134952. * This is a special control allowing the reduction of the specular highlights coming from the
  134953. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134954. */
  134955. protected _specularIntensity: number;
  134956. /**
  134957. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  134958. */
  134959. private _lightingInfos;
  134960. /**
  134961. * Debug Control allowing disabling the bump map on this material.
  134962. */
  134963. protected _disableBumpMap: boolean;
  134964. /**
  134965. * AKA Diffuse Texture in standard nomenclature.
  134966. */
  134967. protected _albedoTexture: Nullable<BaseTexture>;
  134968. /**
  134969. * AKA Occlusion Texture in other nomenclature.
  134970. */
  134971. protected _ambientTexture: Nullable<BaseTexture>;
  134972. /**
  134973. * AKA Occlusion Texture Intensity in other nomenclature.
  134974. */
  134975. protected _ambientTextureStrength: number;
  134976. /**
  134977. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134978. * 1 means it completely occludes it
  134979. * 0 mean it has no impact
  134980. */
  134981. protected _ambientTextureImpactOnAnalyticalLights: number;
  134982. /**
  134983. * Stores the alpha values in a texture.
  134984. */
  134985. protected _opacityTexture: Nullable<BaseTexture>;
  134986. /**
  134987. * Stores the reflection values in a texture.
  134988. */
  134989. protected _reflectionTexture: Nullable<BaseTexture>;
  134990. /**
  134991. * Stores the emissive values in a texture.
  134992. */
  134993. protected _emissiveTexture: Nullable<BaseTexture>;
  134994. /**
  134995. * AKA Specular texture in other nomenclature.
  134996. */
  134997. protected _reflectivityTexture: Nullable<BaseTexture>;
  134998. /**
  134999. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135000. */
  135001. protected _metallicTexture: Nullable<BaseTexture>;
  135002. /**
  135003. * Specifies the metallic scalar of the metallic/roughness workflow.
  135004. * Can also be used to scale the metalness values of the metallic texture.
  135005. */
  135006. protected _metallic: Nullable<number>;
  135007. /**
  135008. * Specifies the roughness scalar of the metallic/roughness workflow.
  135009. * Can also be used to scale the roughness values of the metallic texture.
  135010. */
  135011. protected _roughness: Nullable<number>;
  135012. /**
  135013. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135014. * By default the indexOfrefraction is used to compute F0;
  135015. *
  135016. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135017. *
  135018. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135019. * F90 = metallicReflectanceColor;
  135020. */
  135021. protected _metallicF0Factor: number;
  135022. /**
  135023. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135024. * By default the F90 is always 1;
  135025. *
  135026. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135027. *
  135028. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135029. * F90 = metallicReflectanceColor;
  135030. */
  135031. protected _metallicReflectanceColor: Color3;
  135032. /**
  135033. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135034. * This is multiply against the scalar values defined in the material.
  135035. */
  135036. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135037. /**
  135038. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135039. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135040. */
  135041. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135042. /**
  135043. * Stores surface normal data used to displace a mesh in a texture.
  135044. */
  135045. protected _bumpTexture: Nullable<BaseTexture>;
  135046. /**
  135047. * Stores the pre-calculated light information of a mesh in a texture.
  135048. */
  135049. protected _lightmapTexture: Nullable<BaseTexture>;
  135050. /**
  135051. * The color of a material in ambient lighting.
  135052. */
  135053. protected _ambientColor: Color3;
  135054. /**
  135055. * AKA Diffuse Color in other nomenclature.
  135056. */
  135057. protected _albedoColor: Color3;
  135058. /**
  135059. * AKA Specular Color in other nomenclature.
  135060. */
  135061. protected _reflectivityColor: Color3;
  135062. /**
  135063. * The color applied when light is reflected from a material.
  135064. */
  135065. protected _reflectionColor: Color3;
  135066. /**
  135067. * The color applied when light is emitted from a material.
  135068. */
  135069. protected _emissiveColor: Color3;
  135070. /**
  135071. * AKA Glossiness in other nomenclature.
  135072. */
  135073. protected _microSurface: number;
  135074. /**
  135075. * Specifies that the material will use the light map as a show map.
  135076. */
  135077. protected _useLightmapAsShadowmap: boolean;
  135078. /**
  135079. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135080. * makes the reflect vector face the model (under horizon).
  135081. */
  135082. protected _useHorizonOcclusion: boolean;
  135083. /**
  135084. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135085. * too much the area relying on ambient texture to define their ambient occlusion.
  135086. */
  135087. protected _useRadianceOcclusion: boolean;
  135088. /**
  135089. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135090. */
  135091. protected _useAlphaFromAlbedoTexture: boolean;
  135092. /**
  135093. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135094. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135095. */
  135096. protected _useSpecularOverAlpha: boolean;
  135097. /**
  135098. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135099. */
  135100. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135101. /**
  135102. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135103. */
  135104. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135105. /**
  135106. * Specifies if the metallic texture contains the roughness information in its green channel.
  135107. */
  135108. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135109. /**
  135110. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135111. */
  135112. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135113. /**
  135114. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135115. */
  135116. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135117. /**
  135118. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135119. */
  135120. protected _useAmbientInGrayScale: boolean;
  135121. /**
  135122. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135123. * The material will try to infer what glossiness each pixel should be.
  135124. */
  135125. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135126. /**
  135127. * Defines the falloff type used in this material.
  135128. * It by default is Physical.
  135129. */
  135130. protected _lightFalloff: number;
  135131. /**
  135132. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135133. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135134. */
  135135. protected _useRadianceOverAlpha: boolean;
  135136. /**
  135137. * Allows using an object space normal map (instead of tangent space).
  135138. */
  135139. protected _useObjectSpaceNormalMap: boolean;
  135140. /**
  135141. * Allows using the bump map in parallax mode.
  135142. */
  135143. protected _useParallax: boolean;
  135144. /**
  135145. * Allows using the bump map in parallax occlusion mode.
  135146. */
  135147. protected _useParallaxOcclusion: boolean;
  135148. /**
  135149. * Controls the scale bias of the parallax mode.
  135150. */
  135151. protected _parallaxScaleBias: number;
  135152. /**
  135153. * If sets to true, disables all the lights affecting the material.
  135154. */
  135155. protected _disableLighting: boolean;
  135156. /**
  135157. * Number of Simultaneous lights allowed on the material.
  135158. */
  135159. protected _maxSimultaneousLights: number;
  135160. /**
  135161. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135162. */
  135163. protected _invertNormalMapX: boolean;
  135164. /**
  135165. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135166. */
  135167. protected _invertNormalMapY: boolean;
  135168. /**
  135169. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135170. */
  135171. protected _twoSidedLighting: boolean;
  135172. /**
  135173. * Defines the alpha limits in alpha test mode.
  135174. */
  135175. protected _alphaCutOff: number;
  135176. /**
  135177. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135178. */
  135179. protected _forceAlphaTest: boolean;
  135180. /**
  135181. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135182. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135183. */
  135184. protected _useAlphaFresnel: boolean;
  135185. /**
  135186. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135187. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135188. */
  135189. protected _useLinearAlphaFresnel: boolean;
  135190. /**
  135191. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135192. * from cos thetav and roughness:
  135193. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135194. */
  135195. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135196. /**
  135197. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135198. */
  135199. protected _forceIrradianceInFragment: boolean;
  135200. private _realTimeFiltering;
  135201. /**
  135202. * Enables realtime filtering on the texture.
  135203. */
  135204. get realTimeFiltering(): boolean;
  135205. set realTimeFiltering(b: boolean);
  135206. private _realTimeFilteringQuality;
  135207. /**
  135208. * Quality switch for realtime filtering
  135209. */
  135210. get realTimeFilteringQuality(): number;
  135211. set realTimeFilteringQuality(n: number);
  135212. /**
  135213. * Can this material render to several textures at once
  135214. */
  135215. get canRenderToMRT(): boolean;
  135216. /**
  135217. * Force normal to face away from face.
  135218. */
  135219. protected _forceNormalForward: boolean;
  135220. /**
  135221. * Enables specular anti aliasing in the PBR shader.
  135222. * It will both interacts on the Geometry for analytical and IBL lighting.
  135223. * It also prefilter the roughness map based on the bump values.
  135224. */
  135225. protected _enableSpecularAntiAliasing: boolean;
  135226. /**
  135227. * Default configuration related to image processing available in the PBR Material.
  135228. */
  135229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135230. /**
  135231. * Keep track of the image processing observer to allow dispose and replace.
  135232. */
  135233. private _imageProcessingObserver;
  135234. /**
  135235. * Attaches a new image processing configuration to the PBR Material.
  135236. * @param configuration
  135237. */
  135238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135239. /**
  135240. * Stores the available render targets.
  135241. */
  135242. private _renderTargets;
  135243. /**
  135244. * Sets the global ambient color for the material used in lighting calculations.
  135245. */
  135246. private _globalAmbientColor;
  135247. /**
  135248. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135249. */
  135250. private _useLogarithmicDepth;
  135251. /**
  135252. * If set to true, no lighting calculations will be applied.
  135253. */
  135254. private _unlit;
  135255. private _debugMode;
  135256. /**
  135257. * @hidden
  135258. * This is reserved for the inspector.
  135259. * Defines the material debug mode.
  135260. * It helps seeing only some components of the material while troubleshooting.
  135261. */
  135262. debugMode: number;
  135263. /**
  135264. * @hidden
  135265. * This is reserved for the inspector.
  135266. * Specify from where on screen the debug mode should start.
  135267. * The value goes from -1 (full screen) to 1 (not visible)
  135268. * It helps with side by side comparison against the final render
  135269. * This defaults to -1
  135270. */
  135271. private debugLimit;
  135272. /**
  135273. * @hidden
  135274. * This is reserved for the inspector.
  135275. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135276. * You can use the factor to better multiply the final value.
  135277. */
  135278. private debugFactor;
  135279. /**
  135280. * Defines the clear coat layer parameters for the material.
  135281. */
  135282. readonly clearCoat: PBRClearCoatConfiguration;
  135283. /**
  135284. * Defines the anisotropic parameters for the material.
  135285. */
  135286. readonly anisotropy: PBRAnisotropicConfiguration;
  135287. /**
  135288. * Defines the BRDF parameters for the material.
  135289. */
  135290. readonly brdf: PBRBRDFConfiguration;
  135291. /**
  135292. * Defines the Sheen parameters for the material.
  135293. */
  135294. readonly sheen: PBRSheenConfiguration;
  135295. /**
  135296. * Defines the SubSurface parameters for the material.
  135297. */
  135298. readonly subSurface: PBRSubSurfaceConfiguration;
  135299. /**
  135300. * Defines the detail map parameters for the material.
  135301. */
  135302. readonly detailMap: DetailMapConfiguration;
  135303. protected _rebuildInParallel: boolean;
  135304. /**
  135305. * Instantiates a new PBRMaterial instance.
  135306. *
  135307. * @param name The material name
  135308. * @param scene The scene the material will be use in.
  135309. */
  135310. constructor(name: string, scene: Scene);
  135311. /**
  135312. * Gets a boolean indicating that current material needs to register RTT
  135313. */
  135314. get hasRenderTargetTextures(): boolean;
  135315. /**
  135316. * Gets the name of the material class.
  135317. */
  135318. getClassName(): string;
  135319. /**
  135320. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135321. */
  135322. get useLogarithmicDepth(): boolean;
  135323. /**
  135324. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135325. */
  135326. set useLogarithmicDepth(value: boolean);
  135327. /**
  135328. * Returns true if alpha blending should be disabled.
  135329. */
  135330. protected get _disableAlphaBlending(): boolean;
  135331. /**
  135332. * Specifies whether or not this material should be rendered in alpha blend mode.
  135333. */
  135334. needAlphaBlending(): boolean;
  135335. /**
  135336. * Specifies whether or not this material should be rendered in alpha test mode.
  135337. */
  135338. needAlphaTesting(): boolean;
  135339. /**
  135340. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135341. */
  135342. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135343. /**
  135344. * Gets the texture used for the alpha test.
  135345. */
  135346. getAlphaTestTexture(): Nullable<BaseTexture>;
  135347. /**
  135348. * Specifies that the submesh is ready to be used.
  135349. * @param mesh - BJS mesh.
  135350. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135351. * @param useInstances - Specifies that instances should be used.
  135352. * @returns - boolean indicating that the submesh is ready or not.
  135353. */
  135354. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135355. /**
  135356. * Specifies if the material uses metallic roughness workflow.
  135357. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135358. */
  135359. isMetallicWorkflow(): boolean;
  135360. private _prepareEffect;
  135361. private _prepareDefines;
  135362. /**
  135363. * Force shader compilation
  135364. */
  135365. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135366. /**
  135367. * Initializes the uniform buffer layout for the shader.
  135368. */
  135369. buildUniformLayout(): void;
  135370. /**
  135371. * Unbinds the material from the mesh
  135372. */
  135373. unbind(): void;
  135374. /**
  135375. * Binds the submesh data.
  135376. * @param world - The world matrix.
  135377. * @param mesh - The BJS mesh.
  135378. * @param subMesh - A submesh of the BJS mesh.
  135379. */
  135380. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135381. /**
  135382. * Returns the animatable textures.
  135383. * @returns - Array of animatable textures.
  135384. */
  135385. getAnimatables(): IAnimatable[];
  135386. /**
  135387. * Returns the texture used for reflections.
  135388. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  135389. */
  135390. private _getReflectionTexture;
  135391. /**
  135392. * Returns an array of the actively used textures.
  135393. * @returns - Array of BaseTextures
  135394. */
  135395. getActiveTextures(): BaseTexture[];
  135396. /**
  135397. * Checks to see if a texture is used in the material.
  135398. * @param texture - Base texture to use.
  135399. * @returns - Boolean specifying if a texture is used in the material.
  135400. */
  135401. hasTexture(texture: BaseTexture): boolean;
  135402. /**
  135403. * Sets the required values to the prepass renderer.
  135404. * @param prePassRenderer defines the prepass renderer to setup
  135405. */
  135406. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135407. /**
  135408. * Disposes the resources of the material.
  135409. * @param forceDisposeEffect - Forces the disposal of effects.
  135410. * @param forceDisposeTextures - Forces the disposal of all textures.
  135411. */
  135412. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135413. }
  135414. }
  135415. declare module BABYLON {
  135416. /**
  135417. * The Physically based material of BJS.
  135418. *
  135419. * This offers the main features of a standard PBR material.
  135420. * For more information, please refer to the documentation :
  135421. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135422. */
  135423. export class PBRMaterial extends PBRBaseMaterial {
  135424. /**
  135425. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135426. */
  135427. static readonly PBRMATERIAL_OPAQUE: number;
  135428. /**
  135429. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135430. */
  135431. static readonly PBRMATERIAL_ALPHATEST: number;
  135432. /**
  135433. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135434. */
  135435. static readonly PBRMATERIAL_ALPHABLEND: number;
  135436. /**
  135437. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135438. * They are also discarded below the alpha cutoff threshold to improve performances.
  135439. */
  135440. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135441. /**
  135442. * Defines the default value of how much AO map is occluding the analytical lights
  135443. * (point spot...).
  135444. */
  135445. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135446. /**
  135447. * Intensity of the direct lights e.g. the four lights available in your scene.
  135448. * This impacts both the direct diffuse and specular highlights.
  135449. */
  135450. directIntensity: number;
  135451. /**
  135452. * Intensity of the emissive part of the material.
  135453. * This helps controlling the emissive effect without modifying the emissive color.
  135454. */
  135455. emissiveIntensity: number;
  135456. /**
  135457. * Intensity of the environment e.g. how much the environment will light the object
  135458. * either through harmonics for rough material or through the refelction for shiny ones.
  135459. */
  135460. environmentIntensity: number;
  135461. /**
  135462. * This is a special control allowing the reduction of the specular highlights coming from the
  135463. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135464. */
  135465. specularIntensity: number;
  135466. /**
  135467. * Debug Control allowing disabling the bump map on this material.
  135468. */
  135469. disableBumpMap: boolean;
  135470. /**
  135471. * AKA Diffuse Texture in standard nomenclature.
  135472. */
  135473. albedoTexture: BaseTexture;
  135474. /**
  135475. * AKA Occlusion Texture in other nomenclature.
  135476. */
  135477. ambientTexture: BaseTexture;
  135478. /**
  135479. * AKA Occlusion Texture Intensity in other nomenclature.
  135480. */
  135481. ambientTextureStrength: number;
  135482. /**
  135483. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135484. * 1 means it completely occludes it
  135485. * 0 mean it has no impact
  135486. */
  135487. ambientTextureImpactOnAnalyticalLights: number;
  135488. /**
  135489. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135490. */
  135491. opacityTexture: BaseTexture;
  135492. /**
  135493. * Stores the reflection values in a texture.
  135494. */
  135495. reflectionTexture: Nullable<BaseTexture>;
  135496. /**
  135497. * Stores the emissive values in a texture.
  135498. */
  135499. emissiveTexture: BaseTexture;
  135500. /**
  135501. * AKA Specular texture in other nomenclature.
  135502. */
  135503. reflectivityTexture: BaseTexture;
  135504. /**
  135505. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135506. */
  135507. metallicTexture: BaseTexture;
  135508. /**
  135509. * Specifies the metallic scalar of the metallic/roughness workflow.
  135510. * Can also be used to scale the metalness values of the metallic texture.
  135511. */
  135512. metallic: Nullable<number>;
  135513. /**
  135514. * Specifies the roughness scalar of the metallic/roughness workflow.
  135515. * Can also be used to scale the roughness values of the metallic texture.
  135516. */
  135517. roughness: Nullable<number>;
  135518. /**
  135519. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135520. * By default the indexOfrefraction is used to compute F0;
  135521. *
  135522. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135523. *
  135524. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135525. * F90 = metallicReflectanceColor;
  135526. */
  135527. metallicF0Factor: number;
  135528. /**
  135529. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135530. * By default the F90 is always 1;
  135531. *
  135532. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135533. *
  135534. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135535. * F90 = metallicReflectanceColor;
  135536. */
  135537. metallicReflectanceColor: Color3;
  135538. /**
  135539. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135540. * This is multiply against the scalar values defined in the material.
  135541. */
  135542. metallicReflectanceTexture: Nullable<BaseTexture>;
  135543. /**
  135544. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135545. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135546. */
  135547. microSurfaceTexture: BaseTexture;
  135548. /**
  135549. * Stores surface normal data used to displace a mesh in a texture.
  135550. */
  135551. bumpTexture: BaseTexture;
  135552. /**
  135553. * Stores the pre-calculated light information of a mesh in a texture.
  135554. */
  135555. lightmapTexture: BaseTexture;
  135556. /**
  135557. * Stores the refracted light information in a texture.
  135558. */
  135559. get refractionTexture(): Nullable<BaseTexture>;
  135560. set refractionTexture(value: Nullable<BaseTexture>);
  135561. /**
  135562. * The color of a material in ambient lighting.
  135563. */
  135564. ambientColor: Color3;
  135565. /**
  135566. * AKA Diffuse Color in other nomenclature.
  135567. */
  135568. albedoColor: Color3;
  135569. /**
  135570. * AKA Specular Color in other nomenclature.
  135571. */
  135572. reflectivityColor: Color3;
  135573. /**
  135574. * The color reflected from the material.
  135575. */
  135576. reflectionColor: Color3;
  135577. /**
  135578. * The color emitted from the material.
  135579. */
  135580. emissiveColor: Color3;
  135581. /**
  135582. * AKA Glossiness in other nomenclature.
  135583. */
  135584. microSurface: number;
  135585. /**
  135586. * Index of refraction of the material base layer.
  135587. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135588. *
  135589. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135590. *
  135591. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135592. */
  135593. get indexOfRefraction(): number;
  135594. set indexOfRefraction(value: number);
  135595. /**
  135596. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135597. */
  135598. get invertRefractionY(): boolean;
  135599. set invertRefractionY(value: boolean);
  135600. /**
  135601. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135602. * Materials half opaque for instance using refraction could benefit from this control.
  135603. */
  135604. get linkRefractionWithTransparency(): boolean;
  135605. set linkRefractionWithTransparency(value: boolean);
  135606. /**
  135607. * If true, the light map contains occlusion information instead of lighting info.
  135608. */
  135609. useLightmapAsShadowmap: boolean;
  135610. /**
  135611. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135612. */
  135613. useAlphaFromAlbedoTexture: boolean;
  135614. /**
  135615. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135616. */
  135617. forceAlphaTest: boolean;
  135618. /**
  135619. * Defines the alpha limits in alpha test mode.
  135620. */
  135621. alphaCutOff: number;
  135622. /**
  135623. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135624. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135625. */
  135626. useSpecularOverAlpha: boolean;
  135627. /**
  135628. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135629. */
  135630. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135631. /**
  135632. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135633. */
  135634. useRoughnessFromMetallicTextureAlpha: boolean;
  135635. /**
  135636. * Specifies if the metallic texture contains the roughness information in its green channel.
  135637. */
  135638. useRoughnessFromMetallicTextureGreen: boolean;
  135639. /**
  135640. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135641. */
  135642. useMetallnessFromMetallicTextureBlue: boolean;
  135643. /**
  135644. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135645. */
  135646. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135647. /**
  135648. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135649. */
  135650. useAmbientInGrayScale: boolean;
  135651. /**
  135652. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135653. * The material will try to infer what glossiness each pixel should be.
  135654. */
  135655. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135656. /**
  135657. * BJS is using an harcoded light falloff based on a manually sets up range.
  135658. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135659. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135660. */
  135661. get usePhysicalLightFalloff(): boolean;
  135662. /**
  135663. * BJS is using an harcoded light falloff based on a manually sets up range.
  135664. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135665. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135666. */
  135667. set usePhysicalLightFalloff(value: boolean);
  135668. /**
  135669. * In order to support the falloff compatibility with gltf, a special mode has been added
  135670. * to reproduce the gltf light falloff.
  135671. */
  135672. get useGLTFLightFalloff(): boolean;
  135673. /**
  135674. * In order to support the falloff compatibility with gltf, a special mode has been added
  135675. * to reproduce the gltf light falloff.
  135676. */
  135677. set useGLTFLightFalloff(value: boolean);
  135678. /**
  135679. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135680. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135681. */
  135682. useRadianceOverAlpha: boolean;
  135683. /**
  135684. * Allows using an object space normal map (instead of tangent space).
  135685. */
  135686. useObjectSpaceNormalMap: boolean;
  135687. /**
  135688. * Allows using the bump map in parallax mode.
  135689. */
  135690. useParallax: boolean;
  135691. /**
  135692. * Allows using the bump map in parallax occlusion mode.
  135693. */
  135694. useParallaxOcclusion: boolean;
  135695. /**
  135696. * Controls the scale bias of the parallax mode.
  135697. */
  135698. parallaxScaleBias: number;
  135699. /**
  135700. * If sets to true, disables all the lights affecting the material.
  135701. */
  135702. disableLighting: boolean;
  135703. /**
  135704. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135705. */
  135706. forceIrradianceInFragment: boolean;
  135707. /**
  135708. * Number of Simultaneous lights allowed on the material.
  135709. */
  135710. maxSimultaneousLights: number;
  135711. /**
  135712. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135713. */
  135714. invertNormalMapX: boolean;
  135715. /**
  135716. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135717. */
  135718. invertNormalMapY: boolean;
  135719. /**
  135720. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135721. */
  135722. twoSidedLighting: boolean;
  135723. /**
  135724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135725. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135726. */
  135727. useAlphaFresnel: boolean;
  135728. /**
  135729. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135730. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135731. */
  135732. useLinearAlphaFresnel: boolean;
  135733. /**
  135734. * Let user defines the brdf lookup texture used for IBL.
  135735. * A default 8bit version is embedded but you could point at :
  135736. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135737. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135738. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135739. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135740. */
  135741. environmentBRDFTexture: Nullable<BaseTexture>;
  135742. /**
  135743. * Force normal to face away from face.
  135744. */
  135745. forceNormalForward: boolean;
  135746. /**
  135747. * Enables specular anti aliasing in the PBR shader.
  135748. * It will both interacts on the Geometry for analytical and IBL lighting.
  135749. * It also prefilter the roughness map based on the bump values.
  135750. */
  135751. enableSpecularAntiAliasing: boolean;
  135752. /**
  135753. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135754. * makes the reflect vector face the model (under horizon).
  135755. */
  135756. useHorizonOcclusion: boolean;
  135757. /**
  135758. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135759. * too much the area relying on ambient texture to define their ambient occlusion.
  135760. */
  135761. useRadianceOcclusion: boolean;
  135762. /**
  135763. * If set to true, no lighting calculations will be applied.
  135764. */
  135765. unlit: boolean;
  135766. /**
  135767. * Gets the image processing configuration used either in this material.
  135768. */
  135769. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  135770. /**
  135771. * Sets the Default image processing configuration used either in the this material.
  135772. *
  135773. * If sets to null, the scene one is in use.
  135774. */
  135775. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  135776. /**
  135777. * Gets wether the color curves effect is enabled.
  135778. */
  135779. get cameraColorCurvesEnabled(): boolean;
  135780. /**
  135781. * Sets wether the color curves effect is enabled.
  135782. */
  135783. set cameraColorCurvesEnabled(value: boolean);
  135784. /**
  135785. * Gets wether the color grading effect is enabled.
  135786. */
  135787. get cameraColorGradingEnabled(): boolean;
  135788. /**
  135789. * Gets wether the color grading effect is enabled.
  135790. */
  135791. set cameraColorGradingEnabled(value: boolean);
  135792. /**
  135793. * Gets wether tonemapping is enabled or not.
  135794. */
  135795. get cameraToneMappingEnabled(): boolean;
  135796. /**
  135797. * Sets wether tonemapping is enabled or not
  135798. */
  135799. set cameraToneMappingEnabled(value: boolean);
  135800. /**
  135801. * The camera exposure used on this material.
  135802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135803. * This corresponds to a photographic exposure.
  135804. */
  135805. get cameraExposure(): number;
  135806. /**
  135807. * The camera exposure used on this material.
  135808. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135809. * This corresponds to a photographic exposure.
  135810. */
  135811. set cameraExposure(value: number);
  135812. /**
  135813. * Gets The camera contrast used on this material.
  135814. */
  135815. get cameraContrast(): number;
  135816. /**
  135817. * Sets The camera contrast used on this material.
  135818. */
  135819. set cameraContrast(value: number);
  135820. /**
  135821. * Gets the Color Grading 2D Lookup Texture.
  135822. */
  135823. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135824. /**
  135825. * Sets the Color Grading 2D Lookup Texture.
  135826. */
  135827. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135828. /**
  135829. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135830. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135831. * 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;
  135832. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135833. */
  135834. get cameraColorCurves(): Nullable<ColorCurves>;
  135835. /**
  135836. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135837. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135838. * 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;
  135839. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135840. */
  135841. set cameraColorCurves(value: Nullable<ColorCurves>);
  135842. /**
  135843. * Instantiates a new PBRMaterial instance.
  135844. *
  135845. * @param name The material name
  135846. * @param scene The scene the material will be use in.
  135847. */
  135848. constructor(name: string, scene: Scene);
  135849. /**
  135850. * Returns the name of this material class.
  135851. */
  135852. getClassName(): string;
  135853. /**
  135854. * Makes a duplicate of the current material.
  135855. * @param name - name to use for the new material.
  135856. */
  135857. clone(name: string): PBRMaterial;
  135858. /**
  135859. * Serializes this PBR Material.
  135860. * @returns - An object with the serialized material.
  135861. */
  135862. serialize(): any;
  135863. /**
  135864. * Parses a PBR Material from a serialized object.
  135865. * @param source - Serialized object.
  135866. * @param scene - BJS scene instance.
  135867. * @param rootUrl - url for the scene object
  135868. * @returns - PBRMaterial
  135869. */
  135870. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  135871. }
  135872. }
  135873. declare module BABYLON {
  135874. /**
  135875. * Direct draw surface info
  135876. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  135877. */
  135878. export interface DDSInfo {
  135879. /**
  135880. * Width of the texture
  135881. */
  135882. width: number;
  135883. /**
  135884. * Width of the texture
  135885. */
  135886. height: number;
  135887. /**
  135888. * Number of Mipmaps for the texture
  135889. * @see https://en.wikipedia.org/wiki/Mipmap
  135890. */
  135891. mipmapCount: number;
  135892. /**
  135893. * If the textures format is a known fourCC format
  135894. * @see https://www.fourcc.org/
  135895. */
  135896. isFourCC: boolean;
  135897. /**
  135898. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  135899. */
  135900. isRGB: boolean;
  135901. /**
  135902. * If the texture is a lumincance format
  135903. */
  135904. isLuminance: boolean;
  135905. /**
  135906. * If this is a cube texture
  135907. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  135908. */
  135909. isCube: boolean;
  135910. /**
  135911. * If the texture is a compressed format eg. FOURCC_DXT1
  135912. */
  135913. isCompressed: boolean;
  135914. /**
  135915. * The dxgiFormat of the texture
  135916. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  135917. */
  135918. dxgiFormat: number;
  135919. /**
  135920. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  135921. */
  135922. textureType: number;
  135923. /**
  135924. * Sphericle polynomial created for the dds texture
  135925. */
  135926. sphericalPolynomial?: SphericalPolynomial;
  135927. }
  135928. /**
  135929. * Class used to provide DDS decompression tools
  135930. */
  135931. export class DDSTools {
  135932. /**
  135933. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  135934. */
  135935. static StoreLODInAlphaChannel: boolean;
  135936. /**
  135937. * Gets DDS information from an array buffer
  135938. * @param data defines the array buffer view to read data from
  135939. * @returns the DDS information
  135940. */
  135941. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  135942. private static _FloatView;
  135943. private static _Int32View;
  135944. private static _ToHalfFloat;
  135945. private static _FromHalfFloat;
  135946. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  135947. private static _GetHalfFloatRGBAArrayBuffer;
  135948. private static _GetFloatRGBAArrayBuffer;
  135949. private static _GetFloatAsUIntRGBAArrayBuffer;
  135950. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  135951. private static _GetRGBAArrayBuffer;
  135952. private static _ExtractLongWordOrder;
  135953. private static _GetRGBArrayBuffer;
  135954. private static _GetLuminanceArrayBuffer;
  135955. /**
  135956. * Uploads DDS Levels to a Babylon Texture
  135957. * @hidden
  135958. */
  135959. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  135960. }
  135961. interface ThinEngine {
  135962. /**
  135963. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  135964. * @param rootUrl defines the url where the file to load is located
  135965. * @param scene defines the current scene
  135966. * @param lodScale defines scale to apply to the mip map selection
  135967. * @param lodOffset defines offset to apply to the mip map selection
  135968. * @param onLoad defines an optional callback raised when the texture is loaded
  135969. * @param onError defines an optional callback raised if there is an issue to load the texture
  135970. * @param format defines the format of the data
  135971. * @param forcedExtension defines the extension to use to pick the right loader
  135972. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  135973. * @returns the cube texture as an InternalTexture
  135974. */
  135975. 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;
  135976. }
  135977. }
  135978. declare module BABYLON {
  135979. /**
  135980. * Implementation of the DDS Texture Loader.
  135981. * @hidden
  135982. */
  135983. export class _DDSTextureLoader implements IInternalTextureLoader {
  135984. /**
  135985. * Defines wether the loader supports cascade loading the different faces.
  135986. */
  135987. readonly supportCascades: boolean;
  135988. /**
  135989. * This returns if the loader support the current file information.
  135990. * @param extension defines the file extension of the file being loaded
  135991. * @returns true if the loader can load the specified file
  135992. */
  135993. canLoad(extension: string): boolean;
  135994. /**
  135995. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135996. * @param data contains the texture data
  135997. * @param texture defines the BabylonJS internal texture
  135998. * @param createPolynomials will be true if polynomials have been requested
  135999. * @param onLoad defines the callback to trigger once the texture is ready
  136000. * @param onError defines the callback to trigger in case of error
  136001. */
  136002. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136003. /**
  136004. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136005. * @param data contains the texture data
  136006. * @param texture defines the BabylonJS internal texture
  136007. * @param callback defines the method to call once ready to upload
  136008. */
  136009. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136010. }
  136011. }
  136012. declare module BABYLON {
  136013. /**
  136014. * Implementation of the ENV Texture Loader.
  136015. * @hidden
  136016. */
  136017. export class _ENVTextureLoader implements IInternalTextureLoader {
  136018. /**
  136019. * Defines wether the loader supports cascade loading the different faces.
  136020. */
  136021. readonly supportCascades: boolean;
  136022. /**
  136023. * This returns if the loader support the current file information.
  136024. * @param extension defines the file extension of the file being loaded
  136025. * @returns true if the loader can load the specified file
  136026. */
  136027. canLoad(extension: string): boolean;
  136028. /**
  136029. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136030. * @param data contains the texture data
  136031. * @param texture defines the BabylonJS internal texture
  136032. * @param createPolynomials will be true if polynomials have been requested
  136033. * @param onLoad defines the callback to trigger once the texture is ready
  136034. * @param onError defines the callback to trigger in case of error
  136035. */
  136036. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136037. /**
  136038. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136039. * @param data contains the texture data
  136040. * @param texture defines the BabylonJS internal texture
  136041. * @param callback defines the method to call once ready to upload
  136042. */
  136043. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136044. }
  136045. }
  136046. declare module BABYLON {
  136047. /**
  136048. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136049. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136050. */
  136051. export class KhronosTextureContainer {
  136052. /** contents of the KTX container file */
  136053. data: ArrayBufferView;
  136054. private static HEADER_LEN;
  136055. private static COMPRESSED_2D;
  136056. private static COMPRESSED_3D;
  136057. private static TEX_2D;
  136058. private static TEX_3D;
  136059. /**
  136060. * Gets the openGL type
  136061. */
  136062. glType: number;
  136063. /**
  136064. * Gets the openGL type size
  136065. */
  136066. glTypeSize: number;
  136067. /**
  136068. * Gets the openGL format
  136069. */
  136070. glFormat: number;
  136071. /**
  136072. * Gets the openGL internal format
  136073. */
  136074. glInternalFormat: number;
  136075. /**
  136076. * Gets the base internal format
  136077. */
  136078. glBaseInternalFormat: number;
  136079. /**
  136080. * Gets image width in pixel
  136081. */
  136082. pixelWidth: number;
  136083. /**
  136084. * Gets image height in pixel
  136085. */
  136086. pixelHeight: number;
  136087. /**
  136088. * Gets image depth in pixels
  136089. */
  136090. pixelDepth: number;
  136091. /**
  136092. * Gets the number of array elements
  136093. */
  136094. numberOfArrayElements: number;
  136095. /**
  136096. * Gets the number of faces
  136097. */
  136098. numberOfFaces: number;
  136099. /**
  136100. * Gets the number of mipmap levels
  136101. */
  136102. numberOfMipmapLevels: number;
  136103. /**
  136104. * Gets the bytes of key value data
  136105. */
  136106. bytesOfKeyValueData: number;
  136107. /**
  136108. * Gets the load type
  136109. */
  136110. loadType: number;
  136111. /**
  136112. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136113. */
  136114. isInvalid: boolean;
  136115. /**
  136116. * Creates a new KhronosTextureContainer
  136117. * @param data contents of the KTX container file
  136118. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136119. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136120. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136121. */
  136122. constructor(
  136123. /** contents of the KTX container file */
  136124. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136125. /**
  136126. * Uploads KTX content to a Babylon Texture.
  136127. * It is assumed that the texture has already been created & is currently bound
  136128. * @hidden
  136129. */
  136130. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136131. private _upload2DCompressedLevels;
  136132. /**
  136133. * Checks if the given data starts with a KTX file identifier.
  136134. * @param data the data to check
  136135. * @returns true if the data is a KTX file or false otherwise
  136136. */
  136137. static IsValid(data: ArrayBufferView): boolean;
  136138. }
  136139. }
  136140. declare module BABYLON {
  136141. /**
  136142. * Class for loading KTX2 files
  136143. * !!! Experimental Extension Subject to Changes !!!
  136144. * @hidden
  136145. */
  136146. export class KhronosTextureContainer2 {
  136147. private static _ModulePromise;
  136148. private static _TranscodeFormat;
  136149. constructor(engine: ThinEngine);
  136150. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136151. private _determineTranscodeFormat;
  136152. /**
  136153. * Checks if the given data starts with a KTX2 file identifier.
  136154. * @param data the data to check
  136155. * @returns true if the data is a KTX2 file or false otherwise
  136156. */
  136157. static IsValid(data: ArrayBufferView): boolean;
  136158. }
  136159. }
  136160. declare module BABYLON {
  136161. /**
  136162. * Implementation of the KTX Texture Loader.
  136163. * @hidden
  136164. */
  136165. export class _KTXTextureLoader implements IInternalTextureLoader {
  136166. /**
  136167. * Defines wether the loader supports cascade loading the different faces.
  136168. */
  136169. readonly supportCascades: boolean;
  136170. /**
  136171. * This returns if the loader support the current file information.
  136172. * @param extension defines the file extension of the file being loaded
  136173. * @param mimeType defines the optional mime type of the file being loaded
  136174. * @returns true if the loader can load the specified file
  136175. */
  136176. canLoad(extension: string, mimeType?: string): boolean;
  136177. /**
  136178. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136179. * @param data contains the texture data
  136180. * @param texture defines the BabylonJS internal texture
  136181. * @param createPolynomials will be true if polynomials have been requested
  136182. * @param onLoad defines the callback to trigger once the texture is ready
  136183. * @param onError defines the callback to trigger in case of error
  136184. */
  136185. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136186. /**
  136187. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136188. * @param data contains the texture data
  136189. * @param texture defines the BabylonJS internal texture
  136190. * @param callback defines the method to call once ready to upload
  136191. */
  136192. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136193. }
  136194. }
  136195. declare module BABYLON {
  136196. /** @hidden */
  136197. export var _forceSceneHelpersToBundle: boolean;
  136198. interface Scene {
  136199. /**
  136200. * Creates a default light for the scene.
  136201. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136202. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136203. */
  136204. createDefaultLight(replace?: boolean): void;
  136205. /**
  136206. * Creates a default camera for the scene.
  136207. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136208. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136209. * @param replace has default false, when true replaces the active camera in the scene
  136210. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136211. */
  136212. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136213. /**
  136214. * Creates a default camera and a default light.
  136215. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136216. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136217. * @param replace has the default false, when true replaces the active camera/light in the scene
  136218. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136219. */
  136220. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136221. /**
  136222. * Creates a new sky box
  136223. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136224. * @param environmentTexture defines the texture to use as environment texture
  136225. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136226. * @param scale defines the overall scale of the skybox
  136227. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136228. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136229. * @returns a new mesh holding the sky box
  136230. */
  136231. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136232. /**
  136233. * Creates a new environment
  136234. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136235. * @param options defines the options you can use to configure the environment
  136236. * @returns the new EnvironmentHelper
  136237. */
  136238. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136239. /**
  136240. * Creates a new VREXperienceHelper
  136241. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136242. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136243. * @returns a new VREXperienceHelper
  136244. */
  136245. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136246. /**
  136247. * Creates a new WebXRDefaultExperience
  136248. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136249. * @param options experience options
  136250. * @returns a promise for a new WebXRDefaultExperience
  136251. */
  136252. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136253. }
  136254. }
  136255. declare module BABYLON {
  136256. /**
  136257. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136258. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136259. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136260. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136261. */
  136262. export class VideoDome extends TransformNode {
  136263. /**
  136264. * Define the video source as a Monoscopic panoramic 360 video.
  136265. */
  136266. static readonly MODE_MONOSCOPIC: number;
  136267. /**
  136268. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136269. */
  136270. static readonly MODE_TOPBOTTOM: number;
  136271. /**
  136272. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136273. */
  136274. static readonly MODE_SIDEBYSIDE: number;
  136275. private _halfDome;
  136276. private _useDirectMapping;
  136277. /**
  136278. * The video texture being displayed on the sphere
  136279. */
  136280. protected _videoTexture: VideoTexture;
  136281. /**
  136282. * Gets the video texture being displayed on the sphere
  136283. */
  136284. get videoTexture(): VideoTexture;
  136285. /**
  136286. * The skybox material
  136287. */
  136288. protected _material: BackgroundMaterial;
  136289. /**
  136290. * The surface used for the video dome
  136291. */
  136292. protected _mesh: Mesh;
  136293. /**
  136294. * Gets the mesh used for the video dome.
  136295. */
  136296. get mesh(): Mesh;
  136297. /**
  136298. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136299. */
  136300. private _halfDomeMask;
  136301. /**
  136302. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136303. * Also see the options.resolution property.
  136304. */
  136305. get fovMultiplier(): number;
  136306. set fovMultiplier(value: number);
  136307. private _videoMode;
  136308. /**
  136309. * Gets or set the current video mode for the video. It can be:
  136310. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136311. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136312. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136313. */
  136314. get videoMode(): number;
  136315. set videoMode(value: number);
  136316. /**
  136317. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136318. *
  136319. */
  136320. get halfDome(): boolean;
  136321. /**
  136322. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136323. */
  136324. set halfDome(enabled: boolean);
  136325. /**
  136326. * Oberserver used in Stereoscopic VR Mode.
  136327. */
  136328. private _onBeforeCameraRenderObserver;
  136329. /**
  136330. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136331. * @param name Element's name, child elements will append suffixes for their own names.
  136332. * @param urlsOrVideo defines the url(s) or the video element to use
  136333. * @param options An object containing optional or exposed sub element properties
  136334. */
  136335. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136336. resolution?: number;
  136337. clickToPlay?: boolean;
  136338. autoPlay?: boolean;
  136339. loop?: boolean;
  136340. size?: number;
  136341. poster?: string;
  136342. faceForward?: boolean;
  136343. useDirectMapping?: boolean;
  136344. halfDomeMode?: boolean;
  136345. }, scene: Scene);
  136346. private _changeVideoMode;
  136347. /**
  136348. * Releases resources associated with this node.
  136349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136351. */
  136352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136353. }
  136354. }
  136355. declare module BABYLON {
  136356. /**
  136357. * This class can be used to get instrumentation data from a Babylon engine
  136358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136359. */
  136360. export class EngineInstrumentation implements IDisposable {
  136361. /**
  136362. * Define the instrumented engine.
  136363. */
  136364. engine: Engine;
  136365. private _captureGPUFrameTime;
  136366. private _gpuFrameTimeToken;
  136367. private _gpuFrameTime;
  136368. private _captureShaderCompilationTime;
  136369. private _shaderCompilationTime;
  136370. private _onBeginFrameObserver;
  136371. private _onEndFrameObserver;
  136372. private _onBeforeShaderCompilationObserver;
  136373. private _onAfterShaderCompilationObserver;
  136374. /**
  136375. * Gets the perf counter used for GPU frame time
  136376. */
  136377. get gpuFrameTimeCounter(): PerfCounter;
  136378. /**
  136379. * Gets the GPU frame time capture status
  136380. */
  136381. get captureGPUFrameTime(): boolean;
  136382. /**
  136383. * Enable or disable the GPU frame time capture
  136384. */
  136385. set captureGPUFrameTime(value: boolean);
  136386. /**
  136387. * Gets the perf counter used for shader compilation time
  136388. */
  136389. get shaderCompilationTimeCounter(): PerfCounter;
  136390. /**
  136391. * Gets the shader compilation time capture status
  136392. */
  136393. get captureShaderCompilationTime(): boolean;
  136394. /**
  136395. * Enable or disable the shader compilation time capture
  136396. */
  136397. set captureShaderCompilationTime(value: boolean);
  136398. /**
  136399. * Instantiates a new engine instrumentation.
  136400. * This class can be used to get instrumentation data from a Babylon engine
  136401. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136402. * @param engine Defines the engine to instrument
  136403. */
  136404. constructor(
  136405. /**
  136406. * Define the instrumented engine.
  136407. */
  136408. engine: Engine);
  136409. /**
  136410. * Dispose and release associated resources.
  136411. */
  136412. dispose(): void;
  136413. }
  136414. }
  136415. declare module BABYLON {
  136416. /**
  136417. * This class can be used to get instrumentation data from a Babylon engine
  136418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136419. */
  136420. export class SceneInstrumentation implements IDisposable {
  136421. /**
  136422. * Defines the scene to instrument
  136423. */
  136424. scene: Scene;
  136425. private _captureActiveMeshesEvaluationTime;
  136426. private _activeMeshesEvaluationTime;
  136427. private _captureRenderTargetsRenderTime;
  136428. private _renderTargetsRenderTime;
  136429. private _captureFrameTime;
  136430. private _frameTime;
  136431. private _captureRenderTime;
  136432. private _renderTime;
  136433. private _captureInterFrameTime;
  136434. private _interFrameTime;
  136435. private _captureParticlesRenderTime;
  136436. private _particlesRenderTime;
  136437. private _captureSpritesRenderTime;
  136438. private _spritesRenderTime;
  136439. private _capturePhysicsTime;
  136440. private _physicsTime;
  136441. private _captureAnimationsTime;
  136442. private _animationsTime;
  136443. private _captureCameraRenderTime;
  136444. private _cameraRenderTime;
  136445. private _onBeforeActiveMeshesEvaluationObserver;
  136446. private _onAfterActiveMeshesEvaluationObserver;
  136447. private _onBeforeRenderTargetsRenderObserver;
  136448. private _onAfterRenderTargetsRenderObserver;
  136449. private _onAfterRenderObserver;
  136450. private _onBeforeDrawPhaseObserver;
  136451. private _onAfterDrawPhaseObserver;
  136452. private _onBeforeAnimationsObserver;
  136453. private _onBeforeParticlesRenderingObserver;
  136454. private _onAfterParticlesRenderingObserver;
  136455. private _onBeforeSpritesRenderingObserver;
  136456. private _onAfterSpritesRenderingObserver;
  136457. private _onBeforePhysicsObserver;
  136458. private _onAfterPhysicsObserver;
  136459. private _onAfterAnimationsObserver;
  136460. private _onBeforeCameraRenderObserver;
  136461. private _onAfterCameraRenderObserver;
  136462. /**
  136463. * Gets the perf counter used for active meshes evaluation time
  136464. */
  136465. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136466. /**
  136467. * Gets the active meshes evaluation time capture status
  136468. */
  136469. get captureActiveMeshesEvaluationTime(): boolean;
  136470. /**
  136471. * Enable or disable the active meshes evaluation time capture
  136472. */
  136473. set captureActiveMeshesEvaluationTime(value: boolean);
  136474. /**
  136475. * Gets the perf counter used for render targets render time
  136476. */
  136477. get renderTargetsRenderTimeCounter(): PerfCounter;
  136478. /**
  136479. * Gets the render targets render time capture status
  136480. */
  136481. get captureRenderTargetsRenderTime(): boolean;
  136482. /**
  136483. * Enable or disable the render targets render time capture
  136484. */
  136485. set captureRenderTargetsRenderTime(value: boolean);
  136486. /**
  136487. * Gets the perf counter used for particles render time
  136488. */
  136489. get particlesRenderTimeCounter(): PerfCounter;
  136490. /**
  136491. * Gets the particles render time capture status
  136492. */
  136493. get captureParticlesRenderTime(): boolean;
  136494. /**
  136495. * Enable or disable the particles render time capture
  136496. */
  136497. set captureParticlesRenderTime(value: boolean);
  136498. /**
  136499. * Gets the perf counter used for sprites render time
  136500. */
  136501. get spritesRenderTimeCounter(): PerfCounter;
  136502. /**
  136503. * Gets the sprites render time capture status
  136504. */
  136505. get captureSpritesRenderTime(): boolean;
  136506. /**
  136507. * Enable or disable the sprites render time capture
  136508. */
  136509. set captureSpritesRenderTime(value: boolean);
  136510. /**
  136511. * Gets the perf counter used for physics time
  136512. */
  136513. get physicsTimeCounter(): PerfCounter;
  136514. /**
  136515. * Gets the physics time capture status
  136516. */
  136517. get capturePhysicsTime(): boolean;
  136518. /**
  136519. * Enable or disable the physics time capture
  136520. */
  136521. set capturePhysicsTime(value: boolean);
  136522. /**
  136523. * Gets the perf counter used for animations time
  136524. */
  136525. get animationsTimeCounter(): PerfCounter;
  136526. /**
  136527. * Gets the animations time capture status
  136528. */
  136529. get captureAnimationsTime(): boolean;
  136530. /**
  136531. * Enable or disable the animations time capture
  136532. */
  136533. set captureAnimationsTime(value: boolean);
  136534. /**
  136535. * Gets the perf counter used for frame time capture
  136536. */
  136537. get frameTimeCounter(): PerfCounter;
  136538. /**
  136539. * Gets the frame time capture status
  136540. */
  136541. get captureFrameTime(): boolean;
  136542. /**
  136543. * Enable or disable the frame time capture
  136544. */
  136545. set captureFrameTime(value: boolean);
  136546. /**
  136547. * Gets the perf counter used for inter-frames time capture
  136548. */
  136549. get interFrameTimeCounter(): PerfCounter;
  136550. /**
  136551. * Gets the inter-frames time capture status
  136552. */
  136553. get captureInterFrameTime(): boolean;
  136554. /**
  136555. * Enable or disable the inter-frames time capture
  136556. */
  136557. set captureInterFrameTime(value: boolean);
  136558. /**
  136559. * Gets the perf counter used for render time capture
  136560. */
  136561. get renderTimeCounter(): PerfCounter;
  136562. /**
  136563. * Gets the render time capture status
  136564. */
  136565. get captureRenderTime(): boolean;
  136566. /**
  136567. * Enable or disable the render time capture
  136568. */
  136569. set captureRenderTime(value: boolean);
  136570. /**
  136571. * Gets the perf counter used for camera render time capture
  136572. */
  136573. get cameraRenderTimeCounter(): PerfCounter;
  136574. /**
  136575. * Gets the camera render time capture status
  136576. */
  136577. get captureCameraRenderTime(): boolean;
  136578. /**
  136579. * Enable or disable the camera render time capture
  136580. */
  136581. set captureCameraRenderTime(value: boolean);
  136582. /**
  136583. * Gets the perf counter used for draw calls
  136584. */
  136585. get drawCallsCounter(): PerfCounter;
  136586. /**
  136587. * Instantiates a new scene instrumentation.
  136588. * This class can be used to get instrumentation data from a Babylon engine
  136589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136590. * @param scene Defines the scene to instrument
  136591. */
  136592. constructor(
  136593. /**
  136594. * Defines the scene to instrument
  136595. */
  136596. scene: Scene);
  136597. /**
  136598. * Dispose and release associated resources.
  136599. */
  136600. dispose(): void;
  136601. }
  136602. }
  136603. declare module BABYLON {
  136604. /** @hidden */
  136605. export var glowMapGenerationPixelShader: {
  136606. name: string;
  136607. shader: string;
  136608. };
  136609. }
  136610. declare module BABYLON {
  136611. /** @hidden */
  136612. export var glowMapGenerationVertexShader: {
  136613. name: string;
  136614. shader: string;
  136615. };
  136616. }
  136617. declare module BABYLON {
  136618. /**
  136619. * Effect layer options. This helps customizing the behaviour
  136620. * of the effect layer.
  136621. */
  136622. export interface IEffectLayerOptions {
  136623. /**
  136624. * Multiplication factor apply to the canvas size to compute the render target size
  136625. * used to generated the objects (the smaller the faster).
  136626. */
  136627. mainTextureRatio: number;
  136628. /**
  136629. * Enforces a fixed size texture to ensure effect stability across devices.
  136630. */
  136631. mainTextureFixedSize?: number;
  136632. /**
  136633. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136634. */
  136635. alphaBlendingMode: number;
  136636. /**
  136637. * The camera attached to the layer.
  136638. */
  136639. camera: Nullable<Camera>;
  136640. /**
  136641. * The rendering group to draw the layer in.
  136642. */
  136643. renderingGroupId: number;
  136644. }
  136645. /**
  136646. * The effect layer Helps adding post process effect blended with the main pass.
  136647. *
  136648. * This can be for instance use to generate glow or higlight effects on the scene.
  136649. *
  136650. * The effect layer class can not be used directly and is intented to inherited from to be
  136651. * customized per effects.
  136652. */
  136653. export abstract class EffectLayer {
  136654. private _vertexBuffers;
  136655. private _indexBuffer;
  136656. private _cachedDefines;
  136657. private _effectLayerMapGenerationEffect;
  136658. private _effectLayerOptions;
  136659. private _mergeEffect;
  136660. protected _scene: Scene;
  136661. protected _engine: Engine;
  136662. protected _maxSize: number;
  136663. protected _mainTextureDesiredSize: ISize;
  136664. protected _mainTexture: RenderTargetTexture;
  136665. protected _shouldRender: boolean;
  136666. protected _postProcesses: PostProcess[];
  136667. protected _textures: BaseTexture[];
  136668. protected _emissiveTextureAndColor: {
  136669. texture: Nullable<BaseTexture>;
  136670. color: Color4;
  136671. };
  136672. /**
  136673. * The name of the layer
  136674. */
  136675. name: string;
  136676. /**
  136677. * The clear color of the texture used to generate the glow map.
  136678. */
  136679. neutralColor: Color4;
  136680. /**
  136681. * Specifies whether the highlight layer is enabled or not.
  136682. */
  136683. isEnabled: boolean;
  136684. /**
  136685. * Gets the camera attached to the layer.
  136686. */
  136687. get camera(): Nullable<Camera>;
  136688. /**
  136689. * Gets the rendering group id the layer should render in.
  136690. */
  136691. get renderingGroupId(): number;
  136692. set renderingGroupId(renderingGroupId: number);
  136693. /**
  136694. * An event triggered when the effect layer has been disposed.
  136695. */
  136696. onDisposeObservable: Observable<EffectLayer>;
  136697. /**
  136698. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136699. */
  136700. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136701. /**
  136702. * An event triggered when the generated texture is being merged in the scene.
  136703. */
  136704. onBeforeComposeObservable: Observable<EffectLayer>;
  136705. /**
  136706. * An event triggered when the mesh is rendered into the effect render target.
  136707. */
  136708. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136709. /**
  136710. * An event triggered after the mesh has been rendered into the effect render target.
  136711. */
  136712. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136713. /**
  136714. * An event triggered when the generated texture has been merged in the scene.
  136715. */
  136716. onAfterComposeObservable: Observable<EffectLayer>;
  136717. /**
  136718. * An event triggered when the efffect layer changes its size.
  136719. */
  136720. onSizeChangedObservable: Observable<EffectLayer>;
  136721. /** @hidden */
  136722. static _SceneComponentInitialization: (scene: Scene) => void;
  136723. /**
  136724. * Instantiates a new effect Layer and references it in the scene.
  136725. * @param name The name of the layer
  136726. * @param scene The scene to use the layer in
  136727. */
  136728. constructor(
  136729. /** The Friendly of the effect in the scene */
  136730. name: string, scene: Scene);
  136731. /**
  136732. * Get the effect name of the layer.
  136733. * @return The effect name
  136734. */
  136735. abstract getEffectName(): string;
  136736. /**
  136737. * Checks for the readiness of the element composing the layer.
  136738. * @param subMesh the mesh to check for
  136739. * @param useInstances specify whether or not to use instances to render the mesh
  136740. * @return true if ready otherwise, false
  136741. */
  136742. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136743. /**
  136744. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136745. * @returns true if the effect requires stencil during the main canvas render pass.
  136746. */
  136747. abstract needStencil(): boolean;
  136748. /**
  136749. * Create the merge effect. This is the shader use to blit the information back
  136750. * to the main canvas at the end of the scene rendering.
  136751. * @returns The effect containing the shader used to merge the effect on the main canvas
  136752. */
  136753. protected abstract _createMergeEffect(): Effect;
  136754. /**
  136755. * Creates the render target textures and post processes used in the effect layer.
  136756. */
  136757. protected abstract _createTextureAndPostProcesses(): void;
  136758. /**
  136759. * Implementation specific of rendering the generating effect on the main canvas.
  136760. * @param effect The effect used to render through
  136761. */
  136762. protected abstract _internalRender(effect: Effect): void;
  136763. /**
  136764. * Sets the required values for both the emissive texture and and the main color.
  136765. */
  136766. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136767. /**
  136768. * Free any resources and references associated to a mesh.
  136769. * Internal use
  136770. * @param mesh The mesh to free.
  136771. */
  136772. abstract _disposeMesh(mesh: Mesh): void;
  136773. /**
  136774. * Serializes this layer (Glow or Highlight for example)
  136775. * @returns a serialized layer object
  136776. */
  136777. abstract serialize?(): any;
  136778. /**
  136779. * Initializes the effect layer with the required options.
  136780. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  136781. */
  136782. protected _init(options: Partial<IEffectLayerOptions>): void;
  136783. /**
  136784. * Generates the index buffer of the full screen quad blending to the main canvas.
  136785. */
  136786. private _generateIndexBuffer;
  136787. /**
  136788. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  136789. */
  136790. private _generateVertexBuffer;
  136791. /**
  136792. * Sets the main texture desired size which is the closest power of two
  136793. * of the engine canvas size.
  136794. */
  136795. private _setMainTextureSize;
  136796. /**
  136797. * Creates the main texture for the effect layer.
  136798. */
  136799. protected _createMainTexture(): void;
  136800. /**
  136801. * Adds specific effects defines.
  136802. * @param defines The defines to add specifics to.
  136803. */
  136804. protected _addCustomEffectDefines(defines: string[]): void;
  136805. /**
  136806. * Checks for the readiness of the element composing the layer.
  136807. * @param subMesh the mesh to check for
  136808. * @param useInstances specify whether or not to use instances to render the mesh
  136809. * @param emissiveTexture the associated emissive texture used to generate the glow
  136810. * @return true if ready otherwise, false
  136811. */
  136812. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  136813. /**
  136814. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  136815. */
  136816. render(): void;
  136817. /**
  136818. * Determine if a given mesh will be used in the current effect.
  136819. * @param mesh mesh to test
  136820. * @returns true if the mesh will be used
  136821. */
  136822. hasMesh(mesh: AbstractMesh): boolean;
  136823. /**
  136824. * Returns true if the layer contains information to display, otherwise false.
  136825. * @returns true if the glow layer should be rendered
  136826. */
  136827. shouldRender(): boolean;
  136828. /**
  136829. * Returns true if the mesh should render, otherwise false.
  136830. * @param mesh The mesh to render
  136831. * @returns true if it should render otherwise false
  136832. */
  136833. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  136834. /**
  136835. * Returns true if the mesh can be rendered, otherwise false.
  136836. * @param mesh The mesh to render
  136837. * @param material The material used on the mesh
  136838. * @returns true if it can be rendered otherwise false
  136839. */
  136840. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136841. /**
  136842. * Returns true if the mesh should render, otherwise false.
  136843. * @param mesh The mesh to render
  136844. * @returns true if it should render otherwise false
  136845. */
  136846. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  136847. /**
  136848. * Renders the submesh passed in parameter to the generation map.
  136849. */
  136850. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  136851. /**
  136852. * Defines whether the current material of the mesh should be use to render the effect.
  136853. * @param mesh defines the current mesh to render
  136854. */
  136855. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136856. /**
  136857. * Rebuild the required buffers.
  136858. * @hidden Internal use only.
  136859. */
  136860. _rebuild(): void;
  136861. /**
  136862. * Dispose only the render target textures and post process.
  136863. */
  136864. private _disposeTextureAndPostProcesses;
  136865. /**
  136866. * Dispose the highlight layer and free resources.
  136867. */
  136868. dispose(): void;
  136869. /**
  136870. * Gets the class name of the effect layer
  136871. * @returns the string with the class name of the effect layer
  136872. */
  136873. getClassName(): string;
  136874. /**
  136875. * Creates an effect layer from parsed effect layer data
  136876. * @param parsedEffectLayer defines effect layer data
  136877. * @param scene defines the current scene
  136878. * @param rootUrl defines the root URL containing the effect layer information
  136879. * @returns a parsed effect Layer
  136880. */
  136881. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  136882. }
  136883. }
  136884. declare module BABYLON {
  136885. interface AbstractScene {
  136886. /**
  136887. * The list of effect layers (highlights/glow) added to the scene
  136888. * @see https://doc.babylonjs.com/how_to/highlight_layer
  136889. * @see https://doc.babylonjs.com/how_to/glow_layer
  136890. */
  136891. effectLayers: Array<EffectLayer>;
  136892. /**
  136893. * Removes the given effect layer from this scene.
  136894. * @param toRemove defines the effect layer to remove
  136895. * @returns the index of the removed effect layer
  136896. */
  136897. removeEffectLayer(toRemove: EffectLayer): number;
  136898. /**
  136899. * Adds the given effect layer to this scene
  136900. * @param newEffectLayer defines the effect layer to add
  136901. */
  136902. addEffectLayer(newEffectLayer: EffectLayer): void;
  136903. }
  136904. /**
  136905. * Defines the layer scene component responsible to manage any effect layers
  136906. * in a given scene.
  136907. */
  136908. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  136909. /**
  136910. * The component name helpfull to identify the component in the list of scene components.
  136911. */
  136912. readonly name: string;
  136913. /**
  136914. * The scene the component belongs to.
  136915. */
  136916. scene: Scene;
  136917. private _engine;
  136918. private _renderEffects;
  136919. private _needStencil;
  136920. private _previousStencilState;
  136921. /**
  136922. * Creates a new instance of the component for the given scene
  136923. * @param scene Defines the scene to register the component in
  136924. */
  136925. constructor(scene: Scene);
  136926. /**
  136927. * Registers the component in a given scene
  136928. */
  136929. register(): void;
  136930. /**
  136931. * Rebuilds the elements related to this component in case of
  136932. * context lost for instance.
  136933. */
  136934. rebuild(): void;
  136935. /**
  136936. * Serializes the component data to the specified json object
  136937. * @param serializationObject The object to serialize to
  136938. */
  136939. serialize(serializationObject: any): void;
  136940. /**
  136941. * Adds all the elements from the container to the scene
  136942. * @param container the container holding the elements
  136943. */
  136944. addFromContainer(container: AbstractScene): void;
  136945. /**
  136946. * Removes all the elements in the container from the scene
  136947. * @param container contains the elements to remove
  136948. * @param dispose if the removed element should be disposed (default: false)
  136949. */
  136950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136951. /**
  136952. * Disposes the component and the associated ressources.
  136953. */
  136954. dispose(): void;
  136955. private _isReadyForMesh;
  136956. private _renderMainTexture;
  136957. private _setStencil;
  136958. private _setStencilBack;
  136959. private _draw;
  136960. private _drawCamera;
  136961. private _drawRenderingGroup;
  136962. }
  136963. }
  136964. declare module BABYLON {
  136965. /** @hidden */
  136966. export var glowMapMergePixelShader: {
  136967. name: string;
  136968. shader: string;
  136969. };
  136970. }
  136971. declare module BABYLON {
  136972. /** @hidden */
  136973. export var glowMapMergeVertexShader: {
  136974. name: string;
  136975. shader: string;
  136976. };
  136977. }
  136978. declare module BABYLON {
  136979. interface AbstractScene {
  136980. /**
  136981. * Return a the first highlight layer of the scene with a given name.
  136982. * @param name The name of the highlight layer to look for.
  136983. * @return The highlight layer if found otherwise null.
  136984. */
  136985. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  136986. }
  136987. /**
  136988. * Glow layer options. This helps customizing the behaviour
  136989. * of the glow layer.
  136990. */
  136991. export interface IGlowLayerOptions {
  136992. /**
  136993. * Multiplication factor apply to the canvas size to compute the render target size
  136994. * used to generated the glowing objects (the smaller the faster).
  136995. */
  136996. mainTextureRatio: number;
  136997. /**
  136998. * Enforces a fixed size texture to ensure resize independant blur.
  136999. */
  137000. mainTextureFixedSize?: number;
  137001. /**
  137002. * How big is the kernel of the blur texture.
  137003. */
  137004. blurKernelSize: number;
  137005. /**
  137006. * The camera attached to the layer.
  137007. */
  137008. camera: Nullable<Camera>;
  137009. /**
  137010. * Enable MSAA by chosing the number of samples.
  137011. */
  137012. mainTextureSamples?: number;
  137013. /**
  137014. * The rendering group to draw the layer in.
  137015. */
  137016. renderingGroupId: number;
  137017. }
  137018. /**
  137019. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137020. *
  137021. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137022. *
  137023. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137024. */
  137025. export class GlowLayer extends EffectLayer {
  137026. /**
  137027. * Effect Name of the layer.
  137028. */
  137029. static readonly EffectName: string;
  137030. /**
  137031. * The default blur kernel size used for the glow.
  137032. */
  137033. static DefaultBlurKernelSize: number;
  137034. /**
  137035. * The default texture size ratio used for the glow.
  137036. */
  137037. static DefaultTextureRatio: number;
  137038. /**
  137039. * Sets the kernel size of the blur.
  137040. */
  137041. set blurKernelSize(value: number);
  137042. /**
  137043. * Gets the kernel size of the blur.
  137044. */
  137045. get blurKernelSize(): number;
  137046. /**
  137047. * Sets the glow intensity.
  137048. */
  137049. set intensity(value: number);
  137050. /**
  137051. * Gets the glow intensity.
  137052. */
  137053. get intensity(): number;
  137054. private _options;
  137055. private _intensity;
  137056. private _horizontalBlurPostprocess1;
  137057. private _verticalBlurPostprocess1;
  137058. private _horizontalBlurPostprocess2;
  137059. private _verticalBlurPostprocess2;
  137060. private _blurTexture1;
  137061. private _blurTexture2;
  137062. private _postProcesses1;
  137063. private _postProcesses2;
  137064. private _includedOnlyMeshes;
  137065. private _excludedMeshes;
  137066. private _meshesUsingTheirOwnMaterials;
  137067. /**
  137068. * Callback used to let the user override the color selection on a per mesh basis
  137069. */
  137070. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137071. /**
  137072. * Callback used to let the user override the texture selection on a per mesh basis
  137073. */
  137074. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137075. /**
  137076. * Instantiates a new glow Layer and references it to the scene.
  137077. * @param name The name of the layer
  137078. * @param scene The scene to use the layer in
  137079. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137080. */
  137081. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137082. /**
  137083. * Get the effect name of the layer.
  137084. * @return The effect name
  137085. */
  137086. getEffectName(): string;
  137087. /**
  137088. * Create the merge effect. This is the shader use to blit the information back
  137089. * to the main canvas at the end of the scene rendering.
  137090. */
  137091. protected _createMergeEffect(): Effect;
  137092. /**
  137093. * Creates the render target textures and post processes used in the glow layer.
  137094. */
  137095. protected _createTextureAndPostProcesses(): void;
  137096. /**
  137097. * Checks for the readiness of the element composing the layer.
  137098. * @param subMesh the mesh to check for
  137099. * @param useInstances specify wether or not to use instances to render the mesh
  137100. * @param emissiveTexture the associated emissive texture used to generate the glow
  137101. * @return true if ready otherwise, false
  137102. */
  137103. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137104. /**
  137105. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137106. */
  137107. needStencil(): boolean;
  137108. /**
  137109. * Returns true if the mesh can be rendered, otherwise false.
  137110. * @param mesh The mesh to render
  137111. * @param material The material used on the mesh
  137112. * @returns true if it can be rendered otherwise false
  137113. */
  137114. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137115. /**
  137116. * Implementation specific of rendering the generating effect on the main canvas.
  137117. * @param effect The effect used to render through
  137118. */
  137119. protected _internalRender(effect: Effect): void;
  137120. /**
  137121. * Sets the required values for both the emissive texture and and the main color.
  137122. */
  137123. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137124. /**
  137125. * Returns true if the mesh should render, otherwise false.
  137126. * @param mesh The mesh to render
  137127. * @returns true if it should render otherwise false
  137128. */
  137129. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137130. /**
  137131. * Adds specific effects defines.
  137132. * @param defines The defines to add specifics to.
  137133. */
  137134. protected _addCustomEffectDefines(defines: string[]): void;
  137135. /**
  137136. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137137. * @param mesh The mesh to exclude from the glow layer
  137138. */
  137139. addExcludedMesh(mesh: Mesh): void;
  137140. /**
  137141. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137142. * @param mesh The mesh to remove
  137143. */
  137144. removeExcludedMesh(mesh: Mesh): void;
  137145. /**
  137146. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137147. * @param mesh The mesh to include in the glow layer
  137148. */
  137149. addIncludedOnlyMesh(mesh: Mesh): void;
  137150. /**
  137151. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137152. * @param mesh The mesh to remove
  137153. */
  137154. removeIncludedOnlyMesh(mesh: Mesh): void;
  137155. /**
  137156. * Determine if a given mesh will be used in the glow layer
  137157. * @param mesh The mesh to test
  137158. * @returns true if the mesh will be highlighted by the current glow layer
  137159. */
  137160. hasMesh(mesh: AbstractMesh): boolean;
  137161. /**
  137162. * Defines whether the current material of the mesh should be use to render the effect.
  137163. * @param mesh defines the current mesh to render
  137164. */
  137165. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137166. /**
  137167. * Add a mesh to be rendered through its own material and not with emissive only.
  137168. * @param mesh The mesh for which we need to use its material
  137169. */
  137170. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137171. /**
  137172. * Remove a mesh from being rendered through its own material and not with emissive only.
  137173. * @param mesh The mesh for which we need to not use its material
  137174. */
  137175. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137176. /**
  137177. * Free any resources and references associated to a mesh.
  137178. * Internal use
  137179. * @param mesh The mesh to free.
  137180. * @hidden
  137181. */
  137182. _disposeMesh(mesh: Mesh): void;
  137183. /**
  137184. * Gets the class name of the effect layer
  137185. * @returns the string with the class name of the effect layer
  137186. */
  137187. getClassName(): string;
  137188. /**
  137189. * Serializes this glow layer
  137190. * @returns a serialized glow layer object
  137191. */
  137192. serialize(): any;
  137193. /**
  137194. * Creates a Glow Layer from parsed glow layer data
  137195. * @param parsedGlowLayer defines glow layer data
  137196. * @param scene defines the current scene
  137197. * @param rootUrl defines the root URL containing the glow layer information
  137198. * @returns a parsed Glow Layer
  137199. */
  137200. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137201. }
  137202. }
  137203. declare module BABYLON {
  137204. /** @hidden */
  137205. export var glowBlurPostProcessPixelShader: {
  137206. name: string;
  137207. shader: string;
  137208. };
  137209. }
  137210. declare module BABYLON {
  137211. interface AbstractScene {
  137212. /**
  137213. * Return a the first highlight layer of the scene with a given name.
  137214. * @param name The name of the highlight layer to look for.
  137215. * @return The highlight layer if found otherwise null.
  137216. */
  137217. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137218. }
  137219. /**
  137220. * Highlight layer options. This helps customizing the behaviour
  137221. * of the highlight layer.
  137222. */
  137223. export interface IHighlightLayerOptions {
  137224. /**
  137225. * Multiplication factor apply to the canvas size to compute the render target size
  137226. * used to generated the glowing objects (the smaller the faster).
  137227. */
  137228. mainTextureRatio: number;
  137229. /**
  137230. * Enforces a fixed size texture to ensure resize independant blur.
  137231. */
  137232. mainTextureFixedSize?: number;
  137233. /**
  137234. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137235. * of the picture to blur (the smaller the faster).
  137236. */
  137237. blurTextureSizeRatio: number;
  137238. /**
  137239. * How big in texel of the blur texture is the vertical blur.
  137240. */
  137241. blurVerticalSize: number;
  137242. /**
  137243. * How big in texel of the blur texture is the horizontal blur.
  137244. */
  137245. blurHorizontalSize: number;
  137246. /**
  137247. * Alpha blending mode used to apply the blur. Default is combine.
  137248. */
  137249. alphaBlendingMode: number;
  137250. /**
  137251. * The camera attached to the layer.
  137252. */
  137253. camera: Nullable<Camera>;
  137254. /**
  137255. * Should we display highlight as a solid stroke?
  137256. */
  137257. isStroke?: boolean;
  137258. /**
  137259. * The rendering group to draw the layer in.
  137260. */
  137261. renderingGroupId: number;
  137262. }
  137263. /**
  137264. * The highlight layer Helps adding a glow effect around a mesh.
  137265. *
  137266. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137267. * glowy meshes to your scene.
  137268. *
  137269. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137270. */
  137271. export class HighlightLayer extends EffectLayer {
  137272. name: string;
  137273. /**
  137274. * Effect Name of the highlight layer.
  137275. */
  137276. static readonly EffectName: string;
  137277. /**
  137278. * The neutral color used during the preparation of the glow effect.
  137279. * This is black by default as the blend operation is a blend operation.
  137280. */
  137281. static NeutralColor: Color4;
  137282. /**
  137283. * Stencil value used for glowing meshes.
  137284. */
  137285. static GlowingMeshStencilReference: number;
  137286. /**
  137287. * Stencil value used for the other meshes in the scene.
  137288. */
  137289. static NormalMeshStencilReference: number;
  137290. /**
  137291. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137292. */
  137293. innerGlow: boolean;
  137294. /**
  137295. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137296. */
  137297. outerGlow: boolean;
  137298. /**
  137299. * Specifies the horizontal size of the blur.
  137300. */
  137301. set blurHorizontalSize(value: number);
  137302. /**
  137303. * Specifies the vertical size of the blur.
  137304. */
  137305. set blurVerticalSize(value: number);
  137306. /**
  137307. * Gets the horizontal size of the blur.
  137308. */
  137309. get blurHorizontalSize(): number;
  137310. /**
  137311. * Gets the vertical size of the blur.
  137312. */
  137313. get blurVerticalSize(): number;
  137314. /**
  137315. * An event triggered when the highlight layer is being blurred.
  137316. */
  137317. onBeforeBlurObservable: Observable<HighlightLayer>;
  137318. /**
  137319. * An event triggered when the highlight layer has been blurred.
  137320. */
  137321. onAfterBlurObservable: Observable<HighlightLayer>;
  137322. private _instanceGlowingMeshStencilReference;
  137323. private _options;
  137324. private _downSamplePostprocess;
  137325. private _horizontalBlurPostprocess;
  137326. private _verticalBlurPostprocess;
  137327. private _blurTexture;
  137328. private _meshes;
  137329. private _excludedMeshes;
  137330. /**
  137331. * Instantiates a new highlight Layer and references it to the scene..
  137332. * @param name The name of the layer
  137333. * @param scene The scene to use the layer in
  137334. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137335. */
  137336. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137337. /**
  137338. * Get the effect name of the layer.
  137339. * @return The effect name
  137340. */
  137341. getEffectName(): string;
  137342. /**
  137343. * Create the merge effect. This is the shader use to blit the information back
  137344. * to the main canvas at the end of the scene rendering.
  137345. */
  137346. protected _createMergeEffect(): Effect;
  137347. /**
  137348. * Creates the render target textures and post processes used in the highlight layer.
  137349. */
  137350. protected _createTextureAndPostProcesses(): void;
  137351. /**
  137352. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137353. */
  137354. needStencil(): boolean;
  137355. /**
  137356. * Checks for the readiness of the element composing the layer.
  137357. * @param subMesh the mesh to check for
  137358. * @param useInstances specify wether or not to use instances to render the mesh
  137359. * @param emissiveTexture the associated emissive texture used to generate the glow
  137360. * @return true if ready otherwise, false
  137361. */
  137362. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137363. /**
  137364. * Implementation specific of rendering the generating effect on the main canvas.
  137365. * @param effect The effect used to render through
  137366. */
  137367. protected _internalRender(effect: Effect): void;
  137368. /**
  137369. * Returns true if the layer contains information to display, otherwise false.
  137370. */
  137371. shouldRender(): boolean;
  137372. /**
  137373. * Returns true if the mesh should render, otherwise false.
  137374. * @param mesh The mesh to render
  137375. * @returns true if it should render otherwise false
  137376. */
  137377. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137378. /**
  137379. * Returns true if the mesh can be rendered, otherwise false.
  137380. * @param mesh The mesh to render
  137381. * @param material The material used on the mesh
  137382. * @returns true if it can be rendered otherwise false
  137383. */
  137384. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137385. /**
  137386. * Adds specific effects defines.
  137387. * @param defines The defines to add specifics to.
  137388. */
  137389. protected _addCustomEffectDefines(defines: string[]): void;
  137390. /**
  137391. * Sets the required values for both the emissive texture and and the main color.
  137392. */
  137393. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137394. /**
  137395. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137396. * @param mesh The mesh to exclude from the highlight layer
  137397. */
  137398. addExcludedMesh(mesh: Mesh): void;
  137399. /**
  137400. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137401. * @param mesh The mesh to highlight
  137402. */
  137403. removeExcludedMesh(mesh: Mesh): void;
  137404. /**
  137405. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137406. * @param mesh mesh to test
  137407. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137408. */
  137409. hasMesh(mesh: AbstractMesh): boolean;
  137410. /**
  137411. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137412. * @param mesh The mesh to highlight
  137413. * @param color The color of the highlight
  137414. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137415. */
  137416. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137417. /**
  137418. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137419. * @param mesh The mesh to highlight
  137420. */
  137421. removeMesh(mesh: Mesh): void;
  137422. /**
  137423. * Remove all the meshes currently referenced in the highlight layer
  137424. */
  137425. removeAllMeshes(): void;
  137426. /**
  137427. * Force the stencil to the normal expected value for none glowing parts
  137428. */
  137429. private _defaultStencilReference;
  137430. /**
  137431. * Free any resources and references associated to a mesh.
  137432. * Internal use
  137433. * @param mesh The mesh to free.
  137434. * @hidden
  137435. */
  137436. _disposeMesh(mesh: Mesh): void;
  137437. /**
  137438. * Dispose the highlight layer and free resources.
  137439. */
  137440. dispose(): void;
  137441. /**
  137442. * Gets the class name of the effect layer
  137443. * @returns the string with the class name of the effect layer
  137444. */
  137445. getClassName(): string;
  137446. /**
  137447. * Serializes this Highlight layer
  137448. * @returns a serialized Highlight layer object
  137449. */
  137450. serialize(): any;
  137451. /**
  137452. * Creates a Highlight layer from parsed Highlight layer data
  137453. * @param parsedHightlightLayer defines the Highlight layer data
  137454. * @param scene defines the current scene
  137455. * @param rootUrl defines the root URL containing the Highlight layer information
  137456. * @returns a parsed Highlight layer
  137457. */
  137458. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137459. }
  137460. }
  137461. declare module BABYLON {
  137462. interface AbstractScene {
  137463. /**
  137464. * The list of layers (background and foreground) of the scene
  137465. */
  137466. layers: Array<Layer>;
  137467. }
  137468. /**
  137469. * Defines the layer scene component responsible to manage any layers
  137470. * in a given scene.
  137471. */
  137472. export class LayerSceneComponent implements ISceneComponent {
  137473. /**
  137474. * The component name helpfull to identify the component in the list of scene components.
  137475. */
  137476. readonly name: string;
  137477. /**
  137478. * The scene the component belongs to.
  137479. */
  137480. scene: Scene;
  137481. private _engine;
  137482. /**
  137483. * Creates a new instance of the component for the given scene
  137484. * @param scene Defines the scene to register the component in
  137485. */
  137486. constructor(scene: Scene);
  137487. /**
  137488. * Registers the component in a given scene
  137489. */
  137490. register(): void;
  137491. /**
  137492. * Rebuilds the elements related to this component in case of
  137493. * context lost for instance.
  137494. */
  137495. rebuild(): void;
  137496. /**
  137497. * Disposes the component and the associated ressources.
  137498. */
  137499. dispose(): void;
  137500. private _draw;
  137501. private _drawCameraPredicate;
  137502. private _drawCameraBackground;
  137503. private _drawCameraForeground;
  137504. private _drawRenderTargetPredicate;
  137505. private _drawRenderTargetBackground;
  137506. private _drawRenderTargetForeground;
  137507. /**
  137508. * Adds all the elements from the container to the scene
  137509. * @param container the container holding the elements
  137510. */
  137511. addFromContainer(container: AbstractScene): void;
  137512. /**
  137513. * Removes all the elements in the container from the scene
  137514. * @param container contains the elements to remove
  137515. * @param dispose if the removed element should be disposed (default: false)
  137516. */
  137517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137518. }
  137519. }
  137520. declare module BABYLON {
  137521. /** @hidden */
  137522. export var layerPixelShader: {
  137523. name: string;
  137524. shader: string;
  137525. };
  137526. }
  137527. declare module BABYLON {
  137528. /** @hidden */
  137529. export var layerVertexShader: {
  137530. name: string;
  137531. shader: string;
  137532. };
  137533. }
  137534. declare module BABYLON {
  137535. /**
  137536. * This represents a full screen 2d layer.
  137537. * This can be useful to display a picture in the background of your scene for instance.
  137538. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137539. */
  137540. export class Layer {
  137541. /**
  137542. * Define the name of the layer.
  137543. */
  137544. name: string;
  137545. /**
  137546. * Define the texture the layer should display.
  137547. */
  137548. texture: Nullable<Texture>;
  137549. /**
  137550. * Is the layer in background or foreground.
  137551. */
  137552. isBackground: boolean;
  137553. /**
  137554. * Define the color of the layer (instead of texture).
  137555. */
  137556. color: Color4;
  137557. /**
  137558. * Define the scale of the layer in order to zoom in out of the texture.
  137559. */
  137560. scale: Vector2;
  137561. /**
  137562. * Define an offset for the layer in order to shift the texture.
  137563. */
  137564. offset: Vector2;
  137565. /**
  137566. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137567. */
  137568. alphaBlendingMode: number;
  137569. /**
  137570. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137571. * Alpha test will not mix with the background color in case of transparency.
  137572. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137573. */
  137574. alphaTest: boolean;
  137575. /**
  137576. * Define a mask to restrict the layer to only some of the scene cameras.
  137577. */
  137578. layerMask: number;
  137579. /**
  137580. * Define the list of render target the layer is visible into.
  137581. */
  137582. renderTargetTextures: RenderTargetTexture[];
  137583. /**
  137584. * Define if the layer is only used in renderTarget or if it also
  137585. * renders in the main frame buffer of the canvas.
  137586. */
  137587. renderOnlyInRenderTargetTextures: boolean;
  137588. private _scene;
  137589. private _vertexBuffers;
  137590. private _indexBuffer;
  137591. private _effect;
  137592. private _previousDefines;
  137593. /**
  137594. * An event triggered when the layer is disposed.
  137595. */
  137596. onDisposeObservable: Observable<Layer>;
  137597. private _onDisposeObserver;
  137598. /**
  137599. * Back compatibility with callback before the onDisposeObservable existed.
  137600. * The set callback will be triggered when the layer has been disposed.
  137601. */
  137602. set onDispose(callback: () => void);
  137603. /**
  137604. * An event triggered before rendering the scene
  137605. */
  137606. onBeforeRenderObservable: Observable<Layer>;
  137607. private _onBeforeRenderObserver;
  137608. /**
  137609. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137610. * The set callback will be triggered just before rendering the layer.
  137611. */
  137612. set onBeforeRender(callback: () => void);
  137613. /**
  137614. * An event triggered after rendering the scene
  137615. */
  137616. onAfterRenderObservable: Observable<Layer>;
  137617. private _onAfterRenderObserver;
  137618. /**
  137619. * Back compatibility with callback before the onAfterRenderObservable existed.
  137620. * The set callback will be triggered just after rendering the layer.
  137621. */
  137622. set onAfterRender(callback: () => void);
  137623. /**
  137624. * Instantiates a new layer.
  137625. * This represents a full screen 2d layer.
  137626. * This can be useful to display a picture in the background of your scene for instance.
  137627. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137628. * @param name Define the name of the layer in the scene
  137629. * @param imgUrl Define the url of the texture to display in the layer
  137630. * @param scene Define the scene the layer belongs to
  137631. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137632. * @param color Defines a color for the layer
  137633. */
  137634. constructor(
  137635. /**
  137636. * Define the name of the layer.
  137637. */
  137638. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137639. private _createIndexBuffer;
  137640. /** @hidden */
  137641. _rebuild(): void;
  137642. /**
  137643. * Renders the layer in the scene.
  137644. */
  137645. render(): void;
  137646. /**
  137647. * Disposes and releases the associated ressources.
  137648. */
  137649. dispose(): void;
  137650. }
  137651. }
  137652. declare module BABYLON {
  137653. /** @hidden */
  137654. export var lensFlarePixelShader: {
  137655. name: string;
  137656. shader: string;
  137657. };
  137658. }
  137659. declare module BABYLON {
  137660. /** @hidden */
  137661. export var lensFlareVertexShader: {
  137662. name: string;
  137663. shader: string;
  137664. };
  137665. }
  137666. declare module BABYLON {
  137667. /**
  137668. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137669. * It is usually composed of several `lensFlare`.
  137670. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137671. */
  137672. export class LensFlareSystem {
  137673. /**
  137674. * Define the name of the lens flare system
  137675. */
  137676. name: string;
  137677. /**
  137678. * List of lens flares used in this system.
  137679. */
  137680. lensFlares: LensFlare[];
  137681. /**
  137682. * Define a limit from the border the lens flare can be visible.
  137683. */
  137684. borderLimit: number;
  137685. /**
  137686. * Define a viewport border we do not want to see the lens flare in.
  137687. */
  137688. viewportBorder: number;
  137689. /**
  137690. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137691. */
  137692. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137693. /**
  137694. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137695. */
  137696. layerMask: number;
  137697. /**
  137698. * Define the id of the lens flare system in the scene.
  137699. * (equal to name by default)
  137700. */
  137701. id: string;
  137702. private _scene;
  137703. private _emitter;
  137704. private _vertexBuffers;
  137705. private _indexBuffer;
  137706. private _effect;
  137707. private _positionX;
  137708. private _positionY;
  137709. private _isEnabled;
  137710. /** @hidden */
  137711. static _SceneComponentInitialization: (scene: Scene) => void;
  137712. /**
  137713. * Instantiates a lens flare system.
  137714. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137715. * It is usually composed of several `lensFlare`.
  137716. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137717. * @param name Define the name of the lens flare system in the scene
  137718. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137719. * @param scene Define the scene the lens flare system belongs to
  137720. */
  137721. constructor(
  137722. /**
  137723. * Define the name of the lens flare system
  137724. */
  137725. name: string, emitter: any, scene: Scene);
  137726. /**
  137727. * Define if the lens flare system is enabled.
  137728. */
  137729. get isEnabled(): boolean;
  137730. set isEnabled(value: boolean);
  137731. /**
  137732. * Get the scene the effects belongs to.
  137733. * @returns the scene holding the lens flare system
  137734. */
  137735. getScene(): Scene;
  137736. /**
  137737. * Get the emitter of the lens flare system.
  137738. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137739. * @returns the emitter of the lens flare system
  137740. */
  137741. getEmitter(): any;
  137742. /**
  137743. * Set the emitter of the lens flare system.
  137744. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137745. * @param newEmitter Define the new emitter of the system
  137746. */
  137747. setEmitter(newEmitter: any): void;
  137748. /**
  137749. * Get the lens flare system emitter position.
  137750. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137751. * @returns the position
  137752. */
  137753. getEmitterPosition(): Vector3;
  137754. /**
  137755. * @hidden
  137756. */
  137757. computeEffectivePosition(globalViewport: Viewport): boolean;
  137758. /** @hidden */
  137759. _isVisible(): boolean;
  137760. /**
  137761. * @hidden
  137762. */
  137763. render(): boolean;
  137764. /**
  137765. * Dispose and release the lens flare with its associated resources.
  137766. */
  137767. dispose(): void;
  137768. /**
  137769. * Parse a lens flare system from a JSON repressentation
  137770. * @param parsedLensFlareSystem Define the JSON to parse
  137771. * @param scene Define the scene the parsed system should be instantiated in
  137772. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  137773. * @returns the parsed system
  137774. */
  137775. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  137776. /**
  137777. * Serialize the current Lens Flare System into a JSON representation.
  137778. * @returns the serialized JSON
  137779. */
  137780. serialize(): any;
  137781. }
  137782. }
  137783. declare module BABYLON {
  137784. /**
  137785. * This represents one of the lens effect in a `lensFlareSystem`.
  137786. * It controls one of the indiviual texture used in the effect.
  137787. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137788. */
  137789. export class LensFlare {
  137790. /**
  137791. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137792. */
  137793. size: number;
  137794. /**
  137795. * 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.
  137796. */
  137797. position: number;
  137798. /**
  137799. * Define the lens color.
  137800. */
  137801. color: Color3;
  137802. /**
  137803. * Define the lens texture.
  137804. */
  137805. texture: Nullable<Texture>;
  137806. /**
  137807. * Define the alpha mode to render this particular lens.
  137808. */
  137809. alphaMode: number;
  137810. private _system;
  137811. /**
  137812. * Creates a new Lens Flare.
  137813. * This represents one of the lens effect in a `lensFlareSystem`.
  137814. * It controls one of the indiviual texture used in the effect.
  137815. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137816. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  137817. * @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.
  137818. * @param color Define the lens color
  137819. * @param imgUrl Define the lens texture url
  137820. * @param system Define the `lensFlareSystem` this flare is part of
  137821. * @returns The newly created Lens Flare
  137822. */
  137823. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  137824. /**
  137825. * Instantiates a new Lens Flare.
  137826. * This represents one of the lens effect in a `lensFlareSystem`.
  137827. * It controls one of the indiviual texture used in the effect.
  137828. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137829. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  137830. * @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.
  137831. * @param color Define the lens color
  137832. * @param imgUrl Define the lens texture url
  137833. * @param system Define the `lensFlareSystem` this flare is part of
  137834. */
  137835. constructor(
  137836. /**
  137837. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137838. */
  137839. size: number,
  137840. /**
  137841. * 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.
  137842. */
  137843. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  137844. /**
  137845. * Dispose and release the lens flare with its associated resources.
  137846. */
  137847. dispose(): void;
  137848. }
  137849. }
  137850. declare module BABYLON {
  137851. interface AbstractScene {
  137852. /**
  137853. * The list of lens flare system added to the scene
  137854. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137855. */
  137856. lensFlareSystems: Array<LensFlareSystem>;
  137857. /**
  137858. * Removes the given lens flare system from this scene.
  137859. * @param toRemove The lens flare system to remove
  137860. * @returns The index of the removed lens flare system
  137861. */
  137862. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  137863. /**
  137864. * Adds the given lens flare system to this scene
  137865. * @param newLensFlareSystem The lens flare system to add
  137866. */
  137867. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  137868. /**
  137869. * Gets a lens flare system using its name
  137870. * @param name defines the name to look for
  137871. * @returns the lens flare system or null if not found
  137872. */
  137873. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  137874. /**
  137875. * Gets a lens flare system using its id
  137876. * @param id defines the id to look for
  137877. * @returns the lens flare system or null if not found
  137878. */
  137879. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  137880. }
  137881. /**
  137882. * Defines the lens flare scene component responsible to manage any lens flares
  137883. * in a given scene.
  137884. */
  137885. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  137886. /**
  137887. * The component name helpfull to identify the component in the list of scene components.
  137888. */
  137889. readonly name: string;
  137890. /**
  137891. * The scene the component belongs to.
  137892. */
  137893. scene: Scene;
  137894. /**
  137895. * Creates a new instance of the component for the given scene
  137896. * @param scene Defines the scene to register the component in
  137897. */
  137898. constructor(scene: Scene);
  137899. /**
  137900. * Registers the component in a given scene
  137901. */
  137902. register(): void;
  137903. /**
  137904. * Rebuilds the elements related to this component in case of
  137905. * context lost for instance.
  137906. */
  137907. rebuild(): void;
  137908. /**
  137909. * Adds all the elements from the container to the scene
  137910. * @param container the container holding the elements
  137911. */
  137912. addFromContainer(container: AbstractScene): void;
  137913. /**
  137914. * Removes all the elements in the container from the scene
  137915. * @param container contains the elements to remove
  137916. * @param dispose if the removed element should be disposed (default: false)
  137917. */
  137918. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137919. /**
  137920. * Serializes the component data to the specified json object
  137921. * @param serializationObject The object to serialize to
  137922. */
  137923. serialize(serializationObject: any): void;
  137924. /**
  137925. * Disposes the component and the associated ressources.
  137926. */
  137927. dispose(): void;
  137928. private _draw;
  137929. }
  137930. }
  137931. declare module BABYLON {
  137932. /** @hidden */
  137933. export var depthPixelShader: {
  137934. name: string;
  137935. shader: string;
  137936. };
  137937. }
  137938. declare module BABYLON {
  137939. /** @hidden */
  137940. export var depthVertexShader: {
  137941. name: string;
  137942. shader: string;
  137943. };
  137944. }
  137945. declare module BABYLON {
  137946. /**
  137947. * This represents a depth renderer in Babylon.
  137948. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  137949. */
  137950. export class DepthRenderer {
  137951. private _scene;
  137952. private _depthMap;
  137953. private _effect;
  137954. private readonly _storeNonLinearDepth;
  137955. private readonly _clearColor;
  137956. /** Get if the depth renderer is using packed depth or not */
  137957. readonly isPacked: boolean;
  137958. private _cachedDefines;
  137959. private _camera;
  137960. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  137961. enabled: boolean;
  137962. /**
  137963. * Specifiess that the depth renderer will only be used within
  137964. * the camera it is created for.
  137965. * This can help forcing its rendering during the camera processing.
  137966. */
  137967. useOnlyInActiveCamera: boolean;
  137968. /** @hidden */
  137969. static _SceneComponentInitialization: (scene: Scene) => void;
  137970. /**
  137971. * Instantiates a depth renderer
  137972. * @param scene The scene the renderer belongs to
  137973. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  137974. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  137975. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  137976. */
  137977. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  137978. /**
  137979. * Creates the depth rendering effect and checks if the effect is ready.
  137980. * @param subMesh The submesh to be used to render the depth map of
  137981. * @param useInstances If multiple world instances should be used
  137982. * @returns if the depth renderer is ready to render the depth map
  137983. */
  137984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137985. /**
  137986. * Gets the texture which the depth map will be written to.
  137987. * @returns The depth map texture
  137988. */
  137989. getDepthMap(): RenderTargetTexture;
  137990. /**
  137991. * Disposes of the depth renderer.
  137992. */
  137993. dispose(): void;
  137994. }
  137995. }
  137996. declare module BABYLON {
  137997. /** @hidden */
  137998. export var minmaxReduxPixelShader: {
  137999. name: string;
  138000. shader: string;
  138001. };
  138002. }
  138003. declare module BABYLON {
  138004. /**
  138005. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138006. * and maximum values from all values of the texture.
  138007. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138008. * The source values are read from the red channel of the texture.
  138009. */
  138010. export class MinMaxReducer {
  138011. /**
  138012. * Observable triggered when the computation has been performed
  138013. */
  138014. onAfterReductionPerformed: Observable<{
  138015. min: number;
  138016. max: number;
  138017. }>;
  138018. protected _camera: Camera;
  138019. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138020. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138021. protected _postProcessManager: PostProcessManager;
  138022. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138023. protected _forceFullscreenViewport: boolean;
  138024. /**
  138025. * Creates a min/max reducer
  138026. * @param camera The camera to use for the post processes
  138027. */
  138028. constructor(camera: Camera);
  138029. /**
  138030. * Gets the texture used to read the values from.
  138031. */
  138032. get sourceTexture(): Nullable<RenderTargetTexture>;
  138033. /**
  138034. * Sets the source texture to read the values from.
  138035. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138036. * because in such textures '1' value must not be taken into account to compute the maximum
  138037. * as this value is used to clear the texture.
  138038. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138039. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138040. * @param depthRedux Indicates if the texture is a depth texture or not
  138041. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138042. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138043. */
  138044. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138045. /**
  138046. * Defines the refresh rate of the computation.
  138047. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138048. */
  138049. get refreshRate(): number;
  138050. set refreshRate(value: number);
  138051. protected _activated: boolean;
  138052. /**
  138053. * Gets the activation status of the reducer
  138054. */
  138055. get activated(): boolean;
  138056. /**
  138057. * Activates the reduction computation.
  138058. * When activated, the observers registered in onAfterReductionPerformed are
  138059. * called after the compuation is performed
  138060. */
  138061. activate(): void;
  138062. /**
  138063. * Deactivates the reduction computation.
  138064. */
  138065. deactivate(): void;
  138066. /**
  138067. * Disposes the min/max reducer
  138068. * @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.
  138069. */
  138070. dispose(disposeAll?: boolean): void;
  138071. }
  138072. }
  138073. declare module BABYLON {
  138074. /**
  138075. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138076. */
  138077. export class DepthReducer extends MinMaxReducer {
  138078. private _depthRenderer;
  138079. private _depthRendererId;
  138080. /**
  138081. * Gets the depth renderer used for the computation.
  138082. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138083. */
  138084. get depthRenderer(): Nullable<DepthRenderer>;
  138085. /**
  138086. * Creates a depth reducer
  138087. * @param camera The camera used to render the depth texture
  138088. */
  138089. constructor(camera: Camera);
  138090. /**
  138091. * Sets the depth renderer to use to generate the depth map
  138092. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138093. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138094. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138095. */
  138096. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138097. /** @hidden */
  138098. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138099. /**
  138100. * Activates the reduction computation.
  138101. * When activated, the observers registered in onAfterReductionPerformed are
  138102. * called after the compuation is performed
  138103. */
  138104. activate(): void;
  138105. /**
  138106. * Deactivates the reduction computation.
  138107. */
  138108. deactivate(): void;
  138109. /**
  138110. * Disposes the depth reducer
  138111. * @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.
  138112. */
  138113. dispose(disposeAll?: boolean): void;
  138114. }
  138115. }
  138116. declare module BABYLON {
  138117. /**
  138118. * A CSM implementation allowing casting shadows on large scenes.
  138119. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138120. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138121. */
  138122. export class CascadedShadowGenerator extends ShadowGenerator {
  138123. private static readonly frustumCornersNDCSpace;
  138124. /**
  138125. * Name of the CSM class
  138126. */
  138127. static CLASSNAME: string;
  138128. /**
  138129. * Defines the default number of cascades used by the CSM.
  138130. */
  138131. static readonly DEFAULT_CASCADES_COUNT: number;
  138132. /**
  138133. * Defines the minimum number of cascades used by the CSM.
  138134. */
  138135. static readonly MIN_CASCADES_COUNT: number;
  138136. /**
  138137. * Defines the maximum number of cascades used by the CSM.
  138138. */
  138139. static readonly MAX_CASCADES_COUNT: number;
  138140. protected _validateFilter(filter: number): number;
  138141. /**
  138142. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138143. */
  138144. penumbraDarkness: number;
  138145. private _numCascades;
  138146. /**
  138147. * Gets or set the number of cascades used by the CSM.
  138148. */
  138149. get numCascades(): number;
  138150. set numCascades(value: number);
  138151. /**
  138152. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138153. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138154. */
  138155. stabilizeCascades: boolean;
  138156. private _freezeShadowCastersBoundingInfo;
  138157. private _freezeShadowCastersBoundingInfoObservable;
  138158. /**
  138159. * Enables or disables the shadow casters bounding info computation.
  138160. * If your shadow casters don't move, you can disable this feature.
  138161. * If it is enabled, the bounding box computation is done every frame.
  138162. */
  138163. get freezeShadowCastersBoundingInfo(): boolean;
  138164. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138165. private _scbiMin;
  138166. private _scbiMax;
  138167. protected _computeShadowCastersBoundingInfo(): void;
  138168. protected _shadowCastersBoundingInfo: BoundingInfo;
  138169. /**
  138170. * Gets or sets the shadow casters bounding info.
  138171. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138172. * so that the system won't overwrite the bounds you provide
  138173. */
  138174. get shadowCastersBoundingInfo(): BoundingInfo;
  138175. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138176. protected _breaksAreDirty: boolean;
  138177. protected _minDistance: number;
  138178. protected _maxDistance: number;
  138179. /**
  138180. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138181. *
  138182. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138183. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138184. * @param min minimal distance for the breaks (default to 0.)
  138185. * @param max maximal distance for the breaks (default to 1.)
  138186. */
  138187. setMinMaxDistance(min: number, max: number): void;
  138188. /** Gets the minimal distance used in the cascade break computation */
  138189. get minDistance(): number;
  138190. /** Gets the maximal distance used in the cascade break computation */
  138191. get maxDistance(): number;
  138192. /**
  138193. * Gets the class name of that object
  138194. * @returns "CascadedShadowGenerator"
  138195. */
  138196. getClassName(): string;
  138197. private _cascadeMinExtents;
  138198. private _cascadeMaxExtents;
  138199. /**
  138200. * Gets a cascade minimum extents
  138201. * @param cascadeIndex index of the cascade
  138202. * @returns the minimum cascade extents
  138203. */
  138204. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138205. /**
  138206. * Gets a cascade maximum extents
  138207. * @param cascadeIndex index of the cascade
  138208. * @returns the maximum cascade extents
  138209. */
  138210. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138211. private _cascades;
  138212. private _currentLayer;
  138213. private _viewSpaceFrustumsZ;
  138214. private _viewMatrices;
  138215. private _projectionMatrices;
  138216. private _transformMatrices;
  138217. private _transformMatricesAsArray;
  138218. private _frustumLengths;
  138219. private _lightSizeUVCorrection;
  138220. private _depthCorrection;
  138221. private _frustumCornersWorldSpace;
  138222. private _frustumCenter;
  138223. private _shadowCameraPos;
  138224. private _shadowMaxZ;
  138225. /**
  138226. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138227. * It defaults to camera.maxZ
  138228. */
  138229. get shadowMaxZ(): number;
  138230. /**
  138231. * Sets the shadow max z distance.
  138232. */
  138233. set shadowMaxZ(value: number);
  138234. protected _debug: boolean;
  138235. /**
  138236. * Gets or sets the debug flag.
  138237. * When enabled, the cascades are materialized by different colors on the screen.
  138238. */
  138239. get debug(): boolean;
  138240. set debug(dbg: boolean);
  138241. private _depthClamp;
  138242. /**
  138243. * Gets or sets the depth clamping value.
  138244. *
  138245. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138246. * to account for the shadow casters far away.
  138247. *
  138248. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138249. */
  138250. get depthClamp(): boolean;
  138251. set depthClamp(value: boolean);
  138252. private _cascadeBlendPercentage;
  138253. /**
  138254. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138255. * It defaults to 0.1 (10% blending).
  138256. */
  138257. get cascadeBlendPercentage(): number;
  138258. set cascadeBlendPercentage(value: number);
  138259. private _lambda;
  138260. /**
  138261. * Gets or set the lambda parameter.
  138262. * This parameter is used to split the camera frustum and create the cascades.
  138263. * 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.
  138264. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138265. */
  138266. get lambda(): number;
  138267. set lambda(value: number);
  138268. /**
  138269. * Gets the view matrix corresponding to a given cascade
  138270. * @param cascadeNum cascade to retrieve the view matrix from
  138271. * @returns the cascade view matrix
  138272. */
  138273. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138274. /**
  138275. * Gets the projection matrix corresponding to a given cascade
  138276. * @param cascadeNum cascade to retrieve the projection matrix from
  138277. * @returns the cascade projection matrix
  138278. */
  138279. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138280. /**
  138281. * Gets the transformation matrix corresponding to a given cascade
  138282. * @param cascadeNum cascade to retrieve the transformation matrix from
  138283. * @returns the cascade transformation matrix
  138284. */
  138285. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138286. private _depthRenderer;
  138287. /**
  138288. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138289. *
  138290. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138291. *
  138292. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138293. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138294. * @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
  138295. */
  138296. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138297. private _depthReducer;
  138298. private _autoCalcDepthBounds;
  138299. /**
  138300. * Gets or sets the autoCalcDepthBounds property.
  138301. *
  138302. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138303. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138304. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138305. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138306. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138307. */
  138308. get autoCalcDepthBounds(): boolean;
  138309. set autoCalcDepthBounds(value: boolean);
  138310. /**
  138311. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138312. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138313. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138314. * for setting the refresh rate on the renderer yourself!
  138315. */
  138316. get autoCalcDepthBoundsRefreshRate(): number;
  138317. set autoCalcDepthBoundsRefreshRate(value: number);
  138318. /**
  138319. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138320. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138321. * you change the camera near/far planes!
  138322. */
  138323. splitFrustum(): void;
  138324. private _splitFrustum;
  138325. private _computeMatrices;
  138326. private _computeFrustumInWorldSpace;
  138327. private _computeCascadeFrustum;
  138328. /**
  138329. * Support test.
  138330. */
  138331. static get IsSupported(): boolean;
  138332. /** @hidden */
  138333. static _SceneComponentInitialization: (scene: Scene) => void;
  138334. /**
  138335. * Creates a Cascaded Shadow Generator object.
  138336. * A ShadowGenerator is the required tool to use the shadows.
  138337. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138338. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138339. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138340. * @param light The directional light object generating the shadows.
  138341. * @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.
  138342. */
  138343. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138344. protected _initializeGenerator(): void;
  138345. protected _createTargetRenderTexture(): void;
  138346. protected _initializeShadowMap(): void;
  138347. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138348. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138349. /**
  138350. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138351. * @param defines Defines of the material we want to update
  138352. * @param lightIndex Index of the light in the enabled light list of the material
  138353. */
  138354. prepareDefines(defines: any, lightIndex: number): void;
  138355. /**
  138356. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138357. * defined in the generator but impacting the effect).
  138358. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138359. * @param effect The effect we are binfing the information for
  138360. */
  138361. bindShadowLight(lightIndex: string, effect: Effect): void;
  138362. /**
  138363. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138364. * (eq to view projection * shadow projection matrices)
  138365. * @returns The transform matrix used to create the shadow map
  138366. */
  138367. getTransformMatrix(): Matrix;
  138368. /**
  138369. * Disposes the ShadowGenerator.
  138370. * Returns nothing.
  138371. */
  138372. dispose(): void;
  138373. /**
  138374. * Serializes the shadow generator setup to a json object.
  138375. * @returns The serialized JSON object
  138376. */
  138377. serialize(): any;
  138378. /**
  138379. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  138380. * @param parsedShadowGenerator The JSON object to parse
  138381. * @param scene The scene to create the shadow map for
  138382. * @returns The parsed shadow generator
  138383. */
  138384. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  138385. }
  138386. }
  138387. declare module BABYLON {
  138388. /**
  138389. * Defines the shadow generator component responsible to manage any shadow generators
  138390. * in a given scene.
  138391. */
  138392. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  138393. /**
  138394. * The component name helpfull to identify the component in the list of scene components.
  138395. */
  138396. readonly name: string;
  138397. /**
  138398. * The scene the component belongs to.
  138399. */
  138400. scene: Scene;
  138401. /**
  138402. * Creates a new instance of the component for the given scene
  138403. * @param scene Defines the scene to register the component in
  138404. */
  138405. constructor(scene: Scene);
  138406. /**
  138407. * Registers the component in a given scene
  138408. */
  138409. register(): void;
  138410. /**
  138411. * Rebuilds the elements related to this component in case of
  138412. * context lost for instance.
  138413. */
  138414. rebuild(): void;
  138415. /**
  138416. * Serializes the component data to the specified json object
  138417. * @param serializationObject The object to serialize to
  138418. */
  138419. serialize(serializationObject: any): void;
  138420. /**
  138421. * Adds all the elements from the container to the scene
  138422. * @param container the container holding the elements
  138423. */
  138424. addFromContainer(container: AbstractScene): void;
  138425. /**
  138426. * Removes all the elements in the container from the scene
  138427. * @param container contains the elements to remove
  138428. * @param dispose if the removed element should be disposed (default: false)
  138429. */
  138430. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138431. /**
  138432. * Rebuilds the elements related to this component in case of
  138433. * context lost for instance.
  138434. */
  138435. dispose(): void;
  138436. private _gatherRenderTargets;
  138437. }
  138438. }
  138439. declare module BABYLON {
  138440. /**
  138441. * A point light is a light defined by an unique point in world space.
  138442. * The light is emitted in every direction from this point.
  138443. * A good example of a point light is a standard light bulb.
  138444. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138445. */
  138446. export class PointLight extends ShadowLight {
  138447. private _shadowAngle;
  138448. /**
  138449. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138450. * This specifies what angle the shadow will use to be created.
  138451. *
  138452. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138453. */
  138454. get shadowAngle(): number;
  138455. /**
  138456. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138457. * This specifies what angle the shadow will use to be created.
  138458. *
  138459. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138460. */
  138461. set shadowAngle(value: number);
  138462. /**
  138463. * Gets the direction if it has been set.
  138464. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138465. */
  138466. get direction(): Vector3;
  138467. /**
  138468. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138469. */
  138470. set direction(value: Vector3);
  138471. /**
  138472. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138473. * A PointLight emits the light in every direction.
  138474. * It can cast shadows.
  138475. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138476. * ```javascript
  138477. * var pointLight = new PointLight("pl", camera.position, scene);
  138478. * ```
  138479. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138480. * @param name The light friendly name
  138481. * @param position The position of the point light in the scene
  138482. * @param scene The scene the lights belongs to
  138483. */
  138484. constructor(name: string, position: Vector3, scene: Scene);
  138485. /**
  138486. * Returns the string "PointLight"
  138487. * @returns the class name
  138488. */
  138489. getClassName(): string;
  138490. /**
  138491. * Returns the integer 0.
  138492. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138493. */
  138494. getTypeID(): number;
  138495. /**
  138496. * Specifies wether or not the shadowmap should be a cube texture.
  138497. * @returns true if the shadowmap needs to be a cube texture.
  138498. */
  138499. needCube(): boolean;
  138500. /**
  138501. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138502. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138503. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138504. */
  138505. getShadowDirection(faceIndex?: number): Vector3;
  138506. /**
  138507. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138508. * - fov = PI / 2
  138509. * - aspect ratio : 1.0
  138510. * - z-near and far equal to the active camera minZ and maxZ.
  138511. * Returns the PointLight.
  138512. */
  138513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138514. protected _buildUniformLayout(): void;
  138515. /**
  138516. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138517. * @param effect The effect to update
  138518. * @param lightIndex The index of the light in the effect to update
  138519. * @returns The point light
  138520. */
  138521. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138523. /**
  138524. * Prepares the list of defines specific to the light type.
  138525. * @param defines the list of defines
  138526. * @param lightIndex defines the index of the light for the effect
  138527. */
  138528. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138529. }
  138530. }
  138531. declare module BABYLON {
  138532. /**
  138533. * Header information of HDR texture files.
  138534. */
  138535. export interface HDRInfo {
  138536. /**
  138537. * The height of the texture in pixels.
  138538. */
  138539. height: number;
  138540. /**
  138541. * The width of the texture in pixels.
  138542. */
  138543. width: number;
  138544. /**
  138545. * The index of the beginning of the data in the binary file.
  138546. */
  138547. dataPosition: number;
  138548. }
  138549. /**
  138550. * This groups tools to convert HDR texture to native colors array.
  138551. */
  138552. export class HDRTools {
  138553. private static Ldexp;
  138554. private static Rgbe2float;
  138555. private static readStringLine;
  138556. /**
  138557. * Reads header information from an RGBE texture stored in a native array.
  138558. * More information on this format are available here:
  138559. * https://en.wikipedia.org/wiki/RGBE_image_format
  138560. *
  138561. * @param uint8array The binary file stored in native array.
  138562. * @return The header information.
  138563. */
  138564. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138565. /**
  138566. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138567. * This RGBE texture needs to store the information as a panorama.
  138568. *
  138569. * More information on this format are available here:
  138570. * https://en.wikipedia.org/wiki/RGBE_image_format
  138571. *
  138572. * @param buffer The binary file stored in an array buffer.
  138573. * @param size The expected size of the extracted cubemap.
  138574. * @return The Cube Map information.
  138575. */
  138576. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138577. /**
  138578. * Returns the pixels data extracted from an RGBE texture.
  138579. * This pixels will be stored left to right up to down in the R G B order in one array.
  138580. *
  138581. * More information on this format are available here:
  138582. * https://en.wikipedia.org/wiki/RGBE_image_format
  138583. *
  138584. * @param uint8array The binary file stored in an array buffer.
  138585. * @param hdrInfo The header information of the file.
  138586. * @return The pixels data in RGB right to left up to down order.
  138587. */
  138588. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138589. private static RGBE_ReadPixels_RLE;
  138590. private static RGBE_ReadPixels_NOT_RLE;
  138591. }
  138592. }
  138593. declare module BABYLON {
  138594. /**
  138595. * Effect Render Options
  138596. */
  138597. export interface IEffectRendererOptions {
  138598. /**
  138599. * Defines the vertices positions.
  138600. */
  138601. positions?: number[];
  138602. /**
  138603. * Defines the indices.
  138604. */
  138605. indices?: number[];
  138606. }
  138607. /**
  138608. * Helper class to render one or more effects.
  138609. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138610. */
  138611. export class EffectRenderer {
  138612. private engine;
  138613. private static _DefaultOptions;
  138614. private _vertexBuffers;
  138615. private _indexBuffer;
  138616. private _fullscreenViewport;
  138617. /**
  138618. * Creates an effect renderer
  138619. * @param engine the engine to use for rendering
  138620. * @param options defines the options of the effect renderer
  138621. */
  138622. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138623. /**
  138624. * Sets the current viewport in normalized coordinates 0-1
  138625. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138626. */
  138627. setViewport(viewport?: Viewport): void;
  138628. /**
  138629. * Binds the embedded attributes buffer to the effect.
  138630. * @param effect Defines the effect to bind the attributes for
  138631. */
  138632. bindBuffers(effect: Effect): void;
  138633. /**
  138634. * Sets the current effect wrapper to use during draw.
  138635. * The effect needs to be ready before calling this api.
  138636. * This also sets the default full screen position attribute.
  138637. * @param effectWrapper Defines the effect to draw with
  138638. */
  138639. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138640. /**
  138641. * Restores engine states
  138642. */
  138643. restoreStates(): void;
  138644. /**
  138645. * Draws a full screen quad.
  138646. */
  138647. draw(): void;
  138648. private isRenderTargetTexture;
  138649. /**
  138650. * renders one or more effects to a specified texture
  138651. * @param effectWrapper the effect to renderer
  138652. * @param outputTexture texture to draw to, if null it will render to the screen.
  138653. */
  138654. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138655. /**
  138656. * Disposes of the effect renderer
  138657. */
  138658. dispose(): void;
  138659. }
  138660. /**
  138661. * Options to create an EffectWrapper
  138662. */
  138663. interface EffectWrapperCreationOptions {
  138664. /**
  138665. * Engine to use to create the effect
  138666. */
  138667. engine: ThinEngine;
  138668. /**
  138669. * Fragment shader for the effect
  138670. */
  138671. fragmentShader: string;
  138672. /**
  138673. * Use the shader store instead of direct source code
  138674. */
  138675. useShaderStore?: boolean;
  138676. /**
  138677. * Vertex shader for the effect
  138678. */
  138679. vertexShader?: string;
  138680. /**
  138681. * Attributes to use in the shader
  138682. */
  138683. attributeNames?: Array<string>;
  138684. /**
  138685. * Uniforms to use in the shader
  138686. */
  138687. uniformNames?: Array<string>;
  138688. /**
  138689. * Texture sampler names to use in the shader
  138690. */
  138691. samplerNames?: Array<string>;
  138692. /**
  138693. * Defines to use in the shader
  138694. */
  138695. defines?: Array<string>;
  138696. /**
  138697. * Callback when effect is compiled
  138698. */
  138699. onCompiled?: Nullable<(effect: Effect) => void>;
  138700. /**
  138701. * The friendly name of the effect displayed in Spector.
  138702. */
  138703. name?: string;
  138704. }
  138705. /**
  138706. * Wraps an effect to be used for rendering
  138707. */
  138708. export class EffectWrapper {
  138709. /**
  138710. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138711. */
  138712. onApplyObservable: Observable<{}>;
  138713. /**
  138714. * The underlying effect
  138715. */
  138716. effect: Effect;
  138717. /**
  138718. * Creates an effect to be renderer
  138719. * @param creationOptions options to create the effect
  138720. */
  138721. constructor(creationOptions: EffectWrapperCreationOptions);
  138722. /**
  138723. * Disposes of the effect wrapper
  138724. */
  138725. dispose(): void;
  138726. }
  138727. }
  138728. declare module BABYLON {
  138729. /** @hidden */
  138730. export var hdrFilteringVertexShader: {
  138731. name: string;
  138732. shader: string;
  138733. };
  138734. }
  138735. declare module BABYLON {
  138736. /** @hidden */
  138737. export var hdrFilteringPixelShader: {
  138738. name: string;
  138739. shader: string;
  138740. };
  138741. }
  138742. declare module BABYLON {
  138743. /**
  138744. * Options for texture filtering
  138745. */
  138746. interface IHDRFilteringOptions {
  138747. /**
  138748. * Scales pixel intensity for the input HDR map.
  138749. */
  138750. hdrScale?: number;
  138751. /**
  138752. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138753. */
  138754. quality?: number;
  138755. }
  138756. /**
  138757. * Filters HDR maps to get correct renderings of PBR reflections
  138758. */
  138759. export class HDRFiltering {
  138760. private _engine;
  138761. private _effectRenderer;
  138762. private _effectWrapper;
  138763. private _lodGenerationOffset;
  138764. private _lodGenerationScale;
  138765. /**
  138766. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  138767. * you care about baking speed.
  138768. */
  138769. quality: number;
  138770. /**
  138771. * Scales pixel intensity for the input HDR map.
  138772. */
  138773. hdrScale: number;
  138774. /**
  138775. * Instantiates HDR filter for reflection maps
  138776. *
  138777. * @param engine Thin engine
  138778. * @param options Options
  138779. */
  138780. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  138781. private _createRenderTarget;
  138782. private _prefilterInternal;
  138783. private _createEffect;
  138784. /**
  138785. * Get a value indicating if the filter is ready to be used
  138786. * @param texture Texture to filter
  138787. * @returns true if the filter is ready
  138788. */
  138789. isReady(texture: BaseTexture): boolean;
  138790. /**
  138791. * Prefilters a cube texture to have mipmap levels representing roughness values.
  138792. * Prefiltering will be invoked at the end of next rendering pass.
  138793. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  138794. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  138795. * @param texture Texture to filter
  138796. * @param onFinished Callback when filtering is done
  138797. * @return Promise called when prefiltering is done
  138798. */
  138799. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  138800. }
  138801. }
  138802. declare module BABYLON {
  138803. /**
  138804. * This represents a texture coming from an HDR input.
  138805. *
  138806. * The only supported format is currently panorama picture stored in RGBE format.
  138807. * Example of such files can be found on HDRLib: http://hdrlib.com/
  138808. */
  138809. export class HDRCubeTexture extends BaseTexture {
  138810. private static _facesMapping;
  138811. private _generateHarmonics;
  138812. private _noMipmap;
  138813. private _prefilterOnLoad;
  138814. private _textureMatrix;
  138815. private _size;
  138816. private _onLoad;
  138817. private _onError;
  138818. /**
  138819. * The texture URL.
  138820. */
  138821. url: string;
  138822. /**
  138823. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  138824. */
  138825. coordinatesMode: number;
  138826. protected _isBlocking: boolean;
  138827. /**
  138828. * Sets wether or not the texture is blocking during loading.
  138829. */
  138830. set isBlocking(value: boolean);
  138831. /**
  138832. * Gets wether or not the texture is blocking during loading.
  138833. */
  138834. get isBlocking(): boolean;
  138835. protected _rotationY: number;
  138836. /**
  138837. * Sets texture matrix rotation angle around Y axis in radians.
  138838. */
  138839. set rotationY(value: number);
  138840. /**
  138841. * Gets texture matrix rotation angle around Y axis radians.
  138842. */
  138843. get rotationY(): number;
  138844. /**
  138845. * Gets or sets the center of the bounding box associated with the cube texture
  138846. * It must define where the camera used to render the texture was set
  138847. */
  138848. boundingBoxPosition: Vector3;
  138849. private _boundingBoxSize;
  138850. /**
  138851. * Gets or sets the size of the bounding box associated with the cube texture
  138852. * When defined, the cubemap will switch to local mode
  138853. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  138854. * @example https://www.babylonjs-playground.com/#RNASML
  138855. */
  138856. set boundingBoxSize(value: Vector3);
  138857. get boundingBoxSize(): Vector3;
  138858. /**
  138859. * Instantiates an HDRTexture from the following parameters.
  138860. *
  138861. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  138862. * @param sceneOrEngine The scene or engine the texture will be used in
  138863. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138864. * @param noMipmap Forces to not generate the mipmap if true
  138865. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  138866. * @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)
  138867. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  138868. */
  138869. 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>);
  138870. /**
  138871. * Get the current class name of the texture useful for serialization or dynamic coding.
  138872. * @returns "HDRCubeTexture"
  138873. */
  138874. getClassName(): string;
  138875. /**
  138876. * Occurs when the file is raw .hdr file.
  138877. */
  138878. private loadTexture;
  138879. clone(): HDRCubeTexture;
  138880. delayLoad(): void;
  138881. /**
  138882. * Get the texture reflection matrix used to rotate/transform the reflection.
  138883. * @returns the reflection matrix
  138884. */
  138885. getReflectionTextureMatrix(): Matrix;
  138886. /**
  138887. * Set the texture reflection matrix used to rotate/transform the reflection.
  138888. * @param value Define the reflection matrix to set
  138889. */
  138890. setReflectionTextureMatrix(value: Matrix): void;
  138891. /**
  138892. * Parses a JSON representation of an HDR Texture in order to create the texture
  138893. * @param parsedTexture Define the JSON representation
  138894. * @param scene Define the scene the texture should be created in
  138895. * @param rootUrl Define the root url in case we need to load relative dependencies
  138896. * @returns the newly created texture after parsing
  138897. */
  138898. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  138899. serialize(): any;
  138900. }
  138901. }
  138902. declare module BABYLON {
  138903. /**
  138904. * Class used to control physics engine
  138905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138906. */
  138907. export class PhysicsEngine implements IPhysicsEngine {
  138908. private _physicsPlugin;
  138909. /**
  138910. * Global value used to control the smallest number supported by the simulation
  138911. */
  138912. static Epsilon: number;
  138913. private _impostors;
  138914. private _joints;
  138915. private _subTimeStep;
  138916. /**
  138917. * Gets the gravity vector used by the simulation
  138918. */
  138919. gravity: Vector3;
  138920. /**
  138921. * Factory used to create the default physics plugin.
  138922. * @returns The default physics plugin
  138923. */
  138924. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  138925. /**
  138926. * Creates a new Physics Engine
  138927. * @param gravity defines the gravity vector used by the simulation
  138928. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  138929. */
  138930. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  138931. /**
  138932. * Sets the gravity vector used by the simulation
  138933. * @param gravity defines the gravity vector to use
  138934. */
  138935. setGravity(gravity: Vector3): void;
  138936. /**
  138937. * Set the time step of the physics engine.
  138938. * Default is 1/60.
  138939. * To slow it down, enter 1/600 for example.
  138940. * To speed it up, 1/30
  138941. * @param newTimeStep defines the new timestep to apply to this world.
  138942. */
  138943. setTimeStep(newTimeStep?: number): void;
  138944. /**
  138945. * Get the time step of the physics engine.
  138946. * @returns the current time step
  138947. */
  138948. getTimeStep(): number;
  138949. /**
  138950. * Set the sub time step of the physics engine.
  138951. * Default is 0 meaning there is no sub steps
  138952. * To increase physics resolution precision, set a small value (like 1 ms)
  138953. * @param subTimeStep defines the new sub timestep used for physics resolution.
  138954. */
  138955. setSubTimeStep(subTimeStep?: number): void;
  138956. /**
  138957. * Get the sub time step of the physics engine.
  138958. * @returns the current sub time step
  138959. */
  138960. getSubTimeStep(): number;
  138961. /**
  138962. * Release all resources
  138963. */
  138964. dispose(): void;
  138965. /**
  138966. * Gets the name of the current physics plugin
  138967. * @returns the name of the plugin
  138968. */
  138969. getPhysicsPluginName(): string;
  138970. /**
  138971. * Adding a new impostor for the impostor tracking.
  138972. * This will be done by the impostor itself.
  138973. * @param impostor the impostor to add
  138974. */
  138975. addImpostor(impostor: PhysicsImpostor): void;
  138976. /**
  138977. * Remove an impostor from the engine.
  138978. * This impostor and its mesh will not longer be updated by the physics engine.
  138979. * @param impostor the impostor to remove
  138980. */
  138981. removeImpostor(impostor: PhysicsImpostor): void;
  138982. /**
  138983. * Add a joint to the physics engine
  138984. * @param mainImpostor defines the main impostor to which the joint is added.
  138985. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  138986. * @param joint defines the joint that will connect both impostors.
  138987. */
  138988. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138989. /**
  138990. * Removes a joint from the simulation
  138991. * @param mainImpostor defines the impostor used with the joint
  138992. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  138993. * @param joint defines the joint to remove
  138994. */
  138995. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  138996. /**
  138997. * Called by the scene. No need to call it.
  138998. * @param delta defines the timespam between frames
  138999. */
  139000. _step(delta: number): void;
  139001. /**
  139002. * Gets the current plugin used to run the simulation
  139003. * @returns current plugin
  139004. */
  139005. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139006. /**
  139007. * Gets the list of physic impostors
  139008. * @returns an array of PhysicsImpostor
  139009. */
  139010. getImpostors(): Array<PhysicsImpostor>;
  139011. /**
  139012. * Gets the impostor for a physics enabled object
  139013. * @param object defines the object impersonated by the impostor
  139014. * @returns the PhysicsImpostor or null if not found
  139015. */
  139016. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139017. /**
  139018. * Gets the impostor for a physics body object
  139019. * @param body defines physics body used by the impostor
  139020. * @returns the PhysicsImpostor or null if not found
  139021. */
  139022. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139023. /**
  139024. * Does a raycast in the physics world
  139025. * @param from when should the ray start?
  139026. * @param to when should the ray end?
  139027. * @returns PhysicsRaycastResult
  139028. */
  139029. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139030. }
  139031. }
  139032. declare module BABYLON {
  139033. /** @hidden */
  139034. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139035. private _useDeltaForWorldStep;
  139036. world: any;
  139037. name: string;
  139038. private _physicsMaterials;
  139039. private _fixedTimeStep;
  139040. private _cannonRaycastResult;
  139041. private _raycastResult;
  139042. private _physicsBodysToRemoveAfterStep;
  139043. private _firstFrame;
  139044. BJSCANNON: any;
  139045. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139046. setGravity(gravity: Vector3): void;
  139047. setTimeStep(timeStep: number): void;
  139048. getTimeStep(): number;
  139049. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139050. private _removeMarkedPhysicsBodiesFromWorld;
  139051. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139052. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139053. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139054. private _processChildMeshes;
  139055. removePhysicsBody(impostor: PhysicsImpostor): void;
  139056. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139057. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139058. private _addMaterial;
  139059. private _checkWithEpsilon;
  139060. private _createShape;
  139061. private _createHeightmap;
  139062. private _minus90X;
  139063. private _plus90X;
  139064. private _tmpPosition;
  139065. private _tmpDeltaPosition;
  139066. private _tmpUnityRotation;
  139067. private _updatePhysicsBodyTransformation;
  139068. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139069. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139070. isSupported(): boolean;
  139071. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139072. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139073. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139074. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139075. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139076. getBodyMass(impostor: PhysicsImpostor): number;
  139077. getBodyFriction(impostor: PhysicsImpostor): number;
  139078. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139079. getBodyRestitution(impostor: PhysicsImpostor): number;
  139080. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139081. sleepBody(impostor: PhysicsImpostor): void;
  139082. wakeUpBody(impostor: PhysicsImpostor): void;
  139083. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139084. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139085. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139086. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139087. getRadius(impostor: PhysicsImpostor): number;
  139088. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139089. dispose(): void;
  139090. private _extendNamespace;
  139091. /**
  139092. * Does a raycast in the physics world
  139093. * @param from when should the ray start?
  139094. * @param to when should the ray end?
  139095. * @returns PhysicsRaycastResult
  139096. */
  139097. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139098. }
  139099. }
  139100. declare module BABYLON {
  139101. /** @hidden */
  139102. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139103. private _useDeltaForWorldStep;
  139104. world: any;
  139105. name: string;
  139106. BJSOIMO: any;
  139107. private _raycastResult;
  139108. private _fixedTimeStep;
  139109. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139110. setGravity(gravity: Vector3): void;
  139111. setTimeStep(timeStep: number): void;
  139112. getTimeStep(): number;
  139113. private _tmpImpostorsArray;
  139114. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139115. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139116. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139117. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139118. private _tmpPositionVector;
  139119. removePhysicsBody(impostor: PhysicsImpostor): void;
  139120. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139122. isSupported(): boolean;
  139123. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139124. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139126. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139127. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139128. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139129. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139130. getBodyMass(impostor: PhysicsImpostor): number;
  139131. getBodyFriction(impostor: PhysicsImpostor): number;
  139132. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139133. getBodyRestitution(impostor: PhysicsImpostor): number;
  139134. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139135. sleepBody(impostor: PhysicsImpostor): void;
  139136. wakeUpBody(impostor: PhysicsImpostor): void;
  139137. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139138. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139139. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139140. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139141. getRadius(impostor: PhysicsImpostor): number;
  139142. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139143. dispose(): void;
  139144. /**
  139145. * Does a raycast in the physics world
  139146. * @param from when should the ray start?
  139147. * @param to when should the ray end?
  139148. * @returns PhysicsRaycastResult
  139149. */
  139150. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139151. }
  139152. }
  139153. declare module BABYLON {
  139154. /**
  139155. * AmmoJS Physics plugin
  139156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139157. * @see https://github.com/kripken/ammo.js/
  139158. */
  139159. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139160. private _useDeltaForWorldStep;
  139161. /**
  139162. * Reference to the Ammo library
  139163. */
  139164. bjsAMMO: any;
  139165. /**
  139166. * Created ammoJS world which physics bodies are added to
  139167. */
  139168. world: any;
  139169. /**
  139170. * Name of the plugin
  139171. */
  139172. name: string;
  139173. private _timeStep;
  139174. private _fixedTimeStep;
  139175. private _maxSteps;
  139176. private _tmpQuaternion;
  139177. private _tmpAmmoTransform;
  139178. private _tmpAmmoQuaternion;
  139179. private _tmpAmmoConcreteContactResultCallback;
  139180. private _collisionConfiguration;
  139181. private _dispatcher;
  139182. private _overlappingPairCache;
  139183. private _solver;
  139184. private _softBodySolver;
  139185. private _tmpAmmoVectorA;
  139186. private _tmpAmmoVectorB;
  139187. private _tmpAmmoVectorC;
  139188. private _tmpAmmoVectorD;
  139189. private _tmpContactCallbackResult;
  139190. private _tmpAmmoVectorRCA;
  139191. private _tmpAmmoVectorRCB;
  139192. private _raycastResult;
  139193. private static readonly DISABLE_COLLISION_FLAG;
  139194. private static readonly KINEMATIC_FLAG;
  139195. private static readonly DISABLE_DEACTIVATION_FLAG;
  139196. /**
  139197. * Initializes the ammoJS plugin
  139198. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139199. * @param ammoInjection can be used to inject your own ammo reference
  139200. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139201. */
  139202. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139203. /**
  139204. * Sets the gravity of the physics world (m/(s^2))
  139205. * @param gravity Gravity to set
  139206. */
  139207. setGravity(gravity: Vector3): void;
  139208. /**
  139209. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139210. * @param timeStep timestep to use in seconds
  139211. */
  139212. setTimeStep(timeStep: number): void;
  139213. /**
  139214. * 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)
  139215. * @param fixedTimeStep fixedTimeStep to use in seconds
  139216. */
  139217. setFixedTimeStep(fixedTimeStep: number): void;
  139218. /**
  139219. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139220. * @param maxSteps the maximum number of steps by the physics engine per frame
  139221. */
  139222. setMaxSteps(maxSteps: number): void;
  139223. /**
  139224. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139225. * @returns the current timestep in seconds
  139226. */
  139227. getTimeStep(): number;
  139228. /**
  139229. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139230. */
  139231. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139232. private _isImpostorInContact;
  139233. private _isImpostorPairInContact;
  139234. private _stepSimulation;
  139235. /**
  139236. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139237. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139238. * After the step the babylon meshes are set to the position of the physics imposters
  139239. * @param delta amount of time to step forward
  139240. * @param impostors array of imposters to update before/after the step
  139241. */
  139242. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139243. /**
  139244. * Update babylon mesh to match physics world object
  139245. * @param impostor imposter to match
  139246. */
  139247. private _afterSoftStep;
  139248. /**
  139249. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139250. * @param impostor imposter to match
  139251. */
  139252. private _ropeStep;
  139253. /**
  139254. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139255. * @param impostor imposter to match
  139256. */
  139257. private _softbodyOrClothStep;
  139258. private _tmpMatrix;
  139259. /**
  139260. * Applies an impulse on the imposter
  139261. * @param impostor imposter to apply impulse to
  139262. * @param force amount of force to be applied to the imposter
  139263. * @param contactPoint the location to apply the impulse on the imposter
  139264. */
  139265. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139266. /**
  139267. * Applies a force on the imposter
  139268. * @param impostor imposter to apply force
  139269. * @param force amount of force to be applied to the imposter
  139270. * @param contactPoint the location to apply the force on the imposter
  139271. */
  139272. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139273. /**
  139274. * Creates a physics body using the plugin
  139275. * @param impostor the imposter to create the physics body on
  139276. */
  139277. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139278. /**
  139279. * Removes the physics body from the imposter and disposes of the body's memory
  139280. * @param impostor imposter to remove the physics body from
  139281. */
  139282. removePhysicsBody(impostor: PhysicsImpostor): void;
  139283. /**
  139284. * Generates a joint
  139285. * @param impostorJoint the imposter joint to create the joint with
  139286. */
  139287. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139288. /**
  139289. * Removes a joint
  139290. * @param impostorJoint the imposter joint to remove the joint from
  139291. */
  139292. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139293. private _addMeshVerts;
  139294. /**
  139295. * Initialise the soft body vertices to match its object's (mesh) vertices
  139296. * Softbody vertices (nodes) are in world space and to match this
  139297. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139298. * @param impostor to create the softbody for
  139299. */
  139300. private _softVertexData;
  139301. /**
  139302. * Create an impostor's soft body
  139303. * @param impostor to create the softbody for
  139304. */
  139305. private _createSoftbody;
  139306. /**
  139307. * Create cloth for an impostor
  139308. * @param impostor to create the softbody for
  139309. */
  139310. private _createCloth;
  139311. /**
  139312. * Create rope for an impostor
  139313. * @param impostor to create the softbody for
  139314. */
  139315. private _createRope;
  139316. /**
  139317. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139318. * @param impostor to create the custom physics shape for
  139319. */
  139320. private _createCustom;
  139321. private _addHullVerts;
  139322. private _createShape;
  139323. /**
  139324. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139325. * @param impostor imposter containing the physics body and babylon object
  139326. */
  139327. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139328. /**
  139329. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139330. * @param impostor imposter containing the physics body and babylon object
  139331. * @param newPosition new position
  139332. * @param newRotation new rotation
  139333. */
  139334. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139335. /**
  139336. * If this plugin is supported
  139337. * @returns true if its supported
  139338. */
  139339. isSupported(): boolean;
  139340. /**
  139341. * Sets the linear velocity of the physics body
  139342. * @param impostor imposter to set the velocity on
  139343. * @param velocity velocity to set
  139344. */
  139345. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139346. /**
  139347. * Sets the angular velocity of the physics body
  139348. * @param impostor imposter to set the velocity on
  139349. * @param velocity velocity to set
  139350. */
  139351. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139352. /**
  139353. * gets the linear velocity
  139354. * @param impostor imposter to get linear velocity from
  139355. * @returns linear velocity
  139356. */
  139357. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139358. /**
  139359. * gets the angular velocity
  139360. * @param impostor imposter to get angular velocity from
  139361. * @returns angular velocity
  139362. */
  139363. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139364. /**
  139365. * Sets the mass of physics body
  139366. * @param impostor imposter to set the mass on
  139367. * @param mass mass to set
  139368. */
  139369. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139370. /**
  139371. * Gets the mass of the physics body
  139372. * @param impostor imposter to get the mass from
  139373. * @returns mass
  139374. */
  139375. getBodyMass(impostor: PhysicsImpostor): number;
  139376. /**
  139377. * Gets friction of the impostor
  139378. * @param impostor impostor to get friction from
  139379. * @returns friction value
  139380. */
  139381. getBodyFriction(impostor: PhysicsImpostor): number;
  139382. /**
  139383. * Sets friction of the impostor
  139384. * @param impostor impostor to set friction on
  139385. * @param friction friction value
  139386. */
  139387. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139388. /**
  139389. * Gets restitution of the impostor
  139390. * @param impostor impostor to get restitution from
  139391. * @returns restitution value
  139392. */
  139393. getBodyRestitution(impostor: PhysicsImpostor): number;
  139394. /**
  139395. * Sets resitution of the impostor
  139396. * @param impostor impostor to set resitution on
  139397. * @param restitution resitution value
  139398. */
  139399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139400. /**
  139401. * Gets pressure inside the impostor
  139402. * @param impostor impostor to get pressure from
  139403. * @returns pressure value
  139404. */
  139405. getBodyPressure(impostor: PhysicsImpostor): number;
  139406. /**
  139407. * Sets pressure inside a soft body impostor
  139408. * Cloth and rope must remain 0 pressure
  139409. * @param impostor impostor to set pressure on
  139410. * @param pressure pressure value
  139411. */
  139412. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139413. /**
  139414. * Gets stiffness of the impostor
  139415. * @param impostor impostor to get stiffness from
  139416. * @returns pressure value
  139417. */
  139418. getBodyStiffness(impostor: PhysicsImpostor): number;
  139419. /**
  139420. * Sets stiffness of the impostor
  139421. * @param impostor impostor to set stiffness on
  139422. * @param stiffness stiffness value from 0 to 1
  139423. */
  139424. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139425. /**
  139426. * Gets velocityIterations of the impostor
  139427. * @param impostor impostor to get velocity iterations from
  139428. * @returns velocityIterations value
  139429. */
  139430. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139431. /**
  139432. * Sets velocityIterations of the impostor
  139433. * @param impostor impostor to set velocity iterations on
  139434. * @param velocityIterations velocityIterations value
  139435. */
  139436. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139437. /**
  139438. * Gets positionIterations of the impostor
  139439. * @param impostor impostor to get position iterations from
  139440. * @returns positionIterations value
  139441. */
  139442. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139443. /**
  139444. * Sets positionIterations of the impostor
  139445. * @param impostor impostor to set position on
  139446. * @param positionIterations positionIterations value
  139447. */
  139448. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139449. /**
  139450. * Append an anchor to a cloth object
  139451. * @param impostor is the cloth impostor to add anchor to
  139452. * @param otherImpostor is the rigid impostor to anchor to
  139453. * @param width ratio across width from 0 to 1
  139454. * @param height ratio up height from 0 to 1
  139455. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139456. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139457. */
  139458. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139459. /**
  139460. * Append an hook to a rope object
  139461. * @param impostor is the rope impostor to add hook to
  139462. * @param otherImpostor is the rigid impostor to hook to
  139463. * @param length ratio along the rope from 0 to 1
  139464. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139465. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139466. */
  139467. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139468. /**
  139469. * Sleeps the physics body and stops it from being active
  139470. * @param impostor impostor to sleep
  139471. */
  139472. sleepBody(impostor: PhysicsImpostor): void;
  139473. /**
  139474. * Activates the physics body
  139475. * @param impostor impostor to activate
  139476. */
  139477. wakeUpBody(impostor: PhysicsImpostor): void;
  139478. /**
  139479. * Updates the distance parameters of the joint
  139480. * @param joint joint to update
  139481. * @param maxDistance maximum distance of the joint
  139482. * @param minDistance minimum distance of the joint
  139483. */
  139484. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139485. /**
  139486. * Sets a motor on the joint
  139487. * @param joint joint to set motor on
  139488. * @param speed speed of the motor
  139489. * @param maxForce maximum force of the motor
  139490. * @param motorIndex index of the motor
  139491. */
  139492. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139493. /**
  139494. * Sets the motors limit
  139495. * @param joint joint to set limit on
  139496. * @param upperLimit upper limit
  139497. * @param lowerLimit lower limit
  139498. */
  139499. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139500. /**
  139501. * Syncs the position and rotation of a mesh with the impostor
  139502. * @param mesh mesh to sync
  139503. * @param impostor impostor to update the mesh with
  139504. */
  139505. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139506. /**
  139507. * Gets the radius of the impostor
  139508. * @param impostor impostor to get radius from
  139509. * @returns the radius
  139510. */
  139511. getRadius(impostor: PhysicsImpostor): number;
  139512. /**
  139513. * Gets the box size of the impostor
  139514. * @param impostor impostor to get box size from
  139515. * @param result the resulting box size
  139516. */
  139517. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139518. /**
  139519. * Disposes of the impostor
  139520. */
  139521. dispose(): void;
  139522. /**
  139523. * Does a raycast in the physics world
  139524. * @param from when should the ray start?
  139525. * @param to when should the ray end?
  139526. * @returns PhysicsRaycastResult
  139527. */
  139528. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139529. }
  139530. }
  139531. declare module BABYLON {
  139532. interface AbstractScene {
  139533. /**
  139534. * The list of reflection probes added to the scene
  139535. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139536. */
  139537. reflectionProbes: Array<ReflectionProbe>;
  139538. /**
  139539. * Removes the given reflection probe from this scene.
  139540. * @param toRemove The reflection probe to remove
  139541. * @returns The index of the removed reflection probe
  139542. */
  139543. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139544. /**
  139545. * Adds the given reflection probe to this scene.
  139546. * @param newReflectionProbe The reflection probe to add
  139547. */
  139548. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139549. }
  139550. /**
  139551. * Class used to generate realtime reflection / refraction cube textures
  139552. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139553. */
  139554. export class ReflectionProbe {
  139555. /** defines the name of the probe */
  139556. name: string;
  139557. private _scene;
  139558. private _renderTargetTexture;
  139559. private _projectionMatrix;
  139560. private _viewMatrix;
  139561. private _target;
  139562. private _add;
  139563. private _attachedMesh;
  139564. private _invertYAxis;
  139565. /** Gets or sets probe position (center of the cube map) */
  139566. position: Vector3;
  139567. /**
  139568. * Creates a new reflection probe
  139569. * @param name defines the name of the probe
  139570. * @param size defines the texture resolution (for each face)
  139571. * @param scene defines the hosting scene
  139572. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139573. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139574. */
  139575. constructor(
  139576. /** defines the name of the probe */
  139577. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139578. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139579. get samples(): number;
  139580. set samples(value: number);
  139581. /** Gets or sets the refresh rate to use (on every frame by default) */
  139582. get refreshRate(): number;
  139583. set refreshRate(value: number);
  139584. /**
  139585. * Gets the hosting scene
  139586. * @returns a Scene
  139587. */
  139588. getScene(): Scene;
  139589. /** Gets the internal CubeTexture used to render to */
  139590. get cubeTexture(): RenderTargetTexture;
  139591. /** Gets the list of meshes to render */
  139592. get renderList(): Nullable<AbstractMesh[]>;
  139593. /**
  139594. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139595. * @param mesh defines the mesh to attach to
  139596. */
  139597. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139598. /**
  139599. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139600. * @param renderingGroupId The rendering group id corresponding to its index
  139601. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139602. */
  139603. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139604. /**
  139605. * Clean all associated resources
  139606. */
  139607. dispose(): void;
  139608. /**
  139609. * Converts the reflection probe information to a readable string for debug purpose.
  139610. * @param fullDetails Supports for multiple levels of logging within scene loading
  139611. * @returns the human readable reflection probe info
  139612. */
  139613. toString(fullDetails?: boolean): string;
  139614. /**
  139615. * Get the class name of the relfection probe.
  139616. * @returns "ReflectionProbe"
  139617. */
  139618. getClassName(): string;
  139619. /**
  139620. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139621. * @returns The JSON representation of the texture
  139622. */
  139623. serialize(): any;
  139624. /**
  139625. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139626. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139627. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139628. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139629. * @returns The parsed reflection probe if successful
  139630. */
  139631. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139632. }
  139633. }
  139634. declare module BABYLON {
  139635. /** @hidden */
  139636. export var _BabylonLoaderRegistered: boolean;
  139637. /**
  139638. * Helps setting up some configuration for the babylon file loader.
  139639. */
  139640. export class BabylonFileLoaderConfiguration {
  139641. /**
  139642. * The loader does not allow injecting custom physix engine into the plugins.
  139643. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139644. * So you could set this variable to your engine import to make it work.
  139645. */
  139646. static LoaderInjectedPhysicsEngine: any;
  139647. }
  139648. }
  139649. declare module BABYLON {
  139650. /**
  139651. * The Physically based simple base material of BJS.
  139652. *
  139653. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139654. * It is used as the base class for both the specGloss and metalRough conventions.
  139655. */
  139656. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139657. /**
  139658. * Number of Simultaneous lights allowed on the material.
  139659. */
  139660. maxSimultaneousLights: number;
  139661. /**
  139662. * If sets to true, disables all the lights affecting the material.
  139663. */
  139664. disableLighting: boolean;
  139665. /**
  139666. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139667. */
  139668. environmentTexture: BaseTexture;
  139669. /**
  139670. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139671. */
  139672. invertNormalMapX: boolean;
  139673. /**
  139674. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139675. */
  139676. invertNormalMapY: boolean;
  139677. /**
  139678. * Normal map used in the model.
  139679. */
  139680. normalTexture: BaseTexture;
  139681. /**
  139682. * Emissivie color used to self-illuminate the model.
  139683. */
  139684. emissiveColor: Color3;
  139685. /**
  139686. * Emissivie texture used to self-illuminate the model.
  139687. */
  139688. emissiveTexture: BaseTexture;
  139689. /**
  139690. * Occlusion Channel Strenght.
  139691. */
  139692. occlusionStrength: number;
  139693. /**
  139694. * Occlusion Texture of the material (adding extra occlusion effects).
  139695. */
  139696. occlusionTexture: BaseTexture;
  139697. /**
  139698. * Defines the alpha limits in alpha test mode.
  139699. */
  139700. alphaCutOff: number;
  139701. /**
  139702. * Gets the current double sided mode.
  139703. */
  139704. get doubleSided(): boolean;
  139705. /**
  139706. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139707. */
  139708. set doubleSided(value: boolean);
  139709. /**
  139710. * Stores the pre-calculated light information of a mesh in a texture.
  139711. */
  139712. lightmapTexture: BaseTexture;
  139713. /**
  139714. * If true, the light map contains occlusion information instead of lighting info.
  139715. */
  139716. useLightmapAsShadowmap: boolean;
  139717. /**
  139718. * Instantiates a new PBRMaterial instance.
  139719. *
  139720. * @param name The material name
  139721. * @param scene The scene the material will be use in.
  139722. */
  139723. constructor(name: string, scene: Scene);
  139724. getClassName(): string;
  139725. }
  139726. }
  139727. declare module BABYLON {
  139728. /**
  139729. * The PBR material of BJS following the metal roughness convention.
  139730. *
  139731. * This fits to the PBR convention in the GLTF definition:
  139732. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139733. */
  139734. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139735. /**
  139736. * The base color has two different interpretations depending on the value of metalness.
  139737. * When the material is a metal, the base color is the specific measured reflectance value
  139738. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139739. * of the material.
  139740. */
  139741. baseColor: Color3;
  139742. /**
  139743. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139744. * well as opacity information in the alpha channel.
  139745. */
  139746. baseTexture: BaseTexture;
  139747. /**
  139748. * Specifies the metallic scalar value of the material.
  139749. * Can also be used to scale the metalness values of the metallic texture.
  139750. */
  139751. metallic: number;
  139752. /**
  139753. * Specifies the roughness scalar value of the material.
  139754. * Can also be used to scale the roughness values of the metallic texture.
  139755. */
  139756. roughness: number;
  139757. /**
  139758. * Texture containing both the metallic value in the B channel and the
  139759. * roughness value in the G channel to keep better precision.
  139760. */
  139761. metallicRoughnessTexture: BaseTexture;
  139762. /**
  139763. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139764. *
  139765. * @param name The material name
  139766. * @param scene The scene the material will be use in.
  139767. */
  139768. constructor(name: string, scene: Scene);
  139769. /**
  139770. * Return the currrent class name of the material.
  139771. */
  139772. getClassName(): string;
  139773. /**
  139774. * Makes a duplicate of the current material.
  139775. * @param name - name to use for the new material.
  139776. */
  139777. clone(name: string): PBRMetallicRoughnessMaterial;
  139778. /**
  139779. * Serialize the material to a parsable JSON object.
  139780. */
  139781. serialize(): any;
  139782. /**
  139783. * Parses a JSON object correponding to the serialize function.
  139784. */
  139785. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  139786. }
  139787. }
  139788. declare module BABYLON {
  139789. /**
  139790. * The PBR material of BJS following the specular glossiness convention.
  139791. *
  139792. * This fits to the PBR convention in the GLTF definition:
  139793. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  139794. */
  139795. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  139796. /**
  139797. * Specifies the diffuse color of the material.
  139798. */
  139799. diffuseColor: Color3;
  139800. /**
  139801. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  139802. * channel.
  139803. */
  139804. diffuseTexture: BaseTexture;
  139805. /**
  139806. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  139807. */
  139808. specularColor: Color3;
  139809. /**
  139810. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  139811. */
  139812. glossiness: number;
  139813. /**
  139814. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  139815. */
  139816. specularGlossinessTexture: BaseTexture;
  139817. /**
  139818. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  139819. *
  139820. * @param name The material name
  139821. * @param scene The scene the material will be use in.
  139822. */
  139823. constructor(name: string, scene: Scene);
  139824. /**
  139825. * Return the currrent class name of the material.
  139826. */
  139827. getClassName(): string;
  139828. /**
  139829. * Makes a duplicate of the current material.
  139830. * @param name - name to use for the new material.
  139831. */
  139832. clone(name: string): PBRSpecularGlossinessMaterial;
  139833. /**
  139834. * Serialize the material to a parsable JSON object.
  139835. */
  139836. serialize(): any;
  139837. /**
  139838. * Parses a JSON object correponding to the serialize function.
  139839. */
  139840. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  139841. }
  139842. }
  139843. declare module BABYLON {
  139844. /**
  139845. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  139846. * It can help converting any input color in a desired output one. This can then be used to create effects
  139847. * from sepia, black and white to sixties or futuristic rendering...
  139848. *
  139849. * The only supported format is currently 3dl.
  139850. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  139851. */
  139852. export class ColorGradingTexture extends BaseTexture {
  139853. /**
  139854. * The texture URL.
  139855. */
  139856. url: string;
  139857. /**
  139858. * Empty line regex stored for GC.
  139859. */
  139860. private static _noneEmptyLineRegex;
  139861. private _textureMatrix;
  139862. private _onLoad;
  139863. /**
  139864. * Instantiates a ColorGradingTexture from the following parameters.
  139865. *
  139866. * @param url The location of the color gradind data (currently only supporting 3dl)
  139867. * @param sceneOrEngine The scene or engine the texture will be used in
  139868. * @param onLoad defines a callback triggered when the texture has been loaded
  139869. */
  139870. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  139871. /**
  139872. * Fires the onload event from the constructor if requested.
  139873. */
  139874. private _triggerOnLoad;
  139875. /**
  139876. * Returns the texture matrix used in most of the material.
  139877. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  139878. */
  139879. getTextureMatrix(): Matrix;
  139880. /**
  139881. * Occurs when the file being loaded is a .3dl LUT file.
  139882. */
  139883. private load3dlTexture;
  139884. /**
  139885. * Starts the loading process of the texture.
  139886. */
  139887. private loadTexture;
  139888. /**
  139889. * Clones the color gradind texture.
  139890. */
  139891. clone(): ColorGradingTexture;
  139892. /**
  139893. * Called during delayed load for textures.
  139894. */
  139895. delayLoad(): void;
  139896. /**
  139897. * Parses a color grading texture serialized by Babylon.
  139898. * @param parsedTexture The texture information being parsedTexture
  139899. * @param scene The scene to load the texture in
  139900. * @param rootUrl The root url of the data assets to load
  139901. * @return A color gradind texture
  139902. */
  139903. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  139904. /**
  139905. * Serializes the LUT texture to json format.
  139906. */
  139907. serialize(): any;
  139908. }
  139909. }
  139910. declare module BABYLON {
  139911. /**
  139912. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  139913. */
  139914. export class EquiRectangularCubeTexture extends BaseTexture {
  139915. /** The six faces of the cube. */
  139916. private static _FacesMapping;
  139917. private _noMipmap;
  139918. private _onLoad;
  139919. private _onError;
  139920. /** The size of the cubemap. */
  139921. private _size;
  139922. /** The buffer of the image. */
  139923. private _buffer;
  139924. /** The width of the input image. */
  139925. private _width;
  139926. /** The height of the input image. */
  139927. private _height;
  139928. /** The URL to the image. */
  139929. url: string;
  139930. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  139931. coordinatesMode: number;
  139932. /**
  139933. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  139934. * @param url The location of the image
  139935. * @param scene The scene the texture will be used in
  139936. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  139937. * @param noMipmap Forces to not generate the mipmap if true
  139938. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  139939. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  139940. * @param onLoad — defines a callback called when texture is loaded
  139941. * @param onError — defines a callback called if there is an error
  139942. */
  139943. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  139944. /**
  139945. * Load the image data, by putting the image on a canvas and extracting its buffer.
  139946. */
  139947. private loadImage;
  139948. /**
  139949. * Convert the image buffer into a cubemap and create a CubeTexture.
  139950. */
  139951. private loadTexture;
  139952. /**
  139953. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  139954. * @param buffer The ArrayBuffer that should be converted.
  139955. * @returns The buffer as Float32Array.
  139956. */
  139957. private getFloat32ArrayFromArrayBuffer;
  139958. /**
  139959. * Get the current class name of the texture useful for serialization or dynamic coding.
  139960. * @returns "EquiRectangularCubeTexture"
  139961. */
  139962. getClassName(): string;
  139963. /**
  139964. * Create a clone of the current EquiRectangularCubeTexture and return it.
  139965. * @returns A clone of the current EquiRectangularCubeTexture.
  139966. */
  139967. clone(): EquiRectangularCubeTexture;
  139968. }
  139969. }
  139970. declare module BABYLON {
  139971. /**
  139972. * Defines the options related to the creation of an HtmlElementTexture
  139973. */
  139974. export interface IHtmlElementTextureOptions {
  139975. /**
  139976. * Defines wether mip maps should be created or not.
  139977. */
  139978. generateMipMaps?: boolean;
  139979. /**
  139980. * Defines the sampling mode of the texture.
  139981. */
  139982. samplingMode?: number;
  139983. /**
  139984. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  139985. */
  139986. engine: Nullable<ThinEngine>;
  139987. /**
  139988. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  139989. */
  139990. scene: Nullable<Scene>;
  139991. }
  139992. /**
  139993. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  139994. * To be as efficient as possible depending on your constraints nothing aside the first upload
  139995. * is automatically managed.
  139996. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  139997. * in your application.
  139998. *
  139999. * As the update is not automatic, you need to call them manually.
  140000. */
  140001. export class HtmlElementTexture extends BaseTexture {
  140002. /**
  140003. * The texture URL.
  140004. */
  140005. element: HTMLVideoElement | HTMLCanvasElement;
  140006. private static readonly DefaultOptions;
  140007. private _textureMatrix;
  140008. private _isVideo;
  140009. private _generateMipMaps;
  140010. private _samplingMode;
  140011. /**
  140012. * Instantiates a HtmlElementTexture from the following parameters.
  140013. *
  140014. * @param name Defines the name of the texture
  140015. * @param element Defines the video or canvas the texture is filled with
  140016. * @param options Defines the other none mandatory texture creation options
  140017. */
  140018. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140019. private _createInternalTexture;
  140020. /**
  140021. * Returns the texture matrix used in most of the material.
  140022. */
  140023. getTextureMatrix(): Matrix;
  140024. /**
  140025. * Updates the content of the texture.
  140026. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140027. */
  140028. update(invertY?: Nullable<boolean>): void;
  140029. }
  140030. }
  140031. declare module BABYLON {
  140032. /**
  140033. * Based on jsTGALoader - Javascript loader for TGA file
  140034. * By Vincent Thibault
  140035. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140036. */
  140037. export class TGATools {
  140038. private static _TYPE_INDEXED;
  140039. private static _TYPE_RGB;
  140040. private static _TYPE_GREY;
  140041. private static _TYPE_RLE_INDEXED;
  140042. private static _TYPE_RLE_RGB;
  140043. private static _TYPE_RLE_GREY;
  140044. private static _ORIGIN_MASK;
  140045. private static _ORIGIN_SHIFT;
  140046. private static _ORIGIN_BL;
  140047. private static _ORIGIN_BR;
  140048. private static _ORIGIN_UL;
  140049. private static _ORIGIN_UR;
  140050. /**
  140051. * Gets the header of a TGA file
  140052. * @param data defines the TGA data
  140053. * @returns the header
  140054. */
  140055. static GetTGAHeader(data: Uint8Array): any;
  140056. /**
  140057. * Uploads TGA content to a Babylon Texture
  140058. * @hidden
  140059. */
  140060. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140061. /** @hidden */
  140062. 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;
  140063. /** @hidden */
  140064. 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;
  140065. /** @hidden */
  140066. 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;
  140067. /** @hidden */
  140068. 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;
  140069. /** @hidden */
  140070. 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;
  140071. /** @hidden */
  140072. 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;
  140073. }
  140074. }
  140075. declare module BABYLON {
  140076. /**
  140077. * Implementation of the TGA Texture Loader.
  140078. * @hidden
  140079. */
  140080. export class _TGATextureLoader implements IInternalTextureLoader {
  140081. /**
  140082. * Defines wether the loader supports cascade loading the different faces.
  140083. */
  140084. readonly supportCascades: boolean;
  140085. /**
  140086. * This returns if the loader support the current file information.
  140087. * @param extension defines the file extension of the file being loaded
  140088. * @returns true if the loader can load the specified file
  140089. */
  140090. canLoad(extension: string): boolean;
  140091. /**
  140092. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140093. * @param data contains the texture data
  140094. * @param texture defines the BabylonJS internal texture
  140095. * @param createPolynomials will be true if polynomials have been requested
  140096. * @param onLoad defines the callback to trigger once the texture is ready
  140097. * @param onError defines the callback to trigger in case of error
  140098. */
  140099. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140100. /**
  140101. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140102. * @param data contains the texture data
  140103. * @param texture defines the BabylonJS internal texture
  140104. * @param callback defines the method to call once ready to upload
  140105. */
  140106. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140107. }
  140108. }
  140109. declare module BABYLON {
  140110. /**
  140111. * Info about the .basis files
  140112. */
  140113. class BasisFileInfo {
  140114. /**
  140115. * If the file has alpha
  140116. */
  140117. hasAlpha: boolean;
  140118. /**
  140119. * Info about each image of the basis file
  140120. */
  140121. images: Array<{
  140122. levels: Array<{
  140123. width: number;
  140124. height: number;
  140125. transcodedPixels: ArrayBufferView;
  140126. }>;
  140127. }>;
  140128. }
  140129. /**
  140130. * Result of transcoding a basis file
  140131. */
  140132. class TranscodeResult {
  140133. /**
  140134. * Info about the .basis file
  140135. */
  140136. fileInfo: BasisFileInfo;
  140137. /**
  140138. * Format to use when loading the file
  140139. */
  140140. format: number;
  140141. }
  140142. /**
  140143. * Configuration options for the Basis transcoder
  140144. */
  140145. export class BasisTranscodeConfiguration {
  140146. /**
  140147. * Supported compression formats used to determine the supported output format of the transcoder
  140148. */
  140149. supportedCompressionFormats?: {
  140150. /**
  140151. * etc1 compression format
  140152. */
  140153. etc1?: boolean;
  140154. /**
  140155. * s3tc compression format
  140156. */
  140157. s3tc?: boolean;
  140158. /**
  140159. * pvrtc compression format
  140160. */
  140161. pvrtc?: boolean;
  140162. /**
  140163. * etc2 compression format
  140164. */
  140165. etc2?: boolean;
  140166. };
  140167. /**
  140168. * If mipmap levels should be loaded for transcoded images (Default: true)
  140169. */
  140170. loadMipmapLevels?: boolean;
  140171. /**
  140172. * Index of a single image to load (Default: all images)
  140173. */
  140174. loadSingleImage?: number;
  140175. }
  140176. /**
  140177. * Used to load .Basis files
  140178. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140179. */
  140180. export class BasisTools {
  140181. private static _IgnoreSupportedFormats;
  140182. /**
  140183. * URL to use when loading the basis transcoder
  140184. */
  140185. static JSModuleURL: string;
  140186. /**
  140187. * URL to use when loading the wasm module for the transcoder
  140188. */
  140189. static WasmModuleURL: string;
  140190. /**
  140191. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140192. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140193. * @returns internal format corresponding to the Basis format
  140194. */
  140195. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140196. private static _WorkerPromise;
  140197. private static _Worker;
  140198. private static _actionId;
  140199. private static _CreateWorkerAsync;
  140200. /**
  140201. * Transcodes a loaded image file to compressed pixel data
  140202. * @param data image data to transcode
  140203. * @param config configuration options for the transcoding
  140204. * @returns a promise resulting in the transcoded image
  140205. */
  140206. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140207. /**
  140208. * Loads a texture from the transcode result
  140209. * @param texture texture load to
  140210. * @param transcodeResult the result of transcoding the basis file to load from
  140211. */
  140212. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140213. }
  140214. }
  140215. declare module BABYLON {
  140216. /**
  140217. * Loader for .basis file format
  140218. */
  140219. export class _BasisTextureLoader implements IInternalTextureLoader {
  140220. /**
  140221. * Defines whether the loader supports cascade loading the different faces.
  140222. */
  140223. readonly supportCascades: boolean;
  140224. /**
  140225. * This returns if the loader support the current file information.
  140226. * @param extension defines the file extension of the file being loaded
  140227. * @returns true if the loader can load the specified file
  140228. */
  140229. canLoad(extension: string): boolean;
  140230. /**
  140231. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140232. * @param data contains the texture data
  140233. * @param texture defines the BabylonJS internal texture
  140234. * @param createPolynomials will be true if polynomials have been requested
  140235. * @param onLoad defines the callback to trigger once the texture is ready
  140236. * @param onError defines the callback to trigger in case of error
  140237. */
  140238. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140239. /**
  140240. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140241. * @param data contains the texture data
  140242. * @param texture defines the BabylonJS internal texture
  140243. * @param callback defines the method to call once ready to upload
  140244. */
  140245. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140246. }
  140247. }
  140248. declare module BABYLON {
  140249. /**
  140250. * Defines the basic options interface of a TexturePacker Frame
  140251. */
  140252. export interface ITexturePackerFrame {
  140253. /**
  140254. * The frame ID
  140255. */
  140256. id: number;
  140257. /**
  140258. * The frames Scale
  140259. */
  140260. scale: Vector2;
  140261. /**
  140262. * The Frames offset
  140263. */
  140264. offset: Vector2;
  140265. }
  140266. /**
  140267. * This is a support class for frame Data on texture packer sets.
  140268. */
  140269. export class TexturePackerFrame implements ITexturePackerFrame {
  140270. /**
  140271. * The frame ID
  140272. */
  140273. id: number;
  140274. /**
  140275. * The frames Scale
  140276. */
  140277. scale: Vector2;
  140278. /**
  140279. * The Frames offset
  140280. */
  140281. offset: Vector2;
  140282. /**
  140283. * Initializes a texture package frame.
  140284. * @param id The numerical frame identifier
  140285. * @param scale Scalar Vector2 for UV frame
  140286. * @param offset Vector2 for the frame position in UV units.
  140287. * @returns TexturePackerFrame
  140288. */
  140289. constructor(id: number, scale: Vector2, offset: Vector2);
  140290. }
  140291. }
  140292. declare module BABYLON {
  140293. /**
  140294. * Defines the basic options interface of a TexturePacker
  140295. */
  140296. export interface ITexturePackerOptions {
  140297. /**
  140298. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140299. */
  140300. map?: string[];
  140301. /**
  140302. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140303. */
  140304. uvsIn?: string;
  140305. /**
  140306. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140307. */
  140308. uvsOut?: string;
  140309. /**
  140310. * number representing the layout style. Defaults to LAYOUT_STRIP
  140311. */
  140312. layout?: number;
  140313. /**
  140314. * number of columns if using custom column count layout(2). This defaults to 4.
  140315. */
  140316. colnum?: number;
  140317. /**
  140318. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140319. */
  140320. updateInputMeshes?: boolean;
  140321. /**
  140322. * boolean flag to dispose all the source textures. Defaults to true.
  140323. */
  140324. disposeSources?: boolean;
  140325. /**
  140326. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140327. */
  140328. fillBlanks?: boolean;
  140329. /**
  140330. * string value representing the context fill style color. Defaults to 'black'.
  140331. */
  140332. customFillColor?: string;
  140333. /**
  140334. * Width and Height Value of each Frame in the TexturePacker Sets
  140335. */
  140336. frameSize?: number;
  140337. /**
  140338. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140339. */
  140340. paddingRatio?: number;
  140341. /**
  140342. * Number that declares the fill method for the padding gutter.
  140343. */
  140344. paddingMode?: number;
  140345. /**
  140346. * If in SUBUV_COLOR padding mode what color to use.
  140347. */
  140348. paddingColor?: Color3 | Color4;
  140349. }
  140350. /**
  140351. * Defines the basic interface of a TexturePacker JSON File
  140352. */
  140353. export interface ITexturePackerJSON {
  140354. /**
  140355. * The frame ID
  140356. */
  140357. name: string;
  140358. /**
  140359. * The base64 channel data
  140360. */
  140361. sets: any;
  140362. /**
  140363. * The options of the Packer
  140364. */
  140365. options: ITexturePackerOptions;
  140366. /**
  140367. * The frame data of the Packer
  140368. */
  140369. frames: Array<number>;
  140370. }
  140371. /**
  140372. * This is a support class that generates a series of packed texture sets.
  140373. * @see https://doc.babylonjs.com/babylon101/materials
  140374. */
  140375. export class TexturePacker {
  140376. /** Packer Layout Constant 0 */
  140377. static readonly LAYOUT_STRIP: number;
  140378. /** Packer Layout Constant 1 */
  140379. static readonly LAYOUT_POWER2: number;
  140380. /** Packer Layout Constant 2 */
  140381. static readonly LAYOUT_COLNUM: number;
  140382. /** Packer Layout Constant 0 */
  140383. static readonly SUBUV_WRAP: number;
  140384. /** Packer Layout Constant 1 */
  140385. static readonly SUBUV_EXTEND: number;
  140386. /** Packer Layout Constant 2 */
  140387. static readonly SUBUV_COLOR: number;
  140388. /** The Name of the Texture Package */
  140389. name: string;
  140390. /** The scene scope of the TexturePacker */
  140391. scene: Scene;
  140392. /** The Meshes to target */
  140393. meshes: AbstractMesh[];
  140394. /** Arguments passed with the Constructor */
  140395. options: ITexturePackerOptions;
  140396. /** The promise that is started upon initialization */
  140397. promise: Nullable<Promise<TexturePacker | string>>;
  140398. /** The Container object for the channel sets that are generated */
  140399. sets: object;
  140400. /** The Container array for the frames that are generated */
  140401. frames: TexturePackerFrame[];
  140402. /** The expected number of textures the system is parsing. */
  140403. private _expecting;
  140404. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140405. private _paddingValue;
  140406. /**
  140407. * Initializes a texture package series from an array of meshes or a single mesh.
  140408. * @param name The name of the package
  140409. * @param meshes The target meshes to compose the package from
  140410. * @param options The arguments that texture packer should follow while building.
  140411. * @param scene The scene which the textures are scoped to.
  140412. * @returns TexturePacker
  140413. */
  140414. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140415. /**
  140416. * Starts the package process
  140417. * @param resolve The promises resolution function
  140418. * @returns TexturePacker
  140419. */
  140420. private _createFrames;
  140421. /**
  140422. * Calculates the Size of the Channel Sets
  140423. * @returns Vector2
  140424. */
  140425. private _calculateSize;
  140426. /**
  140427. * Calculates the UV data for the frames.
  140428. * @param baseSize the base frameSize
  140429. * @param padding the base frame padding
  140430. * @param dtSize size of the Dynamic Texture for that channel
  140431. * @param dtUnits is 1/dtSize
  140432. * @param update flag to update the input meshes
  140433. */
  140434. private _calculateMeshUVFrames;
  140435. /**
  140436. * Calculates the frames Offset.
  140437. * @param index of the frame
  140438. * @returns Vector2
  140439. */
  140440. private _getFrameOffset;
  140441. /**
  140442. * Updates a Mesh to the frame data
  140443. * @param mesh that is the target
  140444. * @param frameID or the frame index
  140445. */
  140446. private _updateMeshUV;
  140447. /**
  140448. * Updates a Meshes materials to use the texture packer channels
  140449. * @param m is the mesh to target
  140450. * @param force all channels on the packer to be set.
  140451. */
  140452. private _updateTextureReferences;
  140453. /**
  140454. * Public method to set a Mesh to a frame
  140455. * @param m that is the target
  140456. * @param frameID or the frame index
  140457. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140458. */
  140459. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140460. /**
  140461. * Starts the async promise to compile the texture packer.
  140462. * @returns Promise<void>
  140463. */
  140464. processAsync(): Promise<void>;
  140465. /**
  140466. * Disposes all textures associated with this packer
  140467. */
  140468. dispose(): void;
  140469. /**
  140470. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140471. * @param imageType is the image type to use.
  140472. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140473. */
  140474. download(imageType?: string, quality?: number): void;
  140475. /**
  140476. * Public method to load a texturePacker JSON file.
  140477. * @param data of the JSON file in string format.
  140478. */
  140479. updateFromJSON(data: string): void;
  140480. }
  140481. }
  140482. declare module BABYLON {
  140483. /**
  140484. * 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.
  140485. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140486. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140487. */
  140488. export class CustomProceduralTexture extends ProceduralTexture {
  140489. private _animate;
  140490. private _time;
  140491. private _config;
  140492. private _texturePath;
  140493. /**
  140494. * Instantiates a new Custom Procedural Texture.
  140495. * 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.
  140496. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140497. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140498. * @param name Define the name of the texture
  140499. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140500. * @param size Define the size of the texture to create
  140501. * @param scene Define the scene the texture belongs to
  140502. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140503. * @param generateMipMaps Define if the texture should creates mip maps or not
  140504. */
  140505. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140506. private _loadJson;
  140507. /**
  140508. * Is the texture ready to be used ? (rendered at least once)
  140509. * @returns true if ready, otherwise, false.
  140510. */
  140511. isReady(): boolean;
  140512. /**
  140513. * Render the texture to its associated render target.
  140514. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140515. */
  140516. render(useCameraPostProcess?: boolean): void;
  140517. /**
  140518. * Update the list of dependant textures samplers in the shader.
  140519. */
  140520. updateTextures(): void;
  140521. /**
  140522. * Update the uniform values of the procedural texture in the shader.
  140523. */
  140524. updateShaderUniforms(): void;
  140525. /**
  140526. * Define if the texture animates or not.
  140527. */
  140528. get animate(): boolean;
  140529. set animate(value: boolean);
  140530. }
  140531. }
  140532. declare module BABYLON {
  140533. /** @hidden */
  140534. export var noisePixelShader: {
  140535. name: string;
  140536. shader: string;
  140537. };
  140538. }
  140539. declare module BABYLON {
  140540. /**
  140541. * Class used to generate noise procedural textures
  140542. */
  140543. export class NoiseProceduralTexture extends ProceduralTexture {
  140544. private _time;
  140545. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140546. brightness: number;
  140547. /** Defines the number of octaves to process */
  140548. octaves: number;
  140549. /** Defines the level of persistence (0.8 by default) */
  140550. persistence: number;
  140551. /** Gets or sets animation speed factor (default is 1) */
  140552. animationSpeedFactor: number;
  140553. /**
  140554. * Creates a new NoiseProceduralTexture
  140555. * @param name defines the name fo the texture
  140556. * @param size defines the size of the texture (default is 256)
  140557. * @param scene defines the hosting scene
  140558. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140559. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140560. */
  140561. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140562. private _updateShaderUniforms;
  140563. protected _getDefines(): string;
  140564. /** Generate the current state of the procedural texture */
  140565. render(useCameraPostProcess?: boolean): void;
  140566. /**
  140567. * Serializes this noise procedural texture
  140568. * @returns a serialized noise procedural texture object
  140569. */
  140570. serialize(): any;
  140571. /**
  140572. * Clone the texture.
  140573. * @returns the cloned texture
  140574. */
  140575. clone(): NoiseProceduralTexture;
  140576. /**
  140577. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140578. * @param parsedTexture defines parsed texture data
  140579. * @param scene defines the current scene
  140580. * @param rootUrl defines the root URL containing noise procedural texture information
  140581. * @returns a parsed NoiseProceduralTexture
  140582. */
  140583. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140584. }
  140585. }
  140586. declare module BABYLON {
  140587. /**
  140588. * Raw cube texture where the raw buffers are passed in
  140589. */
  140590. export class RawCubeTexture extends CubeTexture {
  140591. /**
  140592. * Creates a cube texture where the raw buffers are passed in.
  140593. * @param scene defines the scene the texture is attached to
  140594. * @param data defines the array of data to use to create each face
  140595. * @param size defines the size of the textures
  140596. * @param format defines the format of the data
  140597. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140598. * @param generateMipMaps defines if the engine should generate the mip levels
  140599. * @param invertY defines if data must be stored with Y axis inverted
  140600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140601. * @param compression defines the compression used (null by default)
  140602. */
  140603. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140604. /**
  140605. * Updates the raw cube texture.
  140606. * @param data defines the data to store
  140607. * @param format defines the data format
  140608. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140609. * @param invertY defines if data must be stored with Y axis inverted
  140610. * @param compression defines the compression used (null by default)
  140611. * @param level defines which level of the texture to update
  140612. */
  140613. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140614. /**
  140615. * Updates a raw cube texture with RGBD encoded data.
  140616. * @param data defines the array of data [mipmap][face] to use to create each face
  140617. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140620. * @returns a promsie that resolves when the operation is complete
  140621. */
  140622. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140623. /**
  140624. * Clones the raw cube texture.
  140625. * @return a new cube texture
  140626. */
  140627. clone(): CubeTexture;
  140628. /** @hidden */
  140629. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140630. }
  140631. }
  140632. declare module BABYLON {
  140633. /**
  140634. * Class used to store 2D array textures containing user data
  140635. */
  140636. export class RawTexture2DArray extends Texture {
  140637. /** Gets or sets the texture format to use */
  140638. format: number;
  140639. /**
  140640. * Create a new RawTexture2DArray
  140641. * @param data defines the data of the texture
  140642. * @param width defines the width of the texture
  140643. * @param height defines the height of the texture
  140644. * @param depth defines the number of layers of the texture
  140645. * @param format defines the texture format to use
  140646. * @param scene defines the hosting scene
  140647. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140648. * @param invertY defines if texture must be stored with Y axis inverted
  140649. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140650. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140651. */
  140652. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140653. /** Gets or sets the texture format to use */
  140654. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140655. /**
  140656. * Update the texture with new data
  140657. * @param data defines the data to store in the texture
  140658. */
  140659. update(data: ArrayBufferView): void;
  140660. }
  140661. }
  140662. declare module BABYLON {
  140663. /**
  140664. * Class used to store 3D textures containing user data
  140665. */
  140666. export class RawTexture3D extends Texture {
  140667. /** Gets or sets the texture format to use */
  140668. format: number;
  140669. /**
  140670. * Create a new RawTexture3D
  140671. * @param data defines the data of the texture
  140672. * @param width defines the width of the texture
  140673. * @param height defines the height of the texture
  140674. * @param depth defines the depth of the texture
  140675. * @param format defines the texture format to use
  140676. * @param scene defines the hosting scene
  140677. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140678. * @param invertY defines if texture must be stored with Y axis inverted
  140679. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140681. */
  140682. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140683. /** Gets or sets the texture format to use */
  140684. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140685. /**
  140686. * Update the texture with new data
  140687. * @param data defines the data to store in the texture
  140688. */
  140689. update(data: ArrayBufferView): void;
  140690. }
  140691. }
  140692. declare module BABYLON {
  140693. /**
  140694. * Creates a refraction texture used by refraction channel of the standard material.
  140695. * It is like a mirror but to see through a material.
  140696. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140697. */
  140698. export class RefractionTexture extends RenderTargetTexture {
  140699. /**
  140700. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140701. * 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.
  140702. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140703. */
  140704. refractionPlane: Plane;
  140705. /**
  140706. * Define how deep under the surface we should see.
  140707. */
  140708. depth: number;
  140709. /**
  140710. * Creates a refraction texture used by refraction channel of the standard material.
  140711. * It is like a mirror but to see through a material.
  140712. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140713. * @param name Define the texture name
  140714. * @param size Define the size of the underlying texture
  140715. * @param scene Define the scene the refraction belongs to
  140716. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140717. */
  140718. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140719. /**
  140720. * Clone the refraction texture.
  140721. * @returns the cloned texture
  140722. */
  140723. clone(): RefractionTexture;
  140724. /**
  140725. * Serialize the texture to a JSON representation you could use in Parse later on
  140726. * @returns the serialized JSON representation
  140727. */
  140728. serialize(): any;
  140729. }
  140730. }
  140731. declare module BABYLON {
  140732. /**
  140733. * Block used to add support for vertex skinning (bones)
  140734. */
  140735. export class BonesBlock extends NodeMaterialBlock {
  140736. /**
  140737. * Creates a new BonesBlock
  140738. * @param name defines the block name
  140739. */
  140740. constructor(name: string);
  140741. /**
  140742. * Initialize the block and prepare the context for build
  140743. * @param state defines the state that will be used for the build
  140744. */
  140745. initialize(state: NodeMaterialBuildState): void;
  140746. /**
  140747. * Gets the current class name
  140748. * @returns the class name
  140749. */
  140750. getClassName(): string;
  140751. /**
  140752. * Gets the matrix indices input component
  140753. */
  140754. get matricesIndices(): NodeMaterialConnectionPoint;
  140755. /**
  140756. * Gets the matrix weights input component
  140757. */
  140758. get matricesWeights(): NodeMaterialConnectionPoint;
  140759. /**
  140760. * Gets the extra matrix indices input component
  140761. */
  140762. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140763. /**
  140764. * Gets the extra matrix weights input component
  140765. */
  140766. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  140767. /**
  140768. * Gets the world input component
  140769. */
  140770. get world(): NodeMaterialConnectionPoint;
  140771. /**
  140772. * Gets the output component
  140773. */
  140774. get output(): NodeMaterialConnectionPoint;
  140775. autoConfigure(material: NodeMaterial): void;
  140776. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  140777. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140779. protected _buildBlock(state: NodeMaterialBuildState): this;
  140780. }
  140781. }
  140782. declare module BABYLON {
  140783. /**
  140784. * Block used to add support for instances
  140785. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  140786. */
  140787. export class InstancesBlock extends NodeMaterialBlock {
  140788. /**
  140789. * Creates a new InstancesBlock
  140790. * @param name defines the block name
  140791. */
  140792. constructor(name: string);
  140793. /**
  140794. * Gets the current class name
  140795. * @returns the class name
  140796. */
  140797. getClassName(): string;
  140798. /**
  140799. * Gets the first world row input component
  140800. */
  140801. get world0(): NodeMaterialConnectionPoint;
  140802. /**
  140803. * Gets the second world row input component
  140804. */
  140805. get world1(): NodeMaterialConnectionPoint;
  140806. /**
  140807. * Gets the third world row input component
  140808. */
  140809. get world2(): NodeMaterialConnectionPoint;
  140810. /**
  140811. * Gets the forth world row input component
  140812. */
  140813. get world3(): NodeMaterialConnectionPoint;
  140814. /**
  140815. * Gets the world input component
  140816. */
  140817. get world(): NodeMaterialConnectionPoint;
  140818. /**
  140819. * Gets the output component
  140820. */
  140821. get output(): NodeMaterialConnectionPoint;
  140822. /**
  140823. * Gets the isntanceID component
  140824. */
  140825. get instanceID(): NodeMaterialConnectionPoint;
  140826. autoConfigure(material: NodeMaterial): void;
  140827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  140828. protected _buildBlock(state: NodeMaterialBuildState): this;
  140829. }
  140830. }
  140831. declare module BABYLON {
  140832. /**
  140833. * Block used to add morph targets support to vertex shader
  140834. */
  140835. export class MorphTargetsBlock extends NodeMaterialBlock {
  140836. private _repeatableContentAnchor;
  140837. /**
  140838. * Create a new MorphTargetsBlock
  140839. * @param name defines the block name
  140840. */
  140841. constructor(name: string);
  140842. /**
  140843. * Gets the current class name
  140844. * @returns the class name
  140845. */
  140846. getClassName(): string;
  140847. /**
  140848. * Gets the position input component
  140849. */
  140850. get position(): NodeMaterialConnectionPoint;
  140851. /**
  140852. * Gets the normal input component
  140853. */
  140854. get normal(): NodeMaterialConnectionPoint;
  140855. /**
  140856. * Gets the tangent input component
  140857. */
  140858. get tangent(): NodeMaterialConnectionPoint;
  140859. /**
  140860. * Gets the tangent input component
  140861. */
  140862. get uv(): NodeMaterialConnectionPoint;
  140863. /**
  140864. * Gets the position output component
  140865. */
  140866. get positionOutput(): NodeMaterialConnectionPoint;
  140867. /**
  140868. * Gets the normal output component
  140869. */
  140870. get normalOutput(): NodeMaterialConnectionPoint;
  140871. /**
  140872. * Gets the tangent output component
  140873. */
  140874. get tangentOutput(): NodeMaterialConnectionPoint;
  140875. /**
  140876. * Gets the tangent output component
  140877. */
  140878. get uvOutput(): NodeMaterialConnectionPoint;
  140879. initialize(state: NodeMaterialBuildState): void;
  140880. autoConfigure(material: NodeMaterial): void;
  140881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140882. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140883. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  140884. protected _buildBlock(state: NodeMaterialBuildState): this;
  140885. }
  140886. }
  140887. declare module BABYLON {
  140888. /**
  140889. * Block used to get data information from a light
  140890. */
  140891. export class LightInformationBlock extends NodeMaterialBlock {
  140892. private _lightDataUniformName;
  140893. private _lightColorUniformName;
  140894. private _lightTypeDefineName;
  140895. /**
  140896. * Gets or sets the light associated with this block
  140897. */
  140898. light: Nullable<Light>;
  140899. /**
  140900. * Creates a new LightInformationBlock
  140901. * @param name defines the block name
  140902. */
  140903. constructor(name: string);
  140904. /**
  140905. * Gets the current class name
  140906. * @returns the class name
  140907. */
  140908. getClassName(): string;
  140909. /**
  140910. * Gets the world position input component
  140911. */
  140912. get worldPosition(): NodeMaterialConnectionPoint;
  140913. /**
  140914. * Gets the direction output component
  140915. */
  140916. get direction(): NodeMaterialConnectionPoint;
  140917. /**
  140918. * Gets the direction output component
  140919. */
  140920. get color(): NodeMaterialConnectionPoint;
  140921. /**
  140922. * Gets the direction output component
  140923. */
  140924. get intensity(): NodeMaterialConnectionPoint;
  140925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140927. protected _buildBlock(state: NodeMaterialBuildState): this;
  140928. serialize(): any;
  140929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140930. }
  140931. }
  140932. declare module BABYLON {
  140933. /**
  140934. * Block used to add image processing support to fragment shader
  140935. */
  140936. export class ImageProcessingBlock extends NodeMaterialBlock {
  140937. /**
  140938. * Create a new ImageProcessingBlock
  140939. * @param name defines the block name
  140940. */
  140941. constructor(name: string);
  140942. /**
  140943. * Gets the current class name
  140944. * @returns the class name
  140945. */
  140946. getClassName(): string;
  140947. /**
  140948. * Gets the color input component
  140949. */
  140950. get color(): NodeMaterialConnectionPoint;
  140951. /**
  140952. * Gets the output component
  140953. */
  140954. get output(): NodeMaterialConnectionPoint;
  140955. /**
  140956. * Initialize the block and prepare the context for build
  140957. * @param state defines the state that will be used for the build
  140958. */
  140959. initialize(state: NodeMaterialBuildState): void;
  140960. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  140961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140963. protected _buildBlock(state: NodeMaterialBuildState): this;
  140964. }
  140965. }
  140966. declare module BABYLON {
  140967. /**
  140968. * Block used to pertub normals based on a normal map
  140969. */
  140970. export class PerturbNormalBlock extends NodeMaterialBlock {
  140971. private _tangentSpaceParameterName;
  140972. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140973. invertX: boolean;
  140974. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  140975. invertY: boolean;
  140976. /**
  140977. * Create a new PerturbNormalBlock
  140978. * @param name defines the block name
  140979. */
  140980. constructor(name: string);
  140981. /**
  140982. * Gets the current class name
  140983. * @returns the class name
  140984. */
  140985. getClassName(): string;
  140986. /**
  140987. * Gets the world position input component
  140988. */
  140989. get worldPosition(): NodeMaterialConnectionPoint;
  140990. /**
  140991. * Gets the world normal input component
  140992. */
  140993. get worldNormal(): NodeMaterialConnectionPoint;
  140994. /**
  140995. * Gets the world tangent input component
  140996. */
  140997. get worldTangent(): NodeMaterialConnectionPoint;
  140998. /**
  140999. * Gets the uv input component
  141000. */
  141001. get uv(): NodeMaterialConnectionPoint;
  141002. /**
  141003. * Gets the normal map color input component
  141004. */
  141005. get normalMapColor(): NodeMaterialConnectionPoint;
  141006. /**
  141007. * Gets the strength input component
  141008. */
  141009. get strength(): NodeMaterialConnectionPoint;
  141010. /**
  141011. * Gets the output component
  141012. */
  141013. get output(): NodeMaterialConnectionPoint;
  141014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141015. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141016. autoConfigure(material: NodeMaterial): void;
  141017. protected _buildBlock(state: NodeMaterialBuildState): this;
  141018. protected _dumpPropertiesCode(): string;
  141019. serialize(): any;
  141020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141021. }
  141022. }
  141023. declare module BABYLON {
  141024. /**
  141025. * Block used to discard a pixel if a value is smaller than a cutoff
  141026. */
  141027. export class DiscardBlock extends NodeMaterialBlock {
  141028. /**
  141029. * Create a new DiscardBlock
  141030. * @param name defines the block name
  141031. */
  141032. constructor(name: string);
  141033. /**
  141034. * Gets the current class name
  141035. * @returns the class name
  141036. */
  141037. getClassName(): string;
  141038. /**
  141039. * Gets the color input component
  141040. */
  141041. get value(): NodeMaterialConnectionPoint;
  141042. /**
  141043. * Gets the cutoff input component
  141044. */
  141045. get cutoff(): NodeMaterialConnectionPoint;
  141046. protected _buildBlock(state: NodeMaterialBuildState): this;
  141047. }
  141048. }
  141049. declare module BABYLON {
  141050. /**
  141051. * Block used to test if the fragment shader is front facing
  141052. */
  141053. export class FrontFacingBlock extends NodeMaterialBlock {
  141054. /**
  141055. * Creates a new FrontFacingBlock
  141056. * @param name defines the block name
  141057. */
  141058. constructor(name: string);
  141059. /**
  141060. * Gets the current class name
  141061. * @returns the class name
  141062. */
  141063. getClassName(): string;
  141064. /**
  141065. * Gets the output component
  141066. */
  141067. get output(): NodeMaterialConnectionPoint;
  141068. protected _buildBlock(state: NodeMaterialBuildState): this;
  141069. }
  141070. }
  141071. declare module BABYLON {
  141072. /**
  141073. * Block used to get the derivative value on x and y of a given input
  141074. */
  141075. export class DerivativeBlock extends NodeMaterialBlock {
  141076. /**
  141077. * Create a new DerivativeBlock
  141078. * @param name defines the block name
  141079. */
  141080. constructor(name: string);
  141081. /**
  141082. * Gets the current class name
  141083. * @returns the class name
  141084. */
  141085. getClassName(): string;
  141086. /**
  141087. * Gets the input component
  141088. */
  141089. get input(): NodeMaterialConnectionPoint;
  141090. /**
  141091. * Gets the derivative output on x
  141092. */
  141093. get dx(): NodeMaterialConnectionPoint;
  141094. /**
  141095. * Gets the derivative output on y
  141096. */
  141097. get dy(): NodeMaterialConnectionPoint;
  141098. protected _buildBlock(state: NodeMaterialBuildState): this;
  141099. }
  141100. }
  141101. declare module BABYLON {
  141102. /**
  141103. * Block used to make gl_FragCoord available
  141104. */
  141105. export class FragCoordBlock extends NodeMaterialBlock {
  141106. /**
  141107. * Creates a new FragCoordBlock
  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 xy component
  141118. */
  141119. get xy(): NodeMaterialConnectionPoint;
  141120. /**
  141121. * Gets the xyz component
  141122. */
  141123. get xyz(): NodeMaterialConnectionPoint;
  141124. /**
  141125. * Gets the xyzw component
  141126. */
  141127. get xyzw(): NodeMaterialConnectionPoint;
  141128. /**
  141129. * Gets the x component
  141130. */
  141131. get x(): NodeMaterialConnectionPoint;
  141132. /**
  141133. * Gets the y component
  141134. */
  141135. get y(): NodeMaterialConnectionPoint;
  141136. /**
  141137. * Gets the z component
  141138. */
  141139. get z(): NodeMaterialConnectionPoint;
  141140. /**
  141141. * Gets the w component
  141142. */
  141143. get output(): NodeMaterialConnectionPoint;
  141144. protected writeOutputs(state: NodeMaterialBuildState): string;
  141145. protected _buildBlock(state: NodeMaterialBuildState): this;
  141146. }
  141147. }
  141148. declare module BABYLON {
  141149. /**
  141150. * Block used to get the screen sizes
  141151. */
  141152. export class ScreenSizeBlock extends NodeMaterialBlock {
  141153. private _varName;
  141154. private _scene;
  141155. /**
  141156. * Creates a new ScreenSizeBlock
  141157. * @param name defines the block name
  141158. */
  141159. constructor(name: string);
  141160. /**
  141161. * Gets the current class name
  141162. * @returns the class name
  141163. */
  141164. getClassName(): string;
  141165. /**
  141166. * Gets the xy component
  141167. */
  141168. get xy(): NodeMaterialConnectionPoint;
  141169. /**
  141170. * Gets the x component
  141171. */
  141172. get x(): NodeMaterialConnectionPoint;
  141173. /**
  141174. * Gets the y component
  141175. */
  141176. get y(): NodeMaterialConnectionPoint;
  141177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141178. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141179. protected _buildBlock(state: NodeMaterialBuildState): this;
  141180. }
  141181. }
  141182. declare module BABYLON {
  141183. /**
  141184. * Block used to add support for scene fog
  141185. */
  141186. export class FogBlock extends NodeMaterialBlock {
  141187. private _fogDistanceName;
  141188. private _fogParameters;
  141189. /**
  141190. * Create a new FogBlock
  141191. * @param name defines the block name
  141192. */
  141193. constructor(name: string);
  141194. /**
  141195. * Gets the current class name
  141196. * @returns the class name
  141197. */
  141198. getClassName(): string;
  141199. /**
  141200. * Gets the world position input component
  141201. */
  141202. get worldPosition(): NodeMaterialConnectionPoint;
  141203. /**
  141204. * Gets the view input component
  141205. */
  141206. get view(): NodeMaterialConnectionPoint;
  141207. /**
  141208. * Gets the color input component
  141209. */
  141210. get input(): NodeMaterialConnectionPoint;
  141211. /**
  141212. * Gets the fog color input component
  141213. */
  141214. get fogColor(): NodeMaterialConnectionPoint;
  141215. /**
  141216. * Gets the output component
  141217. */
  141218. get output(): NodeMaterialConnectionPoint;
  141219. autoConfigure(material: NodeMaterial): void;
  141220. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141222. protected _buildBlock(state: NodeMaterialBuildState): this;
  141223. }
  141224. }
  141225. declare module BABYLON {
  141226. /**
  141227. * Block used to add light in the fragment shader
  141228. */
  141229. export class LightBlock extends NodeMaterialBlock {
  141230. private _lightId;
  141231. /**
  141232. * Gets or sets the light associated with this block
  141233. */
  141234. light: Nullable<Light>;
  141235. /**
  141236. * Create a new LightBlock
  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 world position input component
  141247. */
  141248. get worldPosition(): NodeMaterialConnectionPoint;
  141249. /**
  141250. * Gets the world normal input component
  141251. */
  141252. get worldNormal(): NodeMaterialConnectionPoint;
  141253. /**
  141254. * Gets the camera (or eye) position component
  141255. */
  141256. get cameraPosition(): NodeMaterialConnectionPoint;
  141257. /**
  141258. * Gets the glossiness component
  141259. */
  141260. get glossiness(): NodeMaterialConnectionPoint;
  141261. /**
  141262. * Gets the glossinness power component
  141263. */
  141264. get glossPower(): NodeMaterialConnectionPoint;
  141265. /**
  141266. * Gets the diffuse color component
  141267. */
  141268. get diffuseColor(): NodeMaterialConnectionPoint;
  141269. /**
  141270. * Gets the specular color component
  141271. */
  141272. get specularColor(): NodeMaterialConnectionPoint;
  141273. /**
  141274. * Gets the diffuse output component
  141275. */
  141276. get diffuseOutput(): NodeMaterialConnectionPoint;
  141277. /**
  141278. * Gets the specular output component
  141279. */
  141280. get specularOutput(): NodeMaterialConnectionPoint;
  141281. /**
  141282. * Gets the shadow output component
  141283. */
  141284. get shadow(): NodeMaterialConnectionPoint;
  141285. autoConfigure(material: NodeMaterial): void;
  141286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141287. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141289. private _injectVertexCode;
  141290. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141291. serialize(): any;
  141292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141293. }
  141294. }
  141295. declare module BABYLON {
  141296. /**
  141297. * Block used to read a reflection texture from a sampler
  141298. */
  141299. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141300. /**
  141301. * Create a new ReflectionTextureBlock
  141302. * @param name defines the block name
  141303. */
  141304. constructor(name: string);
  141305. /**
  141306. * Gets the current class name
  141307. * @returns the class name
  141308. */
  141309. getClassName(): string;
  141310. /**
  141311. * Gets the world position input component
  141312. */
  141313. get position(): NodeMaterialConnectionPoint;
  141314. /**
  141315. * Gets the world position input component
  141316. */
  141317. get worldPosition(): NodeMaterialConnectionPoint;
  141318. /**
  141319. * Gets the world normal input component
  141320. */
  141321. get worldNormal(): NodeMaterialConnectionPoint;
  141322. /**
  141323. * Gets the world input component
  141324. */
  141325. get world(): NodeMaterialConnectionPoint;
  141326. /**
  141327. * Gets the camera (or eye) position component
  141328. */
  141329. get cameraPosition(): NodeMaterialConnectionPoint;
  141330. /**
  141331. * Gets the view input component
  141332. */
  141333. get view(): NodeMaterialConnectionPoint;
  141334. /**
  141335. * Gets the rgb output component
  141336. */
  141337. get rgb(): NodeMaterialConnectionPoint;
  141338. /**
  141339. * Gets the rgba output component
  141340. */
  141341. get rgba(): NodeMaterialConnectionPoint;
  141342. /**
  141343. * Gets the r output component
  141344. */
  141345. get r(): NodeMaterialConnectionPoint;
  141346. /**
  141347. * Gets the g output component
  141348. */
  141349. get g(): NodeMaterialConnectionPoint;
  141350. /**
  141351. * Gets the b output component
  141352. */
  141353. get b(): NodeMaterialConnectionPoint;
  141354. /**
  141355. * Gets the a output component
  141356. */
  141357. get a(): NodeMaterialConnectionPoint;
  141358. autoConfigure(material: NodeMaterial): void;
  141359. protected _buildBlock(state: NodeMaterialBuildState): this;
  141360. }
  141361. }
  141362. declare module BABYLON {
  141363. /**
  141364. * Block used to add 2 vectors
  141365. */
  141366. export class AddBlock extends NodeMaterialBlock {
  141367. /**
  141368. * Creates a new AddBlock
  141369. * @param name defines the block name
  141370. */
  141371. constructor(name: string);
  141372. /**
  141373. * Gets the current class name
  141374. * @returns the class name
  141375. */
  141376. getClassName(): string;
  141377. /**
  141378. * Gets the left operand input component
  141379. */
  141380. get left(): NodeMaterialConnectionPoint;
  141381. /**
  141382. * Gets the right operand input component
  141383. */
  141384. get right(): NodeMaterialConnectionPoint;
  141385. /**
  141386. * Gets the output component
  141387. */
  141388. get output(): NodeMaterialConnectionPoint;
  141389. protected _buildBlock(state: NodeMaterialBuildState): this;
  141390. }
  141391. }
  141392. declare module BABYLON {
  141393. /**
  141394. * Block used to scale a vector by a float
  141395. */
  141396. export class ScaleBlock extends NodeMaterialBlock {
  141397. /**
  141398. * Creates a new ScaleBlock
  141399. * @param name defines the block name
  141400. */
  141401. constructor(name: string);
  141402. /**
  141403. * Gets the current class name
  141404. * @returns the class name
  141405. */
  141406. getClassName(): string;
  141407. /**
  141408. * Gets the input component
  141409. */
  141410. get input(): NodeMaterialConnectionPoint;
  141411. /**
  141412. * Gets the factor input component
  141413. */
  141414. get factor(): NodeMaterialConnectionPoint;
  141415. /**
  141416. * Gets the output component
  141417. */
  141418. get output(): NodeMaterialConnectionPoint;
  141419. protected _buildBlock(state: NodeMaterialBuildState): this;
  141420. }
  141421. }
  141422. declare module BABYLON {
  141423. /**
  141424. * Block used to clamp a float
  141425. */
  141426. export class ClampBlock extends NodeMaterialBlock {
  141427. /** Gets or sets the minimum range */
  141428. minimum: number;
  141429. /** Gets or sets the maximum range */
  141430. maximum: number;
  141431. /**
  141432. * Creates a new ClampBlock
  141433. * @param name defines the block name
  141434. */
  141435. constructor(name: string);
  141436. /**
  141437. * Gets the current class name
  141438. * @returns the class name
  141439. */
  141440. getClassName(): string;
  141441. /**
  141442. * Gets the value input component
  141443. */
  141444. get value(): NodeMaterialConnectionPoint;
  141445. /**
  141446. * Gets the output component
  141447. */
  141448. get output(): NodeMaterialConnectionPoint;
  141449. protected _buildBlock(state: NodeMaterialBuildState): this;
  141450. protected _dumpPropertiesCode(): string;
  141451. serialize(): any;
  141452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141453. }
  141454. }
  141455. declare module BABYLON {
  141456. /**
  141457. * Block used to apply a cross product between 2 vectors
  141458. */
  141459. export class CrossBlock extends NodeMaterialBlock {
  141460. /**
  141461. * Creates a new CrossBlock
  141462. * @param name defines the block name
  141463. */
  141464. constructor(name: string);
  141465. /**
  141466. * Gets the current class name
  141467. * @returns the class name
  141468. */
  141469. getClassName(): string;
  141470. /**
  141471. * Gets the left operand input component
  141472. */
  141473. get left(): NodeMaterialConnectionPoint;
  141474. /**
  141475. * Gets the right operand input component
  141476. */
  141477. get right(): NodeMaterialConnectionPoint;
  141478. /**
  141479. * Gets the output component
  141480. */
  141481. get output(): NodeMaterialConnectionPoint;
  141482. protected _buildBlock(state: NodeMaterialBuildState): this;
  141483. }
  141484. }
  141485. declare module BABYLON {
  141486. /**
  141487. * Block used to apply a dot product between 2 vectors
  141488. */
  141489. export class DotBlock extends NodeMaterialBlock {
  141490. /**
  141491. * Creates a new DotBlock
  141492. * @param name defines the block name
  141493. */
  141494. constructor(name: string);
  141495. /**
  141496. * Gets the current class name
  141497. * @returns the class name
  141498. */
  141499. getClassName(): string;
  141500. /**
  141501. * Gets the left operand input component
  141502. */
  141503. get left(): NodeMaterialConnectionPoint;
  141504. /**
  141505. * Gets the right operand input component
  141506. */
  141507. get right(): NodeMaterialConnectionPoint;
  141508. /**
  141509. * Gets the output component
  141510. */
  141511. get output(): NodeMaterialConnectionPoint;
  141512. protected _buildBlock(state: NodeMaterialBuildState): this;
  141513. }
  141514. }
  141515. declare module BABYLON {
  141516. /**
  141517. * Block used to normalize a vector
  141518. */
  141519. export class NormalizeBlock extends NodeMaterialBlock {
  141520. /**
  141521. * Creates a new NormalizeBlock
  141522. * @param name defines the block name
  141523. */
  141524. constructor(name: string);
  141525. /**
  141526. * Gets the current class name
  141527. * @returns the class name
  141528. */
  141529. getClassName(): string;
  141530. /**
  141531. * Gets the input component
  141532. */
  141533. get input(): NodeMaterialConnectionPoint;
  141534. /**
  141535. * Gets the output component
  141536. */
  141537. get output(): NodeMaterialConnectionPoint;
  141538. protected _buildBlock(state: NodeMaterialBuildState): this;
  141539. }
  141540. }
  141541. declare module BABYLON {
  141542. /**
  141543. * Operations supported by the Trigonometry block
  141544. */
  141545. export enum TrigonometryBlockOperations {
  141546. /** Cos */
  141547. Cos = 0,
  141548. /** Sin */
  141549. Sin = 1,
  141550. /** Abs */
  141551. Abs = 2,
  141552. /** Exp */
  141553. Exp = 3,
  141554. /** Exp2 */
  141555. Exp2 = 4,
  141556. /** Round */
  141557. Round = 5,
  141558. /** Floor */
  141559. Floor = 6,
  141560. /** Ceiling */
  141561. Ceiling = 7,
  141562. /** Square root */
  141563. Sqrt = 8,
  141564. /** Log */
  141565. Log = 9,
  141566. /** Tangent */
  141567. Tan = 10,
  141568. /** Arc tangent */
  141569. ArcTan = 11,
  141570. /** Arc cosinus */
  141571. ArcCos = 12,
  141572. /** Arc sinus */
  141573. ArcSin = 13,
  141574. /** Fraction */
  141575. Fract = 14,
  141576. /** Sign */
  141577. Sign = 15,
  141578. /** To radians (from degrees) */
  141579. Radians = 16,
  141580. /** To degrees (from radians) */
  141581. Degrees = 17
  141582. }
  141583. /**
  141584. * Block used to apply trigonometry operation to floats
  141585. */
  141586. export class TrigonometryBlock extends NodeMaterialBlock {
  141587. /**
  141588. * Gets or sets the operation applied by the block
  141589. */
  141590. operation: TrigonometryBlockOperations;
  141591. /**
  141592. * Creates a new TrigonometryBlock
  141593. * @param name defines the block name
  141594. */
  141595. constructor(name: string);
  141596. /**
  141597. * Gets the current class name
  141598. * @returns the class name
  141599. */
  141600. getClassName(): string;
  141601. /**
  141602. * Gets the input component
  141603. */
  141604. get input(): NodeMaterialConnectionPoint;
  141605. /**
  141606. * Gets the output component
  141607. */
  141608. get output(): NodeMaterialConnectionPoint;
  141609. protected _buildBlock(state: NodeMaterialBuildState): this;
  141610. serialize(): any;
  141611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141612. protected _dumpPropertiesCode(): string;
  141613. }
  141614. }
  141615. declare module BABYLON {
  141616. /**
  141617. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141618. */
  141619. export class ColorMergerBlock extends NodeMaterialBlock {
  141620. /**
  141621. * Create a new ColorMergerBlock
  141622. * @param name defines the block name
  141623. */
  141624. constructor(name: string);
  141625. /**
  141626. * Gets the current class name
  141627. * @returns the class name
  141628. */
  141629. getClassName(): string;
  141630. /**
  141631. * Gets the rgb component (input)
  141632. */
  141633. get rgbIn(): NodeMaterialConnectionPoint;
  141634. /**
  141635. * Gets the r component (input)
  141636. */
  141637. get r(): NodeMaterialConnectionPoint;
  141638. /**
  141639. * Gets the g component (input)
  141640. */
  141641. get g(): NodeMaterialConnectionPoint;
  141642. /**
  141643. * Gets the b component (input)
  141644. */
  141645. get b(): NodeMaterialConnectionPoint;
  141646. /**
  141647. * Gets the a component (input)
  141648. */
  141649. get a(): NodeMaterialConnectionPoint;
  141650. /**
  141651. * Gets the rgba component (output)
  141652. */
  141653. get rgba(): NodeMaterialConnectionPoint;
  141654. /**
  141655. * Gets the rgb component (output)
  141656. */
  141657. get rgbOut(): NodeMaterialConnectionPoint;
  141658. /**
  141659. * Gets the rgb component (output)
  141660. * @deprecated Please use rgbOut instead.
  141661. */
  141662. get rgb(): NodeMaterialConnectionPoint;
  141663. protected _buildBlock(state: NodeMaterialBuildState): this;
  141664. }
  141665. }
  141666. declare module BABYLON {
  141667. /**
  141668. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141669. */
  141670. export class VectorSplitterBlock extends NodeMaterialBlock {
  141671. /**
  141672. * Create a new VectorSplitterBlock
  141673. * @param name defines the block name
  141674. */
  141675. constructor(name: string);
  141676. /**
  141677. * Gets the current class name
  141678. * @returns the class name
  141679. */
  141680. getClassName(): string;
  141681. /**
  141682. * Gets the xyzw component (input)
  141683. */
  141684. get xyzw(): NodeMaterialConnectionPoint;
  141685. /**
  141686. * Gets the xyz component (input)
  141687. */
  141688. get xyzIn(): NodeMaterialConnectionPoint;
  141689. /**
  141690. * Gets the xy component (input)
  141691. */
  141692. get xyIn(): NodeMaterialConnectionPoint;
  141693. /**
  141694. * Gets the xyz component (output)
  141695. */
  141696. get xyzOut(): NodeMaterialConnectionPoint;
  141697. /**
  141698. * Gets the xy component (output)
  141699. */
  141700. get xyOut(): NodeMaterialConnectionPoint;
  141701. /**
  141702. * Gets the x component (output)
  141703. */
  141704. get x(): NodeMaterialConnectionPoint;
  141705. /**
  141706. * Gets the y component (output)
  141707. */
  141708. get y(): NodeMaterialConnectionPoint;
  141709. /**
  141710. * Gets the z component (output)
  141711. */
  141712. get z(): NodeMaterialConnectionPoint;
  141713. /**
  141714. * Gets the w component (output)
  141715. */
  141716. get w(): NodeMaterialConnectionPoint;
  141717. protected _inputRename(name: string): string;
  141718. protected _outputRename(name: string): string;
  141719. protected _buildBlock(state: NodeMaterialBuildState): this;
  141720. }
  141721. }
  141722. declare module BABYLON {
  141723. /**
  141724. * Block used to lerp between 2 values
  141725. */
  141726. export class LerpBlock extends NodeMaterialBlock {
  141727. /**
  141728. * Creates a new LerpBlock
  141729. * @param name defines the block name
  141730. */
  141731. constructor(name: string);
  141732. /**
  141733. * Gets the current class name
  141734. * @returns the class name
  141735. */
  141736. getClassName(): string;
  141737. /**
  141738. * Gets the left operand input component
  141739. */
  141740. get left(): NodeMaterialConnectionPoint;
  141741. /**
  141742. * Gets the right operand input component
  141743. */
  141744. get right(): NodeMaterialConnectionPoint;
  141745. /**
  141746. * Gets the gradient operand input component
  141747. */
  141748. get gradient(): NodeMaterialConnectionPoint;
  141749. /**
  141750. * Gets the output component
  141751. */
  141752. get output(): NodeMaterialConnectionPoint;
  141753. protected _buildBlock(state: NodeMaterialBuildState): this;
  141754. }
  141755. }
  141756. declare module BABYLON {
  141757. /**
  141758. * Block used to divide 2 vectors
  141759. */
  141760. export class DivideBlock extends NodeMaterialBlock {
  141761. /**
  141762. * Creates a new DivideBlock
  141763. * @param name defines the block name
  141764. */
  141765. constructor(name: string);
  141766. /**
  141767. * Gets the current class name
  141768. * @returns the class name
  141769. */
  141770. getClassName(): string;
  141771. /**
  141772. * Gets the left operand input component
  141773. */
  141774. get left(): NodeMaterialConnectionPoint;
  141775. /**
  141776. * Gets the right operand input component
  141777. */
  141778. get right(): NodeMaterialConnectionPoint;
  141779. /**
  141780. * Gets the output component
  141781. */
  141782. get output(): NodeMaterialConnectionPoint;
  141783. protected _buildBlock(state: NodeMaterialBuildState): this;
  141784. }
  141785. }
  141786. declare module BABYLON {
  141787. /**
  141788. * Block used to subtract 2 vectors
  141789. */
  141790. export class SubtractBlock extends NodeMaterialBlock {
  141791. /**
  141792. * Creates a new SubtractBlock
  141793. * @param name defines the block name
  141794. */
  141795. constructor(name: string);
  141796. /**
  141797. * Gets the current class name
  141798. * @returns the class name
  141799. */
  141800. getClassName(): string;
  141801. /**
  141802. * Gets the left operand input component
  141803. */
  141804. get left(): NodeMaterialConnectionPoint;
  141805. /**
  141806. * Gets the right operand input component
  141807. */
  141808. get right(): NodeMaterialConnectionPoint;
  141809. /**
  141810. * Gets the output component
  141811. */
  141812. get output(): NodeMaterialConnectionPoint;
  141813. protected _buildBlock(state: NodeMaterialBuildState): this;
  141814. }
  141815. }
  141816. declare module BABYLON {
  141817. /**
  141818. * Block used to step a value
  141819. */
  141820. export class StepBlock extends NodeMaterialBlock {
  141821. /**
  141822. * Creates a new StepBlock
  141823. * @param name defines the block name
  141824. */
  141825. constructor(name: string);
  141826. /**
  141827. * Gets the current class name
  141828. * @returns the class name
  141829. */
  141830. getClassName(): string;
  141831. /**
  141832. * Gets the value operand input component
  141833. */
  141834. get value(): NodeMaterialConnectionPoint;
  141835. /**
  141836. * Gets the edge operand input component
  141837. */
  141838. get edge(): NodeMaterialConnectionPoint;
  141839. /**
  141840. * Gets the output component
  141841. */
  141842. get output(): NodeMaterialConnectionPoint;
  141843. protected _buildBlock(state: NodeMaterialBuildState): this;
  141844. }
  141845. }
  141846. declare module BABYLON {
  141847. /**
  141848. * Block used to get the opposite (1 - x) of a value
  141849. */
  141850. export class OneMinusBlock extends NodeMaterialBlock {
  141851. /**
  141852. * Creates a new OneMinusBlock
  141853. * @param name defines the block name
  141854. */
  141855. constructor(name: string);
  141856. /**
  141857. * Gets the current class name
  141858. * @returns the class name
  141859. */
  141860. getClassName(): string;
  141861. /**
  141862. * Gets the input component
  141863. */
  141864. get input(): NodeMaterialConnectionPoint;
  141865. /**
  141866. * Gets the output component
  141867. */
  141868. get output(): NodeMaterialConnectionPoint;
  141869. protected _buildBlock(state: NodeMaterialBuildState): this;
  141870. }
  141871. }
  141872. declare module BABYLON {
  141873. /**
  141874. * Block used to get the view direction
  141875. */
  141876. export class ViewDirectionBlock extends NodeMaterialBlock {
  141877. /**
  141878. * Creates a new ViewDirectionBlock
  141879. * @param name defines the block name
  141880. */
  141881. constructor(name: string);
  141882. /**
  141883. * Gets the current class name
  141884. * @returns the class name
  141885. */
  141886. getClassName(): string;
  141887. /**
  141888. * Gets the world position component
  141889. */
  141890. get worldPosition(): NodeMaterialConnectionPoint;
  141891. /**
  141892. * Gets the camera position component
  141893. */
  141894. get cameraPosition(): NodeMaterialConnectionPoint;
  141895. /**
  141896. * Gets the output component
  141897. */
  141898. get output(): NodeMaterialConnectionPoint;
  141899. autoConfigure(material: NodeMaterial): void;
  141900. protected _buildBlock(state: NodeMaterialBuildState): this;
  141901. }
  141902. }
  141903. declare module BABYLON {
  141904. /**
  141905. * Block used to compute fresnel value
  141906. */
  141907. export class FresnelBlock extends NodeMaterialBlock {
  141908. /**
  141909. * Create a new FresnelBlock
  141910. * @param name defines the block name
  141911. */
  141912. constructor(name: string);
  141913. /**
  141914. * Gets the current class name
  141915. * @returns the class name
  141916. */
  141917. getClassName(): string;
  141918. /**
  141919. * Gets the world normal input component
  141920. */
  141921. get worldNormal(): NodeMaterialConnectionPoint;
  141922. /**
  141923. * Gets the view direction input component
  141924. */
  141925. get viewDirection(): NodeMaterialConnectionPoint;
  141926. /**
  141927. * Gets the bias input component
  141928. */
  141929. get bias(): NodeMaterialConnectionPoint;
  141930. /**
  141931. * Gets the camera (or eye) position component
  141932. */
  141933. get power(): NodeMaterialConnectionPoint;
  141934. /**
  141935. * Gets the fresnel output component
  141936. */
  141937. get fresnel(): NodeMaterialConnectionPoint;
  141938. autoConfigure(material: NodeMaterial): void;
  141939. protected _buildBlock(state: NodeMaterialBuildState): this;
  141940. }
  141941. }
  141942. declare module BABYLON {
  141943. /**
  141944. * Block used to get the max of 2 values
  141945. */
  141946. export class MaxBlock extends NodeMaterialBlock {
  141947. /**
  141948. * Creates a new MaxBlock
  141949. * @param name defines the block name
  141950. */
  141951. constructor(name: string);
  141952. /**
  141953. * Gets the current class name
  141954. * @returns the class name
  141955. */
  141956. getClassName(): string;
  141957. /**
  141958. * Gets the left operand input component
  141959. */
  141960. get left(): NodeMaterialConnectionPoint;
  141961. /**
  141962. * Gets the right operand input component
  141963. */
  141964. get right(): NodeMaterialConnectionPoint;
  141965. /**
  141966. * Gets the output component
  141967. */
  141968. get output(): NodeMaterialConnectionPoint;
  141969. protected _buildBlock(state: NodeMaterialBuildState): this;
  141970. }
  141971. }
  141972. declare module BABYLON {
  141973. /**
  141974. * Block used to get the min of 2 values
  141975. */
  141976. export class MinBlock extends NodeMaterialBlock {
  141977. /**
  141978. * Creates a new MinBlock
  141979. * @param name defines the block name
  141980. */
  141981. constructor(name: string);
  141982. /**
  141983. * Gets the current class name
  141984. * @returns the class name
  141985. */
  141986. getClassName(): string;
  141987. /**
  141988. * Gets the left operand input component
  141989. */
  141990. get left(): NodeMaterialConnectionPoint;
  141991. /**
  141992. * Gets the right operand input component
  141993. */
  141994. get right(): NodeMaterialConnectionPoint;
  141995. /**
  141996. * Gets the output component
  141997. */
  141998. get output(): NodeMaterialConnectionPoint;
  141999. protected _buildBlock(state: NodeMaterialBuildState): this;
  142000. }
  142001. }
  142002. declare module BABYLON {
  142003. /**
  142004. * Block used to get the distance between 2 values
  142005. */
  142006. export class DistanceBlock extends NodeMaterialBlock {
  142007. /**
  142008. * Creates a new DistanceBlock
  142009. * @param name defines the block name
  142010. */
  142011. constructor(name: string);
  142012. /**
  142013. * Gets the current class name
  142014. * @returns the class name
  142015. */
  142016. getClassName(): string;
  142017. /**
  142018. * Gets the left operand input component
  142019. */
  142020. get left(): NodeMaterialConnectionPoint;
  142021. /**
  142022. * Gets the right operand input component
  142023. */
  142024. get right(): NodeMaterialConnectionPoint;
  142025. /**
  142026. * Gets the output component
  142027. */
  142028. get output(): NodeMaterialConnectionPoint;
  142029. protected _buildBlock(state: NodeMaterialBuildState): this;
  142030. }
  142031. }
  142032. declare module BABYLON {
  142033. /**
  142034. * Block used to get the length of a vector
  142035. */
  142036. export class LengthBlock extends NodeMaterialBlock {
  142037. /**
  142038. * Creates a new LengthBlock
  142039. * @param name defines the block name
  142040. */
  142041. constructor(name: string);
  142042. /**
  142043. * Gets the current class name
  142044. * @returns the class name
  142045. */
  142046. getClassName(): string;
  142047. /**
  142048. * Gets the value input component
  142049. */
  142050. get value(): NodeMaterialConnectionPoint;
  142051. /**
  142052. * Gets the output component
  142053. */
  142054. get output(): NodeMaterialConnectionPoint;
  142055. protected _buildBlock(state: NodeMaterialBuildState): this;
  142056. }
  142057. }
  142058. declare module BABYLON {
  142059. /**
  142060. * Block used to get negative version of a value (i.e. x * -1)
  142061. */
  142062. export class NegateBlock extends NodeMaterialBlock {
  142063. /**
  142064. * Creates a new NegateBlock
  142065. * @param name defines the block name
  142066. */
  142067. constructor(name: string);
  142068. /**
  142069. * Gets the current class name
  142070. * @returns the class name
  142071. */
  142072. getClassName(): string;
  142073. /**
  142074. * Gets the value input component
  142075. */
  142076. get value(): NodeMaterialConnectionPoint;
  142077. /**
  142078. * Gets the output component
  142079. */
  142080. get output(): NodeMaterialConnectionPoint;
  142081. protected _buildBlock(state: NodeMaterialBuildState): this;
  142082. }
  142083. }
  142084. declare module BABYLON {
  142085. /**
  142086. * Block used to get the value of the first parameter raised to the power of the second
  142087. */
  142088. export class PowBlock extends NodeMaterialBlock {
  142089. /**
  142090. * Creates a new PowBlock
  142091. * @param name defines the block name
  142092. */
  142093. constructor(name: string);
  142094. /**
  142095. * Gets the current class name
  142096. * @returns the class name
  142097. */
  142098. getClassName(): string;
  142099. /**
  142100. * Gets the value operand input component
  142101. */
  142102. get value(): NodeMaterialConnectionPoint;
  142103. /**
  142104. * Gets the power operand input component
  142105. */
  142106. get power(): NodeMaterialConnectionPoint;
  142107. /**
  142108. * Gets the output component
  142109. */
  142110. get output(): NodeMaterialConnectionPoint;
  142111. protected _buildBlock(state: NodeMaterialBuildState): this;
  142112. }
  142113. }
  142114. declare module BABYLON {
  142115. /**
  142116. * Block used to get a random number
  142117. */
  142118. export class RandomNumberBlock extends NodeMaterialBlock {
  142119. /**
  142120. * Creates a new RandomNumberBlock
  142121. * @param name defines the block name
  142122. */
  142123. constructor(name: string);
  142124. /**
  142125. * Gets the current class name
  142126. * @returns the class name
  142127. */
  142128. getClassName(): string;
  142129. /**
  142130. * Gets the seed input component
  142131. */
  142132. get seed(): NodeMaterialConnectionPoint;
  142133. /**
  142134. * Gets the output component
  142135. */
  142136. get output(): NodeMaterialConnectionPoint;
  142137. protected _buildBlock(state: NodeMaterialBuildState): this;
  142138. }
  142139. }
  142140. declare module BABYLON {
  142141. /**
  142142. * Block used to compute arc tangent of 2 values
  142143. */
  142144. export class ArcTan2Block extends NodeMaterialBlock {
  142145. /**
  142146. * Creates a new ArcTan2Block
  142147. * @param name defines the block name
  142148. */
  142149. constructor(name: string);
  142150. /**
  142151. * Gets the current class name
  142152. * @returns the class name
  142153. */
  142154. getClassName(): string;
  142155. /**
  142156. * Gets the x operand input component
  142157. */
  142158. get x(): NodeMaterialConnectionPoint;
  142159. /**
  142160. * Gets the y operand input component
  142161. */
  142162. get y(): NodeMaterialConnectionPoint;
  142163. /**
  142164. * Gets the output component
  142165. */
  142166. get output(): NodeMaterialConnectionPoint;
  142167. protected _buildBlock(state: NodeMaterialBuildState): this;
  142168. }
  142169. }
  142170. declare module BABYLON {
  142171. /**
  142172. * Block used to smooth step a value
  142173. */
  142174. export class SmoothStepBlock extends NodeMaterialBlock {
  142175. /**
  142176. * Creates a new SmoothStepBlock
  142177. * @param name defines the block name
  142178. */
  142179. constructor(name: string);
  142180. /**
  142181. * Gets the current class name
  142182. * @returns the class name
  142183. */
  142184. getClassName(): string;
  142185. /**
  142186. * Gets the value operand input component
  142187. */
  142188. get value(): NodeMaterialConnectionPoint;
  142189. /**
  142190. * Gets the first edge operand input component
  142191. */
  142192. get edge0(): NodeMaterialConnectionPoint;
  142193. /**
  142194. * Gets the second edge operand input component
  142195. */
  142196. get edge1(): NodeMaterialConnectionPoint;
  142197. /**
  142198. * Gets the output component
  142199. */
  142200. get output(): NodeMaterialConnectionPoint;
  142201. protected _buildBlock(state: NodeMaterialBuildState): this;
  142202. }
  142203. }
  142204. declare module BABYLON {
  142205. /**
  142206. * Block used to get the reciprocal (1 / x) of a value
  142207. */
  142208. export class ReciprocalBlock extends NodeMaterialBlock {
  142209. /**
  142210. * Creates a new ReciprocalBlock
  142211. * @param name defines the block name
  142212. */
  142213. constructor(name: string);
  142214. /**
  142215. * Gets the current class name
  142216. * @returns the class name
  142217. */
  142218. getClassName(): string;
  142219. /**
  142220. * Gets the input component
  142221. */
  142222. get input(): NodeMaterialConnectionPoint;
  142223. /**
  142224. * Gets the output component
  142225. */
  142226. get output(): NodeMaterialConnectionPoint;
  142227. protected _buildBlock(state: NodeMaterialBuildState): this;
  142228. }
  142229. }
  142230. declare module BABYLON {
  142231. /**
  142232. * Block used to replace a color by another one
  142233. */
  142234. export class ReplaceColorBlock extends NodeMaterialBlock {
  142235. /**
  142236. * Creates a new ReplaceColorBlock
  142237. * @param name defines the block name
  142238. */
  142239. constructor(name: string);
  142240. /**
  142241. * Gets the current class name
  142242. * @returns the class name
  142243. */
  142244. getClassName(): string;
  142245. /**
  142246. * Gets the value input component
  142247. */
  142248. get value(): NodeMaterialConnectionPoint;
  142249. /**
  142250. * Gets the reference input component
  142251. */
  142252. get reference(): NodeMaterialConnectionPoint;
  142253. /**
  142254. * Gets the distance input component
  142255. */
  142256. get distance(): NodeMaterialConnectionPoint;
  142257. /**
  142258. * Gets the replacement input component
  142259. */
  142260. get replacement(): NodeMaterialConnectionPoint;
  142261. /**
  142262. * Gets the output component
  142263. */
  142264. get output(): NodeMaterialConnectionPoint;
  142265. protected _buildBlock(state: NodeMaterialBuildState): this;
  142266. }
  142267. }
  142268. declare module BABYLON {
  142269. /**
  142270. * Block used to posterize a value
  142271. * @see https://en.wikipedia.org/wiki/Posterization
  142272. */
  142273. export class PosterizeBlock extends NodeMaterialBlock {
  142274. /**
  142275. * Creates a new PosterizeBlock
  142276. * @param name defines the block name
  142277. */
  142278. constructor(name: string);
  142279. /**
  142280. * Gets the current class name
  142281. * @returns the class name
  142282. */
  142283. getClassName(): string;
  142284. /**
  142285. * Gets the value input component
  142286. */
  142287. get value(): NodeMaterialConnectionPoint;
  142288. /**
  142289. * Gets the steps input component
  142290. */
  142291. get steps(): NodeMaterialConnectionPoint;
  142292. /**
  142293. * Gets the output component
  142294. */
  142295. get output(): NodeMaterialConnectionPoint;
  142296. protected _buildBlock(state: NodeMaterialBuildState): this;
  142297. }
  142298. }
  142299. declare module BABYLON {
  142300. /**
  142301. * Operations supported by the Wave block
  142302. */
  142303. export enum WaveBlockKind {
  142304. /** SawTooth */
  142305. SawTooth = 0,
  142306. /** Square */
  142307. Square = 1,
  142308. /** Triangle */
  142309. Triangle = 2
  142310. }
  142311. /**
  142312. * Block used to apply wave operation to floats
  142313. */
  142314. export class WaveBlock extends NodeMaterialBlock {
  142315. /**
  142316. * Gets or sets the kibnd of wave to be applied by the block
  142317. */
  142318. kind: WaveBlockKind;
  142319. /**
  142320. * Creates a new WaveBlock
  142321. * @param name defines the block name
  142322. */
  142323. constructor(name: string);
  142324. /**
  142325. * Gets the current class name
  142326. * @returns the class name
  142327. */
  142328. getClassName(): string;
  142329. /**
  142330. * Gets the input component
  142331. */
  142332. get input(): NodeMaterialConnectionPoint;
  142333. /**
  142334. * Gets the output component
  142335. */
  142336. get output(): NodeMaterialConnectionPoint;
  142337. protected _buildBlock(state: NodeMaterialBuildState): this;
  142338. serialize(): any;
  142339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142340. }
  142341. }
  142342. declare module BABYLON {
  142343. /**
  142344. * Class used to store a color step for the GradientBlock
  142345. */
  142346. export class GradientBlockColorStep {
  142347. /**
  142348. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142349. */
  142350. step: number;
  142351. /**
  142352. * Gets or sets the color associated with this step
  142353. */
  142354. color: Color3;
  142355. /**
  142356. * Creates a new GradientBlockColorStep
  142357. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142358. * @param color defines the color associated with this step
  142359. */
  142360. constructor(
  142361. /**
  142362. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142363. */
  142364. step: number,
  142365. /**
  142366. * Gets or sets the color associated with this step
  142367. */
  142368. color: Color3);
  142369. }
  142370. /**
  142371. * Block used to return a color from a gradient based on an input value between 0 and 1
  142372. */
  142373. export class GradientBlock extends NodeMaterialBlock {
  142374. /**
  142375. * Gets or sets the list of color steps
  142376. */
  142377. colorSteps: GradientBlockColorStep[];
  142378. /**
  142379. * Creates a new GradientBlock
  142380. * @param name defines the block name
  142381. */
  142382. constructor(name: string);
  142383. /**
  142384. * Gets the current class name
  142385. * @returns the class name
  142386. */
  142387. getClassName(): string;
  142388. /**
  142389. * Gets the gradient input component
  142390. */
  142391. get gradient(): NodeMaterialConnectionPoint;
  142392. /**
  142393. * Gets the output component
  142394. */
  142395. get output(): NodeMaterialConnectionPoint;
  142396. private _writeColorConstant;
  142397. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142398. serialize(): any;
  142399. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142400. protected _dumpPropertiesCode(): string;
  142401. }
  142402. }
  142403. declare module BABYLON {
  142404. /**
  142405. * Block used to normalize lerp between 2 values
  142406. */
  142407. export class NLerpBlock extends NodeMaterialBlock {
  142408. /**
  142409. * Creates a new NLerpBlock
  142410. * @param name defines the block name
  142411. */
  142412. constructor(name: string);
  142413. /**
  142414. * Gets the current class name
  142415. * @returns the class name
  142416. */
  142417. getClassName(): string;
  142418. /**
  142419. * Gets the left operand input component
  142420. */
  142421. get left(): NodeMaterialConnectionPoint;
  142422. /**
  142423. * Gets the right operand input component
  142424. */
  142425. get right(): NodeMaterialConnectionPoint;
  142426. /**
  142427. * Gets the gradient operand input component
  142428. */
  142429. get gradient(): NodeMaterialConnectionPoint;
  142430. /**
  142431. * Gets the output component
  142432. */
  142433. get output(): NodeMaterialConnectionPoint;
  142434. protected _buildBlock(state: NodeMaterialBuildState): this;
  142435. }
  142436. }
  142437. declare module BABYLON {
  142438. /**
  142439. * block used to Generate a Worley Noise 3D Noise Pattern
  142440. */
  142441. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142442. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142443. manhattanDistance: boolean;
  142444. /**
  142445. * Creates a new WorleyNoise3DBlock
  142446. * @param name defines the block name
  142447. */
  142448. constructor(name: string);
  142449. /**
  142450. * Gets the current class name
  142451. * @returns the class name
  142452. */
  142453. getClassName(): string;
  142454. /**
  142455. * Gets the seed input component
  142456. */
  142457. get seed(): NodeMaterialConnectionPoint;
  142458. /**
  142459. * Gets the jitter input component
  142460. */
  142461. get jitter(): NodeMaterialConnectionPoint;
  142462. /**
  142463. * Gets the output component
  142464. */
  142465. get output(): NodeMaterialConnectionPoint;
  142466. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142467. /**
  142468. * Exposes the properties to the UI?
  142469. */
  142470. protected _dumpPropertiesCode(): string;
  142471. /**
  142472. * Exposes the properties to the Seralize?
  142473. */
  142474. serialize(): any;
  142475. /**
  142476. * Exposes the properties to the deseralize?
  142477. */
  142478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142479. }
  142480. }
  142481. declare module BABYLON {
  142482. /**
  142483. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142484. */
  142485. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142486. /**
  142487. * Creates a new SimplexPerlin3DBlock
  142488. * @param name defines the block name
  142489. */
  142490. constructor(name: string);
  142491. /**
  142492. * Gets the current class name
  142493. * @returns the class name
  142494. */
  142495. getClassName(): string;
  142496. /**
  142497. * Gets the seed operand input component
  142498. */
  142499. get seed(): NodeMaterialConnectionPoint;
  142500. /**
  142501. * Gets the output component
  142502. */
  142503. get output(): NodeMaterialConnectionPoint;
  142504. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142505. }
  142506. }
  142507. declare module BABYLON {
  142508. /**
  142509. * Block used to blend normals
  142510. */
  142511. export class NormalBlendBlock extends NodeMaterialBlock {
  142512. /**
  142513. * Creates a new NormalBlendBlock
  142514. * @param name defines the block name
  142515. */
  142516. constructor(name: string);
  142517. /**
  142518. * Gets the current class name
  142519. * @returns the class name
  142520. */
  142521. getClassName(): string;
  142522. /**
  142523. * Gets the first input component
  142524. */
  142525. get normalMap0(): NodeMaterialConnectionPoint;
  142526. /**
  142527. * Gets the second input component
  142528. */
  142529. get normalMap1(): NodeMaterialConnectionPoint;
  142530. /**
  142531. * Gets the output component
  142532. */
  142533. get output(): NodeMaterialConnectionPoint;
  142534. protected _buildBlock(state: NodeMaterialBuildState): this;
  142535. }
  142536. }
  142537. declare module BABYLON {
  142538. /**
  142539. * Block used to rotate a 2d vector by a given angle
  142540. */
  142541. export class Rotate2dBlock extends NodeMaterialBlock {
  142542. /**
  142543. * Creates a new Rotate2dBlock
  142544. * @param name defines the block name
  142545. */
  142546. constructor(name: string);
  142547. /**
  142548. * Gets the current class name
  142549. * @returns the class name
  142550. */
  142551. getClassName(): string;
  142552. /**
  142553. * Gets the input vector
  142554. */
  142555. get input(): NodeMaterialConnectionPoint;
  142556. /**
  142557. * Gets the input angle
  142558. */
  142559. get angle(): NodeMaterialConnectionPoint;
  142560. /**
  142561. * Gets the output component
  142562. */
  142563. get output(): NodeMaterialConnectionPoint;
  142564. autoConfigure(material: NodeMaterial): void;
  142565. protected _buildBlock(state: NodeMaterialBuildState): this;
  142566. }
  142567. }
  142568. declare module BABYLON {
  142569. /**
  142570. * Block used to get the reflected vector from a direction and a normal
  142571. */
  142572. export class ReflectBlock extends NodeMaterialBlock {
  142573. /**
  142574. * Creates a new ReflectBlock
  142575. * @param name defines the block name
  142576. */
  142577. constructor(name: string);
  142578. /**
  142579. * Gets the current class name
  142580. * @returns the class name
  142581. */
  142582. getClassName(): string;
  142583. /**
  142584. * Gets the incident component
  142585. */
  142586. get incident(): NodeMaterialConnectionPoint;
  142587. /**
  142588. * Gets the normal component
  142589. */
  142590. get normal(): NodeMaterialConnectionPoint;
  142591. /**
  142592. * Gets the output component
  142593. */
  142594. get output(): NodeMaterialConnectionPoint;
  142595. protected _buildBlock(state: NodeMaterialBuildState): this;
  142596. }
  142597. }
  142598. declare module BABYLON {
  142599. /**
  142600. * Block used to get the refracted vector from a direction and a normal
  142601. */
  142602. export class RefractBlock extends NodeMaterialBlock {
  142603. /**
  142604. * Creates a new RefractBlock
  142605. * @param name defines the block name
  142606. */
  142607. constructor(name: string);
  142608. /**
  142609. * Gets the current class name
  142610. * @returns the class name
  142611. */
  142612. getClassName(): string;
  142613. /**
  142614. * Gets the incident component
  142615. */
  142616. get incident(): NodeMaterialConnectionPoint;
  142617. /**
  142618. * Gets the normal component
  142619. */
  142620. get normal(): NodeMaterialConnectionPoint;
  142621. /**
  142622. * Gets the index of refraction component
  142623. */
  142624. get ior(): NodeMaterialConnectionPoint;
  142625. /**
  142626. * Gets the output component
  142627. */
  142628. get output(): NodeMaterialConnectionPoint;
  142629. protected _buildBlock(state: NodeMaterialBuildState): this;
  142630. }
  142631. }
  142632. declare module BABYLON {
  142633. /**
  142634. * Block used to desaturate a color
  142635. */
  142636. export class DesaturateBlock extends NodeMaterialBlock {
  142637. /**
  142638. * Creates a new DesaturateBlock
  142639. * @param name defines the block name
  142640. */
  142641. constructor(name: string);
  142642. /**
  142643. * Gets the current class name
  142644. * @returns the class name
  142645. */
  142646. getClassName(): string;
  142647. /**
  142648. * Gets the color operand input component
  142649. */
  142650. get color(): NodeMaterialConnectionPoint;
  142651. /**
  142652. * Gets the level operand input component
  142653. */
  142654. get level(): NodeMaterialConnectionPoint;
  142655. /**
  142656. * Gets the output component
  142657. */
  142658. get output(): NodeMaterialConnectionPoint;
  142659. protected _buildBlock(state: NodeMaterialBuildState): this;
  142660. }
  142661. }
  142662. declare module BABYLON {
  142663. /**
  142664. * Block used to implement the ambient occlusion module of the PBR material
  142665. */
  142666. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142667. /**
  142668. * Create a new AmbientOcclusionBlock
  142669. * @param name defines the block name
  142670. */
  142671. constructor(name: string);
  142672. /**
  142673. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142674. */
  142675. useAmbientInGrayScale: boolean;
  142676. /**
  142677. * Initialize the block and prepare the context for build
  142678. * @param state defines the state that will be used for the build
  142679. */
  142680. initialize(state: NodeMaterialBuildState): void;
  142681. /**
  142682. * Gets the current class name
  142683. * @returns the class name
  142684. */
  142685. getClassName(): string;
  142686. /**
  142687. * Gets the texture input component
  142688. */
  142689. get texture(): NodeMaterialConnectionPoint;
  142690. /**
  142691. * Gets the texture intensity component
  142692. */
  142693. get intensity(): NodeMaterialConnectionPoint;
  142694. /**
  142695. * Gets the direct light intensity input component
  142696. */
  142697. get directLightIntensity(): NodeMaterialConnectionPoint;
  142698. /**
  142699. * Gets the ambient occlusion object output component
  142700. */
  142701. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142702. /**
  142703. * Gets the main code of the block (fragment side)
  142704. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142705. * @returns the shader code
  142706. */
  142707. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142709. protected _buildBlock(state: NodeMaterialBuildState): this;
  142710. protected _dumpPropertiesCode(): string;
  142711. serialize(): any;
  142712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142713. }
  142714. }
  142715. declare module BABYLON {
  142716. /**
  142717. * Block used to implement the reflection module of the PBR material
  142718. */
  142719. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142720. /** @hidden */
  142721. _defineLODReflectionAlpha: string;
  142722. /** @hidden */
  142723. _defineLinearSpecularReflection: string;
  142724. private _vEnvironmentIrradianceName;
  142725. /** @hidden */
  142726. _vReflectionMicrosurfaceInfosName: string;
  142727. /** @hidden */
  142728. _vReflectionInfosName: string;
  142729. /** @hidden */
  142730. _vReflectionFilteringInfoName: string;
  142731. private _scene;
  142732. /**
  142733. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142734. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142735. * It's less burden on the user side in the editor part.
  142736. */
  142737. /** @hidden */
  142738. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142739. /** @hidden */
  142740. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142741. /** @hidden */
  142742. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142743. /**
  142744. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142745. * diffuse part of the IBL.
  142746. */
  142747. useSphericalHarmonics: boolean;
  142748. /**
  142749. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142750. */
  142751. forceIrradianceInFragment: boolean;
  142752. /**
  142753. * Create a new ReflectionBlock
  142754. * @param name defines the block name
  142755. */
  142756. constructor(name: string);
  142757. /**
  142758. * Gets the current class name
  142759. * @returns the class name
  142760. */
  142761. getClassName(): string;
  142762. /**
  142763. * Gets the position input component
  142764. */
  142765. get position(): NodeMaterialConnectionPoint;
  142766. /**
  142767. * Gets the world position input component
  142768. */
  142769. get worldPosition(): NodeMaterialConnectionPoint;
  142770. /**
  142771. * Gets the world normal input component
  142772. */
  142773. get worldNormal(): NodeMaterialConnectionPoint;
  142774. /**
  142775. * Gets the world input component
  142776. */
  142777. get world(): NodeMaterialConnectionPoint;
  142778. /**
  142779. * Gets the camera (or eye) position component
  142780. */
  142781. get cameraPosition(): NodeMaterialConnectionPoint;
  142782. /**
  142783. * Gets the view input component
  142784. */
  142785. get view(): NodeMaterialConnectionPoint;
  142786. /**
  142787. * Gets the color input component
  142788. */
  142789. get color(): NodeMaterialConnectionPoint;
  142790. /**
  142791. * Gets the reflection object output component
  142792. */
  142793. get reflection(): NodeMaterialConnectionPoint;
  142794. /**
  142795. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  142796. */
  142797. get hasTexture(): boolean;
  142798. /**
  142799. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  142800. */
  142801. get reflectionColor(): string;
  142802. protected _getTexture(): Nullable<BaseTexture>;
  142803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142804. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142805. /**
  142806. * Gets the code to inject in the vertex shader
  142807. * @param state current state of the node material building
  142808. * @returns the shader code
  142809. */
  142810. handleVertexSide(state: NodeMaterialBuildState): string;
  142811. /**
  142812. * Gets the main code of the block (fragment side)
  142813. * @param state current state of the node material building
  142814. * @param normalVarName name of the existing variable corresponding to the normal
  142815. * @returns the shader code
  142816. */
  142817. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  142818. protected _buildBlock(state: NodeMaterialBuildState): this;
  142819. protected _dumpPropertiesCode(): string;
  142820. serialize(): any;
  142821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142822. }
  142823. }
  142824. declare module BABYLON {
  142825. /**
  142826. * Block used to implement the sheen module of the PBR material
  142827. */
  142828. export class SheenBlock extends NodeMaterialBlock {
  142829. /**
  142830. * Create a new SheenBlock
  142831. * @param name defines the block name
  142832. */
  142833. constructor(name: string);
  142834. /**
  142835. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  142836. * It allows the strength of the sheen effect to not depend on the base color of the material,
  142837. * making it easier to setup and tweak the effect
  142838. */
  142839. albedoScaling: boolean;
  142840. /**
  142841. * Defines if the sheen is linked to the sheen color.
  142842. */
  142843. linkSheenWithAlbedo: boolean;
  142844. /**
  142845. * Initialize the block and prepare the context for build
  142846. * @param state defines the state that will be used for the build
  142847. */
  142848. initialize(state: NodeMaterialBuildState): void;
  142849. /**
  142850. * Gets the current class name
  142851. * @returns the class name
  142852. */
  142853. getClassName(): string;
  142854. /**
  142855. * Gets the intensity input component
  142856. */
  142857. get intensity(): NodeMaterialConnectionPoint;
  142858. /**
  142859. * Gets the color input component
  142860. */
  142861. get color(): NodeMaterialConnectionPoint;
  142862. /**
  142863. * Gets the roughness input component
  142864. */
  142865. get roughness(): NodeMaterialConnectionPoint;
  142866. /**
  142867. * Gets the sheen object output component
  142868. */
  142869. get sheen(): NodeMaterialConnectionPoint;
  142870. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142871. /**
  142872. * Gets the main code of the block (fragment side)
  142873. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142874. * @returns the shader code
  142875. */
  142876. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  142877. protected _buildBlock(state: NodeMaterialBuildState): this;
  142878. protected _dumpPropertiesCode(): string;
  142879. serialize(): any;
  142880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142881. }
  142882. }
  142883. declare module BABYLON {
  142884. /**
  142885. * Block used to implement the reflectivity module of the PBR material
  142886. */
  142887. export class ReflectivityBlock extends NodeMaterialBlock {
  142888. private _metallicReflectanceColor;
  142889. private _metallicF0Factor;
  142890. /** @hidden */
  142891. _vMetallicReflectanceFactorsName: string;
  142892. /**
  142893. * The property below is set by the main PBR block prior to calling methods of this class.
  142894. */
  142895. /** @hidden */
  142896. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  142897. /**
  142898. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  142899. */
  142900. useAmbientOcclusionFromMetallicTextureRed: boolean;
  142901. /**
  142902. * Specifies if the metallic texture contains the metallness information in its blue channel.
  142903. */
  142904. useMetallnessFromMetallicTextureBlue: boolean;
  142905. /**
  142906. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  142907. */
  142908. useRoughnessFromMetallicTextureAlpha: boolean;
  142909. /**
  142910. * Specifies if the metallic texture contains the roughness information in its green channel.
  142911. */
  142912. useRoughnessFromMetallicTextureGreen: boolean;
  142913. /**
  142914. * Create a new ReflectivityBlock
  142915. * @param name defines the block name
  142916. */
  142917. constructor(name: string);
  142918. /**
  142919. * Initialize the block and prepare the context for build
  142920. * @param state defines the state that will be used for the build
  142921. */
  142922. initialize(state: NodeMaterialBuildState): void;
  142923. /**
  142924. * Gets the current class name
  142925. * @returns the class name
  142926. */
  142927. getClassName(): string;
  142928. /**
  142929. * Gets the metallic input component
  142930. */
  142931. get metallic(): NodeMaterialConnectionPoint;
  142932. /**
  142933. * Gets the roughness input component
  142934. */
  142935. get roughness(): NodeMaterialConnectionPoint;
  142936. /**
  142937. * Gets the texture input component
  142938. */
  142939. get texture(): NodeMaterialConnectionPoint;
  142940. /**
  142941. * Gets the reflectivity object output component
  142942. */
  142943. get reflectivity(): NodeMaterialConnectionPoint;
  142944. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142945. /**
  142946. * Gets the main code of the block (fragment side)
  142947. * @param state current state of the node material building
  142948. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  142949. * @returns the shader code
  142950. */
  142951. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  142952. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142953. protected _buildBlock(state: NodeMaterialBuildState): this;
  142954. protected _dumpPropertiesCode(): string;
  142955. serialize(): any;
  142956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142957. }
  142958. }
  142959. declare module BABYLON {
  142960. /**
  142961. * Block used to implement the anisotropy module of the PBR material
  142962. */
  142963. export class AnisotropyBlock extends NodeMaterialBlock {
  142964. /**
  142965. * The two properties below are set by the main PBR block prior to calling methods of this class.
  142966. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142967. * It's less burden on the user side in the editor part.
  142968. */
  142969. /** @hidden */
  142970. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142971. /** @hidden */
  142972. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142973. /**
  142974. * Create a new AnisotropyBlock
  142975. * @param name defines the block name
  142976. */
  142977. constructor(name: string);
  142978. /**
  142979. * Initialize the block and prepare the context for build
  142980. * @param state defines the state that will be used for the build
  142981. */
  142982. initialize(state: NodeMaterialBuildState): void;
  142983. /**
  142984. * Gets the current class name
  142985. * @returns the class name
  142986. */
  142987. getClassName(): string;
  142988. /**
  142989. * Gets the intensity input component
  142990. */
  142991. get intensity(): NodeMaterialConnectionPoint;
  142992. /**
  142993. * Gets the direction input component
  142994. */
  142995. get direction(): NodeMaterialConnectionPoint;
  142996. /**
  142997. * Gets the texture input component
  142998. */
  142999. get texture(): NodeMaterialConnectionPoint;
  143000. /**
  143001. * Gets the uv input component
  143002. */
  143003. get uv(): NodeMaterialConnectionPoint;
  143004. /**
  143005. * Gets the worldTangent input component
  143006. */
  143007. get worldTangent(): NodeMaterialConnectionPoint;
  143008. /**
  143009. * Gets the anisotropy object output component
  143010. */
  143011. get anisotropy(): NodeMaterialConnectionPoint;
  143012. private _generateTBNSpace;
  143013. /**
  143014. * Gets the main code of the block (fragment side)
  143015. * @param state current state of the node material building
  143016. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143017. * @returns the shader code
  143018. */
  143019. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143021. protected _buildBlock(state: NodeMaterialBuildState): this;
  143022. }
  143023. }
  143024. declare module BABYLON {
  143025. /**
  143026. * Block used to implement the clear coat module of the PBR material
  143027. */
  143028. export class ClearCoatBlock extends NodeMaterialBlock {
  143029. private _scene;
  143030. /**
  143031. * Create a new ClearCoatBlock
  143032. * @param name defines the block name
  143033. */
  143034. constructor(name: string);
  143035. /**
  143036. * Initialize the block and prepare the context for build
  143037. * @param state defines the state that will be used for the build
  143038. */
  143039. initialize(state: NodeMaterialBuildState): void;
  143040. /**
  143041. * Gets the current class name
  143042. * @returns the class name
  143043. */
  143044. getClassName(): string;
  143045. /**
  143046. * Gets the intensity input component
  143047. */
  143048. get intensity(): NodeMaterialConnectionPoint;
  143049. /**
  143050. * Gets the roughness input component
  143051. */
  143052. get roughness(): NodeMaterialConnectionPoint;
  143053. /**
  143054. * Gets the ior input component
  143055. */
  143056. get ior(): NodeMaterialConnectionPoint;
  143057. /**
  143058. * Gets the texture input component
  143059. */
  143060. get texture(): NodeMaterialConnectionPoint;
  143061. /**
  143062. * Gets the bump texture input component
  143063. */
  143064. get bumpTexture(): NodeMaterialConnectionPoint;
  143065. /**
  143066. * Gets the uv input component
  143067. */
  143068. get uv(): NodeMaterialConnectionPoint;
  143069. /**
  143070. * Gets the tint color input component
  143071. */
  143072. get tintColor(): NodeMaterialConnectionPoint;
  143073. /**
  143074. * Gets the tint "at distance" input component
  143075. */
  143076. get tintAtDistance(): NodeMaterialConnectionPoint;
  143077. /**
  143078. * Gets the tint thickness input component
  143079. */
  143080. get tintThickness(): NodeMaterialConnectionPoint;
  143081. /**
  143082. * Gets the world tangent input component
  143083. */
  143084. get worldTangent(): NodeMaterialConnectionPoint;
  143085. /**
  143086. * Gets the clear coat object output component
  143087. */
  143088. get clearcoat(): NodeMaterialConnectionPoint;
  143089. autoConfigure(material: NodeMaterial): void;
  143090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143092. private _generateTBNSpace;
  143093. /**
  143094. * Gets the main code of the block (fragment side)
  143095. * @param state current state of the node material building
  143096. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143097. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143098. * @param worldPosVarName name of the variable holding the world position
  143099. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143100. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143101. * @param worldNormalVarName name of the variable holding the world normal
  143102. * @returns the shader code
  143103. */
  143104. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143105. protected _buildBlock(state: NodeMaterialBuildState): this;
  143106. }
  143107. }
  143108. declare module BABYLON {
  143109. /**
  143110. * Block used to implement the sub surface module of the PBR material
  143111. */
  143112. export class SubSurfaceBlock extends NodeMaterialBlock {
  143113. /**
  143114. * Create a new SubSurfaceBlock
  143115. * @param name defines the block name
  143116. */
  143117. constructor(name: string);
  143118. /**
  143119. * Stores the intensity of the different subsurface effects in the thickness texture.
  143120. * * the green channel is the translucency intensity.
  143121. * * the blue channel is the scattering intensity.
  143122. * * the alpha channel is the refraction intensity.
  143123. */
  143124. useMaskFromThicknessTexture: boolean;
  143125. /**
  143126. * Initialize the block and prepare the context for build
  143127. * @param state defines the state that will be used for the build
  143128. */
  143129. initialize(state: NodeMaterialBuildState): void;
  143130. /**
  143131. * Gets the current class name
  143132. * @returns the class name
  143133. */
  143134. getClassName(): string;
  143135. /**
  143136. * Gets the min thickness input component
  143137. */
  143138. get minThickness(): NodeMaterialConnectionPoint;
  143139. /**
  143140. * Gets the max thickness input component
  143141. */
  143142. get maxThickness(): NodeMaterialConnectionPoint;
  143143. /**
  143144. * Gets the thickness texture component
  143145. */
  143146. get thicknessTexture(): NodeMaterialConnectionPoint;
  143147. /**
  143148. * Gets the tint color input component
  143149. */
  143150. get tintColor(): NodeMaterialConnectionPoint;
  143151. /**
  143152. * Gets the translucency intensity input component
  143153. */
  143154. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143155. /**
  143156. * Gets the translucency diffusion distance input component
  143157. */
  143158. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143159. /**
  143160. * Gets the refraction object parameters
  143161. */
  143162. get refraction(): NodeMaterialConnectionPoint;
  143163. /**
  143164. * Gets the sub surface object output component
  143165. */
  143166. get subsurface(): NodeMaterialConnectionPoint;
  143167. autoConfigure(material: NodeMaterial): void;
  143168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143169. /**
  143170. * Gets the main code of the block (fragment side)
  143171. * @param state current state of the node material building
  143172. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143173. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143174. * @param worldPosVarName name of the variable holding the world position
  143175. * @returns the shader code
  143176. */
  143177. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143178. protected _buildBlock(state: NodeMaterialBuildState): this;
  143179. }
  143180. }
  143181. declare module BABYLON {
  143182. /**
  143183. * Block used to implement the PBR metallic/roughness model
  143184. */
  143185. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143186. /**
  143187. * Gets or sets the light associated with this block
  143188. */
  143189. light: Nullable<Light>;
  143190. private _lightId;
  143191. private _scene;
  143192. private _environmentBRDFTexture;
  143193. private _environmentBrdfSamplerName;
  143194. private _vNormalWName;
  143195. private _invertNormalName;
  143196. /**
  143197. * Create a new ReflectionBlock
  143198. * @param name defines the block name
  143199. */
  143200. constructor(name: string);
  143201. /**
  143202. * Intensity of the direct lights e.g. the four lights available in your scene.
  143203. * This impacts both the direct diffuse and specular highlights.
  143204. */
  143205. directIntensity: number;
  143206. /**
  143207. * Intensity of the environment e.g. how much the environment will light the object
  143208. * either through harmonics for rough material or through the refelction for shiny ones.
  143209. */
  143210. environmentIntensity: number;
  143211. /**
  143212. * This is a special control allowing the reduction of the specular highlights coming from the
  143213. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143214. */
  143215. specularIntensity: number;
  143216. /**
  143217. * Defines the falloff type used in this material.
  143218. * It by default is Physical.
  143219. */
  143220. lightFalloff: number;
  143221. /**
  143222. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143223. */
  143224. useAlphaFromAlbedoTexture: boolean;
  143225. /**
  143226. * Specifies that alpha test should be used
  143227. */
  143228. useAlphaTest: boolean;
  143229. /**
  143230. * Defines the alpha limits in alpha test mode.
  143231. */
  143232. alphaTestCutoff: number;
  143233. /**
  143234. * Specifies that alpha blending should be used
  143235. */
  143236. useAlphaBlending: boolean;
  143237. /**
  143238. * Defines if the alpha value should be determined via the rgb values.
  143239. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143240. */
  143241. opacityRGB: boolean;
  143242. /**
  143243. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143244. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143245. */
  143246. useRadianceOverAlpha: boolean;
  143247. /**
  143248. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143249. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143250. */
  143251. useSpecularOverAlpha: boolean;
  143252. /**
  143253. * Enables specular anti aliasing in the PBR shader.
  143254. * It will both interacts on the Geometry for analytical and IBL lighting.
  143255. * It also prefilter the roughness map based on the bump values.
  143256. */
  143257. enableSpecularAntiAliasing: boolean;
  143258. /**
  143259. * Enables realtime filtering on the texture.
  143260. */
  143261. realTimeFiltering: boolean;
  143262. /**
  143263. * Quality switch for realtime filtering
  143264. */
  143265. realTimeFilteringQuality: number;
  143266. /**
  143267. * Defines if the material uses energy conservation.
  143268. */
  143269. useEnergyConservation: boolean;
  143270. /**
  143271. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143272. * too much the area relying on ambient texture to define their ambient occlusion.
  143273. */
  143274. useRadianceOcclusion: boolean;
  143275. /**
  143276. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143277. * makes the reflect vector face the model (under horizon).
  143278. */
  143279. useHorizonOcclusion: boolean;
  143280. /**
  143281. * If set to true, no lighting calculations will be applied.
  143282. */
  143283. unlit: boolean;
  143284. /**
  143285. * Force normal to face away from face.
  143286. */
  143287. forceNormalForward: boolean;
  143288. /**
  143289. * Defines the material debug mode.
  143290. * It helps seeing only some components of the material while troubleshooting.
  143291. */
  143292. debugMode: number;
  143293. /**
  143294. * Specify from where on screen the debug mode should start.
  143295. * The value goes from -1 (full screen) to 1 (not visible)
  143296. * It helps with side by side comparison against the final render
  143297. * This defaults to 0
  143298. */
  143299. debugLimit: number;
  143300. /**
  143301. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143302. * You can use the factor to better multiply the final value.
  143303. */
  143304. debugFactor: number;
  143305. /**
  143306. * Initialize the block and prepare the context for build
  143307. * @param state defines the state that will be used for the build
  143308. */
  143309. initialize(state: NodeMaterialBuildState): void;
  143310. /**
  143311. * Gets the current class name
  143312. * @returns the class name
  143313. */
  143314. getClassName(): string;
  143315. /**
  143316. * Gets the world position input component
  143317. */
  143318. get worldPosition(): NodeMaterialConnectionPoint;
  143319. /**
  143320. * Gets the world normal input component
  143321. */
  143322. get worldNormal(): NodeMaterialConnectionPoint;
  143323. /**
  143324. * Gets the perturbed normal input component
  143325. */
  143326. get perturbedNormal(): NodeMaterialConnectionPoint;
  143327. /**
  143328. * Gets the camera position input component
  143329. */
  143330. get cameraPosition(): NodeMaterialConnectionPoint;
  143331. /**
  143332. * Gets the base color input component
  143333. */
  143334. get baseColor(): NodeMaterialConnectionPoint;
  143335. /**
  143336. * Gets the opacity texture input component
  143337. */
  143338. get opacityTexture(): NodeMaterialConnectionPoint;
  143339. /**
  143340. * Gets the ambient color input component
  143341. */
  143342. get ambientColor(): NodeMaterialConnectionPoint;
  143343. /**
  143344. * Gets the reflectivity object parameters
  143345. */
  143346. get reflectivity(): NodeMaterialConnectionPoint;
  143347. /**
  143348. * Gets the ambient occlusion object parameters
  143349. */
  143350. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143351. /**
  143352. * Gets the reflection object parameters
  143353. */
  143354. get reflection(): NodeMaterialConnectionPoint;
  143355. /**
  143356. * Gets the sheen object parameters
  143357. */
  143358. get sheen(): NodeMaterialConnectionPoint;
  143359. /**
  143360. * Gets the clear coat object parameters
  143361. */
  143362. get clearcoat(): NodeMaterialConnectionPoint;
  143363. /**
  143364. * Gets the sub surface object parameters
  143365. */
  143366. get subsurface(): NodeMaterialConnectionPoint;
  143367. /**
  143368. * Gets the anisotropy object parameters
  143369. */
  143370. get anisotropy(): NodeMaterialConnectionPoint;
  143371. /**
  143372. * Gets the ambient output component
  143373. */
  143374. get ambient(): NodeMaterialConnectionPoint;
  143375. /**
  143376. * Gets the diffuse output component
  143377. */
  143378. get diffuse(): NodeMaterialConnectionPoint;
  143379. /**
  143380. * Gets the specular output component
  143381. */
  143382. get specular(): NodeMaterialConnectionPoint;
  143383. /**
  143384. * Gets the sheen output component
  143385. */
  143386. get sheenDir(): NodeMaterialConnectionPoint;
  143387. /**
  143388. * Gets the clear coat output component
  143389. */
  143390. get clearcoatDir(): NodeMaterialConnectionPoint;
  143391. /**
  143392. * Gets the indirect diffuse output component
  143393. */
  143394. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143395. /**
  143396. * Gets the indirect specular output component
  143397. */
  143398. get specularIndirect(): NodeMaterialConnectionPoint;
  143399. /**
  143400. * Gets the indirect sheen output component
  143401. */
  143402. get sheenIndirect(): NodeMaterialConnectionPoint;
  143403. /**
  143404. * Gets the indirect clear coat output component
  143405. */
  143406. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143407. /**
  143408. * Gets the refraction output component
  143409. */
  143410. get refraction(): NodeMaterialConnectionPoint;
  143411. /**
  143412. * Gets the global lighting output component
  143413. */
  143414. get lighting(): NodeMaterialConnectionPoint;
  143415. /**
  143416. * Gets the shadow output component
  143417. */
  143418. get shadow(): NodeMaterialConnectionPoint;
  143419. /**
  143420. * Gets the alpha output component
  143421. */
  143422. get alpha(): NodeMaterialConnectionPoint;
  143423. autoConfigure(material: NodeMaterial): void;
  143424. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143425. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143427. private _injectVertexCode;
  143428. /**
  143429. * Gets the code corresponding to the albedo/opacity module
  143430. * @returns the shader code
  143431. */
  143432. getAlbedoOpacityCode(): string;
  143433. protected _buildBlock(state: NodeMaterialBuildState): this;
  143434. protected _dumpPropertiesCode(): string;
  143435. serialize(): any;
  143436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143437. }
  143438. }
  143439. declare module BABYLON {
  143440. /**
  143441. * Block used to compute value of one parameter modulo another
  143442. */
  143443. export class ModBlock extends NodeMaterialBlock {
  143444. /**
  143445. * Creates a new ModBlock
  143446. * @param name defines the block name
  143447. */
  143448. constructor(name: string);
  143449. /**
  143450. * Gets the current class name
  143451. * @returns the class name
  143452. */
  143453. getClassName(): string;
  143454. /**
  143455. * Gets the left operand input component
  143456. */
  143457. get left(): NodeMaterialConnectionPoint;
  143458. /**
  143459. * Gets the right operand input component
  143460. */
  143461. get right(): NodeMaterialConnectionPoint;
  143462. /**
  143463. * Gets the output component
  143464. */
  143465. get output(): NodeMaterialConnectionPoint;
  143466. protected _buildBlock(state: NodeMaterialBuildState): this;
  143467. }
  143468. }
  143469. declare module BABYLON {
  143470. /**
  143471. * Helper class to push actions to a pool of workers.
  143472. */
  143473. export class WorkerPool implements IDisposable {
  143474. private _workerInfos;
  143475. private _pendingActions;
  143476. /**
  143477. * Constructor
  143478. * @param workers Array of workers to use for actions
  143479. */
  143480. constructor(workers: Array<Worker>);
  143481. /**
  143482. * Terminates all workers and clears any pending actions.
  143483. */
  143484. dispose(): void;
  143485. /**
  143486. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143487. * pended until a worker has completed its action.
  143488. * @param action The action to perform. Call onComplete when the action is complete.
  143489. */
  143490. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143491. private _execute;
  143492. }
  143493. }
  143494. declare module BABYLON {
  143495. /**
  143496. * Configuration for Draco compression
  143497. */
  143498. export interface IDracoCompressionConfiguration {
  143499. /**
  143500. * Configuration for the decoder.
  143501. */
  143502. decoder: {
  143503. /**
  143504. * The url to the WebAssembly module.
  143505. */
  143506. wasmUrl?: string;
  143507. /**
  143508. * The url to the WebAssembly binary.
  143509. */
  143510. wasmBinaryUrl?: string;
  143511. /**
  143512. * The url to the fallback JavaScript module.
  143513. */
  143514. fallbackUrl?: string;
  143515. };
  143516. }
  143517. /**
  143518. * Draco compression (https://google.github.io/draco/)
  143519. *
  143520. * This class wraps the Draco module.
  143521. *
  143522. * **Encoder**
  143523. *
  143524. * The encoder is not currently implemented.
  143525. *
  143526. * **Decoder**
  143527. *
  143528. * 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.
  143529. *
  143530. * To update the configuration, use the following code:
  143531. * ```javascript
  143532. * DracoCompression.Configuration = {
  143533. * decoder: {
  143534. * wasmUrl: "<url to the WebAssembly library>",
  143535. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143536. * fallbackUrl: "<url to the fallback JavaScript library>",
  143537. * }
  143538. * };
  143539. * ```
  143540. *
  143541. * 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.
  143542. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143543. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143544. *
  143545. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143546. * ```javascript
  143547. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143548. * ```
  143549. *
  143550. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143551. */
  143552. export class DracoCompression implements IDisposable {
  143553. private _workerPoolPromise?;
  143554. private _decoderModulePromise?;
  143555. /**
  143556. * The configuration. Defaults to the following urls:
  143557. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143558. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143559. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143560. */
  143561. static Configuration: IDracoCompressionConfiguration;
  143562. /**
  143563. * Returns true if the decoder configuration is available.
  143564. */
  143565. static get DecoderAvailable(): boolean;
  143566. /**
  143567. * Default number of workers to create when creating the draco compression object.
  143568. */
  143569. static DefaultNumWorkers: number;
  143570. private static GetDefaultNumWorkers;
  143571. private static _Default;
  143572. /**
  143573. * Default instance for the draco compression object.
  143574. */
  143575. static get Default(): DracoCompression;
  143576. /**
  143577. * Constructor
  143578. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143579. */
  143580. constructor(numWorkers?: number);
  143581. /**
  143582. * Stop all async operations and release resources.
  143583. */
  143584. dispose(): void;
  143585. /**
  143586. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143587. * @returns a promise that resolves when ready
  143588. */
  143589. whenReadyAsync(): Promise<void>;
  143590. /**
  143591. * Decode Draco compressed mesh data to vertex data.
  143592. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143593. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143594. * @returns A promise that resolves with the decoded vertex data
  143595. */
  143596. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143597. [kind: string]: number;
  143598. }): Promise<VertexData>;
  143599. }
  143600. }
  143601. declare module BABYLON {
  143602. /**
  143603. * Class for building Constructive Solid Geometry
  143604. */
  143605. export class CSG {
  143606. private polygons;
  143607. /**
  143608. * The world matrix
  143609. */
  143610. matrix: Matrix;
  143611. /**
  143612. * Stores the position
  143613. */
  143614. position: Vector3;
  143615. /**
  143616. * Stores the rotation
  143617. */
  143618. rotation: Vector3;
  143619. /**
  143620. * Stores the rotation quaternion
  143621. */
  143622. rotationQuaternion: Nullable<Quaternion>;
  143623. /**
  143624. * Stores the scaling vector
  143625. */
  143626. scaling: Vector3;
  143627. /**
  143628. * Convert the Mesh to CSG
  143629. * @param mesh The Mesh to convert to CSG
  143630. * @returns A new CSG from the Mesh
  143631. */
  143632. static FromMesh(mesh: Mesh): CSG;
  143633. /**
  143634. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143635. * @param polygons Polygons used to construct a CSG solid
  143636. */
  143637. private static FromPolygons;
  143638. /**
  143639. * Clones, or makes a deep copy, of the CSG
  143640. * @returns A new CSG
  143641. */
  143642. clone(): CSG;
  143643. /**
  143644. * Unions this CSG with another CSG
  143645. * @param csg The CSG to union against this CSG
  143646. * @returns The unioned CSG
  143647. */
  143648. union(csg: CSG): CSG;
  143649. /**
  143650. * Unions this CSG with another CSG in place
  143651. * @param csg The CSG to union against this CSG
  143652. */
  143653. unionInPlace(csg: CSG): void;
  143654. /**
  143655. * Subtracts this CSG with another CSG
  143656. * @param csg The CSG to subtract against this CSG
  143657. * @returns A new CSG
  143658. */
  143659. subtract(csg: CSG): CSG;
  143660. /**
  143661. * Subtracts this CSG with another CSG in place
  143662. * @param csg The CSG to subtact against this CSG
  143663. */
  143664. subtractInPlace(csg: CSG): void;
  143665. /**
  143666. * Intersect this CSG with another CSG
  143667. * @param csg The CSG to intersect against this CSG
  143668. * @returns A new CSG
  143669. */
  143670. intersect(csg: CSG): CSG;
  143671. /**
  143672. * Intersects this CSG with another CSG in place
  143673. * @param csg The CSG to intersect against this CSG
  143674. */
  143675. intersectInPlace(csg: CSG): void;
  143676. /**
  143677. * Return a new CSG solid with solid and empty space switched. This solid is
  143678. * not modified.
  143679. * @returns A new CSG solid with solid and empty space switched
  143680. */
  143681. inverse(): CSG;
  143682. /**
  143683. * Inverses the CSG in place
  143684. */
  143685. inverseInPlace(): void;
  143686. /**
  143687. * This is used to keep meshes transformations so they can be restored
  143688. * when we build back a Babylon Mesh
  143689. * NB : All CSG operations are performed in world coordinates
  143690. * @param csg The CSG to copy the transform attributes from
  143691. * @returns This CSG
  143692. */
  143693. copyTransformAttributes(csg: CSG): CSG;
  143694. /**
  143695. * Build Raw mesh from CSG
  143696. * Coordinates here are in world space
  143697. * @param name The name of the mesh geometry
  143698. * @param scene The Scene
  143699. * @param keepSubMeshes Specifies if the submeshes should be kept
  143700. * @returns A new Mesh
  143701. */
  143702. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143703. /**
  143704. * Build Mesh from CSG taking material and transforms into account
  143705. * @param name The name of the Mesh
  143706. * @param material The material of the Mesh
  143707. * @param scene The Scene
  143708. * @param keepSubMeshes Specifies if submeshes should be kept
  143709. * @returns The new Mesh
  143710. */
  143711. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143712. }
  143713. }
  143714. declare module BABYLON {
  143715. /**
  143716. * Class used to create a trail following a mesh
  143717. */
  143718. export class TrailMesh extends Mesh {
  143719. private _generator;
  143720. private _autoStart;
  143721. private _running;
  143722. private _diameter;
  143723. private _length;
  143724. private _sectionPolygonPointsCount;
  143725. private _sectionVectors;
  143726. private _sectionNormalVectors;
  143727. private _beforeRenderObserver;
  143728. /**
  143729. * @constructor
  143730. * @param name The value used by scene.getMeshByName() to do a lookup.
  143731. * @param generator The mesh or transform node to generate a trail.
  143732. * @param scene The scene to add this mesh to.
  143733. * @param diameter Diameter of trailing mesh. Default is 1.
  143734. * @param length Length of trailing mesh. Default is 60.
  143735. * @param autoStart Automatically start trailing mesh. Default true.
  143736. */
  143737. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143738. /**
  143739. * "TrailMesh"
  143740. * @returns "TrailMesh"
  143741. */
  143742. getClassName(): string;
  143743. private _createMesh;
  143744. /**
  143745. * Start trailing mesh.
  143746. */
  143747. start(): void;
  143748. /**
  143749. * Stop trailing mesh.
  143750. */
  143751. stop(): void;
  143752. /**
  143753. * Update trailing mesh geometry.
  143754. */
  143755. update(): void;
  143756. /**
  143757. * Returns a new TrailMesh object.
  143758. * @param name is a string, the name given to the new mesh
  143759. * @param newGenerator use new generator object for cloned trail mesh
  143760. * @returns a new mesh
  143761. */
  143762. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143763. /**
  143764. * Serializes this trail mesh
  143765. * @param serializationObject object to write serialization to
  143766. */
  143767. serialize(serializationObject: any): void;
  143768. /**
  143769. * Parses a serialized trail mesh
  143770. * @param parsedMesh the serialized mesh
  143771. * @param scene the scene to create the trail mesh in
  143772. * @returns the created trail mesh
  143773. */
  143774. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  143775. }
  143776. }
  143777. declare module BABYLON {
  143778. /**
  143779. * Class containing static functions to help procedurally build meshes
  143780. */
  143781. export class TiledBoxBuilder {
  143782. /**
  143783. * Creates a box mesh
  143784. * 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)
  143785. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143789. * @param name defines the name of the mesh
  143790. * @param options defines the options used to create the mesh
  143791. * @param scene defines the hosting scene
  143792. * @returns the box mesh
  143793. */
  143794. static CreateTiledBox(name: string, options: {
  143795. pattern?: number;
  143796. width?: number;
  143797. height?: number;
  143798. depth?: number;
  143799. tileSize?: number;
  143800. tileWidth?: number;
  143801. tileHeight?: number;
  143802. alignHorizontal?: number;
  143803. alignVertical?: number;
  143804. faceUV?: Vector4[];
  143805. faceColors?: Color4[];
  143806. sideOrientation?: number;
  143807. updatable?: boolean;
  143808. }, scene?: Nullable<Scene>): Mesh;
  143809. }
  143810. }
  143811. declare module BABYLON {
  143812. /**
  143813. * Class containing static functions to help procedurally build meshes
  143814. */
  143815. export class TorusKnotBuilder {
  143816. /**
  143817. * Creates a torus knot mesh
  143818. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143819. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143820. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143821. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143825. * @param name defines the name of the mesh
  143826. * @param options defines the options used to create the mesh
  143827. * @param scene defines the hosting scene
  143828. * @returns the torus knot mesh
  143829. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143830. */
  143831. static CreateTorusKnot(name: string, options: {
  143832. radius?: number;
  143833. tube?: number;
  143834. radialSegments?: number;
  143835. tubularSegments?: number;
  143836. p?: number;
  143837. q?: number;
  143838. updatable?: boolean;
  143839. sideOrientation?: number;
  143840. frontUVs?: Vector4;
  143841. backUVs?: Vector4;
  143842. }, scene: any): Mesh;
  143843. }
  143844. }
  143845. declare module BABYLON {
  143846. /**
  143847. * Polygon
  143848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  143849. */
  143850. export class Polygon {
  143851. /**
  143852. * Creates a rectangle
  143853. * @param xmin bottom X coord
  143854. * @param ymin bottom Y coord
  143855. * @param xmax top X coord
  143856. * @param ymax top Y coord
  143857. * @returns points that make the resulting rectation
  143858. */
  143859. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  143860. /**
  143861. * Creates a circle
  143862. * @param radius radius of circle
  143863. * @param cx scale in x
  143864. * @param cy scale in y
  143865. * @param numberOfSides number of sides that make up the circle
  143866. * @returns points that make the resulting circle
  143867. */
  143868. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  143869. /**
  143870. * Creates a polygon from input string
  143871. * @param input Input polygon data
  143872. * @returns the parsed points
  143873. */
  143874. static Parse(input: string): Vector2[];
  143875. /**
  143876. * Starts building a polygon from x and y coordinates
  143877. * @param x x coordinate
  143878. * @param y y coordinate
  143879. * @returns the started path2
  143880. */
  143881. static StartingAt(x: number, y: number): Path2;
  143882. }
  143883. /**
  143884. * Builds a polygon
  143885. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  143886. */
  143887. export class PolygonMeshBuilder {
  143888. private _points;
  143889. private _outlinepoints;
  143890. private _holes;
  143891. private _name;
  143892. private _scene;
  143893. private _epoints;
  143894. private _eholes;
  143895. private _addToepoint;
  143896. /**
  143897. * Babylon reference to the earcut plugin.
  143898. */
  143899. bjsEarcut: any;
  143900. /**
  143901. * Creates a PolygonMeshBuilder
  143902. * @param name name of the builder
  143903. * @param contours Path of the polygon
  143904. * @param scene scene to add to when creating the mesh
  143905. * @param earcutInjection can be used to inject your own earcut reference
  143906. */
  143907. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  143908. /**
  143909. * Adds a whole within the polygon
  143910. * @param hole Array of points defining the hole
  143911. * @returns this
  143912. */
  143913. addHole(hole: Vector2[]): PolygonMeshBuilder;
  143914. /**
  143915. * Creates the polygon
  143916. * @param updatable If the mesh should be updatable
  143917. * @param depth The depth of the mesh created
  143918. * @returns the created mesh
  143919. */
  143920. build(updatable?: boolean, depth?: number): Mesh;
  143921. /**
  143922. * Creates the polygon
  143923. * @param depth The depth of the mesh created
  143924. * @returns the created VertexData
  143925. */
  143926. buildVertexData(depth?: number): VertexData;
  143927. /**
  143928. * Adds a side to the polygon
  143929. * @param positions points that make the polygon
  143930. * @param normals normals of the polygon
  143931. * @param uvs uvs of the polygon
  143932. * @param indices indices of the polygon
  143933. * @param bounds bounds of the polygon
  143934. * @param points points of the polygon
  143935. * @param depth depth of the polygon
  143936. * @param flip flip of the polygon
  143937. */
  143938. private addSide;
  143939. }
  143940. }
  143941. declare module BABYLON {
  143942. /**
  143943. * Class containing static functions to help procedurally build meshes
  143944. */
  143945. export class PolygonBuilder {
  143946. /**
  143947. * Creates a polygon mesh
  143948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143949. * * 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
  143950. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143953. * * Remember you can only change the shape positions, not their number when updating a polygon
  143954. * @param name defines the name of the mesh
  143955. * @param options defines the options used to create the mesh
  143956. * @param scene defines the hosting scene
  143957. * @param earcutInjection can be used to inject your own earcut reference
  143958. * @returns the polygon mesh
  143959. */
  143960. static CreatePolygon(name: string, options: {
  143961. shape: Vector3[];
  143962. holes?: Vector3[][];
  143963. depth?: number;
  143964. faceUV?: Vector4[];
  143965. faceColors?: Color4[];
  143966. updatable?: boolean;
  143967. sideOrientation?: number;
  143968. frontUVs?: Vector4;
  143969. backUVs?: Vector4;
  143970. wrap?: boolean;
  143971. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143972. /**
  143973. * Creates an extruded polygon mesh, with depth in the Y direction.
  143974. * * 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)
  143975. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143976. * @param name defines the name of the mesh
  143977. * @param options defines the options used to create the mesh
  143978. * @param scene defines the hosting scene
  143979. * @param earcutInjection can be used to inject your own earcut reference
  143980. * @returns the polygon mesh
  143981. */
  143982. static ExtrudePolygon(name: string, options: {
  143983. shape: Vector3[];
  143984. holes?: Vector3[][];
  143985. depth?: number;
  143986. faceUV?: Vector4[];
  143987. faceColors?: Color4[];
  143988. updatable?: boolean;
  143989. sideOrientation?: number;
  143990. frontUVs?: Vector4;
  143991. backUVs?: Vector4;
  143992. wrap?: boolean;
  143993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143994. }
  143995. }
  143996. declare module BABYLON {
  143997. /**
  143998. * Class containing static functions to help procedurally build meshes
  143999. */
  144000. export class LatheBuilder {
  144001. /**
  144002. * Creates lathe mesh.
  144003. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144004. * * 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
  144005. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144006. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144007. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144008. * * 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
  144009. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144010. * * 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
  144011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144015. * @param name defines the name of the mesh
  144016. * @param options defines the options used to create the mesh
  144017. * @param scene defines the hosting scene
  144018. * @returns the lathe mesh
  144019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144020. */
  144021. static CreateLathe(name: string, options: {
  144022. shape: Vector3[];
  144023. radius?: number;
  144024. tessellation?: number;
  144025. clip?: number;
  144026. arc?: number;
  144027. closed?: boolean;
  144028. updatable?: boolean;
  144029. sideOrientation?: number;
  144030. frontUVs?: Vector4;
  144031. backUVs?: Vector4;
  144032. cap?: number;
  144033. invertUV?: boolean;
  144034. }, scene?: Nullable<Scene>): Mesh;
  144035. }
  144036. }
  144037. declare module BABYLON {
  144038. /**
  144039. * Class containing static functions to help procedurally build meshes
  144040. */
  144041. export class TiledPlaneBuilder {
  144042. /**
  144043. * Creates a tiled plane mesh
  144044. * * The parameter `pattern` will, depending on value, do nothing or
  144045. * * * flip (reflect about central vertical) alternate tiles across and up
  144046. * * * flip every tile on alternate rows
  144047. * * * rotate (180 degs) alternate tiles across and up
  144048. * * * rotate every tile on alternate rows
  144049. * * * flip and rotate alternate tiles across and up
  144050. * * * flip and rotate every tile on alternate rows
  144051. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144052. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144055. * * 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)
  144056. * * 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)
  144057. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144058. * @param name defines the name of the mesh
  144059. * @param options defines the options used to create the mesh
  144060. * @param scene defines the hosting scene
  144061. * @returns the box mesh
  144062. */
  144063. static CreateTiledPlane(name: string, options: {
  144064. pattern?: number;
  144065. tileSize?: number;
  144066. tileWidth?: number;
  144067. tileHeight?: number;
  144068. size?: number;
  144069. width?: number;
  144070. height?: number;
  144071. alignHorizontal?: number;
  144072. alignVertical?: number;
  144073. sideOrientation?: number;
  144074. frontUVs?: Vector4;
  144075. backUVs?: Vector4;
  144076. updatable?: boolean;
  144077. }, scene?: Nullable<Scene>): Mesh;
  144078. }
  144079. }
  144080. declare module BABYLON {
  144081. /**
  144082. * Class containing static functions to help procedurally build meshes
  144083. */
  144084. export class TubeBuilder {
  144085. /**
  144086. * Creates a tube mesh.
  144087. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144088. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144089. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144090. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144091. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144092. * * 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)
  144093. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144094. * * 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
  144095. * * 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
  144096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144100. * @param name defines the name of the mesh
  144101. * @param options defines the options used to create the mesh
  144102. * @param scene defines the hosting scene
  144103. * @returns the tube mesh
  144104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144105. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144106. */
  144107. static CreateTube(name: string, options: {
  144108. path: Vector3[];
  144109. radius?: number;
  144110. tessellation?: number;
  144111. radiusFunction?: {
  144112. (i: number, distance: number): number;
  144113. };
  144114. cap?: number;
  144115. arc?: number;
  144116. updatable?: boolean;
  144117. sideOrientation?: number;
  144118. frontUVs?: Vector4;
  144119. backUVs?: Vector4;
  144120. instance?: Mesh;
  144121. invertUV?: boolean;
  144122. }, scene?: Nullable<Scene>): Mesh;
  144123. }
  144124. }
  144125. declare module BABYLON {
  144126. /**
  144127. * Class containing static functions to help procedurally build meshes
  144128. */
  144129. export class IcoSphereBuilder {
  144130. /**
  144131. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144132. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144133. * * 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`)
  144134. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144135. * * 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
  144136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144139. * @param name defines the name of the mesh
  144140. * @param options defines the options used to create the mesh
  144141. * @param scene defines the hosting scene
  144142. * @returns the icosahedron mesh
  144143. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144144. */
  144145. static CreateIcoSphere(name: string, options: {
  144146. radius?: number;
  144147. radiusX?: number;
  144148. radiusY?: number;
  144149. radiusZ?: number;
  144150. flat?: boolean;
  144151. subdivisions?: number;
  144152. sideOrientation?: number;
  144153. frontUVs?: Vector4;
  144154. backUVs?: Vector4;
  144155. updatable?: boolean;
  144156. }, scene?: Nullable<Scene>): Mesh;
  144157. }
  144158. }
  144159. declare module BABYLON {
  144160. /**
  144161. * Class containing static functions to help procedurally build meshes
  144162. */
  144163. export class DecalBuilder {
  144164. /**
  144165. * Creates a decal mesh.
  144166. * 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
  144167. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144168. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144169. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144170. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144171. * @param name defines the name of the mesh
  144172. * @param sourceMesh defines the mesh where the decal must be applied
  144173. * @param options defines the options used to create the mesh
  144174. * @param scene defines the hosting scene
  144175. * @returns the decal mesh
  144176. * @see https://doc.babylonjs.com/how_to/decals
  144177. */
  144178. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144179. position?: Vector3;
  144180. normal?: Vector3;
  144181. size?: Vector3;
  144182. angle?: number;
  144183. }): Mesh;
  144184. }
  144185. }
  144186. declare module BABYLON {
  144187. /**
  144188. * Class containing static functions to help procedurally build meshes
  144189. */
  144190. export class MeshBuilder {
  144191. /**
  144192. * Creates a box mesh
  144193. * * The parameter `size` sets the size (float) of each box side (default 1)
  144194. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144195. * * 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)
  144196. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144200. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144201. * @param name defines the name of the mesh
  144202. * @param options defines the options used to create the mesh
  144203. * @param scene defines the hosting scene
  144204. * @returns the box mesh
  144205. */
  144206. static CreateBox(name: string, options: {
  144207. size?: number;
  144208. width?: number;
  144209. height?: number;
  144210. depth?: number;
  144211. faceUV?: Vector4[];
  144212. faceColors?: Color4[];
  144213. sideOrientation?: number;
  144214. frontUVs?: Vector4;
  144215. backUVs?: Vector4;
  144216. wrap?: boolean;
  144217. topBaseAt?: number;
  144218. bottomBaseAt?: number;
  144219. updatable?: boolean;
  144220. }, scene?: Nullable<Scene>): Mesh;
  144221. /**
  144222. * Creates a tiled box mesh
  144223. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144225. * @param name defines the name of the mesh
  144226. * @param options defines the options used to create the mesh
  144227. * @param scene defines the hosting scene
  144228. * @returns the tiled box mesh
  144229. */
  144230. static CreateTiledBox(name: string, options: {
  144231. pattern?: number;
  144232. size?: number;
  144233. width?: number;
  144234. height?: number;
  144235. depth: number;
  144236. tileSize?: number;
  144237. tileWidth?: number;
  144238. tileHeight?: number;
  144239. faceUV?: Vector4[];
  144240. faceColors?: Color4[];
  144241. alignHorizontal?: number;
  144242. alignVertical?: number;
  144243. sideOrientation?: number;
  144244. updatable?: boolean;
  144245. }, scene?: Nullable<Scene>): Mesh;
  144246. /**
  144247. * Creates a sphere mesh
  144248. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144249. * * 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`)
  144250. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144251. * * 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
  144252. * * 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)
  144253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144256. * @param name defines the name of the mesh
  144257. * @param options defines the options used to create the mesh
  144258. * @param scene defines the hosting scene
  144259. * @returns the sphere mesh
  144260. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144261. */
  144262. static CreateSphere(name: string, options: {
  144263. segments?: number;
  144264. diameter?: number;
  144265. diameterX?: number;
  144266. diameterY?: number;
  144267. diameterZ?: number;
  144268. arc?: number;
  144269. slice?: number;
  144270. sideOrientation?: number;
  144271. frontUVs?: Vector4;
  144272. backUVs?: Vector4;
  144273. updatable?: boolean;
  144274. }, scene?: Nullable<Scene>): Mesh;
  144275. /**
  144276. * Creates a plane polygonal mesh. By default, this is a disc
  144277. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144278. * * 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
  144279. * * 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
  144280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144283. * @param name defines the name of the mesh
  144284. * @param options defines the options used to create the mesh
  144285. * @param scene defines the hosting scene
  144286. * @returns the plane polygonal mesh
  144287. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144288. */
  144289. static CreateDisc(name: string, options: {
  144290. radius?: number;
  144291. tessellation?: number;
  144292. arc?: number;
  144293. updatable?: boolean;
  144294. sideOrientation?: number;
  144295. frontUVs?: Vector4;
  144296. backUVs?: Vector4;
  144297. }, scene?: Nullable<Scene>): Mesh;
  144298. /**
  144299. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144300. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144301. * * 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`)
  144302. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144303. * * 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
  144304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144307. * @param name defines the name of the mesh
  144308. * @param options defines the options used to create the mesh
  144309. * @param scene defines the hosting scene
  144310. * @returns the icosahedron mesh
  144311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144312. */
  144313. static CreateIcoSphere(name: string, options: {
  144314. radius?: number;
  144315. radiusX?: number;
  144316. radiusY?: number;
  144317. radiusZ?: number;
  144318. flat?: boolean;
  144319. subdivisions?: number;
  144320. sideOrientation?: number;
  144321. frontUVs?: Vector4;
  144322. backUVs?: Vector4;
  144323. updatable?: boolean;
  144324. }, scene?: Nullable<Scene>): Mesh;
  144325. /**
  144326. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144327. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144328. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144329. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144330. * * 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
  144331. * * 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
  144332. * * 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
  144333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144336. * * 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
  144337. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144338. * * 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
  144339. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144341. * @param name defines the name of the mesh
  144342. * @param options defines the options used to create the mesh
  144343. * @param scene defines the hosting scene
  144344. * @returns the ribbon mesh
  144345. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144347. */
  144348. static CreateRibbon(name: string, options: {
  144349. pathArray: Vector3[][];
  144350. closeArray?: boolean;
  144351. closePath?: boolean;
  144352. offset?: number;
  144353. updatable?: boolean;
  144354. sideOrientation?: number;
  144355. frontUVs?: Vector4;
  144356. backUVs?: Vector4;
  144357. instance?: Mesh;
  144358. invertUV?: boolean;
  144359. uvs?: Vector2[];
  144360. colors?: Color4[];
  144361. }, scene?: Nullable<Scene>): Mesh;
  144362. /**
  144363. * Creates a cylinder or a cone mesh
  144364. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144365. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144366. * * 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.
  144367. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144368. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144369. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144370. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144371. * * 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).
  144372. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144373. * * 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).
  144374. * * 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
  144375. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144376. * * 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
  144377. * * 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.
  144378. * * If `enclose` is false, a ring surface is one element.
  144379. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144380. * * 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
  144381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144384. * @param name defines the name of the mesh
  144385. * @param options defines the options used to create the mesh
  144386. * @param scene defines the hosting scene
  144387. * @returns the cylinder mesh
  144388. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144389. */
  144390. static CreateCylinder(name: string, options: {
  144391. height?: number;
  144392. diameterTop?: number;
  144393. diameterBottom?: number;
  144394. diameter?: number;
  144395. tessellation?: number;
  144396. subdivisions?: number;
  144397. arc?: number;
  144398. faceColors?: Color4[];
  144399. faceUV?: Vector4[];
  144400. updatable?: boolean;
  144401. hasRings?: boolean;
  144402. enclose?: boolean;
  144403. cap?: number;
  144404. sideOrientation?: number;
  144405. frontUVs?: Vector4;
  144406. backUVs?: Vector4;
  144407. }, scene?: Nullable<Scene>): Mesh;
  144408. /**
  144409. * Creates a torus mesh
  144410. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144411. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144412. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144416. * @param name defines the name of the mesh
  144417. * @param options defines the options used to create the mesh
  144418. * @param scene defines the hosting scene
  144419. * @returns the torus mesh
  144420. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144421. */
  144422. static CreateTorus(name: string, options: {
  144423. diameter?: number;
  144424. thickness?: number;
  144425. tessellation?: number;
  144426. updatable?: boolean;
  144427. sideOrientation?: number;
  144428. frontUVs?: Vector4;
  144429. backUVs?: Vector4;
  144430. }, scene?: Nullable<Scene>): Mesh;
  144431. /**
  144432. * Creates a torus knot mesh
  144433. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144434. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144435. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144436. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144440. * @param name defines the name of the mesh
  144441. * @param options defines the options used to create the mesh
  144442. * @param scene defines the hosting scene
  144443. * @returns the torus knot mesh
  144444. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144445. */
  144446. static CreateTorusKnot(name: string, options: {
  144447. radius?: number;
  144448. tube?: number;
  144449. radialSegments?: number;
  144450. tubularSegments?: number;
  144451. p?: number;
  144452. q?: number;
  144453. updatable?: boolean;
  144454. sideOrientation?: number;
  144455. frontUVs?: Vector4;
  144456. backUVs?: Vector4;
  144457. }, scene?: Nullable<Scene>): Mesh;
  144458. /**
  144459. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144460. * * 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
  144461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144462. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144463. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144464. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144466. * * 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
  144467. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144470. * @param name defines the name of the new line system
  144471. * @param options defines the options used to create the line system
  144472. * @param scene defines the hosting scene
  144473. * @returns a new line system mesh
  144474. */
  144475. static CreateLineSystem(name: string, options: {
  144476. lines: Vector3[][];
  144477. updatable?: boolean;
  144478. instance?: Nullable<LinesMesh>;
  144479. colors?: Nullable<Color4[][]>;
  144480. useVertexAlpha?: boolean;
  144481. }, scene: Nullable<Scene>): LinesMesh;
  144482. /**
  144483. * Creates a line mesh
  144484. * 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
  144485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144486. * * The parameter `points` is an array successive Vector3
  144487. * * 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
  144488. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144489. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144490. * * When updating an instance, remember that only point positions can change, not the number of points
  144491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144493. * @param name defines the name of the new line system
  144494. * @param options defines the options used to create the line system
  144495. * @param scene defines the hosting scene
  144496. * @returns a new line mesh
  144497. */
  144498. static CreateLines(name: string, options: {
  144499. points: Vector3[];
  144500. updatable?: boolean;
  144501. instance?: Nullable<LinesMesh>;
  144502. colors?: Color4[];
  144503. useVertexAlpha?: boolean;
  144504. }, scene?: Nullable<Scene>): LinesMesh;
  144505. /**
  144506. * Creates a dashed line mesh
  144507. * * 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
  144508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144509. * * The parameter `points` is an array successive Vector3
  144510. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144511. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144512. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144513. * * 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
  144514. * * When updating an instance, remember that only point positions can change, not the number of points
  144515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144516. * @param name defines the name of the mesh
  144517. * @param options defines the options used to create the mesh
  144518. * @param scene defines the hosting scene
  144519. * @returns the dashed line mesh
  144520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144521. */
  144522. static CreateDashedLines(name: string, options: {
  144523. points: Vector3[];
  144524. dashSize?: number;
  144525. gapSize?: number;
  144526. dashNb?: number;
  144527. updatable?: boolean;
  144528. instance?: LinesMesh;
  144529. }, scene?: Nullable<Scene>): LinesMesh;
  144530. /**
  144531. * 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.
  144532. * * 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.
  144533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144534. * * 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.
  144535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144536. * * 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
  144537. * * 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
  144538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144543. * @param name defines the name of the mesh
  144544. * @param options defines the options used to create the mesh
  144545. * @param scene defines the hosting scene
  144546. * @returns the extruded shape mesh
  144547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144549. */
  144550. static ExtrudeShape(name: string, options: {
  144551. shape: Vector3[];
  144552. path: Vector3[];
  144553. scale?: number;
  144554. rotation?: number;
  144555. cap?: number;
  144556. updatable?: boolean;
  144557. sideOrientation?: number;
  144558. frontUVs?: Vector4;
  144559. backUVs?: Vector4;
  144560. instance?: Mesh;
  144561. invertUV?: boolean;
  144562. }, scene?: Nullable<Scene>): Mesh;
  144563. /**
  144564. * Creates an custom extruded shape mesh.
  144565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144566. * * 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.
  144567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144568. * * 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
  144569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144570. * * 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
  144571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144574. * * 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
  144575. * * 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
  144576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144581. * @param name defines the name of the mesh
  144582. * @param options defines the options used to create the mesh
  144583. * @param scene defines the hosting scene
  144584. * @returns the custom extruded shape mesh
  144585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144588. */
  144589. static ExtrudeShapeCustom(name: string, options: {
  144590. shape: Vector3[];
  144591. path: Vector3[];
  144592. scaleFunction?: any;
  144593. rotationFunction?: any;
  144594. ribbonCloseArray?: boolean;
  144595. ribbonClosePath?: boolean;
  144596. cap?: number;
  144597. updatable?: boolean;
  144598. sideOrientation?: number;
  144599. frontUVs?: Vector4;
  144600. backUVs?: Vector4;
  144601. instance?: Mesh;
  144602. invertUV?: boolean;
  144603. }, scene?: Nullable<Scene>): Mesh;
  144604. /**
  144605. * Creates lathe mesh.
  144606. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144607. * * 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
  144608. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144609. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144610. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144611. * * 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
  144612. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144613. * * 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
  144614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144616. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144618. * @param name defines the name of the mesh
  144619. * @param options defines the options used to create the mesh
  144620. * @param scene defines the hosting scene
  144621. * @returns the lathe mesh
  144622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144623. */
  144624. static CreateLathe(name: string, options: {
  144625. shape: Vector3[];
  144626. radius?: number;
  144627. tessellation?: number;
  144628. clip?: number;
  144629. arc?: number;
  144630. closed?: boolean;
  144631. updatable?: boolean;
  144632. sideOrientation?: number;
  144633. frontUVs?: Vector4;
  144634. backUVs?: Vector4;
  144635. cap?: number;
  144636. invertUV?: boolean;
  144637. }, scene?: Nullable<Scene>): Mesh;
  144638. /**
  144639. * Creates a tiled plane mesh
  144640. * * You can set a limited pattern arrangement with the tiles
  144641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144644. * @param name defines the name of the mesh
  144645. * @param options defines the options used to create the mesh
  144646. * @param scene defines the hosting scene
  144647. * @returns the plane mesh
  144648. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144649. */
  144650. static CreateTiledPlane(name: string, options: {
  144651. pattern?: number;
  144652. tileSize?: number;
  144653. tileWidth?: number;
  144654. tileHeight?: number;
  144655. size?: number;
  144656. width?: number;
  144657. height?: number;
  144658. alignHorizontal?: number;
  144659. alignVertical?: number;
  144660. sideOrientation?: number;
  144661. frontUVs?: Vector4;
  144662. backUVs?: Vector4;
  144663. updatable?: boolean;
  144664. }, scene?: Nullable<Scene>): Mesh;
  144665. /**
  144666. * Creates a plane mesh
  144667. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144668. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144669. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144673. * @param name defines the name of the mesh
  144674. * @param options defines the options used to create the mesh
  144675. * @param scene defines the hosting scene
  144676. * @returns the plane mesh
  144677. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144678. */
  144679. static CreatePlane(name: string, options: {
  144680. size?: number;
  144681. width?: number;
  144682. height?: number;
  144683. sideOrientation?: number;
  144684. frontUVs?: Vector4;
  144685. backUVs?: Vector4;
  144686. updatable?: boolean;
  144687. sourcePlane?: Plane;
  144688. }, scene?: Nullable<Scene>): Mesh;
  144689. /**
  144690. * Creates a ground mesh
  144691. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144692. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144694. * @param name defines the name of the mesh
  144695. * @param options defines the options used to create the mesh
  144696. * @param scene defines the hosting scene
  144697. * @returns the ground mesh
  144698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144699. */
  144700. static CreateGround(name: string, options: {
  144701. width?: number;
  144702. height?: number;
  144703. subdivisions?: number;
  144704. subdivisionsX?: number;
  144705. subdivisionsY?: number;
  144706. updatable?: boolean;
  144707. }, scene?: Nullable<Scene>): Mesh;
  144708. /**
  144709. * Creates a tiled ground mesh
  144710. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144711. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144712. * * 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
  144713. * * 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
  144714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144715. * @param name defines the name of the mesh
  144716. * @param options defines the options used to create the mesh
  144717. * @param scene defines the hosting scene
  144718. * @returns the tiled ground mesh
  144719. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144720. */
  144721. static CreateTiledGround(name: string, options: {
  144722. xmin: number;
  144723. zmin: number;
  144724. xmax: number;
  144725. zmax: number;
  144726. subdivisions?: {
  144727. w: number;
  144728. h: number;
  144729. };
  144730. precision?: {
  144731. w: number;
  144732. h: number;
  144733. };
  144734. updatable?: boolean;
  144735. }, scene?: Nullable<Scene>): Mesh;
  144736. /**
  144737. * Creates a ground mesh from a height map
  144738. * * The parameter `url` sets the URL of the height map image resource.
  144739. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144740. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144741. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144742. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144743. * * 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.
  144744. * * 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).
  144745. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144747. * @param name defines the name of the mesh
  144748. * @param url defines the url to the height map
  144749. * @param options defines the options used to create the mesh
  144750. * @param scene defines the hosting scene
  144751. * @returns the ground mesh
  144752. * @see https://doc.babylonjs.com/babylon101/height_map
  144753. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144754. */
  144755. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144756. width?: number;
  144757. height?: number;
  144758. subdivisions?: number;
  144759. minHeight?: number;
  144760. maxHeight?: number;
  144761. colorFilter?: Color3;
  144762. alphaFilter?: number;
  144763. updatable?: boolean;
  144764. onReady?: (mesh: GroundMesh) => void;
  144765. }, scene?: Nullable<Scene>): GroundMesh;
  144766. /**
  144767. * Creates a polygon mesh
  144768. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144769. * * 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
  144770. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144773. * * Remember you can only change the shape positions, not their number when updating a polygon
  144774. * @param name defines the name of the mesh
  144775. * @param options defines the options used to create the mesh
  144776. * @param scene defines the hosting scene
  144777. * @param earcutInjection can be used to inject your own earcut reference
  144778. * @returns the polygon mesh
  144779. */
  144780. static CreatePolygon(name: string, options: {
  144781. shape: Vector3[];
  144782. holes?: Vector3[][];
  144783. depth?: number;
  144784. faceUV?: Vector4[];
  144785. faceColors?: Color4[];
  144786. updatable?: boolean;
  144787. sideOrientation?: number;
  144788. frontUVs?: Vector4;
  144789. backUVs?: Vector4;
  144790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144791. /**
  144792. * Creates an extruded polygon mesh, with depth in the Y direction.
  144793. * * 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)
  144794. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144795. * @param name defines the name of the mesh
  144796. * @param options defines the options used to create the mesh
  144797. * @param scene defines the hosting scene
  144798. * @param earcutInjection can be used to inject your own earcut reference
  144799. * @returns the polygon mesh
  144800. */
  144801. static ExtrudePolygon(name: string, options: {
  144802. shape: Vector3[];
  144803. holes?: Vector3[][];
  144804. depth?: number;
  144805. faceUV?: Vector4[];
  144806. faceColors?: Color4[];
  144807. updatable?: boolean;
  144808. sideOrientation?: number;
  144809. frontUVs?: Vector4;
  144810. backUVs?: Vector4;
  144811. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144812. /**
  144813. * Creates a tube mesh.
  144814. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144815. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144816. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144817. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144818. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144819. * * 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)
  144820. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144821. * * 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
  144822. * * 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
  144823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144827. * @param name defines the name of the mesh
  144828. * @param options defines the options used to create the mesh
  144829. * @param scene defines the hosting scene
  144830. * @returns the tube mesh
  144831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144832. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144833. */
  144834. static CreateTube(name: string, options: {
  144835. path: Vector3[];
  144836. radius?: number;
  144837. tessellation?: number;
  144838. radiusFunction?: {
  144839. (i: number, distance: number): number;
  144840. };
  144841. cap?: number;
  144842. arc?: number;
  144843. updatable?: boolean;
  144844. sideOrientation?: number;
  144845. frontUVs?: Vector4;
  144846. backUVs?: Vector4;
  144847. instance?: Mesh;
  144848. invertUV?: boolean;
  144849. }, scene?: Nullable<Scene>): Mesh;
  144850. /**
  144851. * Creates a polyhedron mesh
  144852. * * 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
  144853. * * The parameter `size` (positive float, default 1) sets the polygon size
  144854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  144855. * * 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`
  144856. * * 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
  144857. * * 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)`)
  144858. * * 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
  144859. * * 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
  144860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144863. * @param name defines the name of the mesh
  144864. * @param options defines the options used to create the mesh
  144865. * @param scene defines the hosting scene
  144866. * @returns the polyhedron mesh
  144867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  144868. */
  144869. static CreatePolyhedron(name: string, options: {
  144870. type?: number;
  144871. size?: number;
  144872. sizeX?: number;
  144873. sizeY?: number;
  144874. sizeZ?: number;
  144875. custom?: any;
  144876. faceUV?: Vector4[];
  144877. faceColors?: Color4[];
  144878. flat?: boolean;
  144879. updatable?: boolean;
  144880. sideOrientation?: number;
  144881. frontUVs?: Vector4;
  144882. backUVs?: Vector4;
  144883. }, scene?: Nullable<Scene>): Mesh;
  144884. /**
  144885. * Creates a decal mesh.
  144886. * 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
  144887. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144888. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144889. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144890. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144891. * @param name defines the name of the mesh
  144892. * @param sourceMesh defines the mesh where the decal must be applied
  144893. * @param options defines the options used to create the mesh
  144894. * @param scene defines the hosting scene
  144895. * @returns the decal mesh
  144896. * @see https://doc.babylonjs.com/how_to/decals
  144897. */
  144898. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144899. position?: Vector3;
  144900. normal?: Vector3;
  144901. size?: Vector3;
  144902. angle?: number;
  144903. }): Mesh;
  144904. }
  144905. }
  144906. declare module BABYLON {
  144907. /**
  144908. * A simplifier interface for future simplification implementations
  144909. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144910. */
  144911. export interface ISimplifier {
  144912. /**
  144913. * Simplification of a given mesh according to the given settings.
  144914. * Since this requires computation, it is assumed that the function runs async.
  144915. * @param settings The settings of the simplification, including quality and distance
  144916. * @param successCallback A callback that will be called after the mesh was simplified.
  144917. * @param errorCallback in case of an error, this callback will be called. optional.
  144918. */
  144919. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  144920. }
  144921. /**
  144922. * Expected simplification settings.
  144923. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  144924. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144925. */
  144926. export interface ISimplificationSettings {
  144927. /**
  144928. * Gets or sets the expected quality
  144929. */
  144930. quality: number;
  144931. /**
  144932. * Gets or sets the distance when this optimized version should be used
  144933. */
  144934. distance: number;
  144935. /**
  144936. * Gets an already optimized mesh
  144937. */
  144938. optimizeMesh?: boolean;
  144939. }
  144940. /**
  144941. * Class used to specify simplification options
  144942. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144943. */
  144944. export class SimplificationSettings implements ISimplificationSettings {
  144945. /** expected quality */
  144946. quality: number;
  144947. /** distance when this optimized version should be used */
  144948. distance: number;
  144949. /** already optimized mesh */
  144950. optimizeMesh?: boolean | undefined;
  144951. /**
  144952. * Creates a SimplificationSettings
  144953. * @param quality expected quality
  144954. * @param distance distance when this optimized version should be used
  144955. * @param optimizeMesh already optimized mesh
  144956. */
  144957. constructor(
  144958. /** expected quality */
  144959. quality: number,
  144960. /** distance when this optimized version should be used */
  144961. distance: number,
  144962. /** already optimized mesh */
  144963. optimizeMesh?: boolean | undefined);
  144964. }
  144965. /**
  144966. * Interface used to define a simplification task
  144967. */
  144968. export interface ISimplificationTask {
  144969. /**
  144970. * Array of settings
  144971. */
  144972. settings: Array<ISimplificationSettings>;
  144973. /**
  144974. * Simplification type
  144975. */
  144976. simplificationType: SimplificationType;
  144977. /**
  144978. * Mesh to simplify
  144979. */
  144980. mesh: Mesh;
  144981. /**
  144982. * Callback called on success
  144983. */
  144984. successCallback?: () => void;
  144985. /**
  144986. * Defines if parallel processing can be used
  144987. */
  144988. parallelProcessing: boolean;
  144989. }
  144990. /**
  144991. * Queue used to order the simplification tasks
  144992. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144993. */
  144994. export class SimplificationQueue {
  144995. private _simplificationArray;
  144996. /**
  144997. * Gets a boolean indicating that the process is still running
  144998. */
  144999. running: boolean;
  145000. /**
  145001. * Creates a new queue
  145002. */
  145003. constructor();
  145004. /**
  145005. * Adds a new simplification task
  145006. * @param task defines a task to add
  145007. */
  145008. addTask(task: ISimplificationTask): void;
  145009. /**
  145010. * Execute next task
  145011. */
  145012. executeNext(): void;
  145013. /**
  145014. * Execute a simplification task
  145015. * @param task defines the task to run
  145016. */
  145017. runSimplification(task: ISimplificationTask): void;
  145018. private getSimplifier;
  145019. }
  145020. /**
  145021. * The implemented types of simplification
  145022. * At the moment only Quadratic Error Decimation is implemented
  145023. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145024. */
  145025. export enum SimplificationType {
  145026. /** Quadratic error decimation */
  145027. QUADRATIC = 0
  145028. }
  145029. /**
  145030. * An implementation of the Quadratic Error simplification algorithm.
  145031. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145032. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145033. * @author RaananW
  145034. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145035. */
  145036. export class QuadraticErrorSimplification implements ISimplifier {
  145037. private _mesh;
  145038. private triangles;
  145039. private vertices;
  145040. private references;
  145041. private _reconstructedMesh;
  145042. /** Gets or sets the number pf sync interations */
  145043. syncIterations: number;
  145044. /** Gets or sets the aggressiveness of the simplifier */
  145045. aggressiveness: number;
  145046. /** Gets or sets the number of allowed iterations for decimation */
  145047. decimationIterations: number;
  145048. /** Gets or sets the espilon to use for bounding box computation */
  145049. boundingBoxEpsilon: number;
  145050. /**
  145051. * Creates a new QuadraticErrorSimplification
  145052. * @param _mesh defines the target mesh
  145053. */
  145054. constructor(_mesh: Mesh);
  145055. /**
  145056. * Simplification of a given mesh according to the given settings.
  145057. * Since this requires computation, it is assumed that the function runs async.
  145058. * @param settings The settings of the simplification, including quality and distance
  145059. * @param successCallback A callback that will be called after the mesh was simplified.
  145060. */
  145061. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145062. private runDecimation;
  145063. private initWithMesh;
  145064. private init;
  145065. private reconstructMesh;
  145066. private initDecimatedMesh;
  145067. private isFlipped;
  145068. private updateTriangles;
  145069. private identifyBorder;
  145070. private updateMesh;
  145071. private vertexError;
  145072. private calculateError;
  145073. }
  145074. }
  145075. declare module BABYLON {
  145076. interface Scene {
  145077. /** @hidden (Backing field) */
  145078. _simplificationQueue: SimplificationQueue;
  145079. /**
  145080. * Gets or sets the simplification queue attached to the scene
  145081. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145082. */
  145083. simplificationQueue: SimplificationQueue;
  145084. }
  145085. interface Mesh {
  145086. /**
  145087. * Simplify the mesh according to the given array of settings.
  145088. * Function will return immediately and will simplify async
  145089. * @param settings a collection of simplification settings
  145090. * @param parallelProcessing should all levels calculate parallel or one after the other
  145091. * @param simplificationType the type of simplification to run
  145092. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145093. * @returns the current mesh
  145094. */
  145095. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145096. }
  145097. /**
  145098. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145099. * created in a scene
  145100. */
  145101. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145102. /**
  145103. * The component name helpfull to identify the component in the list of scene components.
  145104. */
  145105. readonly name: string;
  145106. /**
  145107. * The scene the component belongs to.
  145108. */
  145109. scene: Scene;
  145110. /**
  145111. * Creates a new instance of the component for the given scene
  145112. * @param scene Defines the scene to register the component in
  145113. */
  145114. constructor(scene: Scene);
  145115. /**
  145116. * Registers the component in a given scene
  145117. */
  145118. register(): void;
  145119. /**
  145120. * Rebuilds the elements related to this component in case of
  145121. * context lost for instance.
  145122. */
  145123. rebuild(): void;
  145124. /**
  145125. * Disposes the component and the associated ressources
  145126. */
  145127. dispose(): void;
  145128. private _beforeCameraUpdate;
  145129. }
  145130. }
  145131. declare module BABYLON {
  145132. interface Mesh {
  145133. /**
  145134. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145135. */
  145136. thinInstanceEnablePicking: boolean;
  145137. /**
  145138. * Creates a new thin instance
  145139. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145140. * @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
  145141. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145142. */
  145143. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145144. /**
  145145. * Adds the transformation (matrix) of the current mesh as a thin instance
  145146. * @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
  145147. * @returns the thin instance index number
  145148. */
  145149. thinInstanceAddSelf(refresh: boolean): number;
  145150. /**
  145151. * Registers a custom attribute to be used with thin instances
  145152. * @param kind name of the attribute
  145153. * @param stride size in floats of the attribute
  145154. */
  145155. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145156. /**
  145157. * Sets the matrix of a thin instance
  145158. * @param index index of the thin instance
  145159. * @param matrix matrix to set
  145160. * @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
  145161. */
  145162. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145163. /**
  145164. * Sets the value of a custom attribute for a thin instance
  145165. * @param kind name of the attribute
  145166. * @param index index of the thin instance
  145167. * @param value value to set
  145168. * @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
  145169. */
  145170. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145171. /**
  145172. * 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.
  145173. */
  145174. thinInstanceCount: number;
  145175. /**
  145176. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145177. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145178. * @param buffer buffer to set
  145179. * @param stride size in floats of each value of the buffer
  145180. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145181. */
  145182. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145183. /**
  145184. * Gets the list of world matrices
  145185. * @return an array containing all the world matrices from the thin instances
  145186. */
  145187. thinInstanceGetWorldMatrices(): Matrix[];
  145188. /**
  145189. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145190. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145191. */
  145192. thinInstanceBufferUpdated(kind: string): void;
  145193. /**
  145194. * Refreshes the bounding info, taking into account all the thin instances defined
  145195. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145196. */
  145197. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145198. /** @hidden */
  145199. _thinInstanceInitializeUserStorage(): void;
  145200. /** @hidden */
  145201. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145202. /** @hidden */
  145203. _userThinInstanceBuffersStorage: {
  145204. data: {
  145205. [key: string]: Float32Array;
  145206. };
  145207. sizes: {
  145208. [key: string]: number;
  145209. };
  145210. vertexBuffers: {
  145211. [key: string]: Nullable<VertexBuffer>;
  145212. };
  145213. strides: {
  145214. [key: string]: number;
  145215. };
  145216. };
  145217. }
  145218. }
  145219. declare module BABYLON {
  145220. /**
  145221. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145222. */
  145223. export interface INavigationEnginePlugin {
  145224. /**
  145225. * plugin name
  145226. */
  145227. name: string;
  145228. /**
  145229. * Creates a navigation mesh
  145230. * @param meshes array of all the geometry used to compute the navigatio mesh
  145231. * @param parameters bunch of parameters used to filter geometry
  145232. */
  145233. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145234. /**
  145235. * Create a navigation mesh debug mesh
  145236. * @param scene is where the mesh will be added
  145237. * @returns debug display mesh
  145238. */
  145239. createDebugNavMesh(scene: Scene): Mesh;
  145240. /**
  145241. * Get a navigation mesh constrained position, closest to the parameter position
  145242. * @param position world position
  145243. * @returns the closest point to position constrained by the navigation mesh
  145244. */
  145245. getClosestPoint(position: Vector3): Vector3;
  145246. /**
  145247. * Get a navigation mesh constrained position, closest to the parameter position
  145248. * @param position world position
  145249. * @param result output the closest point to position constrained by the navigation mesh
  145250. */
  145251. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145252. /**
  145253. * Get a navigation mesh constrained position, within a particular radius
  145254. * @param position world position
  145255. * @param maxRadius the maximum distance to the constrained world position
  145256. * @returns the closest point to position constrained by the navigation mesh
  145257. */
  145258. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145259. /**
  145260. * Get a navigation mesh constrained position, within a particular radius
  145261. * @param position world position
  145262. * @param maxRadius the maximum distance to the constrained world position
  145263. * @param result output the closest point to position constrained by the navigation mesh
  145264. */
  145265. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145266. /**
  145267. * Compute the final position from a segment made of destination-position
  145268. * @param position world position
  145269. * @param destination world position
  145270. * @returns the resulting point along the navmesh
  145271. */
  145272. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145273. /**
  145274. * Compute the final position from a segment made of destination-position
  145275. * @param position world position
  145276. * @param destination world position
  145277. * @param result output the resulting point along the navmesh
  145278. */
  145279. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145280. /**
  145281. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145282. * @param start world position
  145283. * @param end world position
  145284. * @returns array containing world position composing the path
  145285. */
  145286. computePath(start: Vector3, end: Vector3): Vector3[];
  145287. /**
  145288. * If this plugin is supported
  145289. * @returns true if plugin is supported
  145290. */
  145291. isSupported(): boolean;
  145292. /**
  145293. * Create a new Crowd so you can add agents
  145294. * @param maxAgents the maximum agent count in the crowd
  145295. * @param maxAgentRadius the maximum radius an agent can have
  145296. * @param scene to attach the crowd to
  145297. * @returns the crowd you can add agents to
  145298. */
  145299. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145300. /**
  145301. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145302. * The queries will try to find a solution within those bounds
  145303. * default is (1,1,1)
  145304. * @param extent x,y,z value that define the extent around the queries point of reference
  145305. */
  145306. setDefaultQueryExtent(extent: Vector3): void;
  145307. /**
  145308. * Get the Bounding box extent specified by setDefaultQueryExtent
  145309. * @returns the box extent values
  145310. */
  145311. getDefaultQueryExtent(): Vector3;
  145312. /**
  145313. * build the navmesh from a previously saved state using getNavmeshData
  145314. * @param data the Uint8Array returned by getNavmeshData
  145315. */
  145316. buildFromNavmeshData(data: Uint8Array): void;
  145317. /**
  145318. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145319. * @returns data the Uint8Array that can be saved and reused
  145320. */
  145321. getNavmeshData(): Uint8Array;
  145322. /**
  145323. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145324. * @param result output the box extent values
  145325. */
  145326. getDefaultQueryExtentToRef(result: Vector3): void;
  145327. /**
  145328. * Release all resources
  145329. */
  145330. dispose(): void;
  145331. }
  145332. /**
  145333. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145334. */
  145335. export interface ICrowd {
  145336. /**
  145337. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145338. * You can attach anything to that node. The node position is updated in the scene update tick.
  145339. * @param pos world position that will be constrained by the navigation mesh
  145340. * @param parameters agent parameters
  145341. * @param transform hooked to the agent that will be update by the scene
  145342. * @returns agent index
  145343. */
  145344. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145345. /**
  145346. * Returns the agent position in world space
  145347. * @param index agent index returned by addAgent
  145348. * @returns world space position
  145349. */
  145350. getAgentPosition(index: number): Vector3;
  145351. /**
  145352. * Gets the agent position result in world space
  145353. * @param index agent index returned by addAgent
  145354. * @param result output world space position
  145355. */
  145356. getAgentPositionToRef(index: number, result: Vector3): void;
  145357. /**
  145358. * Gets the agent velocity in world space
  145359. * @param index agent index returned by addAgent
  145360. * @returns world space velocity
  145361. */
  145362. getAgentVelocity(index: number): Vector3;
  145363. /**
  145364. * Gets the agent velocity result in world space
  145365. * @param index agent index returned by addAgent
  145366. * @param result output world space velocity
  145367. */
  145368. getAgentVelocityToRef(index: number, result: Vector3): void;
  145369. /**
  145370. * remove a particular agent previously created
  145371. * @param index agent index returned by addAgent
  145372. */
  145373. removeAgent(index: number): void;
  145374. /**
  145375. * get the list of all agents attached to this crowd
  145376. * @returns list of agent indices
  145377. */
  145378. getAgents(): number[];
  145379. /**
  145380. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145381. * @param deltaTime in seconds
  145382. */
  145383. update(deltaTime: number): void;
  145384. /**
  145385. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145386. * @param index agent index returned by addAgent
  145387. * @param destination targeted world position
  145388. */
  145389. agentGoto(index: number, destination: Vector3): void;
  145390. /**
  145391. * Teleport the agent to a new position
  145392. * @param index agent index returned by addAgent
  145393. * @param destination targeted world position
  145394. */
  145395. agentTeleport(index: number, destination: Vector3): void;
  145396. /**
  145397. * Update agent parameters
  145398. * @param index agent index returned by addAgent
  145399. * @param parameters agent parameters
  145400. */
  145401. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145402. /**
  145403. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145404. * The queries will try to find a solution within those bounds
  145405. * default is (1,1,1)
  145406. * @param extent x,y,z value that define the extent around the queries point of reference
  145407. */
  145408. setDefaultQueryExtent(extent: Vector3): void;
  145409. /**
  145410. * Get the Bounding box extent specified by setDefaultQueryExtent
  145411. * @returns the box extent values
  145412. */
  145413. getDefaultQueryExtent(): Vector3;
  145414. /**
  145415. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145416. * @param result output the box extent values
  145417. */
  145418. getDefaultQueryExtentToRef(result: Vector3): void;
  145419. /**
  145420. * Release all resources
  145421. */
  145422. dispose(): void;
  145423. }
  145424. /**
  145425. * Configures an agent
  145426. */
  145427. export interface IAgentParameters {
  145428. /**
  145429. * Agent radius. [Limit: >= 0]
  145430. */
  145431. radius: number;
  145432. /**
  145433. * Agent height. [Limit: > 0]
  145434. */
  145435. height: number;
  145436. /**
  145437. * Maximum allowed acceleration. [Limit: >= 0]
  145438. */
  145439. maxAcceleration: number;
  145440. /**
  145441. * Maximum allowed speed. [Limit: >= 0]
  145442. */
  145443. maxSpeed: number;
  145444. /**
  145445. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145446. */
  145447. collisionQueryRange: number;
  145448. /**
  145449. * The path visibility optimization range. [Limit: > 0]
  145450. */
  145451. pathOptimizationRange: number;
  145452. /**
  145453. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145454. */
  145455. separationWeight: number;
  145456. }
  145457. /**
  145458. * Configures the navigation mesh creation
  145459. */
  145460. export interface INavMeshParameters {
  145461. /**
  145462. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145463. */
  145464. cs: number;
  145465. /**
  145466. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145467. */
  145468. ch: number;
  145469. /**
  145470. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145471. */
  145472. walkableSlopeAngle: number;
  145473. /**
  145474. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145475. * be considered walkable. [Limit: >= 3] [Units: vx]
  145476. */
  145477. walkableHeight: number;
  145478. /**
  145479. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145480. */
  145481. walkableClimb: number;
  145482. /**
  145483. * The distance to erode/shrink the walkable area of the heightfield away from
  145484. * obstructions. [Limit: >=0] [Units: vx]
  145485. */
  145486. walkableRadius: number;
  145487. /**
  145488. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145489. */
  145490. maxEdgeLen: number;
  145491. /**
  145492. * The maximum distance a simplfied contour's border edges should deviate
  145493. * the original raw contour. [Limit: >=0] [Units: vx]
  145494. */
  145495. maxSimplificationError: number;
  145496. /**
  145497. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145498. */
  145499. minRegionArea: number;
  145500. /**
  145501. * Any regions with a span count smaller than this value will, if possible,
  145502. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145503. */
  145504. mergeRegionArea: number;
  145505. /**
  145506. * The maximum number of vertices allowed for polygons generated during the
  145507. * contour to polygon conversion process. [Limit: >= 3]
  145508. */
  145509. maxVertsPerPoly: number;
  145510. /**
  145511. * Sets the sampling distance to use when generating the detail mesh.
  145512. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145513. */
  145514. detailSampleDist: number;
  145515. /**
  145516. * The maximum distance the detail mesh surface should deviate from heightfield
  145517. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145518. */
  145519. detailSampleMaxError: number;
  145520. }
  145521. }
  145522. declare module BABYLON {
  145523. /**
  145524. * RecastJS navigation plugin
  145525. */
  145526. export class RecastJSPlugin implements INavigationEnginePlugin {
  145527. /**
  145528. * Reference to the Recast library
  145529. */
  145530. bjsRECAST: any;
  145531. /**
  145532. * plugin name
  145533. */
  145534. name: string;
  145535. /**
  145536. * the first navmesh created. We might extend this to support multiple navmeshes
  145537. */
  145538. navMesh: any;
  145539. /**
  145540. * Initializes the recastJS plugin
  145541. * @param recastInjection can be used to inject your own recast reference
  145542. */
  145543. constructor(recastInjection?: any);
  145544. /**
  145545. * Creates a navigation mesh
  145546. * @param meshes array of all the geometry used to compute the navigatio mesh
  145547. * @param parameters bunch of parameters used to filter geometry
  145548. */
  145549. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145550. /**
  145551. * Create a navigation mesh debug mesh
  145552. * @param scene is where the mesh will be added
  145553. * @returns debug display mesh
  145554. */
  145555. createDebugNavMesh(scene: Scene): Mesh;
  145556. /**
  145557. * Get a navigation mesh constrained position, closest to the parameter position
  145558. * @param position world position
  145559. * @returns the closest point to position constrained by the navigation mesh
  145560. */
  145561. getClosestPoint(position: Vector3): Vector3;
  145562. /**
  145563. * Get a navigation mesh constrained position, closest to the parameter position
  145564. * @param position world position
  145565. * @param result output the closest point to position constrained by the navigation mesh
  145566. */
  145567. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145568. /**
  145569. * Get a navigation mesh constrained position, within a particular radius
  145570. * @param position world position
  145571. * @param maxRadius the maximum distance to the constrained world position
  145572. * @returns the closest point to position constrained by the navigation mesh
  145573. */
  145574. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145575. /**
  145576. * Get a navigation mesh constrained position, within a particular radius
  145577. * @param position world position
  145578. * @param maxRadius the maximum distance to the constrained world position
  145579. * @param result output the closest point to position constrained by the navigation mesh
  145580. */
  145581. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145582. /**
  145583. * Compute the final position from a segment made of destination-position
  145584. * @param position world position
  145585. * @param destination world position
  145586. * @returns the resulting point along the navmesh
  145587. */
  145588. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145589. /**
  145590. * Compute the final position from a segment made of destination-position
  145591. * @param position world position
  145592. * @param destination world position
  145593. * @param result output the resulting point along the navmesh
  145594. */
  145595. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145596. /**
  145597. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145598. * @param start world position
  145599. * @param end world position
  145600. * @returns array containing world position composing the path
  145601. */
  145602. computePath(start: Vector3, end: Vector3): Vector3[];
  145603. /**
  145604. * Create a new Crowd so you can add agents
  145605. * @param maxAgents the maximum agent count in the crowd
  145606. * @param maxAgentRadius the maximum radius an agent can have
  145607. * @param scene to attach the crowd to
  145608. * @returns the crowd you can add agents to
  145609. */
  145610. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145611. /**
  145612. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145613. * The queries will try to find a solution within those bounds
  145614. * default is (1,1,1)
  145615. * @param extent x,y,z value that define the extent around the queries point of reference
  145616. */
  145617. setDefaultQueryExtent(extent: Vector3): void;
  145618. /**
  145619. * Get the Bounding box extent specified by setDefaultQueryExtent
  145620. * @returns the box extent values
  145621. */
  145622. getDefaultQueryExtent(): Vector3;
  145623. /**
  145624. * build the navmesh from a previously saved state using getNavmeshData
  145625. * @param data the Uint8Array returned by getNavmeshData
  145626. */
  145627. buildFromNavmeshData(data: Uint8Array): void;
  145628. /**
  145629. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145630. * @returns data the Uint8Array that can be saved and reused
  145631. */
  145632. getNavmeshData(): Uint8Array;
  145633. /**
  145634. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145635. * @param result output the box extent values
  145636. */
  145637. getDefaultQueryExtentToRef(result: Vector3): void;
  145638. /**
  145639. * Disposes
  145640. */
  145641. dispose(): void;
  145642. /**
  145643. * If this plugin is supported
  145644. * @returns true if plugin is supported
  145645. */
  145646. isSupported(): boolean;
  145647. }
  145648. /**
  145649. * Recast detour crowd implementation
  145650. */
  145651. export class RecastJSCrowd implements ICrowd {
  145652. /**
  145653. * Recast/detour plugin
  145654. */
  145655. bjsRECASTPlugin: RecastJSPlugin;
  145656. /**
  145657. * Link to the detour crowd
  145658. */
  145659. recastCrowd: any;
  145660. /**
  145661. * One transform per agent
  145662. */
  145663. transforms: TransformNode[];
  145664. /**
  145665. * All agents created
  145666. */
  145667. agents: number[];
  145668. /**
  145669. * Link to the scene is kept to unregister the crowd from the scene
  145670. */
  145671. private _scene;
  145672. /**
  145673. * Observer for crowd updates
  145674. */
  145675. private _onBeforeAnimationsObserver;
  145676. /**
  145677. * Constructor
  145678. * @param plugin recastJS plugin
  145679. * @param maxAgents the maximum agent count in the crowd
  145680. * @param maxAgentRadius the maximum radius an agent can have
  145681. * @param scene to attach the crowd to
  145682. * @returns the crowd you can add agents to
  145683. */
  145684. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145685. /**
  145686. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145687. * You can attach anything to that node. The node position is updated in the scene update tick.
  145688. * @param pos world position that will be constrained by the navigation mesh
  145689. * @param parameters agent parameters
  145690. * @param transform hooked to the agent that will be update by the scene
  145691. * @returns agent index
  145692. */
  145693. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145694. /**
  145695. * Returns the agent position in world space
  145696. * @param index agent index returned by addAgent
  145697. * @returns world space position
  145698. */
  145699. getAgentPosition(index: number): Vector3;
  145700. /**
  145701. * Returns the agent position result in world space
  145702. * @param index agent index returned by addAgent
  145703. * @param result output world space position
  145704. */
  145705. getAgentPositionToRef(index: number, result: Vector3): void;
  145706. /**
  145707. * Returns the agent velocity in world space
  145708. * @param index agent index returned by addAgent
  145709. * @returns world space velocity
  145710. */
  145711. getAgentVelocity(index: number): Vector3;
  145712. /**
  145713. * Returns the agent velocity result in world space
  145714. * @param index agent index returned by addAgent
  145715. * @param result output world space velocity
  145716. */
  145717. getAgentVelocityToRef(index: number, result: Vector3): void;
  145718. /**
  145719. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145720. * @param index agent index returned by addAgent
  145721. * @param destination targeted world position
  145722. */
  145723. agentGoto(index: number, destination: Vector3): void;
  145724. /**
  145725. * Teleport the agent to a new position
  145726. * @param index agent index returned by addAgent
  145727. * @param destination targeted world position
  145728. */
  145729. agentTeleport(index: number, destination: Vector3): void;
  145730. /**
  145731. * Update agent parameters
  145732. * @param index agent index returned by addAgent
  145733. * @param parameters agent parameters
  145734. */
  145735. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145736. /**
  145737. * remove a particular agent previously created
  145738. * @param index agent index returned by addAgent
  145739. */
  145740. removeAgent(index: number): void;
  145741. /**
  145742. * get the list of all agents attached to this crowd
  145743. * @returns list of agent indices
  145744. */
  145745. getAgents(): number[];
  145746. /**
  145747. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145748. * @param deltaTime in seconds
  145749. */
  145750. update(deltaTime: number): void;
  145751. /**
  145752. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145753. * The queries will try to find a solution within those bounds
  145754. * default is (1,1,1)
  145755. * @param extent x,y,z value that define the extent around the queries point of reference
  145756. */
  145757. setDefaultQueryExtent(extent: Vector3): void;
  145758. /**
  145759. * Get the Bounding box extent specified by setDefaultQueryExtent
  145760. * @returns the box extent values
  145761. */
  145762. getDefaultQueryExtent(): Vector3;
  145763. /**
  145764. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145765. * @param result output the box extent values
  145766. */
  145767. getDefaultQueryExtentToRef(result: Vector3): void;
  145768. /**
  145769. * Release all resources
  145770. */
  145771. dispose(): void;
  145772. }
  145773. }
  145774. declare module BABYLON {
  145775. /**
  145776. * Class used to enable access to IndexedDB
  145777. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  145778. */
  145779. export class Database implements IOfflineProvider {
  145780. private _callbackManifestChecked;
  145781. private _currentSceneUrl;
  145782. private _db;
  145783. private _enableSceneOffline;
  145784. private _enableTexturesOffline;
  145785. private _manifestVersionFound;
  145786. private _mustUpdateRessources;
  145787. private _hasReachedQuota;
  145788. private _isSupported;
  145789. private _idbFactory;
  145790. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  145791. private static IsUASupportingBlobStorage;
  145792. /**
  145793. * Gets a boolean indicating if Database storate is enabled (off by default)
  145794. */
  145795. static IDBStorageEnabled: boolean;
  145796. /**
  145797. * Gets a boolean indicating if scene must be saved in the database
  145798. */
  145799. get enableSceneOffline(): boolean;
  145800. /**
  145801. * Gets a boolean indicating if textures must be saved in the database
  145802. */
  145803. get enableTexturesOffline(): boolean;
  145804. /**
  145805. * Creates a new Database
  145806. * @param urlToScene defines the url to load the scene
  145807. * @param callbackManifestChecked defines the callback to use when manifest is checked
  145808. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  145809. */
  145810. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  145811. private static _ParseURL;
  145812. private static _ReturnFullUrlLocation;
  145813. private _checkManifestFile;
  145814. /**
  145815. * Open the database and make it available
  145816. * @param successCallback defines the callback to call on success
  145817. * @param errorCallback defines the callback to call on error
  145818. */
  145819. open(successCallback: () => void, errorCallback: () => void): void;
  145820. /**
  145821. * Loads an image from the database
  145822. * @param url defines the url to load from
  145823. * @param image defines the target DOM image
  145824. */
  145825. loadImage(url: string, image: HTMLImageElement): void;
  145826. private _loadImageFromDBAsync;
  145827. private _saveImageIntoDBAsync;
  145828. private _checkVersionFromDB;
  145829. private _loadVersionFromDBAsync;
  145830. private _saveVersionIntoDBAsync;
  145831. /**
  145832. * Loads a file from database
  145833. * @param url defines the URL to load from
  145834. * @param sceneLoaded defines a callback to call on success
  145835. * @param progressCallBack defines a callback to call when progress changed
  145836. * @param errorCallback defines a callback to call on error
  145837. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  145838. */
  145839. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  145840. private _loadFileAsync;
  145841. private _saveFileAsync;
  145842. /**
  145843. * Validates if xhr data is correct
  145844. * @param xhr defines the request to validate
  145845. * @param dataType defines the expected data type
  145846. * @returns true if data is correct
  145847. */
  145848. private static _ValidateXHRData;
  145849. }
  145850. }
  145851. declare module BABYLON {
  145852. /** @hidden */
  145853. export var gpuUpdateParticlesPixelShader: {
  145854. name: string;
  145855. shader: string;
  145856. };
  145857. }
  145858. declare module BABYLON {
  145859. /** @hidden */
  145860. export var gpuUpdateParticlesVertexShader: {
  145861. name: string;
  145862. shader: string;
  145863. };
  145864. }
  145865. declare module BABYLON {
  145866. /** @hidden */
  145867. export var clipPlaneFragmentDeclaration2: {
  145868. name: string;
  145869. shader: string;
  145870. };
  145871. }
  145872. declare module BABYLON {
  145873. /** @hidden */
  145874. export var gpuRenderParticlesPixelShader: {
  145875. name: string;
  145876. shader: string;
  145877. };
  145878. }
  145879. declare module BABYLON {
  145880. /** @hidden */
  145881. export var clipPlaneVertexDeclaration2: {
  145882. name: string;
  145883. shader: string;
  145884. };
  145885. }
  145886. declare module BABYLON {
  145887. /** @hidden */
  145888. export var gpuRenderParticlesVertexShader: {
  145889. name: string;
  145890. shader: string;
  145891. };
  145892. }
  145893. declare module BABYLON {
  145894. /**
  145895. * This represents a GPU particle system in Babylon
  145896. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  145897. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  145898. */
  145899. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  145900. /**
  145901. * The layer mask we are rendering the particles through.
  145902. */
  145903. layerMask: number;
  145904. private _capacity;
  145905. private _activeCount;
  145906. private _currentActiveCount;
  145907. private _accumulatedCount;
  145908. private _renderEffect;
  145909. private _updateEffect;
  145910. private _buffer0;
  145911. private _buffer1;
  145912. private _spriteBuffer;
  145913. private _updateVAO;
  145914. private _renderVAO;
  145915. private _targetIndex;
  145916. private _sourceBuffer;
  145917. private _targetBuffer;
  145918. private _engine;
  145919. private _currentRenderId;
  145920. private _started;
  145921. private _stopped;
  145922. private _timeDelta;
  145923. private _randomTexture;
  145924. private _randomTexture2;
  145925. private _attributesStrideSize;
  145926. private _updateEffectOptions;
  145927. private _randomTextureSize;
  145928. private _actualFrame;
  145929. private _customEffect;
  145930. private readonly _rawTextureWidth;
  145931. /**
  145932. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  145933. */
  145934. static get IsSupported(): boolean;
  145935. /**
  145936. * An event triggered when the system is disposed.
  145937. */
  145938. onDisposeObservable: Observable<IParticleSystem>;
  145939. /**
  145940. * Gets the maximum number of particles active at the same time.
  145941. * @returns The max number of active particles.
  145942. */
  145943. getCapacity(): number;
  145944. /**
  145945. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  145946. * to override the particles.
  145947. */
  145948. forceDepthWrite: boolean;
  145949. /**
  145950. * Gets or set the number of active particles
  145951. */
  145952. get activeParticleCount(): number;
  145953. set activeParticleCount(value: number);
  145954. private _preWarmDone;
  145955. /**
  145956. * Specifies if the particles are updated in emitter local space or world space.
  145957. */
  145958. isLocal: boolean;
  145959. /**
  145960. * Is this system ready to be used/rendered
  145961. * @return true if the system is ready
  145962. */
  145963. isReady(): boolean;
  145964. /**
  145965. * Gets if the system has been started. (Note: this will still be true after stop is called)
  145966. * @returns True if it has been started, otherwise false.
  145967. */
  145968. isStarted(): boolean;
  145969. /**
  145970. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  145971. * @returns True if it has been stopped, otherwise false.
  145972. */
  145973. isStopped(): boolean;
  145974. /**
  145975. * Gets a boolean indicating that the system is stopping
  145976. * @returns true if the system is currently stopping
  145977. */
  145978. isStopping(): boolean;
  145979. /**
  145980. * Gets the number of particles active at the same time.
  145981. * @returns The number of active particles.
  145982. */
  145983. getActiveCount(): number;
  145984. /**
  145985. * Starts the particle system and begins to emit
  145986. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  145987. */
  145988. start(delay?: number): void;
  145989. /**
  145990. * Stops the particle system.
  145991. */
  145992. stop(): void;
  145993. /**
  145994. * Remove all active particles
  145995. */
  145996. reset(): void;
  145997. /**
  145998. * Returns the string "GPUParticleSystem"
  145999. * @returns a string containing the class name
  146000. */
  146001. getClassName(): string;
  146002. /**
  146003. * Gets the custom effect used to render the particles
  146004. * @param blendMode Blend mode for which the effect should be retrieved
  146005. * @returns The effect
  146006. */
  146007. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146008. /**
  146009. * Sets the custom effect used to render the particles
  146010. * @param effect The effect to set
  146011. * @param blendMode Blend mode for which the effect should be set
  146012. */
  146013. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146014. /** @hidden */
  146015. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146016. /**
  146017. * Observable that will be called just before the particles are drawn
  146018. */
  146019. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146020. /**
  146021. * Gets the name of the particle vertex shader
  146022. */
  146023. get vertexShaderName(): string;
  146024. private _colorGradientsTexture;
  146025. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146026. /**
  146027. * Adds a new color gradient
  146028. * @param gradient defines the gradient to use (between 0 and 1)
  146029. * @param color1 defines the color to affect to the specified gradient
  146030. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146031. * @returns the current particle system
  146032. */
  146033. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146034. private _refreshColorGradient;
  146035. /** Force the system to rebuild all gradients that need to be resync */
  146036. forceRefreshGradients(): void;
  146037. /**
  146038. * Remove a specific color gradient
  146039. * @param gradient defines the gradient to remove
  146040. * @returns the current particle system
  146041. */
  146042. removeColorGradient(gradient: number): GPUParticleSystem;
  146043. private _angularSpeedGradientsTexture;
  146044. private _sizeGradientsTexture;
  146045. private _velocityGradientsTexture;
  146046. private _limitVelocityGradientsTexture;
  146047. private _dragGradientsTexture;
  146048. private _addFactorGradient;
  146049. /**
  146050. * Adds a new size gradient
  146051. * @param gradient defines the gradient to use (between 0 and 1)
  146052. * @param factor defines the size factor to affect to the specified gradient
  146053. * @returns the current particle system
  146054. */
  146055. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146056. /**
  146057. * Remove a specific size gradient
  146058. * @param gradient defines the gradient to remove
  146059. * @returns the current particle system
  146060. */
  146061. removeSizeGradient(gradient: number): GPUParticleSystem;
  146062. private _refreshFactorGradient;
  146063. /**
  146064. * Adds a new angular speed gradient
  146065. * @param gradient defines the gradient to use (between 0 and 1)
  146066. * @param factor defines the angular speed to affect to the specified gradient
  146067. * @returns the current particle system
  146068. */
  146069. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146070. /**
  146071. * Remove a specific angular speed gradient
  146072. * @param gradient defines the gradient to remove
  146073. * @returns the current particle system
  146074. */
  146075. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146076. /**
  146077. * Adds a new velocity gradient
  146078. * @param gradient defines the gradient to use (between 0 and 1)
  146079. * @param factor defines the velocity to affect to the specified gradient
  146080. * @returns the current particle system
  146081. */
  146082. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146083. /**
  146084. * Remove a specific velocity gradient
  146085. * @param gradient defines the gradient to remove
  146086. * @returns the current particle system
  146087. */
  146088. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146089. /**
  146090. * Adds a new limit velocity gradient
  146091. * @param gradient defines the gradient to use (between 0 and 1)
  146092. * @param factor defines the limit velocity value to affect to the specified gradient
  146093. * @returns the current particle system
  146094. */
  146095. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146096. /**
  146097. * Remove a specific limit velocity gradient
  146098. * @param gradient defines the gradient to remove
  146099. * @returns the current particle system
  146100. */
  146101. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146102. /**
  146103. * Adds a new drag gradient
  146104. * @param gradient defines the gradient to use (between 0 and 1)
  146105. * @param factor defines the drag value to affect to the specified gradient
  146106. * @returns the current particle system
  146107. */
  146108. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146109. /**
  146110. * Remove a specific drag gradient
  146111. * @param gradient defines the gradient to remove
  146112. * @returns the current particle system
  146113. */
  146114. removeDragGradient(gradient: number): GPUParticleSystem;
  146115. /**
  146116. * Not supported by GPUParticleSystem
  146117. * @param gradient defines the gradient to use (between 0 and 1)
  146118. * @param factor defines the emit rate value to affect to the specified gradient
  146119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146120. * @returns the current particle system
  146121. */
  146122. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146123. /**
  146124. * Not supported by GPUParticleSystem
  146125. * @param gradient defines the gradient to remove
  146126. * @returns the current particle system
  146127. */
  146128. removeEmitRateGradient(gradient: number): IParticleSystem;
  146129. /**
  146130. * Not supported by GPUParticleSystem
  146131. * @param gradient defines the gradient to use (between 0 and 1)
  146132. * @param factor defines the start size value to affect to the specified gradient
  146133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146134. * @returns the current particle system
  146135. */
  146136. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146137. /**
  146138. * Not supported by GPUParticleSystem
  146139. * @param gradient defines the gradient to remove
  146140. * @returns the current particle system
  146141. */
  146142. removeStartSizeGradient(gradient: number): IParticleSystem;
  146143. /**
  146144. * Not supported by GPUParticleSystem
  146145. * @param gradient defines the gradient to use (between 0 and 1)
  146146. * @param min defines the color remap minimal range
  146147. * @param max defines the color remap maximal range
  146148. * @returns the current particle system
  146149. */
  146150. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146151. /**
  146152. * Not supported by GPUParticleSystem
  146153. * @param gradient defines the gradient to remove
  146154. * @returns the current particle system
  146155. */
  146156. removeColorRemapGradient(): IParticleSystem;
  146157. /**
  146158. * Not supported by GPUParticleSystem
  146159. * @param gradient defines the gradient to use (between 0 and 1)
  146160. * @param min defines the alpha remap minimal range
  146161. * @param max defines the alpha remap maximal range
  146162. * @returns the current particle system
  146163. */
  146164. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146165. /**
  146166. * Not supported by GPUParticleSystem
  146167. * @param gradient defines the gradient to remove
  146168. * @returns the current particle system
  146169. */
  146170. removeAlphaRemapGradient(): IParticleSystem;
  146171. /**
  146172. * Not supported by GPUParticleSystem
  146173. * @param gradient defines the gradient to use (between 0 and 1)
  146174. * @param color defines the color to affect to the specified gradient
  146175. * @returns the current particle system
  146176. */
  146177. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146178. /**
  146179. * Not supported by GPUParticleSystem
  146180. * @param gradient defines the gradient to remove
  146181. * @returns the current particle system
  146182. */
  146183. removeRampGradient(): IParticleSystem;
  146184. /**
  146185. * Not supported by GPUParticleSystem
  146186. * @returns the list of ramp gradients
  146187. */
  146188. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146189. /**
  146190. * Not supported by GPUParticleSystem
  146191. * Gets or sets a boolean indicating that ramp gradients must be used
  146192. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146193. */
  146194. get useRampGradients(): boolean;
  146195. set useRampGradients(value: boolean);
  146196. /**
  146197. * Not supported by GPUParticleSystem
  146198. * @param gradient defines the gradient to use (between 0 and 1)
  146199. * @param factor defines the life time factor to affect to the specified gradient
  146200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146201. * @returns the current particle system
  146202. */
  146203. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146204. /**
  146205. * Not supported by GPUParticleSystem
  146206. * @param gradient defines the gradient to remove
  146207. * @returns the current particle system
  146208. */
  146209. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146210. /**
  146211. * Instantiates a GPU particle system.
  146212. * 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.
  146213. * @param name The name of the particle system
  146214. * @param options The options used to create the system
  146215. * @param scene The scene the particle system belongs to
  146216. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146217. * @param customEffect a custom effect used to change the way particles are rendered by default
  146218. */
  146219. constructor(name: string, options: Partial<{
  146220. capacity: number;
  146221. randomTextureSize: number;
  146222. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146223. protected _reset(): void;
  146224. private _createUpdateVAO;
  146225. private _createRenderVAO;
  146226. private _initialize;
  146227. /** @hidden */
  146228. _recreateUpdateEffect(): void;
  146229. private _getEffect;
  146230. /**
  146231. * Fill the defines array according to the current settings of the particle system
  146232. * @param defines Array to be updated
  146233. * @param blendMode blend mode to take into account when updating the array
  146234. */
  146235. fillDefines(defines: Array<string>, blendMode?: number): void;
  146236. /**
  146237. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146238. * @param uniforms Uniforms array to fill
  146239. * @param attributes Attributes array to fill
  146240. * @param samplers Samplers array to fill
  146241. */
  146242. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146243. /** @hidden */
  146244. _recreateRenderEffect(): Effect;
  146245. /**
  146246. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146247. * @param preWarm defines if we are in the pre-warmimg phase
  146248. */
  146249. animate(preWarm?: boolean): void;
  146250. private _createFactorGradientTexture;
  146251. private _createSizeGradientTexture;
  146252. private _createAngularSpeedGradientTexture;
  146253. private _createVelocityGradientTexture;
  146254. private _createLimitVelocityGradientTexture;
  146255. private _createDragGradientTexture;
  146256. private _createColorGradientTexture;
  146257. /**
  146258. * Renders the particle system in its current state
  146259. * @param preWarm defines if the system should only update the particles but not render them
  146260. * @returns the current number of particles
  146261. */
  146262. render(preWarm?: boolean): number;
  146263. /**
  146264. * Rebuilds the particle system
  146265. */
  146266. rebuild(): void;
  146267. private _releaseBuffers;
  146268. private _releaseVAOs;
  146269. /**
  146270. * Disposes the particle system and free the associated resources
  146271. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146272. */
  146273. dispose(disposeTexture?: boolean): void;
  146274. /**
  146275. * Clones the particle system.
  146276. * @param name The name of the cloned object
  146277. * @param newEmitter The new emitter to use
  146278. * @returns the cloned particle system
  146279. */
  146280. clone(name: string, newEmitter: any): GPUParticleSystem;
  146281. /**
  146282. * Serializes the particle system to a JSON object
  146283. * @param serializeTexture defines if the texture must be serialized as well
  146284. * @returns the JSON object
  146285. */
  146286. serialize(serializeTexture?: boolean): any;
  146287. /**
  146288. * Parses a JSON object to create a GPU particle system.
  146289. * @param parsedParticleSystem The JSON object to parse
  146290. * @param scene The scene to create the particle system in
  146291. * @param rootUrl The root url to use to load external dependencies like texture
  146292. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146293. * @returns the parsed GPU particle system
  146294. */
  146295. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146296. }
  146297. }
  146298. declare module BABYLON {
  146299. /**
  146300. * Represents a set of particle systems working together to create a specific effect
  146301. */
  146302. export class ParticleSystemSet implements IDisposable {
  146303. /**
  146304. * Gets or sets base Assets URL
  146305. */
  146306. static BaseAssetsUrl: string;
  146307. private _emitterCreationOptions;
  146308. private _emitterNode;
  146309. /**
  146310. * Gets the particle system list
  146311. */
  146312. systems: IParticleSystem[];
  146313. /**
  146314. * Gets the emitter node used with this set
  146315. */
  146316. get emitterNode(): Nullable<TransformNode>;
  146317. /**
  146318. * Creates a new emitter mesh as a sphere
  146319. * @param options defines the options used to create the sphere
  146320. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146321. * @param scene defines the hosting scene
  146322. */
  146323. setEmitterAsSphere(options: {
  146324. diameter: number;
  146325. segments: number;
  146326. color: Color3;
  146327. }, renderingGroupId: number, scene: Scene): void;
  146328. /**
  146329. * Starts all particle systems of the set
  146330. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146331. */
  146332. start(emitter?: AbstractMesh): void;
  146333. /**
  146334. * Release all associated resources
  146335. */
  146336. dispose(): void;
  146337. /**
  146338. * Serialize the set into a JSON compatible object
  146339. * @param serializeTexture defines if the texture must be serialized as well
  146340. * @returns a JSON compatible representation of the set
  146341. */
  146342. serialize(serializeTexture?: boolean): any;
  146343. /**
  146344. * Parse a new ParticleSystemSet from a serialized source
  146345. * @param data defines a JSON compatible representation of the set
  146346. * @param scene defines the hosting scene
  146347. * @param gpu defines if we want GPU particles or CPU particles
  146348. * @returns a new ParticleSystemSet
  146349. */
  146350. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146351. }
  146352. }
  146353. declare module BABYLON {
  146354. /**
  146355. * This class is made for on one-liner static method to help creating particle system set.
  146356. */
  146357. export class ParticleHelper {
  146358. /**
  146359. * Gets or sets base Assets URL
  146360. */
  146361. static BaseAssetsUrl: string;
  146362. /** Define the Url to load snippets */
  146363. static SnippetUrl: string;
  146364. /**
  146365. * Create a default particle system that you can tweak
  146366. * @param emitter defines the emitter to use
  146367. * @param capacity defines the system capacity (default is 500 particles)
  146368. * @param scene defines the hosting scene
  146369. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146370. * @returns the new Particle system
  146371. */
  146372. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146373. /**
  146374. * This is the main static method (one-liner) of this helper to create different particle systems
  146375. * @param type This string represents the type to the particle system to create
  146376. * @param scene The scene where the particle system should live
  146377. * @param gpu If the system will use gpu
  146378. * @returns the ParticleSystemSet created
  146379. */
  146380. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146381. /**
  146382. * Static function used to export a particle system to a ParticleSystemSet variable.
  146383. * Please note that the emitter shape is not exported
  146384. * @param systems defines the particle systems to export
  146385. * @returns the created particle system set
  146386. */
  146387. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146388. /**
  146389. * Creates a particle system from a snippet saved in a remote file
  146390. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146391. * @param url defines the url to load from
  146392. * @param scene defines the hosting scene
  146393. * @param gpu If the system will use gpu
  146394. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146395. * @returns a promise that will resolve to the new particle system
  146396. */
  146397. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146398. /**
  146399. * Creates a particle system from a snippet saved by the particle system editor
  146400. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146401. * @param scene defines the hosting scene
  146402. * @param gpu If the system will use gpu
  146403. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146404. * @returns a promise that will resolve to the new particle system
  146405. */
  146406. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146407. }
  146408. }
  146409. declare module BABYLON {
  146410. interface Engine {
  146411. /**
  146412. * Create an effect to use with particle systems.
  146413. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146414. * the particle system for which you want to create a custom effect in the last parameter
  146415. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146416. * @param uniformsNames defines a list of attribute names
  146417. * @param samplers defines an array of string used to represent textures
  146418. * @param defines defines the string containing the defines to use to compile the shaders
  146419. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146420. * @param onCompiled defines a function to call when the effect creation is successful
  146421. * @param onError defines a function to call when the effect creation has failed
  146422. * @param particleSystem the particle system you want to create the effect for
  146423. * @returns the new Effect
  146424. */
  146425. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146426. }
  146427. interface Mesh {
  146428. /**
  146429. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146430. * @returns an array of IParticleSystem
  146431. */
  146432. getEmittedParticleSystems(): IParticleSystem[];
  146433. /**
  146434. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146435. * @returns an array of IParticleSystem
  146436. */
  146437. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146438. }
  146439. }
  146440. declare module BABYLON {
  146441. /** Defines the 4 color options */
  146442. export enum PointColor {
  146443. /** color value */
  146444. Color = 2,
  146445. /** uv value */
  146446. UV = 1,
  146447. /** random value */
  146448. Random = 0,
  146449. /** stated value */
  146450. Stated = 3
  146451. }
  146452. /**
  146453. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146454. * 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.
  146455. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146456. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146457. *
  146458. * Full documentation here : TO BE ENTERED
  146459. */
  146460. export class PointsCloudSystem implements IDisposable {
  146461. /**
  146462. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146463. * Example : var p = SPS.particles[i];
  146464. */
  146465. particles: CloudPoint[];
  146466. /**
  146467. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146468. */
  146469. nbParticles: number;
  146470. /**
  146471. * This a counter for your own usage. It's not set by any SPS functions.
  146472. */
  146473. counter: number;
  146474. /**
  146475. * The PCS name. This name is also given to the underlying mesh.
  146476. */
  146477. name: string;
  146478. /**
  146479. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146480. */
  146481. mesh: Mesh;
  146482. /**
  146483. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146484. * Please read :
  146485. */
  146486. vars: any;
  146487. /**
  146488. * @hidden
  146489. */
  146490. _size: number;
  146491. private _scene;
  146492. private _promises;
  146493. private _positions;
  146494. private _indices;
  146495. private _normals;
  146496. private _colors;
  146497. private _uvs;
  146498. private _indices32;
  146499. private _positions32;
  146500. private _colors32;
  146501. private _uvs32;
  146502. private _updatable;
  146503. private _isVisibilityBoxLocked;
  146504. private _alwaysVisible;
  146505. private _groups;
  146506. private _groupCounter;
  146507. private _computeParticleColor;
  146508. private _computeParticleTexture;
  146509. private _computeParticleRotation;
  146510. private _computeBoundingBox;
  146511. private _isReady;
  146512. /**
  146513. * Creates a PCS (Points Cloud System) object
  146514. * @param name (String) is the PCS name, this will be the underlying mesh name
  146515. * @param pointSize (number) is the size for each point
  146516. * @param scene (Scene) is the scene in which the PCS is added
  146517. * @param options defines the options of the PCS e.g.
  146518. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146519. */
  146520. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146521. updatable?: boolean;
  146522. });
  146523. /**
  146524. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146525. * If no points were added to the PCS, the returned mesh is just a single point.
  146526. * @returns a promise for the created mesh
  146527. */
  146528. buildMeshAsync(): Promise<Mesh>;
  146529. /**
  146530. * @hidden
  146531. */
  146532. private _buildMesh;
  146533. private _addParticle;
  146534. private _randomUnitVector;
  146535. private _getColorIndicesForCoord;
  146536. private _setPointsColorOrUV;
  146537. private _colorFromTexture;
  146538. private _calculateDensity;
  146539. /**
  146540. * Adds points to the PCS in random positions within a unit sphere
  146541. * @param nb (positive integer) the number of particles to be created from this model
  146542. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146543. * @returns the number of groups in the system
  146544. */
  146545. addPoints(nb: number, pointFunction?: any): number;
  146546. /**
  146547. * Adds points to the PCS from the surface of the model shape
  146548. * @param mesh is any Mesh object that will be used as a surface model for the points
  146549. * @param nb (positive integer) the number of particles to be created from this model
  146550. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146551. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146552. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146553. * @returns the number of groups in the system
  146554. */
  146555. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146556. /**
  146557. * Adds points to the PCS inside the model shape
  146558. * @param mesh is any Mesh object that will be used as a surface model for the points
  146559. * @param nb (positive integer) the number of particles to be created from this model
  146560. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146561. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146562. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146563. * @returns the number of groups in the system
  146564. */
  146565. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146566. /**
  146567. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146568. * This method calls `updateParticle()` for each particle of the SPS.
  146569. * For an animated SPS, it is usually called within the render loop.
  146570. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146571. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146572. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146573. * @returns the PCS.
  146574. */
  146575. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146576. /**
  146577. * Disposes the PCS.
  146578. */
  146579. dispose(): void;
  146580. /**
  146581. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146582. * doc :
  146583. * @returns the PCS.
  146584. */
  146585. refreshVisibleSize(): PointsCloudSystem;
  146586. /**
  146587. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146588. * @param size the size (float) of the visibility box
  146589. * note : this doesn't lock the PCS mesh bounding box.
  146590. * doc :
  146591. */
  146592. setVisibilityBox(size: number): void;
  146593. /**
  146594. * Gets whether the PCS is always visible or not
  146595. * doc :
  146596. */
  146597. get isAlwaysVisible(): boolean;
  146598. /**
  146599. * Sets the PCS as always visible or not
  146600. * doc :
  146601. */
  146602. set isAlwaysVisible(val: boolean);
  146603. /**
  146604. * Tells to `setParticles()` to compute the particle rotations or not
  146605. * Default value : false. The PCS is faster when it's set to false
  146606. * Note : particle rotations are only applied to parent particles
  146607. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146608. */
  146609. set computeParticleRotation(val: boolean);
  146610. /**
  146611. * Tells to `setParticles()` to compute the particle colors or not.
  146612. * Default value : true. The PCS is faster when it's set to false.
  146613. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146614. */
  146615. set computeParticleColor(val: boolean);
  146616. set computeParticleTexture(val: boolean);
  146617. /**
  146618. * Gets if `setParticles()` computes the particle colors or not.
  146619. * Default value : false. The PCS is faster when it's set to false.
  146620. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146621. */
  146622. get computeParticleColor(): boolean;
  146623. /**
  146624. * Gets if `setParticles()` computes the particle textures or not.
  146625. * Default value : false. The PCS is faster when it's set to false.
  146626. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146627. */
  146628. get computeParticleTexture(): boolean;
  146629. /**
  146630. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146631. */
  146632. set computeBoundingBox(val: boolean);
  146633. /**
  146634. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146635. */
  146636. get computeBoundingBox(): boolean;
  146637. /**
  146638. * This function does nothing. It may be overwritten to set all the particle first values.
  146639. * The PCS doesn't call this function, you may have to call it by your own.
  146640. * doc :
  146641. */
  146642. initParticles(): void;
  146643. /**
  146644. * This function does nothing. It may be overwritten to recycle a particle
  146645. * The PCS doesn't call this function, you can to call it
  146646. * doc :
  146647. * @param particle The particle to recycle
  146648. * @returns the recycled particle
  146649. */
  146650. recycleParticle(particle: CloudPoint): CloudPoint;
  146651. /**
  146652. * Updates a particle : this function should be overwritten by the user.
  146653. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146654. * doc :
  146655. * @example : just set a particle position or velocity and recycle conditions
  146656. * @param particle The particle to update
  146657. * @returns the updated particle
  146658. */
  146659. updateParticle(particle: CloudPoint): CloudPoint;
  146660. /**
  146661. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146662. * This does nothing and may be overwritten by the user.
  146663. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146665. * @param update the boolean update value actually passed to setParticles()
  146666. */
  146667. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146668. /**
  146669. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146670. * This will be passed three parameters.
  146671. * This does nothing and may be overwritten by the user.
  146672. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146674. * @param update the boolean update value actually passed to setParticles()
  146675. */
  146676. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146677. }
  146678. }
  146679. declare module BABYLON {
  146680. /**
  146681. * Represents one particle of a points cloud system.
  146682. */
  146683. export class CloudPoint {
  146684. /**
  146685. * particle global index
  146686. */
  146687. idx: number;
  146688. /**
  146689. * The color of the particle
  146690. */
  146691. color: Nullable<Color4>;
  146692. /**
  146693. * The world space position of the particle.
  146694. */
  146695. position: Vector3;
  146696. /**
  146697. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146698. */
  146699. rotation: Vector3;
  146700. /**
  146701. * The world space rotation quaternion of the particle.
  146702. */
  146703. rotationQuaternion: Nullable<Quaternion>;
  146704. /**
  146705. * The uv of the particle.
  146706. */
  146707. uv: Nullable<Vector2>;
  146708. /**
  146709. * The current speed of the particle.
  146710. */
  146711. velocity: Vector3;
  146712. /**
  146713. * The pivot point in the particle local space.
  146714. */
  146715. pivot: Vector3;
  146716. /**
  146717. * Must the particle be translated from its pivot point in its local space ?
  146718. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146719. * Default : false
  146720. */
  146721. translateFromPivot: boolean;
  146722. /**
  146723. * Index of this particle in the global "positions" array (Internal use)
  146724. * @hidden
  146725. */
  146726. _pos: number;
  146727. /**
  146728. * @hidden Index of this particle in the global "indices" array (Internal use)
  146729. */
  146730. _ind: number;
  146731. /**
  146732. * Group this particle belongs to
  146733. */
  146734. _group: PointsGroup;
  146735. /**
  146736. * Group id of this particle
  146737. */
  146738. groupId: number;
  146739. /**
  146740. * Index of the particle in its group id (Internal use)
  146741. */
  146742. idxInGroup: number;
  146743. /**
  146744. * @hidden Particle BoundingInfo object (Internal use)
  146745. */
  146746. _boundingInfo: BoundingInfo;
  146747. /**
  146748. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146749. */
  146750. _pcs: PointsCloudSystem;
  146751. /**
  146752. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146753. */
  146754. _stillInvisible: boolean;
  146755. /**
  146756. * @hidden Last computed particle rotation matrix
  146757. */
  146758. _rotationMatrix: number[];
  146759. /**
  146760. * Parent particle Id, if any.
  146761. * Default null.
  146762. */
  146763. parentId: Nullable<number>;
  146764. /**
  146765. * @hidden Internal global position in the PCS.
  146766. */
  146767. _globalPosition: Vector3;
  146768. /**
  146769. * Creates a Point Cloud object.
  146770. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  146771. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  146772. * @param group (PointsGroup) is the group the particle belongs to
  146773. * @param groupId (integer) is the group identifier in the PCS.
  146774. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  146775. * @param pcs defines the PCS it is associated to
  146776. */
  146777. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  146778. /**
  146779. * get point size
  146780. */
  146781. get size(): Vector3;
  146782. /**
  146783. * Set point size
  146784. */
  146785. set size(scale: Vector3);
  146786. /**
  146787. * Legacy support, changed quaternion to rotationQuaternion
  146788. */
  146789. get quaternion(): Nullable<Quaternion>;
  146790. /**
  146791. * Legacy support, changed quaternion to rotationQuaternion
  146792. */
  146793. set quaternion(q: Nullable<Quaternion>);
  146794. /**
  146795. * Returns a boolean. True if the particle intersects a mesh, else false
  146796. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  146797. * @param target is the object (point or mesh) what the intersection is computed against
  146798. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  146799. * @returns true if it intersects
  146800. */
  146801. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  146802. /**
  146803. * get the rotation matrix of the particle
  146804. * @hidden
  146805. */
  146806. getRotationMatrix(m: Matrix): void;
  146807. }
  146808. /**
  146809. * Represents a group of points in a points cloud system
  146810. * * PCS internal tool, don't use it manually.
  146811. */
  146812. export class PointsGroup {
  146813. /**
  146814. * The group id
  146815. * @hidden
  146816. */
  146817. groupID: number;
  146818. /**
  146819. * image data for group (internal use)
  146820. * @hidden
  146821. */
  146822. _groupImageData: Nullable<ArrayBufferView>;
  146823. /**
  146824. * Image Width (internal use)
  146825. * @hidden
  146826. */
  146827. _groupImgWidth: number;
  146828. /**
  146829. * Image Height (internal use)
  146830. * @hidden
  146831. */
  146832. _groupImgHeight: number;
  146833. /**
  146834. * Custom position function (internal use)
  146835. * @hidden
  146836. */
  146837. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  146838. /**
  146839. * density per facet for surface points
  146840. * @hidden
  146841. */
  146842. _groupDensity: number[];
  146843. /**
  146844. * Only when points are colored by texture carries pointer to texture list array
  146845. * @hidden
  146846. */
  146847. _textureNb: number;
  146848. /**
  146849. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  146850. * PCS internal tool, don't use it manually.
  146851. * @hidden
  146852. */
  146853. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  146854. }
  146855. }
  146856. declare module BABYLON {
  146857. interface Scene {
  146858. /** @hidden (Backing field) */
  146859. _physicsEngine: Nullable<IPhysicsEngine>;
  146860. /** @hidden */
  146861. _physicsTimeAccumulator: number;
  146862. /**
  146863. * Gets the current physics engine
  146864. * @returns a IPhysicsEngine or null if none attached
  146865. */
  146866. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  146867. /**
  146868. * Enables physics to the current scene
  146869. * @param gravity defines the scene's gravity for the physics engine
  146870. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  146871. * @return a boolean indicating if the physics engine was initialized
  146872. */
  146873. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  146874. /**
  146875. * Disables and disposes the physics engine associated with the scene
  146876. */
  146877. disablePhysicsEngine(): void;
  146878. /**
  146879. * Gets a boolean indicating if there is an active physics engine
  146880. * @returns a boolean indicating if there is an active physics engine
  146881. */
  146882. isPhysicsEnabled(): boolean;
  146883. /**
  146884. * Deletes a physics compound impostor
  146885. * @param compound defines the compound to delete
  146886. */
  146887. deleteCompoundImpostor(compound: any): void;
  146888. /**
  146889. * An event triggered when physic simulation is about to be run
  146890. */
  146891. onBeforePhysicsObservable: Observable<Scene>;
  146892. /**
  146893. * An event triggered when physic simulation has been done
  146894. */
  146895. onAfterPhysicsObservable: Observable<Scene>;
  146896. }
  146897. interface AbstractMesh {
  146898. /** @hidden */
  146899. _physicsImpostor: Nullable<PhysicsImpostor>;
  146900. /**
  146901. * Gets or sets impostor used for physic simulation
  146902. * @see https://doc.babylonjs.com/features/physics_engine
  146903. */
  146904. physicsImpostor: Nullable<PhysicsImpostor>;
  146905. /**
  146906. * Gets the current physics impostor
  146907. * @see https://doc.babylonjs.com/features/physics_engine
  146908. * @returns a physics impostor or null
  146909. */
  146910. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  146911. /** Apply a physic impulse to the mesh
  146912. * @param force defines the force to apply
  146913. * @param contactPoint defines where to apply the force
  146914. * @returns the current mesh
  146915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  146916. */
  146917. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  146918. /**
  146919. * Creates a physic joint between two meshes
  146920. * @param otherMesh defines the other mesh to use
  146921. * @param pivot1 defines the pivot to use on this mesh
  146922. * @param pivot2 defines the pivot to use on the other mesh
  146923. * @param options defines additional options (can be plugin dependent)
  146924. * @returns the current mesh
  146925. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  146926. */
  146927. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  146928. /** @hidden */
  146929. _disposePhysicsObserver: Nullable<Observer<Node>>;
  146930. }
  146931. /**
  146932. * Defines the physics engine scene component responsible to manage a physics engine
  146933. */
  146934. export class PhysicsEngineSceneComponent implements ISceneComponent {
  146935. /**
  146936. * The component name helpful to identify the component in the list of scene components.
  146937. */
  146938. readonly name: string;
  146939. /**
  146940. * The scene the component belongs to.
  146941. */
  146942. scene: Scene;
  146943. /**
  146944. * Creates a new instance of the component for the given scene
  146945. * @param scene Defines the scene to register the component in
  146946. */
  146947. constructor(scene: Scene);
  146948. /**
  146949. * Registers the component in a given scene
  146950. */
  146951. register(): void;
  146952. /**
  146953. * Rebuilds the elements related to this component in case of
  146954. * context lost for instance.
  146955. */
  146956. rebuild(): void;
  146957. /**
  146958. * Disposes the component and the associated ressources
  146959. */
  146960. dispose(): void;
  146961. }
  146962. }
  146963. declare module BABYLON {
  146964. /**
  146965. * A helper for physics simulations
  146966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146967. */
  146968. export class PhysicsHelper {
  146969. private _scene;
  146970. private _physicsEngine;
  146971. /**
  146972. * Initializes the Physics helper
  146973. * @param scene Babylon.js scene
  146974. */
  146975. constructor(scene: Scene);
  146976. /**
  146977. * Applies a radial explosion impulse
  146978. * @param origin the origin of the explosion
  146979. * @param radiusOrEventOptions the radius or the options of radial explosion
  146980. * @param strength the explosion strength
  146981. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146982. * @returns A physics radial explosion event, or null
  146983. */
  146984. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146985. /**
  146986. * Applies a radial explosion force
  146987. * @param origin the origin of the explosion
  146988. * @param radiusOrEventOptions the radius or the options of radial explosion
  146989. * @param strength the explosion strength
  146990. * @param falloff possible options: Constant & Linear. Defaults to Constant
  146991. * @returns A physics radial explosion event, or null
  146992. */
  146993. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  146994. /**
  146995. * Creates a gravitational field
  146996. * @param origin the origin of the explosion
  146997. * @param radiusOrEventOptions the radius or the options of radial explosion
  146998. * @param strength the explosion strength
  146999. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147000. * @returns A physics gravitational field event, or null
  147001. */
  147002. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147003. /**
  147004. * Creates a physics updraft event
  147005. * @param origin the origin of the updraft
  147006. * @param radiusOrEventOptions the radius or the options of the updraft
  147007. * @param strength the strength of the updraft
  147008. * @param height the height of the updraft
  147009. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147010. * @returns A physics updraft event, or null
  147011. */
  147012. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147013. /**
  147014. * Creates a physics vortex event
  147015. * @param origin the of the vortex
  147016. * @param radiusOrEventOptions the radius or the options of the vortex
  147017. * @param strength the strength of the vortex
  147018. * @param height the height of the vortex
  147019. * @returns a Physics vortex event, or null
  147020. * A physics vortex event or null
  147021. */
  147022. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147023. }
  147024. /**
  147025. * Represents a physics radial explosion event
  147026. */
  147027. class PhysicsRadialExplosionEvent {
  147028. private _scene;
  147029. private _options;
  147030. private _sphere;
  147031. private _dataFetched;
  147032. /**
  147033. * Initializes a radial explosioin event
  147034. * @param _scene BabylonJS scene
  147035. * @param _options The options for the vortex event
  147036. */
  147037. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147038. /**
  147039. * Returns the data related to the radial explosion event (sphere).
  147040. * @returns The radial explosion event data
  147041. */
  147042. getData(): PhysicsRadialExplosionEventData;
  147043. /**
  147044. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147045. * @param impostor A physics imposter
  147046. * @param origin the origin of the explosion
  147047. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147048. */
  147049. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147050. /**
  147051. * Triggers affecterd impostors callbacks
  147052. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147053. */
  147054. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147055. /**
  147056. * Disposes the sphere.
  147057. * @param force Specifies if the sphere should be disposed by force
  147058. */
  147059. dispose(force?: boolean): void;
  147060. /*** Helpers ***/
  147061. private _prepareSphere;
  147062. private _intersectsWithSphere;
  147063. }
  147064. /**
  147065. * Represents a gravitational field event
  147066. */
  147067. class PhysicsGravitationalFieldEvent {
  147068. private _physicsHelper;
  147069. private _scene;
  147070. private _origin;
  147071. private _options;
  147072. private _tickCallback;
  147073. private _sphere;
  147074. private _dataFetched;
  147075. /**
  147076. * Initializes the physics gravitational field event
  147077. * @param _physicsHelper A physics helper
  147078. * @param _scene BabylonJS scene
  147079. * @param _origin The origin position of the gravitational field event
  147080. * @param _options The options for the vortex event
  147081. */
  147082. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147083. /**
  147084. * Returns the data related to the gravitational field event (sphere).
  147085. * @returns A gravitational field event
  147086. */
  147087. getData(): PhysicsGravitationalFieldEventData;
  147088. /**
  147089. * Enables the gravitational field.
  147090. */
  147091. enable(): void;
  147092. /**
  147093. * Disables the gravitational field.
  147094. */
  147095. disable(): void;
  147096. /**
  147097. * Disposes the sphere.
  147098. * @param force The force to dispose from the gravitational field event
  147099. */
  147100. dispose(force?: boolean): void;
  147101. private _tick;
  147102. }
  147103. /**
  147104. * Represents a physics updraft event
  147105. */
  147106. class PhysicsUpdraftEvent {
  147107. private _scene;
  147108. private _origin;
  147109. private _options;
  147110. private _physicsEngine;
  147111. private _originTop;
  147112. private _originDirection;
  147113. private _tickCallback;
  147114. private _cylinder;
  147115. private _cylinderPosition;
  147116. private _dataFetched;
  147117. /**
  147118. * Initializes the physics updraft event
  147119. * @param _scene BabylonJS scene
  147120. * @param _origin The origin position of the updraft
  147121. * @param _options The options for the updraft event
  147122. */
  147123. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147124. /**
  147125. * Returns the data related to the updraft event (cylinder).
  147126. * @returns A physics updraft event
  147127. */
  147128. getData(): PhysicsUpdraftEventData;
  147129. /**
  147130. * Enables the updraft.
  147131. */
  147132. enable(): void;
  147133. /**
  147134. * Disables the updraft.
  147135. */
  147136. disable(): void;
  147137. /**
  147138. * Disposes the cylinder.
  147139. * @param force Specifies if the updraft should be disposed by force
  147140. */
  147141. dispose(force?: boolean): void;
  147142. private getImpostorHitData;
  147143. private _tick;
  147144. /*** Helpers ***/
  147145. private _prepareCylinder;
  147146. private _intersectsWithCylinder;
  147147. }
  147148. /**
  147149. * Represents a physics vortex event
  147150. */
  147151. class PhysicsVortexEvent {
  147152. private _scene;
  147153. private _origin;
  147154. private _options;
  147155. private _physicsEngine;
  147156. private _originTop;
  147157. private _tickCallback;
  147158. private _cylinder;
  147159. private _cylinderPosition;
  147160. private _dataFetched;
  147161. /**
  147162. * Initializes the physics vortex event
  147163. * @param _scene The BabylonJS scene
  147164. * @param _origin The origin position of the vortex
  147165. * @param _options The options for the vortex event
  147166. */
  147167. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147168. /**
  147169. * Returns the data related to the vortex event (cylinder).
  147170. * @returns The physics vortex event data
  147171. */
  147172. getData(): PhysicsVortexEventData;
  147173. /**
  147174. * Enables the vortex.
  147175. */
  147176. enable(): void;
  147177. /**
  147178. * Disables the cortex.
  147179. */
  147180. disable(): void;
  147181. /**
  147182. * Disposes the sphere.
  147183. * @param force
  147184. */
  147185. dispose(force?: boolean): void;
  147186. private getImpostorHitData;
  147187. private _tick;
  147188. /*** Helpers ***/
  147189. private _prepareCylinder;
  147190. private _intersectsWithCylinder;
  147191. }
  147192. /**
  147193. * Options fot the radial explosion event
  147194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147195. */
  147196. export class PhysicsRadialExplosionEventOptions {
  147197. /**
  147198. * The radius of the sphere for the radial explosion.
  147199. */
  147200. radius: number;
  147201. /**
  147202. * The strenth of the explosion.
  147203. */
  147204. strength: number;
  147205. /**
  147206. * The strenght of the force in correspondence to the distance of the affected object
  147207. */
  147208. falloff: PhysicsRadialImpulseFalloff;
  147209. /**
  147210. * Sphere options for the radial explosion.
  147211. */
  147212. sphere: {
  147213. segments: number;
  147214. diameter: number;
  147215. };
  147216. /**
  147217. * Sphere options for the radial explosion.
  147218. */
  147219. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147220. }
  147221. /**
  147222. * Options fot the updraft event
  147223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147224. */
  147225. export class PhysicsUpdraftEventOptions {
  147226. /**
  147227. * The radius of the cylinder for the vortex
  147228. */
  147229. radius: number;
  147230. /**
  147231. * The strenth of the updraft.
  147232. */
  147233. strength: number;
  147234. /**
  147235. * The height of the cylinder for the updraft.
  147236. */
  147237. height: number;
  147238. /**
  147239. * The mode for the the updraft.
  147240. */
  147241. updraftMode: PhysicsUpdraftMode;
  147242. }
  147243. /**
  147244. * Options fot the vortex event
  147245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147246. */
  147247. export class PhysicsVortexEventOptions {
  147248. /**
  147249. * The radius of the cylinder for the vortex
  147250. */
  147251. radius: number;
  147252. /**
  147253. * The strenth of the vortex.
  147254. */
  147255. strength: number;
  147256. /**
  147257. * The height of the cylinder for the vortex.
  147258. */
  147259. height: number;
  147260. /**
  147261. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147262. */
  147263. centripetalForceThreshold: number;
  147264. /**
  147265. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147266. */
  147267. centripetalForceMultiplier: number;
  147268. /**
  147269. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147270. */
  147271. centrifugalForceMultiplier: number;
  147272. /**
  147273. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147274. */
  147275. updraftForceMultiplier: number;
  147276. }
  147277. /**
  147278. * The strenght of the force in correspondence to the distance of the affected object
  147279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147280. */
  147281. export enum PhysicsRadialImpulseFalloff {
  147282. /** Defines that impulse is constant in strength across it's whole radius */
  147283. Constant = 0,
  147284. /** Defines that impulse gets weaker if it's further from the origin */
  147285. Linear = 1
  147286. }
  147287. /**
  147288. * The strength of the force in correspondence to the distance of the affected object
  147289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147290. */
  147291. export enum PhysicsUpdraftMode {
  147292. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147293. Center = 0,
  147294. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147295. Perpendicular = 1
  147296. }
  147297. /**
  147298. * Interface for a physics hit data
  147299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147300. */
  147301. export interface PhysicsHitData {
  147302. /**
  147303. * The force applied at the contact point
  147304. */
  147305. force: Vector3;
  147306. /**
  147307. * The contact point
  147308. */
  147309. contactPoint: Vector3;
  147310. /**
  147311. * The distance from the origin to the contact point
  147312. */
  147313. distanceFromOrigin: number;
  147314. }
  147315. /**
  147316. * Interface for radial explosion event data
  147317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147318. */
  147319. export interface PhysicsRadialExplosionEventData {
  147320. /**
  147321. * A sphere used for the radial explosion event
  147322. */
  147323. sphere: Mesh;
  147324. }
  147325. /**
  147326. * Interface for gravitational field event data
  147327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147328. */
  147329. export interface PhysicsGravitationalFieldEventData {
  147330. /**
  147331. * A sphere mesh used for the gravitational field event
  147332. */
  147333. sphere: Mesh;
  147334. }
  147335. /**
  147336. * Interface for updraft event data
  147337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147338. */
  147339. export interface PhysicsUpdraftEventData {
  147340. /**
  147341. * A cylinder used for the updraft event
  147342. */
  147343. cylinder: Mesh;
  147344. }
  147345. /**
  147346. * Interface for vortex event data
  147347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147348. */
  147349. export interface PhysicsVortexEventData {
  147350. /**
  147351. * A cylinder used for the vortex event
  147352. */
  147353. cylinder: Mesh;
  147354. }
  147355. /**
  147356. * Interface for an affected physics impostor
  147357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147358. */
  147359. export interface PhysicsAffectedImpostorWithData {
  147360. /**
  147361. * The impostor affected by the effect
  147362. */
  147363. impostor: PhysicsImpostor;
  147364. /**
  147365. * The data about the hit/horce from the explosion
  147366. */
  147367. hitData: PhysicsHitData;
  147368. }
  147369. }
  147370. declare module BABYLON {
  147371. /** @hidden */
  147372. export var blackAndWhitePixelShader: {
  147373. name: string;
  147374. shader: string;
  147375. };
  147376. }
  147377. declare module BABYLON {
  147378. /**
  147379. * Post process used to render in black and white
  147380. */
  147381. export class BlackAndWhitePostProcess extends PostProcess {
  147382. /**
  147383. * Linear about to convert he result to black and white (default: 1)
  147384. */
  147385. degree: number;
  147386. /**
  147387. * Creates a black and white post process
  147388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147389. * @param name The name of the effect.
  147390. * @param options The required width/height ratio to downsize to before computing the render pass.
  147391. * @param camera The camera to apply the render pass to.
  147392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147393. * @param engine The engine which the post process will be applied. (default: current engine)
  147394. * @param reusable If the post process can be reused on the same frame. (default: false)
  147395. */
  147396. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147397. }
  147398. }
  147399. declare module BABYLON {
  147400. /**
  147401. * This represents a set of one or more post processes in Babylon.
  147402. * A post process can be used to apply a shader to a texture after it is rendered.
  147403. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147404. */
  147405. export class PostProcessRenderEffect {
  147406. private _postProcesses;
  147407. private _getPostProcesses;
  147408. private _singleInstance;
  147409. private _cameras;
  147410. private _indicesForCamera;
  147411. /**
  147412. * Name of the effect
  147413. * @hidden
  147414. */
  147415. _name: string;
  147416. /**
  147417. * Instantiates a post process render effect.
  147418. * A post process can be used to apply a shader to a texture after it is rendered.
  147419. * @param engine The engine the effect is tied to
  147420. * @param name The name of the effect
  147421. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147422. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147423. */
  147424. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147425. /**
  147426. * Checks if all the post processes in the effect are supported.
  147427. */
  147428. get isSupported(): boolean;
  147429. /**
  147430. * Updates the current state of the effect
  147431. * @hidden
  147432. */
  147433. _update(): void;
  147434. /**
  147435. * Attaches the effect on cameras
  147436. * @param cameras The camera to attach to.
  147437. * @hidden
  147438. */
  147439. _attachCameras(cameras: Camera): void;
  147440. /**
  147441. * Attaches the effect on cameras
  147442. * @param cameras The camera to attach to.
  147443. * @hidden
  147444. */
  147445. _attachCameras(cameras: Camera[]): void;
  147446. /**
  147447. * Detaches the effect on cameras
  147448. * @param cameras The camera to detatch from.
  147449. * @hidden
  147450. */
  147451. _detachCameras(cameras: Camera): void;
  147452. /**
  147453. * Detatches the effect on cameras
  147454. * @param cameras The camera to detatch from.
  147455. * @hidden
  147456. */
  147457. _detachCameras(cameras: Camera[]): void;
  147458. /**
  147459. * Enables the effect on given cameras
  147460. * @param cameras The camera to enable.
  147461. * @hidden
  147462. */
  147463. _enable(cameras: Camera): void;
  147464. /**
  147465. * Enables the effect on given cameras
  147466. * @param cameras The camera to enable.
  147467. * @hidden
  147468. */
  147469. _enable(cameras: Nullable<Camera[]>): void;
  147470. /**
  147471. * Disables the effect on the given cameras
  147472. * @param cameras The camera to disable.
  147473. * @hidden
  147474. */
  147475. _disable(cameras: Camera): void;
  147476. /**
  147477. * Disables the effect on the given cameras
  147478. * @param cameras The camera to disable.
  147479. * @hidden
  147480. */
  147481. _disable(cameras: Nullable<Camera[]>): void;
  147482. /**
  147483. * Gets a list of the post processes contained in the effect.
  147484. * @param camera The camera to get the post processes on.
  147485. * @returns The list of the post processes in the effect.
  147486. */
  147487. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147488. }
  147489. }
  147490. declare module BABYLON {
  147491. /** @hidden */
  147492. export var extractHighlightsPixelShader: {
  147493. name: string;
  147494. shader: string;
  147495. };
  147496. }
  147497. declare module BABYLON {
  147498. /**
  147499. * 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.
  147500. */
  147501. export class ExtractHighlightsPostProcess extends PostProcess {
  147502. /**
  147503. * The luminance threshold, pixels below this value will be set to black.
  147504. */
  147505. threshold: number;
  147506. /** @hidden */
  147507. _exposure: number;
  147508. /**
  147509. * Post process which has the input texture to be used when performing highlight extraction
  147510. * @hidden
  147511. */
  147512. _inputPostProcess: Nullable<PostProcess>;
  147513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147514. }
  147515. }
  147516. declare module BABYLON {
  147517. /** @hidden */
  147518. export var bloomMergePixelShader: {
  147519. name: string;
  147520. shader: string;
  147521. };
  147522. }
  147523. declare module BABYLON {
  147524. /**
  147525. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147526. */
  147527. export class BloomMergePostProcess extends PostProcess {
  147528. /** Weight of the bloom to be added to the original input. */
  147529. weight: number;
  147530. /**
  147531. * Creates a new instance of @see BloomMergePostProcess
  147532. * @param name The name of the effect.
  147533. * @param originalFromInput Post process which's input will be used for the merge.
  147534. * @param blurred Blurred highlights post process which's output will be used.
  147535. * @param weight Weight of the bloom to be added to the original input.
  147536. * @param options The required width/height ratio to downsize to before computing the render pass.
  147537. * @param camera The camera to apply the render pass to.
  147538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147539. * @param engine The engine which the post process will be applied. (default: current engine)
  147540. * @param reusable If the post process can be reused on the same frame. (default: false)
  147541. * @param textureType Type of textures used when performing the post process. (default: 0)
  147542. * @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)
  147543. */
  147544. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147545. /** Weight of the bloom to be added to the original input. */
  147546. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147547. }
  147548. }
  147549. declare module BABYLON {
  147550. /**
  147551. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147552. */
  147553. export class BloomEffect extends PostProcessRenderEffect {
  147554. private bloomScale;
  147555. /**
  147556. * @hidden Internal
  147557. */
  147558. _effects: Array<PostProcess>;
  147559. /**
  147560. * @hidden Internal
  147561. */
  147562. _downscale: ExtractHighlightsPostProcess;
  147563. private _blurX;
  147564. private _blurY;
  147565. private _merge;
  147566. /**
  147567. * The luminance threshold to find bright areas of the image to bloom.
  147568. */
  147569. get threshold(): number;
  147570. set threshold(value: number);
  147571. /**
  147572. * The strength of the bloom.
  147573. */
  147574. get weight(): number;
  147575. set weight(value: number);
  147576. /**
  147577. * Specifies the size of the bloom blur kernel, relative to the final output size
  147578. */
  147579. get kernel(): number;
  147580. set kernel(value: number);
  147581. /**
  147582. * Creates a new instance of @see BloomEffect
  147583. * @param scene The scene the effect belongs to.
  147584. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147585. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147586. * @param bloomWeight The the strength of bloom.
  147587. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147588. * @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)
  147589. */
  147590. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147591. /**
  147592. * Disposes each of the internal effects for a given camera.
  147593. * @param camera The camera to dispose the effect on.
  147594. */
  147595. disposeEffects(camera: Camera): void;
  147596. /**
  147597. * @hidden Internal
  147598. */
  147599. _updateEffects(): void;
  147600. /**
  147601. * Internal
  147602. * @returns if all the contained post processes are ready.
  147603. * @hidden
  147604. */
  147605. _isReady(): boolean;
  147606. }
  147607. }
  147608. declare module BABYLON {
  147609. /** @hidden */
  147610. export var chromaticAberrationPixelShader: {
  147611. name: string;
  147612. shader: string;
  147613. };
  147614. }
  147615. declare module BABYLON {
  147616. /**
  147617. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147618. */
  147619. export class ChromaticAberrationPostProcess extends PostProcess {
  147620. /**
  147621. * The amount of seperation of rgb channels (default: 30)
  147622. */
  147623. aberrationAmount: number;
  147624. /**
  147625. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147626. */
  147627. radialIntensity: number;
  147628. /**
  147629. * 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))
  147630. */
  147631. direction: Vector2;
  147632. /**
  147633. * 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))
  147634. */
  147635. centerPosition: Vector2;
  147636. /**
  147637. * Creates a new instance ChromaticAberrationPostProcess
  147638. * @param name The name of the effect.
  147639. * @param screenWidth The width of the screen to apply the effect on.
  147640. * @param screenHeight The height of the screen to apply the effect on.
  147641. * @param options The required width/height ratio to downsize to before computing the render pass.
  147642. * @param camera The camera to apply the render pass to.
  147643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147644. * @param engine The engine which the post process will be applied. (default: current engine)
  147645. * @param reusable If the post process can be reused on the same frame. (default: false)
  147646. * @param textureType Type of textures used when performing the post process. (default: 0)
  147647. * @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)
  147648. */
  147649. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147650. }
  147651. }
  147652. declare module BABYLON {
  147653. /** @hidden */
  147654. export var circleOfConfusionPixelShader: {
  147655. name: string;
  147656. shader: string;
  147657. };
  147658. }
  147659. declare module BABYLON {
  147660. /**
  147661. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147662. */
  147663. export class CircleOfConfusionPostProcess extends PostProcess {
  147664. /**
  147665. * 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.
  147666. */
  147667. lensSize: number;
  147668. /**
  147669. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147670. */
  147671. fStop: number;
  147672. /**
  147673. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147674. */
  147675. focusDistance: number;
  147676. /**
  147677. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147678. */
  147679. focalLength: number;
  147680. private _depthTexture;
  147681. /**
  147682. * Creates a new instance CircleOfConfusionPostProcess
  147683. * @param name The name of the effect.
  147684. * @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.
  147685. * @param options The required width/height ratio to downsize to before computing the render pass.
  147686. * @param camera The camera to apply the render pass to.
  147687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147688. * @param engine The engine which the post process will be applied. (default: current engine)
  147689. * @param reusable If the post process can be reused on the same frame. (default: false)
  147690. * @param textureType Type of textures used when performing the post process. (default: 0)
  147691. * @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)
  147692. */
  147693. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147694. /**
  147695. * 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.
  147696. */
  147697. set depthTexture(value: RenderTargetTexture);
  147698. }
  147699. }
  147700. declare module BABYLON {
  147701. /** @hidden */
  147702. export var colorCorrectionPixelShader: {
  147703. name: string;
  147704. shader: string;
  147705. };
  147706. }
  147707. declare module BABYLON {
  147708. /**
  147709. *
  147710. * This post-process allows the modification of rendered colors by using
  147711. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147712. *
  147713. * The object needs to be provided an url to a texture containing the color
  147714. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147715. * Use an image editing software to tweak the LUT to match your needs.
  147716. *
  147717. * For an example of a color LUT, see here:
  147718. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147719. * For explanations on color grading, see here:
  147720. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147721. *
  147722. */
  147723. export class ColorCorrectionPostProcess extends PostProcess {
  147724. private _colorTableTexture;
  147725. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147726. }
  147727. }
  147728. declare module BABYLON {
  147729. /** @hidden */
  147730. export var convolutionPixelShader: {
  147731. name: string;
  147732. shader: string;
  147733. };
  147734. }
  147735. declare module BABYLON {
  147736. /**
  147737. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147738. * input texture to perform effects such as edge detection or sharpening
  147739. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147740. */
  147741. export class ConvolutionPostProcess extends PostProcess {
  147742. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147743. kernel: number[];
  147744. /**
  147745. * Creates a new instance ConvolutionPostProcess
  147746. * @param name The name of the effect.
  147747. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147748. * @param options The required width/height ratio to downsize to before computing the render pass.
  147749. * @param camera The camera to apply the render pass to.
  147750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147751. * @param engine The engine which the post process will be applied. (default: current engine)
  147752. * @param reusable If the post process can be reused on the same frame. (default: false)
  147753. * @param textureType Type of textures used when performing the post process. (default: 0)
  147754. */
  147755. constructor(name: string,
  147756. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147757. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147758. /**
  147759. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147760. */
  147761. static EdgeDetect0Kernel: number[];
  147762. /**
  147763. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147764. */
  147765. static EdgeDetect1Kernel: number[];
  147766. /**
  147767. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147768. */
  147769. static EdgeDetect2Kernel: number[];
  147770. /**
  147771. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147772. */
  147773. static SharpenKernel: number[];
  147774. /**
  147775. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147776. */
  147777. static EmbossKernel: number[];
  147778. /**
  147779. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147780. */
  147781. static GaussianKernel: number[];
  147782. }
  147783. }
  147784. declare module BABYLON {
  147785. /**
  147786. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  147787. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  147788. * based on samples that have a large difference in distance than the center pixel.
  147789. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  147790. */
  147791. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  147792. direction: Vector2;
  147793. /**
  147794. * Creates a new instance CircleOfConfusionPostProcess
  147795. * @param name The name of the effect.
  147796. * @param scene The scene the effect belongs to.
  147797. * @param direction The direction the blur should be applied.
  147798. * @param kernel The size of the kernel used to blur.
  147799. * @param options The required width/height ratio to downsize to before computing the render pass.
  147800. * @param camera The camera to apply the render pass to.
  147801. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  147802. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  147803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147804. * @param engine The engine which the post process will be applied. (default: current engine)
  147805. * @param reusable If the post process can be reused on the same frame. (default: false)
  147806. * @param textureType Type of textures used when performing the post process. (default: 0)
  147807. * @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)
  147808. */
  147809. 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);
  147810. }
  147811. }
  147812. declare module BABYLON {
  147813. /** @hidden */
  147814. export var depthOfFieldMergePixelShader: {
  147815. name: string;
  147816. shader: string;
  147817. };
  147818. }
  147819. declare module BABYLON {
  147820. /**
  147821. * Options to be set when merging outputs from the default pipeline.
  147822. */
  147823. export class DepthOfFieldMergePostProcessOptions {
  147824. /**
  147825. * The original image to merge on top of
  147826. */
  147827. originalFromInput: PostProcess;
  147828. /**
  147829. * Parameters to perform the merge of the depth of field effect
  147830. */
  147831. depthOfField?: {
  147832. circleOfConfusion: PostProcess;
  147833. blurSteps: Array<PostProcess>;
  147834. };
  147835. /**
  147836. * Parameters to perform the merge of bloom effect
  147837. */
  147838. bloom?: {
  147839. blurred: PostProcess;
  147840. weight: number;
  147841. };
  147842. }
  147843. /**
  147844. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147845. */
  147846. export class DepthOfFieldMergePostProcess extends PostProcess {
  147847. private blurSteps;
  147848. /**
  147849. * Creates a new instance of DepthOfFieldMergePostProcess
  147850. * @param name The name of the effect.
  147851. * @param originalFromInput Post process which's input will be used for the merge.
  147852. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  147853. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  147854. * @param options The required width/height ratio to downsize to before computing the render pass.
  147855. * @param camera The camera to apply the render pass to.
  147856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147857. * @param engine The engine which the post process will be applied. (default: current engine)
  147858. * @param reusable If the post process can be reused on the same frame. (default: false)
  147859. * @param textureType Type of textures used when performing the post process. (default: 0)
  147860. * @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)
  147861. */
  147862. 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);
  147863. /**
  147864. * Updates the effect with the current post process compile time values and recompiles the shader.
  147865. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  147866. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  147867. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  147868. * @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
  147869. * @param onCompiled Called when the shader has been compiled.
  147870. * @param onError Called if there is an error when compiling a shader.
  147871. */
  147872. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  147873. }
  147874. }
  147875. declare module BABYLON {
  147876. /**
  147877. * Specifies the level of max blur that should be applied when using the depth of field effect
  147878. */
  147879. export enum DepthOfFieldEffectBlurLevel {
  147880. /**
  147881. * Subtle blur
  147882. */
  147883. Low = 0,
  147884. /**
  147885. * Medium blur
  147886. */
  147887. Medium = 1,
  147888. /**
  147889. * Large blur
  147890. */
  147891. High = 2
  147892. }
  147893. /**
  147894. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  147895. */
  147896. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  147897. private _circleOfConfusion;
  147898. /**
  147899. * @hidden Internal, blurs from high to low
  147900. */
  147901. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  147902. private _depthOfFieldBlurY;
  147903. private _dofMerge;
  147904. /**
  147905. * @hidden Internal post processes in depth of field effect
  147906. */
  147907. _effects: Array<PostProcess>;
  147908. /**
  147909. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  147910. */
  147911. set focalLength(value: number);
  147912. get focalLength(): number;
  147913. /**
  147914. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147915. */
  147916. set fStop(value: number);
  147917. get fStop(): number;
  147918. /**
  147919. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147920. */
  147921. set focusDistance(value: number);
  147922. get focusDistance(): number;
  147923. /**
  147924. * 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.
  147925. */
  147926. set lensSize(value: number);
  147927. get lensSize(): number;
  147928. /**
  147929. * Creates a new instance DepthOfFieldEffect
  147930. * @param scene The scene the effect belongs to.
  147931. * @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.
  147932. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147933. * @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)
  147934. */
  147935. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  147936. /**
  147937. * Get the current class name of the current effet
  147938. * @returns "DepthOfFieldEffect"
  147939. */
  147940. getClassName(): string;
  147941. /**
  147942. * 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.
  147943. */
  147944. set depthTexture(value: RenderTargetTexture);
  147945. /**
  147946. * Disposes each of the internal effects for a given camera.
  147947. * @param camera The camera to dispose the effect on.
  147948. */
  147949. disposeEffects(camera: Camera): void;
  147950. /**
  147951. * @hidden Internal
  147952. */
  147953. _updateEffects(): void;
  147954. /**
  147955. * Internal
  147956. * @returns if all the contained post processes are ready.
  147957. * @hidden
  147958. */
  147959. _isReady(): boolean;
  147960. }
  147961. }
  147962. declare module BABYLON {
  147963. /** @hidden */
  147964. export var displayPassPixelShader: {
  147965. name: string;
  147966. shader: string;
  147967. };
  147968. }
  147969. declare module BABYLON {
  147970. /**
  147971. * DisplayPassPostProcess which produces an output the same as it's input
  147972. */
  147973. export class DisplayPassPostProcess extends PostProcess {
  147974. /**
  147975. * Creates the DisplayPassPostProcess
  147976. * @param name The name of the effect.
  147977. * @param options The required width/height ratio to downsize to before computing the render pass.
  147978. * @param camera The camera to apply the render pass to.
  147979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147980. * @param engine The engine which the post process will be applied. (default: current engine)
  147981. * @param reusable If the post process can be reused on the same frame. (default: false)
  147982. */
  147983. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147984. }
  147985. }
  147986. declare module BABYLON {
  147987. /** @hidden */
  147988. export var filterPixelShader: {
  147989. name: string;
  147990. shader: string;
  147991. };
  147992. }
  147993. declare module BABYLON {
  147994. /**
  147995. * Applies a kernel filter to the image
  147996. */
  147997. export class FilterPostProcess extends PostProcess {
  147998. /** The matrix to be applied to the image */
  147999. kernelMatrix: Matrix;
  148000. /**
  148001. *
  148002. * @param name The name of the effect.
  148003. * @param kernelMatrix The matrix to be applied to the image
  148004. * @param options The required width/height ratio to downsize to before computing the render pass.
  148005. * @param camera The camera to apply the render pass to.
  148006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148007. * @param engine The engine which the post process will be applied. (default: current engine)
  148008. * @param reusable If the post process can be reused on the same frame. (default: false)
  148009. */
  148010. constructor(name: string,
  148011. /** The matrix to be applied to the image */
  148012. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148013. }
  148014. }
  148015. declare module BABYLON {
  148016. /** @hidden */
  148017. export var fxaaPixelShader: {
  148018. name: string;
  148019. shader: string;
  148020. };
  148021. }
  148022. declare module BABYLON {
  148023. /** @hidden */
  148024. export var fxaaVertexShader: {
  148025. name: string;
  148026. shader: string;
  148027. };
  148028. }
  148029. declare module BABYLON {
  148030. /**
  148031. * Fxaa post process
  148032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148033. */
  148034. export class FxaaPostProcess extends PostProcess {
  148035. /** @hidden */
  148036. texelWidth: number;
  148037. /** @hidden */
  148038. texelHeight: number;
  148039. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148040. private _getDefines;
  148041. }
  148042. }
  148043. declare module BABYLON {
  148044. /** @hidden */
  148045. export var grainPixelShader: {
  148046. name: string;
  148047. shader: string;
  148048. };
  148049. }
  148050. declare module BABYLON {
  148051. /**
  148052. * The GrainPostProcess adds noise to the image at mid luminance levels
  148053. */
  148054. export class GrainPostProcess extends PostProcess {
  148055. /**
  148056. * The intensity of the grain added (default: 30)
  148057. */
  148058. intensity: number;
  148059. /**
  148060. * If the grain should be randomized on every frame
  148061. */
  148062. animated: boolean;
  148063. /**
  148064. * Creates a new instance of @see GrainPostProcess
  148065. * @param name The name of the effect.
  148066. * @param options The required width/height ratio to downsize to before computing the render pass.
  148067. * @param camera The camera to apply the render pass to.
  148068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148069. * @param engine The engine which the post process will be applied. (default: current engine)
  148070. * @param reusable If the post process can be reused on the same frame. (default: false)
  148071. * @param textureType Type of textures used when performing the post process. (default: 0)
  148072. * @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)
  148073. */
  148074. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148075. }
  148076. }
  148077. declare module BABYLON {
  148078. /** @hidden */
  148079. export var highlightsPixelShader: {
  148080. name: string;
  148081. shader: string;
  148082. };
  148083. }
  148084. declare module BABYLON {
  148085. /**
  148086. * Extracts highlights from the image
  148087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148088. */
  148089. export class HighlightsPostProcess extends PostProcess {
  148090. /**
  148091. * Extracts highlights from the image
  148092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148093. * @param name The name of the effect.
  148094. * @param options The required width/height ratio to downsize to before computing the render pass.
  148095. * @param camera The camera to apply the render pass to.
  148096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148097. * @param engine The engine which the post process will be applied. (default: current engine)
  148098. * @param reusable If the post process can be reused on the same frame. (default: false)
  148099. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148100. */
  148101. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148102. }
  148103. }
  148104. declare module BABYLON {
  148105. /** @hidden */
  148106. export var mrtFragmentDeclaration: {
  148107. name: string;
  148108. shader: string;
  148109. };
  148110. }
  148111. declare module BABYLON {
  148112. /** @hidden */
  148113. export var geometryPixelShader: {
  148114. name: string;
  148115. shader: string;
  148116. };
  148117. }
  148118. declare module BABYLON {
  148119. /** @hidden */
  148120. export var geometryVertexShader: {
  148121. name: string;
  148122. shader: string;
  148123. };
  148124. }
  148125. declare module BABYLON {
  148126. /** @hidden */
  148127. interface ISavedTransformationMatrix {
  148128. world: Matrix;
  148129. viewProjection: Matrix;
  148130. }
  148131. /**
  148132. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148133. */
  148134. export class GeometryBufferRenderer {
  148135. /**
  148136. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148137. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148138. */
  148139. static readonly POSITION_TEXTURE_TYPE: number;
  148140. /**
  148141. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148142. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148143. */
  148144. static readonly VELOCITY_TEXTURE_TYPE: number;
  148145. /**
  148146. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148147. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148148. */
  148149. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148150. /**
  148151. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148152. * in order to compute objects velocities when enableVelocity is set to "true"
  148153. * @hidden
  148154. */
  148155. _previousTransformationMatrices: {
  148156. [index: number]: ISavedTransformationMatrix;
  148157. };
  148158. /**
  148159. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148160. * in order to compute objects velocities when enableVelocity is set to "true"
  148161. * @hidden
  148162. */
  148163. _previousBonesTransformationMatrices: {
  148164. [index: number]: Float32Array;
  148165. };
  148166. /**
  148167. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148168. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148169. */
  148170. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148171. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148172. renderTransparentMeshes: boolean;
  148173. private _scene;
  148174. private _resizeObserver;
  148175. private _multiRenderTarget;
  148176. private _ratio;
  148177. private _enablePosition;
  148178. private _enableVelocity;
  148179. private _enableReflectivity;
  148180. private _positionIndex;
  148181. private _velocityIndex;
  148182. private _reflectivityIndex;
  148183. protected _effect: Effect;
  148184. protected _cachedDefines: string;
  148185. /**
  148186. * Set the render list (meshes to be rendered) used in the G buffer.
  148187. */
  148188. set renderList(meshes: Mesh[]);
  148189. /**
  148190. * Gets wether or not G buffer are supported by the running hardware.
  148191. * This requires draw buffer supports
  148192. */
  148193. get isSupported(): boolean;
  148194. /**
  148195. * Returns the index of the given texture type in the G-Buffer textures array
  148196. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148197. * @returns the index of the given texture type in the G-Buffer textures array
  148198. */
  148199. getTextureIndex(textureType: number): number;
  148200. /**
  148201. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148202. */
  148203. get enablePosition(): boolean;
  148204. /**
  148205. * Sets whether or not objects positions are enabled for the G buffer.
  148206. */
  148207. set enablePosition(enable: boolean);
  148208. /**
  148209. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148210. */
  148211. get enableVelocity(): boolean;
  148212. /**
  148213. * Sets wether or not objects velocities are enabled for the G buffer.
  148214. */
  148215. set enableVelocity(enable: boolean);
  148216. /**
  148217. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148218. */
  148219. get enableReflectivity(): boolean;
  148220. /**
  148221. * Sets wether or not objects roughness are enabled for the G buffer.
  148222. */
  148223. set enableReflectivity(enable: boolean);
  148224. /**
  148225. * Gets the scene associated with the buffer.
  148226. */
  148227. get scene(): Scene;
  148228. /**
  148229. * Gets the ratio used by the buffer during its creation.
  148230. * How big is the buffer related to the main canvas.
  148231. */
  148232. get ratio(): number;
  148233. /** @hidden */
  148234. static _SceneComponentInitialization: (scene: Scene) => void;
  148235. /**
  148236. * Creates a new G Buffer for the scene
  148237. * @param scene The scene the buffer belongs to
  148238. * @param ratio How big is the buffer related to the main canvas.
  148239. */
  148240. constructor(scene: Scene, ratio?: number);
  148241. /**
  148242. * Checks wether everything is ready to render a submesh to the G buffer.
  148243. * @param subMesh the submesh to check readiness for
  148244. * @param useInstances is the mesh drawn using instance or not
  148245. * @returns true if ready otherwise false
  148246. */
  148247. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148248. /**
  148249. * Gets the current underlying G Buffer.
  148250. * @returns the buffer
  148251. */
  148252. getGBuffer(): MultiRenderTarget;
  148253. /**
  148254. * Gets the number of samples used to render the buffer (anti aliasing).
  148255. */
  148256. get samples(): number;
  148257. /**
  148258. * Sets the number of samples used to render the buffer (anti aliasing).
  148259. */
  148260. set samples(value: number);
  148261. /**
  148262. * Disposes the renderer and frees up associated resources.
  148263. */
  148264. dispose(): void;
  148265. protected _createRenderTargets(): void;
  148266. private _copyBonesTransformationMatrices;
  148267. }
  148268. }
  148269. declare module BABYLON {
  148270. interface Scene {
  148271. /** @hidden (Backing field) */
  148272. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148273. /**
  148274. * Gets or Sets the current geometry buffer associated to the scene.
  148275. */
  148276. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148277. /**
  148278. * Enables a GeometryBufferRender and associates it with the scene
  148279. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148280. * @returns the GeometryBufferRenderer
  148281. */
  148282. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148283. /**
  148284. * Disables the GeometryBufferRender associated with the scene
  148285. */
  148286. disableGeometryBufferRenderer(): void;
  148287. }
  148288. /**
  148289. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148290. * in several rendering techniques.
  148291. */
  148292. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148293. /**
  148294. * The component name helpful to identify the component in the list of scene components.
  148295. */
  148296. readonly name: string;
  148297. /**
  148298. * The scene the component belongs to.
  148299. */
  148300. scene: Scene;
  148301. /**
  148302. * Creates a new instance of the component for the given scene
  148303. * @param scene Defines the scene to register the component in
  148304. */
  148305. constructor(scene: Scene);
  148306. /**
  148307. * Registers the component in a given scene
  148308. */
  148309. register(): void;
  148310. /**
  148311. * Rebuilds the elements related to this component in case of
  148312. * context lost for instance.
  148313. */
  148314. rebuild(): void;
  148315. /**
  148316. * Disposes the component and the associated ressources
  148317. */
  148318. dispose(): void;
  148319. private _gatherRenderTargets;
  148320. }
  148321. }
  148322. declare module BABYLON {
  148323. /** @hidden */
  148324. export var motionBlurPixelShader: {
  148325. name: string;
  148326. shader: string;
  148327. };
  148328. }
  148329. declare module BABYLON {
  148330. /**
  148331. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148332. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148333. * As an example, all you have to do is to create the post-process:
  148334. * var mb = new BABYLON.MotionBlurPostProcess(
  148335. * 'mb', // The name of the effect.
  148336. * scene, // The scene containing the objects to blur according to their velocity.
  148337. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148338. * camera // The camera to apply the render pass to.
  148339. * );
  148340. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148341. */
  148342. export class MotionBlurPostProcess extends PostProcess {
  148343. /**
  148344. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148345. */
  148346. motionStrength: number;
  148347. /**
  148348. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148349. */
  148350. get motionBlurSamples(): number;
  148351. /**
  148352. * Sets the number of iterations to be used for motion blur quality
  148353. */
  148354. set motionBlurSamples(samples: number);
  148355. private _motionBlurSamples;
  148356. private _geometryBufferRenderer;
  148357. /**
  148358. * Creates a new instance MotionBlurPostProcess
  148359. * @param name The name of the effect.
  148360. * @param scene The scene containing the objects to blur according to their velocity.
  148361. * @param options The required width/height ratio to downsize to before computing the render pass.
  148362. * @param camera The camera to apply the render pass to.
  148363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148364. * @param engine The engine which the post process will be applied. (default: current engine)
  148365. * @param reusable If the post process can be reused on the same frame. (default: false)
  148366. * @param textureType Type of textures used when performing the post process. (default: 0)
  148367. * @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)
  148368. */
  148369. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148370. /**
  148371. * Excludes the given skinned mesh from computing bones velocities.
  148372. * 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.
  148373. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148374. */
  148375. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148376. /**
  148377. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148378. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148379. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148380. */
  148381. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148382. /**
  148383. * Disposes the post process.
  148384. * @param camera The camera to dispose the post process on.
  148385. */
  148386. dispose(camera?: Camera): void;
  148387. }
  148388. }
  148389. declare module BABYLON {
  148390. /** @hidden */
  148391. export var refractionPixelShader: {
  148392. name: string;
  148393. shader: string;
  148394. };
  148395. }
  148396. declare module BABYLON {
  148397. /**
  148398. * Post process which applies a refractin texture
  148399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148400. */
  148401. export class RefractionPostProcess extends PostProcess {
  148402. /** the base color of the refraction (used to taint the rendering) */
  148403. color: Color3;
  148404. /** simulated refraction depth */
  148405. depth: number;
  148406. /** the coefficient of the base color (0 to remove base color tainting) */
  148407. colorLevel: number;
  148408. private _refTexture;
  148409. private _ownRefractionTexture;
  148410. /**
  148411. * Gets or sets the refraction texture
  148412. * Please note that you are responsible for disposing the texture if you set it manually
  148413. */
  148414. get refractionTexture(): Texture;
  148415. set refractionTexture(value: Texture);
  148416. /**
  148417. * Initializes the RefractionPostProcess
  148418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148419. * @param name The name of the effect.
  148420. * @param refractionTextureUrl Url of the refraction texture to use
  148421. * @param color the base color of the refraction (used to taint the rendering)
  148422. * @param depth simulated refraction depth
  148423. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148424. * @param camera The camera to apply the render pass to.
  148425. * @param options The required width/height ratio to downsize to before computing the render pass.
  148426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148427. * @param engine The engine which the post process will be applied. (default: current engine)
  148428. * @param reusable If the post process can be reused on the same frame. (default: false)
  148429. */
  148430. constructor(name: string, refractionTextureUrl: string,
  148431. /** the base color of the refraction (used to taint the rendering) */
  148432. color: Color3,
  148433. /** simulated refraction depth */
  148434. depth: number,
  148435. /** the coefficient of the base color (0 to remove base color tainting) */
  148436. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148437. /**
  148438. * Disposes of the post process
  148439. * @param camera Camera to dispose post process on
  148440. */
  148441. dispose(camera: Camera): void;
  148442. }
  148443. }
  148444. declare module BABYLON {
  148445. /** @hidden */
  148446. export var sharpenPixelShader: {
  148447. name: string;
  148448. shader: string;
  148449. };
  148450. }
  148451. declare module BABYLON {
  148452. /**
  148453. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148454. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148455. */
  148456. export class SharpenPostProcess extends PostProcess {
  148457. /**
  148458. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148459. */
  148460. colorAmount: number;
  148461. /**
  148462. * How much sharpness should be applied (default: 0.3)
  148463. */
  148464. edgeAmount: number;
  148465. /**
  148466. * Creates a new instance ConvolutionPostProcess
  148467. * @param name The name of the effect.
  148468. * @param options The required width/height ratio to downsize to before computing the render pass.
  148469. * @param camera The camera to apply the render pass to.
  148470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148471. * @param engine The engine which the post process will be applied. (default: current engine)
  148472. * @param reusable If the post process can be reused on the same frame. (default: false)
  148473. * @param textureType Type of textures used when performing the post process. (default: 0)
  148474. * @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)
  148475. */
  148476. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148477. }
  148478. }
  148479. declare module BABYLON {
  148480. /**
  148481. * PostProcessRenderPipeline
  148482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148483. */
  148484. export class PostProcessRenderPipeline {
  148485. private engine;
  148486. private _renderEffects;
  148487. private _renderEffectsForIsolatedPass;
  148488. /**
  148489. * List of inspectable custom properties (used by the Inspector)
  148490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148491. */
  148492. inspectableCustomProperties: IInspectable[];
  148493. /**
  148494. * @hidden
  148495. */
  148496. protected _cameras: Camera[];
  148497. /** @hidden */
  148498. _name: string;
  148499. /**
  148500. * Gets pipeline name
  148501. */
  148502. get name(): string;
  148503. /** Gets the list of attached cameras */
  148504. get cameras(): Camera[];
  148505. /**
  148506. * Initializes a PostProcessRenderPipeline
  148507. * @param engine engine to add the pipeline to
  148508. * @param name name of the pipeline
  148509. */
  148510. constructor(engine: Engine, name: string);
  148511. /**
  148512. * Gets the class name
  148513. * @returns "PostProcessRenderPipeline"
  148514. */
  148515. getClassName(): string;
  148516. /**
  148517. * If all the render effects in the pipeline are supported
  148518. */
  148519. get isSupported(): boolean;
  148520. /**
  148521. * Adds an effect to the pipeline
  148522. * @param renderEffect the effect to add
  148523. */
  148524. addEffect(renderEffect: PostProcessRenderEffect): void;
  148525. /** @hidden */
  148526. _rebuild(): void;
  148527. /** @hidden */
  148528. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148529. /** @hidden */
  148530. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148531. /** @hidden */
  148532. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148533. /** @hidden */
  148534. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148535. /** @hidden */
  148536. _attachCameras(cameras: Camera, unique: boolean): void;
  148537. /** @hidden */
  148538. _attachCameras(cameras: Camera[], unique: boolean): void;
  148539. /** @hidden */
  148540. _detachCameras(cameras: Camera): void;
  148541. /** @hidden */
  148542. _detachCameras(cameras: Nullable<Camera[]>): void;
  148543. /** @hidden */
  148544. _update(): void;
  148545. /** @hidden */
  148546. _reset(): void;
  148547. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148548. /**
  148549. * Sets the required values to the prepass renderer.
  148550. * @param prePassRenderer defines the prepass renderer to setup.
  148551. * @returns true if the pre pass is needed.
  148552. */
  148553. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148554. /**
  148555. * Disposes of the pipeline
  148556. */
  148557. dispose(): void;
  148558. }
  148559. }
  148560. declare module BABYLON {
  148561. /**
  148562. * PostProcessRenderPipelineManager class
  148563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148564. */
  148565. export class PostProcessRenderPipelineManager {
  148566. private _renderPipelines;
  148567. /**
  148568. * Initializes a PostProcessRenderPipelineManager
  148569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148570. */
  148571. constructor();
  148572. /**
  148573. * Gets the list of supported render pipelines
  148574. */
  148575. get supportedPipelines(): PostProcessRenderPipeline[];
  148576. /**
  148577. * Adds a pipeline to the manager
  148578. * @param renderPipeline The pipeline to add
  148579. */
  148580. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148581. /**
  148582. * Attaches a camera to the pipeline
  148583. * @param renderPipelineName The name of the pipeline to attach to
  148584. * @param cameras the camera to attach
  148585. * @param unique if the camera can be attached multiple times to the pipeline
  148586. */
  148587. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148588. /**
  148589. * Detaches a camera from the pipeline
  148590. * @param renderPipelineName The name of the pipeline to detach from
  148591. * @param cameras the camera to detach
  148592. */
  148593. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148594. /**
  148595. * Enables an effect by name on a pipeline
  148596. * @param renderPipelineName the name of the pipeline to enable the effect in
  148597. * @param renderEffectName the name of the effect to enable
  148598. * @param cameras the cameras that the effect should be enabled on
  148599. */
  148600. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148601. /**
  148602. * Disables an effect by name on a pipeline
  148603. * @param renderPipelineName the name of the pipeline to disable the effect in
  148604. * @param renderEffectName the name of the effect to disable
  148605. * @param cameras the cameras that the effect should be disabled on
  148606. */
  148607. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148608. /**
  148609. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148610. */
  148611. update(): void;
  148612. /** @hidden */
  148613. _rebuild(): void;
  148614. /**
  148615. * Disposes of the manager and pipelines
  148616. */
  148617. dispose(): void;
  148618. }
  148619. }
  148620. declare module BABYLON {
  148621. interface Scene {
  148622. /** @hidden (Backing field) */
  148623. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148624. /**
  148625. * Gets the postprocess render pipeline manager
  148626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148627. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148628. */
  148629. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148630. }
  148631. /**
  148632. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148633. */
  148634. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148635. /**
  148636. * The component name helpfull to identify the component in the list of scene components.
  148637. */
  148638. readonly name: string;
  148639. /**
  148640. * The scene the component belongs to.
  148641. */
  148642. scene: Scene;
  148643. /**
  148644. * Creates a new instance of the component for the given scene
  148645. * @param scene Defines the scene to register the component in
  148646. */
  148647. constructor(scene: Scene);
  148648. /**
  148649. * Registers the component in a given scene
  148650. */
  148651. register(): void;
  148652. /**
  148653. * Rebuilds the elements related to this component in case of
  148654. * context lost for instance.
  148655. */
  148656. rebuild(): void;
  148657. /**
  148658. * Disposes the component and the associated ressources
  148659. */
  148660. dispose(): void;
  148661. private _gatherRenderTargets;
  148662. }
  148663. }
  148664. declare module BABYLON {
  148665. /**
  148666. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148667. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148668. */
  148669. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148670. private _scene;
  148671. private _camerasToBeAttached;
  148672. /**
  148673. * ID of the sharpen post process,
  148674. */
  148675. private readonly SharpenPostProcessId;
  148676. /**
  148677. * @ignore
  148678. * ID of the image processing post process;
  148679. */
  148680. readonly ImageProcessingPostProcessId: string;
  148681. /**
  148682. * @ignore
  148683. * ID of the Fast Approximate Anti-Aliasing post process;
  148684. */
  148685. readonly FxaaPostProcessId: string;
  148686. /**
  148687. * ID of the chromatic aberration post process,
  148688. */
  148689. private readonly ChromaticAberrationPostProcessId;
  148690. /**
  148691. * ID of the grain post process
  148692. */
  148693. private readonly GrainPostProcessId;
  148694. /**
  148695. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148696. */
  148697. sharpen: SharpenPostProcess;
  148698. private _sharpenEffect;
  148699. private bloom;
  148700. /**
  148701. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148702. */
  148703. depthOfField: DepthOfFieldEffect;
  148704. /**
  148705. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148706. */
  148707. fxaa: FxaaPostProcess;
  148708. /**
  148709. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148710. */
  148711. imageProcessing: ImageProcessingPostProcess;
  148712. /**
  148713. * Chromatic aberration post process which will shift rgb colors in the image
  148714. */
  148715. chromaticAberration: ChromaticAberrationPostProcess;
  148716. private _chromaticAberrationEffect;
  148717. /**
  148718. * Grain post process which add noise to the image
  148719. */
  148720. grain: GrainPostProcess;
  148721. private _grainEffect;
  148722. /**
  148723. * Glow post process which adds a glow to emissive areas of the image
  148724. */
  148725. private _glowLayer;
  148726. /**
  148727. * Animations which can be used to tweak settings over a period of time
  148728. */
  148729. animations: Animation[];
  148730. private _imageProcessingConfigurationObserver;
  148731. private _sharpenEnabled;
  148732. private _bloomEnabled;
  148733. private _depthOfFieldEnabled;
  148734. private _depthOfFieldBlurLevel;
  148735. private _fxaaEnabled;
  148736. private _imageProcessingEnabled;
  148737. private _defaultPipelineTextureType;
  148738. private _bloomScale;
  148739. private _chromaticAberrationEnabled;
  148740. private _grainEnabled;
  148741. private _buildAllowed;
  148742. /**
  148743. * Gets active scene
  148744. */
  148745. get scene(): Scene;
  148746. /**
  148747. * Enable or disable the sharpen process from the pipeline
  148748. */
  148749. set sharpenEnabled(enabled: boolean);
  148750. get sharpenEnabled(): boolean;
  148751. private _resizeObserver;
  148752. private _hardwareScaleLevel;
  148753. private _bloomKernel;
  148754. /**
  148755. * Specifies the size of the bloom blur kernel, relative to the final output size
  148756. */
  148757. get bloomKernel(): number;
  148758. set bloomKernel(value: number);
  148759. /**
  148760. * Specifies the weight of the bloom in the final rendering
  148761. */
  148762. private _bloomWeight;
  148763. /**
  148764. * Specifies the luma threshold for the area that will be blurred by the bloom
  148765. */
  148766. private _bloomThreshold;
  148767. private _hdr;
  148768. /**
  148769. * The strength of the bloom.
  148770. */
  148771. set bloomWeight(value: number);
  148772. get bloomWeight(): number;
  148773. /**
  148774. * The strength of the bloom.
  148775. */
  148776. set bloomThreshold(value: number);
  148777. get bloomThreshold(): number;
  148778. /**
  148779. * The scale of the bloom, lower value will provide better performance.
  148780. */
  148781. set bloomScale(value: number);
  148782. get bloomScale(): number;
  148783. /**
  148784. * Enable or disable the bloom from the pipeline
  148785. */
  148786. set bloomEnabled(enabled: boolean);
  148787. get bloomEnabled(): boolean;
  148788. private _rebuildBloom;
  148789. /**
  148790. * If the depth of field is enabled.
  148791. */
  148792. get depthOfFieldEnabled(): boolean;
  148793. set depthOfFieldEnabled(enabled: boolean);
  148794. /**
  148795. * Blur level of the depth of field effect. (Higher blur will effect performance)
  148796. */
  148797. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  148798. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  148799. /**
  148800. * If the anti aliasing is enabled.
  148801. */
  148802. set fxaaEnabled(enabled: boolean);
  148803. get fxaaEnabled(): boolean;
  148804. private _samples;
  148805. /**
  148806. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148807. */
  148808. set samples(sampleCount: number);
  148809. get samples(): number;
  148810. /**
  148811. * If image processing is enabled.
  148812. */
  148813. set imageProcessingEnabled(enabled: boolean);
  148814. get imageProcessingEnabled(): boolean;
  148815. /**
  148816. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  148817. */
  148818. set glowLayerEnabled(enabled: boolean);
  148819. get glowLayerEnabled(): boolean;
  148820. /**
  148821. * Gets the glow layer (or null if not defined)
  148822. */
  148823. get glowLayer(): Nullable<GlowLayer>;
  148824. /**
  148825. * Enable or disable the chromaticAberration process from the pipeline
  148826. */
  148827. set chromaticAberrationEnabled(enabled: boolean);
  148828. get chromaticAberrationEnabled(): boolean;
  148829. /**
  148830. * Enable or disable the grain process from the pipeline
  148831. */
  148832. set grainEnabled(enabled: boolean);
  148833. get grainEnabled(): boolean;
  148834. /**
  148835. * @constructor
  148836. * @param name - The rendering pipeline name (default: "")
  148837. * @param hdr - If high dynamic range textures should be used (default: true)
  148838. * @param scene - The scene linked to this pipeline (default: the last created scene)
  148839. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  148840. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  148841. */
  148842. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  148843. /**
  148844. * Get the class name
  148845. * @returns "DefaultRenderingPipeline"
  148846. */
  148847. getClassName(): string;
  148848. /**
  148849. * Force the compilation of the entire pipeline.
  148850. */
  148851. prepare(): void;
  148852. private _hasCleared;
  148853. private _prevPostProcess;
  148854. private _prevPrevPostProcess;
  148855. private _setAutoClearAndTextureSharing;
  148856. private _depthOfFieldSceneObserver;
  148857. private _buildPipeline;
  148858. private _disposePostProcesses;
  148859. /**
  148860. * Adds a camera to the pipeline
  148861. * @param camera the camera to be added
  148862. */
  148863. addCamera(camera: Camera): void;
  148864. /**
  148865. * Removes a camera from the pipeline
  148866. * @param camera the camera to remove
  148867. */
  148868. removeCamera(camera: Camera): void;
  148869. /**
  148870. * Dispose of the pipeline and stop all post processes
  148871. */
  148872. dispose(): void;
  148873. /**
  148874. * Serialize the rendering pipeline (Used when exporting)
  148875. * @returns the serialized object
  148876. */
  148877. serialize(): any;
  148878. /**
  148879. * Parse the serialized pipeline
  148880. * @param source Source pipeline.
  148881. * @param scene The scene to load the pipeline to.
  148882. * @param rootUrl The URL of the serialized pipeline.
  148883. * @returns An instantiated pipeline from the serialized object.
  148884. */
  148885. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  148886. }
  148887. }
  148888. declare module BABYLON {
  148889. /** @hidden */
  148890. export var lensHighlightsPixelShader: {
  148891. name: string;
  148892. shader: string;
  148893. };
  148894. }
  148895. declare module BABYLON {
  148896. /** @hidden */
  148897. export var depthOfFieldPixelShader: {
  148898. name: string;
  148899. shader: string;
  148900. };
  148901. }
  148902. declare module BABYLON {
  148903. /**
  148904. * BABYLON.JS Chromatic Aberration GLSL Shader
  148905. * Author: Olivier Guyot
  148906. * Separates very slightly R, G and B colors on the edges of the screen
  148907. * Inspired by Francois Tarlier & Martins Upitis
  148908. */
  148909. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  148910. /**
  148911. * @ignore
  148912. * The chromatic aberration PostProcess id in the pipeline
  148913. */
  148914. LensChromaticAberrationEffect: string;
  148915. /**
  148916. * @ignore
  148917. * The highlights enhancing PostProcess id in the pipeline
  148918. */
  148919. HighlightsEnhancingEffect: string;
  148920. /**
  148921. * @ignore
  148922. * The depth-of-field PostProcess id in the pipeline
  148923. */
  148924. LensDepthOfFieldEffect: string;
  148925. private _scene;
  148926. private _depthTexture;
  148927. private _grainTexture;
  148928. private _chromaticAberrationPostProcess;
  148929. private _highlightsPostProcess;
  148930. private _depthOfFieldPostProcess;
  148931. private _edgeBlur;
  148932. private _grainAmount;
  148933. private _chromaticAberration;
  148934. private _distortion;
  148935. private _highlightsGain;
  148936. private _highlightsThreshold;
  148937. private _dofDistance;
  148938. private _dofAperture;
  148939. private _dofDarken;
  148940. private _dofPentagon;
  148941. private _blurNoise;
  148942. /**
  148943. * @constructor
  148944. *
  148945. * Effect parameters are as follow:
  148946. * {
  148947. * chromatic_aberration: number; // from 0 to x (1 for realism)
  148948. * edge_blur: number; // from 0 to x (1 for realism)
  148949. * distortion: number; // from 0 to x (1 for realism)
  148950. * grain_amount: number; // from 0 to 1
  148951. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  148952. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  148953. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  148954. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  148955. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  148956. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  148957. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  148958. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  148959. * }
  148960. * Note: if an effect parameter is unset, effect is disabled
  148961. *
  148962. * @param name The rendering pipeline name
  148963. * @param parameters - An object containing all parameters (see above)
  148964. * @param scene The scene linked to this pipeline
  148965. * @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)
  148966. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148967. */
  148968. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  148969. /**
  148970. * Get the class name
  148971. * @returns "LensRenderingPipeline"
  148972. */
  148973. getClassName(): string;
  148974. /**
  148975. * Gets associated scene
  148976. */
  148977. get scene(): Scene;
  148978. /**
  148979. * Gets or sets the edge blur
  148980. */
  148981. get edgeBlur(): number;
  148982. set edgeBlur(value: number);
  148983. /**
  148984. * Gets or sets the grain amount
  148985. */
  148986. get grainAmount(): number;
  148987. set grainAmount(value: number);
  148988. /**
  148989. * Gets or sets the chromatic aberration amount
  148990. */
  148991. get chromaticAberration(): number;
  148992. set chromaticAberration(value: number);
  148993. /**
  148994. * Gets or sets the depth of field aperture
  148995. */
  148996. get dofAperture(): number;
  148997. set dofAperture(value: number);
  148998. /**
  148999. * Gets or sets the edge distortion
  149000. */
  149001. get edgeDistortion(): number;
  149002. set edgeDistortion(value: number);
  149003. /**
  149004. * Gets or sets the depth of field distortion
  149005. */
  149006. get dofDistortion(): number;
  149007. set dofDistortion(value: number);
  149008. /**
  149009. * Gets or sets the darken out of focus amount
  149010. */
  149011. get darkenOutOfFocus(): number;
  149012. set darkenOutOfFocus(value: number);
  149013. /**
  149014. * Gets or sets a boolean indicating if blur noise is enabled
  149015. */
  149016. get blurNoise(): boolean;
  149017. set blurNoise(value: boolean);
  149018. /**
  149019. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149020. */
  149021. get pentagonBokeh(): boolean;
  149022. set pentagonBokeh(value: boolean);
  149023. /**
  149024. * Gets or sets the highlight grain amount
  149025. */
  149026. get highlightsGain(): number;
  149027. set highlightsGain(value: number);
  149028. /**
  149029. * Gets or sets the highlight threshold
  149030. */
  149031. get highlightsThreshold(): number;
  149032. set highlightsThreshold(value: number);
  149033. /**
  149034. * Sets the amount of blur at the edges
  149035. * @param amount blur amount
  149036. */
  149037. setEdgeBlur(amount: number): void;
  149038. /**
  149039. * Sets edge blur to 0
  149040. */
  149041. disableEdgeBlur(): void;
  149042. /**
  149043. * Sets the amout of grain
  149044. * @param amount Amount of grain
  149045. */
  149046. setGrainAmount(amount: number): void;
  149047. /**
  149048. * Set grain amount to 0
  149049. */
  149050. disableGrain(): void;
  149051. /**
  149052. * Sets the chromatic aberration amount
  149053. * @param amount amount of chromatic aberration
  149054. */
  149055. setChromaticAberration(amount: number): void;
  149056. /**
  149057. * Sets chromatic aberration amount to 0
  149058. */
  149059. disableChromaticAberration(): void;
  149060. /**
  149061. * Sets the EdgeDistortion amount
  149062. * @param amount amount of EdgeDistortion
  149063. */
  149064. setEdgeDistortion(amount: number): void;
  149065. /**
  149066. * Sets edge distortion to 0
  149067. */
  149068. disableEdgeDistortion(): void;
  149069. /**
  149070. * Sets the FocusDistance amount
  149071. * @param amount amount of FocusDistance
  149072. */
  149073. setFocusDistance(amount: number): void;
  149074. /**
  149075. * Disables depth of field
  149076. */
  149077. disableDepthOfField(): void;
  149078. /**
  149079. * Sets the Aperture amount
  149080. * @param amount amount of Aperture
  149081. */
  149082. setAperture(amount: number): void;
  149083. /**
  149084. * Sets the DarkenOutOfFocus amount
  149085. * @param amount amount of DarkenOutOfFocus
  149086. */
  149087. setDarkenOutOfFocus(amount: number): void;
  149088. private _pentagonBokehIsEnabled;
  149089. /**
  149090. * Creates a pentagon bokeh effect
  149091. */
  149092. enablePentagonBokeh(): void;
  149093. /**
  149094. * Disables the pentagon bokeh effect
  149095. */
  149096. disablePentagonBokeh(): void;
  149097. /**
  149098. * Enables noise blur
  149099. */
  149100. enableNoiseBlur(): void;
  149101. /**
  149102. * Disables noise blur
  149103. */
  149104. disableNoiseBlur(): void;
  149105. /**
  149106. * Sets the HighlightsGain amount
  149107. * @param amount amount of HighlightsGain
  149108. */
  149109. setHighlightsGain(amount: number): void;
  149110. /**
  149111. * Sets the HighlightsThreshold amount
  149112. * @param amount amount of HighlightsThreshold
  149113. */
  149114. setHighlightsThreshold(amount: number): void;
  149115. /**
  149116. * Disables highlights
  149117. */
  149118. disableHighlights(): void;
  149119. /**
  149120. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149121. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149122. */
  149123. dispose(disableDepthRender?: boolean): void;
  149124. private _createChromaticAberrationPostProcess;
  149125. private _createHighlightsPostProcess;
  149126. private _createDepthOfFieldPostProcess;
  149127. private _createGrainTexture;
  149128. }
  149129. }
  149130. declare module BABYLON {
  149131. /** @hidden */
  149132. export var ssao2PixelShader: {
  149133. name: string;
  149134. shader: string;
  149135. };
  149136. }
  149137. declare module BABYLON {
  149138. /** @hidden */
  149139. export var ssaoCombinePixelShader: {
  149140. name: string;
  149141. shader: string;
  149142. };
  149143. }
  149144. declare module BABYLON {
  149145. /**
  149146. * Render pipeline to produce ssao effect
  149147. */
  149148. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149149. /**
  149150. * @ignore
  149151. * The PassPostProcess id in the pipeline that contains the original scene color
  149152. */
  149153. SSAOOriginalSceneColorEffect: string;
  149154. /**
  149155. * @ignore
  149156. * The SSAO PostProcess id in the pipeline
  149157. */
  149158. SSAORenderEffect: string;
  149159. /**
  149160. * @ignore
  149161. * The horizontal blur PostProcess id in the pipeline
  149162. */
  149163. SSAOBlurHRenderEffect: string;
  149164. /**
  149165. * @ignore
  149166. * The vertical blur PostProcess id in the pipeline
  149167. */
  149168. SSAOBlurVRenderEffect: string;
  149169. /**
  149170. * @ignore
  149171. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149172. */
  149173. SSAOCombineRenderEffect: string;
  149174. /**
  149175. * The output strength of the SSAO post-process. Default value is 1.0.
  149176. */
  149177. totalStrength: number;
  149178. /**
  149179. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149180. */
  149181. maxZ: number;
  149182. /**
  149183. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149184. */
  149185. minZAspect: number;
  149186. private _samples;
  149187. /**
  149188. * Number of samples used for the SSAO calculations. Default value is 8
  149189. */
  149190. set samples(n: number);
  149191. get samples(): number;
  149192. private _textureSamples;
  149193. /**
  149194. * Number of samples to use for antialiasing
  149195. */
  149196. set textureSamples(n: number);
  149197. get textureSamples(): number;
  149198. /**
  149199. * Force rendering the geometry through geometry buffer
  149200. */
  149201. private _forceGeometryBuffer;
  149202. /**
  149203. * Ratio object used for SSAO ratio and blur ratio
  149204. */
  149205. private _ratio;
  149206. /**
  149207. * Dynamically generated sphere sampler.
  149208. */
  149209. private _sampleSphere;
  149210. /**
  149211. * Blur filter offsets
  149212. */
  149213. private _samplerOffsets;
  149214. private _expensiveBlur;
  149215. /**
  149216. * If bilateral blur should be used
  149217. */
  149218. set expensiveBlur(b: boolean);
  149219. get expensiveBlur(): boolean;
  149220. /**
  149221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149222. */
  149223. radius: number;
  149224. /**
  149225. * The base color of the SSAO post-process
  149226. * The final result is "base + ssao" between [0, 1]
  149227. */
  149228. base: number;
  149229. /**
  149230. * Support test.
  149231. */
  149232. static get IsSupported(): boolean;
  149233. private _scene;
  149234. private _randomTexture;
  149235. private _originalColorPostProcess;
  149236. private _ssaoPostProcess;
  149237. private _blurHPostProcess;
  149238. private _blurVPostProcess;
  149239. private _ssaoCombinePostProcess;
  149240. private _prePassRenderer;
  149241. /**
  149242. * Gets active scene
  149243. */
  149244. get scene(): Scene;
  149245. /**
  149246. * @constructor
  149247. * @param name The rendering pipeline name
  149248. * @param scene The scene linked to this pipeline
  149249. * @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 }
  149250. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149251. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149252. */
  149253. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149254. /**
  149255. * Get the class name
  149256. * @returns "SSAO2RenderingPipeline"
  149257. */
  149258. getClassName(): string;
  149259. /**
  149260. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149261. */
  149262. dispose(disableGeometryBufferRenderer?: boolean): void;
  149263. private _createBlurPostProcess;
  149264. /** @hidden */
  149265. _rebuild(): void;
  149266. private _bits;
  149267. private _radicalInverse_VdC;
  149268. private _hammersley;
  149269. private _hemisphereSample_uniform;
  149270. private _generateHemisphere;
  149271. private _getDefinesForSSAO;
  149272. private _createSSAOPostProcess;
  149273. private _createSSAOCombinePostProcess;
  149274. private _createRandomTexture;
  149275. /**
  149276. * Serialize the rendering pipeline (Used when exporting)
  149277. * @returns the serialized object
  149278. */
  149279. serialize(): any;
  149280. /**
  149281. * Parse the serialized pipeline
  149282. * @param source Source pipeline.
  149283. * @param scene The scene to load the pipeline to.
  149284. * @param rootUrl The URL of the serialized pipeline.
  149285. * @returns An instantiated pipeline from the serialized object.
  149286. */
  149287. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149288. /**
  149289. * Sets the required values to the prepass renderer.
  149290. * @param prePassRenderer defines the prepass renderer to setup
  149291. * @returns true if the pre pass is needed.
  149292. */
  149293. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149294. }
  149295. }
  149296. declare module BABYLON {
  149297. /** @hidden */
  149298. export var ssaoPixelShader: {
  149299. name: string;
  149300. shader: string;
  149301. };
  149302. }
  149303. declare module BABYLON {
  149304. /**
  149305. * Render pipeline to produce ssao effect
  149306. */
  149307. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149308. /**
  149309. * @ignore
  149310. * The PassPostProcess id in the pipeline that contains the original scene color
  149311. */
  149312. SSAOOriginalSceneColorEffect: string;
  149313. /**
  149314. * @ignore
  149315. * The SSAO PostProcess id in the pipeline
  149316. */
  149317. SSAORenderEffect: string;
  149318. /**
  149319. * @ignore
  149320. * The horizontal blur PostProcess id in the pipeline
  149321. */
  149322. SSAOBlurHRenderEffect: string;
  149323. /**
  149324. * @ignore
  149325. * The vertical blur PostProcess id in the pipeline
  149326. */
  149327. SSAOBlurVRenderEffect: string;
  149328. /**
  149329. * @ignore
  149330. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149331. */
  149332. SSAOCombineRenderEffect: string;
  149333. /**
  149334. * The output strength of the SSAO post-process. Default value is 1.0.
  149335. */
  149336. totalStrength: number;
  149337. /**
  149338. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149339. */
  149340. radius: number;
  149341. /**
  149342. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149343. * Must not be equal to fallOff and superior to fallOff.
  149344. * Default value is 0.0075
  149345. */
  149346. area: number;
  149347. /**
  149348. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149349. * Must not be equal to area and inferior to area.
  149350. * Default value is 0.000001
  149351. */
  149352. fallOff: number;
  149353. /**
  149354. * The base color of the SSAO post-process
  149355. * The final result is "base + ssao" between [0, 1]
  149356. */
  149357. base: number;
  149358. private _scene;
  149359. private _depthTexture;
  149360. private _randomTexture;
  149361. private _originalColorPostProcess;
  149362. private _ssaoPostProcess;
  149363. private _blurHPostProcess;
  149364. private _blurVPostProcess;
  149365. private _ssaoCombinePostProcess;
  149366. private _firstUpdate;
  149367. /**
  149368. * Gets active scene
  149369. */
  149370. get scene(): Scene;
  149371. /**
  149372. * @constructor
  149373. * @param name - The rendering pipeline name
  149374. * @param scene - The scene linked to this pipeline
  149375. * @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 }
  149376. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149377. */
  149378. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149379. /**
  149380. * Get the class name
  149381. * @returns "SSAORenderingPipeline"
  149382. */
  149383. getClassName(): string;
  149384. /**
  149385. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149386. */
  149387. dispose(disableDepthRender?: boolean): void;
  149388. private _createBlurPostProcess;
  149389. /** @hidden */
  149390. _rebuild(): void;
  149391. private _createSSAOPostProcess;
  149392. private _createSSAOCombinePostProcess;
  149393. private _createRandomTexture;
  149394. }
  149395. }
  149396. declare module BABYLON {
  149397. /** @hidden */
  149398. export var screenSpaceReflectionPixelShader: {
  149399. name: string;
  149400. shader: string;
  149401. };
  149402. }
  149403. declare module BABYLON {
  149404. /**
  149405. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149406. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149407. */
  149408. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149409. /**
  149410. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149411. */
  149412. threshold: number;
  149413. /**
  149414. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149415. */
  149416. strength: number;
  149417. /**
  149418. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149419. */
  149420. reflectionSpecularFalloffExponent: number;
  149421. /**
  149422. * 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]
  149423. */
  149424. step: number;
  149425. /**
  149426. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149427. */
  149428. roughnessFactor: number;
  149429. private _geometryBufferRenderer;
  149430. private _enableSmoothReflections;
  149431. private _reflectionSamples;
  149432. private _smoothSteps;
  149433. /**
  149434. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149435. * @param name The name of the effect.
  149436. * @param scene The scene containing the objects to calculate reflections.
  149437. * @param options The required width/height ratio to downsize to before computing the render pass.
  149438. * @param camera The camera to apply the render pass to.
  149439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149440. * @param engine The engine which the post process will be applied. (default: current engine)
  149441. * @param reusable If the post process can be reused on the same frame. (default: false)
  149442. * @param textureType Type of textures used when performing the post process. (default: 0)
  149443. * @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)
  149444. */
  149445. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149446. /**
  149447. * Gets wether or not smoothing reflections is enabled.
  149448. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149449. */
  149450. get enableSmoothReflections(): boolean;
  149451. /**
  149452. * Sets wether or not smoothing reflections is enabled.
  149453. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149454. */
  149455. set enableSmoothReflections(enabled: boolean);
  149456. /**
  149457. * Gets the number of samples taken while computing reflections. More samples count is high,
  149458. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149459. */
  149460. get reflectionSamples(): number;
  149461. /**
  149462. * Sets the number of samples taken while computing reflections. More samples count is high,
  149463. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149464. */
  149465. set reflectionSamples(samples: number);
  149466. /**
  149467. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149468. * more the post-process will require GPU power and can generate a drop in FPS.
  149469. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149470. */
  149471. get smoothSteps(): number;
  149472. set smoothSteps(steps: number);
  149473. private _updateEffectDefines;
  149474. }
  149475. }
  149476. declare module BABYLON {
  149477. /** @hidden */
  149478. export var standardPixelShader: {
  149479. name: string;
  149480. shader: string;
  149481. };
  149482. }
  149483. declare module BABYLON {
  149484. /**
  149485. * Standard rendering pipeline
  149486. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149487. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149488. */
  149489. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149490. /**
  149491. * Public members
  149492. */
  149493. /**
  149494. * Post-process which contains the original scene color before the pipeline applies all the effects
  149495. */
  149496. originalPostProcess: Nullable<PostProcess>;
  149497. /**
  149498. * Post-process used to down scale an image x4
  149499. */
  149500. downSampleX4PostProcess: Nullable<PostProcess>;
  149501. /**
  149502. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149503. */
  149504. brightPassPostProcess: Nullable<PostProcess>;
  149505. /**
  149506. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149507. */
  149508. blurHPostProcesses: PostProcess[];
  149509. /**
  149510. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149511. */
  149512. blurVPostProcesses: PostProcess[];
  149513. /**
  149514. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149515. */
  149516. textureAdderPostProcess: Nullable<PostProcess>;
  149517. /**
  149518. * Post-process used to create volumetric lighting effect
  149519. */
  149520. volumetricLightPostProcess: Nullable<PostProcess>;
  149521. /**
  149522. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149523. */
  149524. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149525. /**
  149526. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149527. */
  149528. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149529. /**
  149530. * Post-process used to merge the volumetric light effect and the real scene color
  149531. */
  149532. volumetricLightMergePostProces: Nullable<PostProcess>;
  149533. /**
  149534. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149535. */
  149536. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149537. /**
  149538. * Base post-process used to calculate the average luminance of the final image for HDR
  149539. */
  149540. luminancePostProcess: Nullable<PostProcess>;
  149541. /**
  149542. * Post-processes used to create down sample post-processes in order to get
  149543. * the average luminance of the final image for HDR
  149544. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149545. */
  149546. luminanceDownSamplePostProcesses: PostProcess[];
  149547. /**
  149548. * Post-process used to create a HDR effect (light adaptation)
  149549. */
  149550. hdrPostProcess: Nullable<PostProcess>;
  149551. /**
  149552. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149553. */
  149554. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149555. /**
  149556. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149557. */
  149558. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149559. /**
  149560. * Post-process used to merge the final HDR post-process and the real scene color
  149561. */
  149562. hdrFinalPostProcess: Nullable<PostProcess>;
  149563. /**
  149564. * Post-process used to create a lens flare effect
  149565. */
  149566. lensFlarePostProcess: Nullable<PostProcess>;
  149567. /**
  149568. * Post-process that merges the result of the lens flare post-process and the real scene color
  149569. */
  149570. lensFlareComposePostProcess: Nullable<PostProcess>;
  149571. /**
  149572. * Post-process used to create a motion blur effect
  149573. */
  149574. motionBlurPostProcess: Nullable<PostProcess>;
  149575. /**
  149576. * Post-process used to create a depth of field effect
  149577. */
  149578. depthOfFieldPostProcess: Nullable<PostProcess>;
  149579. /**
  149580. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149581. */
  149582. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149583. /**
  149584. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149585. */
  149586. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149587. /**
  149588. * Represents the brightness threshold in order to configure the illuminated surfaces
  149589. */
  149590. brightThreshold: number;
  149591. /**
  149592. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149593. */
  149594. blurWidth: number;
  149595. /**
  149596. * Sets if the blur for highlighted surfaces must be only horizontal
  149597. */
  149598. horizontalBlur: boolean;
  149599. /**
  149600. * Gets the overall exposure used by the pipeline
  149601. */
  149602. get exposure(): number;
  149603. /**
  149604. * Sets the overall exposure used by the pipeline
  149605. */
  149606. set exposure(value: number);
  149607. /**
  149608. * Texture used typically to simulate "dirty" on camera lens
  149609. */
  149610. lensTexture: Nullable<Texture>;
  149611. /**
  149612. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149613. */
  149614. volumetricLightCoefficient: number;
  149615. /**
  149616. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149617. */
  149618. volumetricLightPower: number;
  149619. /**
  149620. * Used the set the blur intensity to smooth the volumetric lights
  149621. */
  149622. volumetricLightBlurScale: number;
  149623. /**
  149624. * Light (spot or directional) used to generate the volumetric lights rays
  149625. * The source light must have a shadow generate so the pipeline can get its
  149626. * depth map
  149627. */
  149628. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149629. /**
  149630. * For eye adaptation, represents the minimum luminance the eye can see
  149631. */
  149632. hdrMinimumLuminance: number;
  149633. /**
  149634. * For eye adaptation, represents the decrease luminance speed
  149635. */
  149636. hdrDecreaseRate: number;
  149637. /**
  149638. * For eye adaptation, represents the increase luminance speed
  149639. */
  149640. hdrIncreaseRate: number;
  149641. /**
  149642. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149643. */
  149644. get hdrAutoExposure(): boolean;
  149645. /**
  149646. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149647. */
  149648. set hdrAutoExposure(value: boolean);
  149649. /**
  149650. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149651. */
  149652. lensColorTexture: Nullable<Texture>;
  149653. /**
  149654. * The overall strengh for the lens flare effect
  149655. */
  149656. lensFlareStrength: number;
  149657. /**
  149658. * Dispersion coefficient for lens flare ghosts
  149659. */
  149660. lensFlareGhostDispersal: number;
  149661. /**
  149662. * Main lens flare halo width
  149663. */
  149664. lensFlareHaloWidth: number;
  149665. /**
  149666. * Based on the lens distortion effect, defines how much the lens flare result
  149667. * is distorted
  149668. */
  149669. lensFlareDistortionStrength: number;
  149670. /**
  149671. * Configures the blur intensity used for for lens flare (halo)
  149672. */
  149673. lensFlareBlurWidth: number;
  149674. /**
  149675. * Lens star texture must be used to simulate rays on the flares and is available
  149676. * in the documentation
  149677. */
  149678. lensStarTexture: Nullable<Texture>;
  149679. /**
  149680. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149681. * flare effect by taking account of the dirt texture
  149682. */
  149683. lensFlareDirtTexture: Nullable<Texture>;
  149684. /**
  149685. * Represents the focal length for the depth of field effect
  149686. */
  149687. depthOfFieldDistance: number;
  149688. /**
  149689. * Represents the blur intensity for the blurred part of the depth of field effect
  149690. */
  149691. depthOfFieldBlurWidth: number;
  149692. /**
  149693. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149694. */
  149695. get motionStrength(): number;
  149696. /**
  149697. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149698. */
  149699. set motionStrength(strength: number);
  149700. /**
  149701. * Gets wether or not the motion blur post-process is object based or screen based.
  149702. */
  149703. get objectBasedMotionBlur(): boolean;
  149704. /**
  149705. * Sets wether or not the motion blur post-process should be object based or screen based
  149706. */
  149707. set objectBasedMotionBlur(value: boolean);
  149708. /**
  149709. * List of animations for the pipeline (IAnimatable implementation)
  149710. */
  149711. animations: Animation[];
  149712. /**
  149713. * Private members
  149714. */
  149715. private _scene;
  149716. private _currentDepthOfFieldSource;
  149717. private _basePostProcess;
  149718. private _fixedExposure;
  149719. private _currentExposure;
  149720. private _hdrAutoExposure;
  149721. private _hdrCurrentLuminance;
  149722. private _motionStrength;
  149723. private _isObjectBasedMotionBlur;
  149724. private _floatTextureType;
  149725. private _camerasToBeAttached;
  149726. private _ratio;
  149727. private _bloomEnabled;
  149728. private _depthOfFieldEnabled;
  149729. private _vlsEnabled;
  149730. private _lensFlareEnabled;
  149731. private _hdrEnabled;
  149732. private _motionBlurEnabled;
  149733. private _fxaaEnabled;
  149734. private _screenSpaceReflectionsEnabled;
  149735. private _motionBlurSamples;
  149736. private _volumetricLightStepsCount;
  149737. private _samples;
  149738. /**
  149739. * @ignore
  149740. * Specifies if the bloom pipeline is enabled
  149741. */
  149742. get BloomEnabled(): boolean;
  149743. set BloomEnabled(enabled: boolean);
  149744. /**
  149745. * @ignore
  149746. * Specifies if the depth of field pipeline is enabed
  149747. */
  149748. get DepthOfFieldEnabled(): boolean;
  149749. set DepthOfFieldEnabled(enabled: boolean);
  149750. /**
  149751. * @ignore
  149752. * Specifies if the lens flare pipeline is enabed
  149753. */
  149754. get LensFlareEnabled(): boolean;
  149755. set LensFlareEnabled(enabled: boolean);
  149756. /**
  149757. * @ignore
  149758. * Specifies if the HDR pipeline is enabled
  149759. */
  149760. get HDREnabled(): boolean;
  149761. set HDREnabled(enabled: boolean);
  149762. /**
  149763. * @ignore
  149764. * Specifies if the volumetric lights scattering effect is enabled
  149765. */
  149766. get VLSEnabled(): boolean;
  149767. set VLSEnabled(enabled: boolean);
  149768. /**
  149769. * @ignore
  149770. * Specifies if the motion blur effect is enabled
  149771. */
  149772. get MotionBlurEnabled(): boolean;
  149773. set MotionBlurEnabled(enabled: boolean);
  149774. /**
  149775. * Specifies if anti-aliasing is enabled
  149776. */
  149777. get fxaaEnabled(): boolean;
  149778. set fxaaEnabled(enabled: boolean);
  149779. /**
  149780. * Specifies if screen space reflections are enabled.
  149781. */
  149782. get screenSpaceReflectionsEnabled(): boolean;
  149783. set screenSpaceReflectionsEnabled(enabled: boolean);
  149784. /**
  149785. * Specifies the number of steps used to calculate the volumetric lights
  149786. * Typically in interval [50, 200]
  149787. */
  149788. get volumetricLightStepsCount(): number;
  149789. set volumetricLightStepsCount(count: number);
  149790. /**
  149791. * Specifies the number of samples used for the motion blur effect
  149792. * Typically in interval [16, 64]
  149793. */
  149794. get motionBlurSamples(): number;
  149795. set motionBlurSamples(samples: number);
  149796. /**
  149797. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149798. */
  149799. get samples(): number;
  149800. set samples(sampleCount: number);
  149801. /**
  149802. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149803. * @constructor
  149804. * @param name The rendering pipeline name
  149805. * @param scene The scene linked to this pipeline
  149806. * @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)
  149807. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149808. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149809. */
  149810. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149811. private _buildPipeline;
  149812. private _createDownSampleX4PostProcess;
  149813. private _createBrightPassPostProcess;
  149814. private _createBlurPostProcesses;
  149815. private _createTextureAdderPostProcess;
  149816. private _createVolumetricLightPostProcess;
  149817. private _createLuminancePostProcesses;
  149818. private _createHdrPostProcess;
  149819. private _createLensFlarePostProcess;
  149820. private _createDepthOfFieldPostProcess;
  149821. private _createMotionBlurPostProcess;
  149822. private _getDepthTexture;
  149823. private _disposePostProcesses;
  149824. /**
  149825. * Dispose of the pipeline and stop all post processes
  149826. */
  149827. dispose(): void;
  149828. /**
  149829. * Serialize the rendering pipeline (Used when exporting)
  149830. * @returns the serialized object
  149831. */
  149832. serialize(): any;
  149833. /**
  149834. * Parse the serialized pipeline
  149835. * @param source Source pipeline.
  149836. * @param scene The scene to load the pipeline to.
  149837. * @param rootUrl The URL of the serialized pipeline.
  149838. * @returns An instantiated pipeline from the serialized object.
  149839. */
  149840. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149841. /**
  149842. * Luminance steps
  149843. */
  149844. static LuminanceSteps: number;
  149845. }
  149846. }
  149847. declare module BABYLON {
  149848. /** @hidden */
  149849. export var stereoscopicInterlacePixelShader: {
  149850. name: string;
  149851. shader: string;
  149852. };
  149853. }
  149854. declare module BABYLON {
  149855. /**
  149856. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149857. */
  149858. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149859. private _stepSize;
  149860. private _passedProcess;
  149861. /**
  149862. * Initializes a StereoscopicInterlacePostProcessI
  149863. * @param name The name of the effect.
  149864. * @param rigCameras The rig cameras to be appled to the post process
  149865. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149866. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149868. * @param engine The engine which the post process will be applied. (default: current engine)
  149869. * @param reusable If the post process can be reused on the same frame. (default: false)
  149870. */
  149871. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149872. }
  149873. /**
  149874. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149875. */
  149876. export class StereoscopicInterlacePostProcess extends PostProcess {
  149877. private _stepSize;
  149878. private _passedProcess;
  149879. /**
  149880. * Initializes a StereoscopicInterlacePostProcess
  149881. * @param name The name of the effect.
  149882. * @param rigCameras The rig cameras to be appled to the post process
  149883. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149885. * @param engine The engine which the post process will be applied. (default: current engine)
  149886. * @param reusable If the post process can be reused on the same frame. (default: false)
  149887. */
  149888. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149889. }
  149890. }
  149891. declare module BABYLON {
  149892. /** @hidden */
  149893. export var tonemapPixelShader: {
  149894. name: string;
  149895. shader: string;
  149896. };
  149897. }
  149898. declare module BABYLON {
  149899. /** Defines operator used for tonemapping */
  149900. export enum TonemappingOperator {
  149901. /** Hable */
  149902. Hable = 0,
  149903. /** Reinhard */
  149904. Reinhard = 1,
  149905. /** HejiDawson */
  149906. HejiDawson = 2,
  149907. /** Photographic */
  149908. Photographic = 3
  149909. }
  149910. /**
  149911. * Defines a post process to apply tone mapping
  149912. */
  149913. export class TonemapPostProcess extends PostProcess {
  149914. private _operator;
  149915. /** Defines the required exposure adjustement */
  149916. exposureAdjustment: number;
  149917. /**
  149918. * Creates a new TonemapPostProcess
  149919. * @param name defines the name of the postprocess
  149920. * @param _operator defines the operator to use
  149921. * @param exposureAdjustment defines the required exposure adjustement
  149922. * @param camera defines the camera to use (can be null)
  149923. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149924. * @param engine defines the hosting engine (can be ignore if camera is set)
  149925. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149926. */
  149927. constructor(name: string, _operator: TonemappingOperator,
  149928. /** Defines the required exposure adjustement */
  149929. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149930. }
  149931. }
  149932. declare module BABYLON {
  149933. /** @hidden */
  149934. export var volumetricLightScatteringPixelShader: {
  149935. name: string;
  149936. shader: string;
  149937. };
  149938. }
  149939. declare module BABYLON {
  149940. /** @hidden */
  149941. export var volumetricLightScatteringPassVertexShader: {
  149942. name: string;
  149943. shader: string;
  149944. };
  149945. }
  149946. declare module BABYLON {
  149947. /** @hidden */
  149948. export var volumetricLightScatteringPassPixelShader: {
  149949. name: string;
  149950. shader: string;
  149951. };
  149952. }
  149953. declare module BABYLON {
  149954. /**
  149955. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149956. */
  149957. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149958. private _volumetricLightScatteringPass;
  149959. private _volumetricLightScatteringRTT;
  149960. private _viewPort;
  149961. private _screenCoordinates;
  149962. private _cachedDefines;
  149963. /**
  149964. * If not undefined, the mesh position is computed from the attached node position
  149965. */
  149966. attachedNode: {
  149967. position: Vector3;
  149968. };
  149969. /**
  149970. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149971. */
  149972. customMeshPosition: Vector3;
  149973. /**
  149974. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149975. */
  149976. useCustomMeshPosition: boolean;
  149977. /**
  149978. * If the post-process should inverse the light scattering direction
  149979. */
  149980. invert: boolean;
  149981. /**
  149982. * The internal mesh used by the post-process
  149983. */
  149984. mesh: Mesh;
  149985. /**
  149986. * @hidden
  149987. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149988. */
  149989. get useDiffuseColor(): boolean;
  149990. set useDiffuseColor(useDiffuseColor: boolean);
  149991. /**
  149992. * Array containing the excluded meshes not rendered in the internal pass
  149993. */
  149994. excludedMeshes: AbstractMesh[];
  149995. /**
  149996. * Controls the overall intensity of the post-process
  149997. */
  149998. exposure: number;
  149999. /**
  150000. * Dissipates each sample's contribution in range [0, 1]
  150001. */
  150002. decay: number;
  150003. /**
  150004. * Controls the overall intensity of each sample
  150005. */
  150006. weight: number;
  150007. /**
  150008. * Controls the density of each sample
  150009. */
  150010. density: number;
  150011. /**
  150012. * @constructor
  150013. * @param name The post-process name
  150014. * @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)
  150015. * @param camera The camera that the post-process will be attached to
  150016. * @param mesh The mesh used to create the light scattering
  150017. * @param samples The post-process quality, default 100
  150018. * @param samplingModeThe post-process filtering mode
  150019. * @param engine The babylon engine
  150020. * @param reusable If the post-process is reusable
  150021. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150022. */
  150023. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150024. /**
  150025. * Returns the string "VolumetricLightScatteringPostProcess"
  150026. * @returns "VolumetricLightScatteringPostProcess"
  150027. */
  150028. getClassName(): string;
  150029. private _isReady;
  150030. /**
  150031. * Sets the new light position for light scattering effect
  150032. * @param position The new custom light position
  150033. */
  150034. setCustomMeshPosition(position: Vector3): void;
  150035. /**
  150036. * Returns the light position for light scattering effect
  150037. * @return Vector3 The custom light position
  150038. */
  150039. getCustomMeshPosition(): Vector3;
  150040. /**
  150041. * Disposes the internal assets and detaches the post-process from the camera
  150042. */
  150043. dispose(camera: Camera): void;
  150044. /**
  150045. * Returns the render target texture used by the post-process
  150046. * @return the render target texture used by the post-process
  150047. */
  150048. getPass(): RenderTargetTexture;
  150049. private _meshExcluded;
  150050. private _createPass;
  150051. private _updateMeshScreenCoordinates;
  150052. /**
  150053. * Creates a default mesh for the Volumeric Light Scattering post-process
  150054. * @param name The mesh name
  150055. * @param scene The scene where to create the mesh
  150056. * @return the default mesh
  150057. */
  150058. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150059. }
  150060. }
  150061. declare module BABYLON {
  150062. /** @hidden */
  150063. export var screenSpaceCurvaturePixelShader: {
  150064. name: string;
  150065. shader: string;
  150066. };
  150067. }
  150068. declare module BABYLON {
  150069. /**
  150070. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150071. */
  150072. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150073. /**
  150074. * Defines how much ridge the curvature effect displays.
  150075. */
  150076. ridge: number;
  150077. /**
  150078. * Defines how much valley the curvature effect displays.
  150079. */
  150080. valley: number;
  150081. private _geometryBufferRenderer;
  150082. /**
  150083. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150084. * @param name The name of the effect.
  150085. * @param scene The scene containing the objects to blur according to their velocity.
  150086. * @param options The required width/height ratio to downsize to before computing the render pass.
  150087. * @param camera The camera to apply the render pass to.
  150088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150089. * @param engine The engine which the post process will be applied. (default: current engine)
  150090. * @param reusable If the post process can be reused on the same frame. (default: false)
  150091. * @param textureType Type of textures used when performing the post process. (default: 0)
  150092. * @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)
  150093. */
  150094. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150095. /**
  150096. * Support test.
  150097. */
  150098. static get IsSupported(): boolean;
  150099. }
  150100. }
  150101. declare module BABYLON {
  150102. interface Scene {
  150103. /** @hidden (Backing field) */
  150104. _boundingBoxRenderer: BoundingBoxRenderer;
  150105. /** @hidden (Backing field) */
  150106. _forceShowBoundingBoxes: boolean;
  150107. /**
  150108. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150109. */
  150110. forceShowBoundingBoxes: boolean;
  150111. /**
  150112. * Gets the bounding box renderer associated with the scene
  150113. * @returns a BoundingBoxRenderer
  150114. */
  150115. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150116. }
  150117. interface AbstractMesh {
  150118. /** @hidden (Backing field) */
  150119. _showBoundingBox: boolean;
  150120. /**
  150121. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150122. */
  150123. showBoundingBox: boolean;
  150124. }
  150125. /**
  150126. * Component responsible of rendering the bounding box of the meshes in a scene.
  150127. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150128. */
  150129. export class BoundingBoxRenderer implements ISceneComponent {
  150130. /**
  150131. * The component name helpfull to identify the component in the list of scene components.
  150132. */
  150133. readonly name: string;
  150134. /**
  150135. * The scene the component belongs to.
  150136. */
  150137. scene: Scene;
  150138. /**
  150139. * Color of the bounding box lines placed in front of an object
  150140. */
  150141. frontColor: Color3;
  150142. /**
  150143. * Color of the bounding box lines placed behind an object
  150144. */
  150145. backColor: Color3;
  150146. /**
  150147. * Defines if the renderer should show the back lines or not
  150148. */
  150149. showBackLines: boolean;
  150150. /**
  150151. * Observable raised before rendering a bounding box
  150152. */
  150153. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150154. /**
  150155. * Observable raised after rendering a bounding box
  150156. */
  150157. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150158. /**
  150159. * @hidden
  150160. */
  150161. renderList: SmartArray<BoundingBox>;
  150162. private _colorShader;
  150163. private _vertexBuffers;
  150164. private _indexBuffer;
  150165. private _fillIndexBuffer;
  150166. private _fillIndexData;
  150167. /**
  150168. * Instantiates a new bounding box renderer in a scene.
  150169. * @param scene the scene the renderer renders in
  150170. */
  150171. constructor(scene: Scene);
  150172. /**
  150173. * Registers the component in a given scene
  150174. */
  150175. register(): void;
  150176. private _evaluateSubMesh;
  150177. private _activeMesh;
  150178. private _prepareRessources;
  150179. private _createIndexBuffer;
  150180. /**
  150181. * Rebuilds the elements related to this component in case of
  150182. * context lost for instance.
  150183. */
  150184. rebuild(): void;
  150185. /**
  150186. * @hidden
  150187. */
  150188. reset(): void;
  150189. /**
  150190. * Render the bounding boxes of a specific rendering group
  150191. * @param renderingGroupId defines the rendering group to render
  150192. */
  150193. render(renderingGroupId: number): void;
  150194. /**
  150195. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150196. * @param mesh Define the mesh to render the occlusion bounding box for
  150197. */
  150198. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150199. /**
  150200. * Dispose and release the resources attached to this renderer.
  150201. */
  150202. dispose(): void;
  150203. }
  150204. }
  150205. declare module BABYLON {
  150206. interface Scene {
  150207. /** @hidden (Backing field) */
  150208. _depthRenderer: {
  150209. [id: string]: DepthRenderer;
  150210. };
  150211. /**
  150212. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150213. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150214. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150215. * @returns the created depth renderer
  150216. */
  150217. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150218. /**
  150219. * Disables a depth renderer for a given camera
  150220. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150221. */
  150222. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150223. }
  150224. /**
  150225. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150226. * in several rendering techniques.
  150227. */
  150228. export class DepthRendererSceneComponent implements ISceneComponent {
  150229. /**
  150230. * The component name helpfull to identify the component in the list of scene components.
  150231. */
  150232. readonly name: string;
  150233. /**
  150234. * The scene the component belongs to.
  150235. */
  150236. scene: Scene;
  150237. /**
  150238. * Creates a new instance of the component for the given scene
  150239. * @param scene Defines the scene to register the component in
  150240. */
  150241. constructor(scene: Scene);
  150242. /**
  150243. * Registers the component in a given scene
  150244. */
  150245. register(): void;
  150246. /**
  150247. * Rebuilds the elements related to this component in case of
  150248. * context lost for instance.
  150249. */
  150250. rebuild(): void;
  150251. /**
  150252. * Disposes the component and the associated ressources
  150253. */
  150254. dispose(): void;
  150255. private _gatherRenderTargets;
  150256. private _gatherActiveCameraRenderTargets;
  150257. }
  150258. }
  150259. declare module BABYLON {
  150260. interface AbstractScene {
  150261. /** @hidden (Backing field) */
  150262. _prePassRenderer: Nullable<PrePassRenderer>;
  150263. /**
  150264. * Gets or Sets the current prepass renderer associated to the scene.
  150265. */
  150266. prePassRenderer: Nullable<PrePassRenderer>;
  150267. /**
  150268. * Enables the prepass and associates it with the scene
  150269. * @returns the PrePassRenderer
  150270. */
  150271. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  150272. /**
  150273. * Disables the prepass associated with the scene
  150274. */
  150275. disablePrePassRenderer(): void;
  150276. }
  150277. /**
  150278. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150279. * in several rendering techniques.
  150280. */
  150281. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150282. /**
  150283. * The component name helpful to identify the component in the list of scene components.
  150284. */
  150285. readonly name: string;
  150286. /**
  150287. * The scene the component belongs to.
  150288. */
  150289. scene: Scene;
  150290. /**
  150291. * Creates a new instance of the component for the given scene
  150292. * @param scene Defines the scene to register the component in
  150293. */
  150294. constructor(scene: Scene);
  150295. /**
  150296. * Registers the component in a given scene
  150297. */
  150298. register(): void;
  150299. private _beforeCameraDraw;
  150300. private _afterCameraDraw;
  150301. private _beforeClearStage;
  150302. /**
  150303. * Serializes the component data to the specified json object
  150304. * @param serializationObject The object to serialize to
  150305. */
  150306. serialize(serializationObject: any): void;
  150307. /**
  150308. * Adds all the elements from the container to the scene
  150309. * @param container the container holding the elements
  150310. */
  150311. addFromContainer(container: AbstractScene): void;
  150312. /**
  150313. * Removes all the elements in the container from the scene
  150314. * @param container contains the elements to remove
  150315. * @param dispose if the removed element should be disposed (default: false)
  150316. */
  150317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150318. /**
  150319. * Rebuilds the elements related to this component in case of
  150320. * context lost for instance.
  150321. */
  150322. rebuild(): void;
  150323. /**
  150324. * Disposes the component and the associated ressources
  150325. */
  150326. dispose(): void;
  150327. }
  150328. }
  150329. declare module BABYLON {
  150330. /** @hidden */
  150331. export var outlinePixelShader: {
  150332. name: string;
  150333. shader: string;
  150334. };
  150335. }
  150336. declare module BABYLON {
  150337. /** @hidden */
  150338. export var outlineVertexShader: {
  150339. name: string;
  150340. shader: string;
  150341. };
  150342. }
  150343. declare module BABYLON {
  150344. interface Scene {
  150345. /** @hidden */
  150346. _outlineRenderer: OutlineRenderer;
  150347. /**
  150348. * Gets the outline renderer associated with the scene
  150349. * @returns a OutlineRenderer
  150350. */
  150351. getOutlineRenderer(): OutlineRenderer;
  150352. }
  150353. interface AbstractMesh {
  150354. /** @hidden (Backing field) */
  150355. _renderOutline: boolean;
  150356. /**
  150357. * Gets or sets a boolean indicating if the outline must be rendered as well
  150358. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150359. */
  150360. renderOutline: boolean;
  150361. /** @hidden (Backing field) */
  150362. _renderOverlay: boolean;
  150363. /**
  150364. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150365. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150366. */
  150367. renderOverlay: boolean;
  150368. }
  150369. /**
  150370. * This class is responsible to draw bothe outline/overlay of meshes.
  150371. * It should not be used directly but through the available method on mesh.
  150372. */
  150373. export class OutlineRenderer implements ISceneComponent {
  150374. /**
  150375. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150376. */
  150377. private static _StencilReference;
  150378. /**
  150379. * The name of the component. Each component must have a unique name.
  150380. */
  150381. name: string;
  150382. /**
  150383. * The scene the component belongs to.
  150384. */
  150385. scene: Scene;
  150386. /**
  150387. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150388. */
  150389. zOffset: number;
  150390. private _engine;
  150391. private _effect;
  150392. private _cachedDefines;
  150393. private _savedDepthWrite;
  150394. /**
  150395. * Instantiates a new outline renderer. (There could be only one per scene).
  150396. * @param scene Defines the scene it belongs to
  150397. */
  150398. constructor(scene: Scene);
  150399. /**
  150400. * Register the component to one instance of a scene.
  150401. */
  150402. register(): void;
  150403. /**
  150404. * Rebuilds the elements related to this component in case of
  150405. * context lost for instance.
  150406. */
  150407. rebuild(): void;
  150408. /**
  150409. * Disposes the component and the associated ressources.
  150410. */
  150411. dispose(): void;
  150412. /**
  150413. * Renders the outline in the canvas.
  150414. * @param subMesh Defines the sumesh to render
  150415. * @param batch Defines the batch of meshes in case of instances
  150416. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150417. */
  150418. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150419. /**
  150420. * Returns whether or not the outline renderer is ready for a given submesh.
  150421. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150422. * @param subMesh Defines the submesh to check readyness for
  150423. * @param useInstances Defines wheter wee are trying to render instances or not
  150424. * @returns true if ready otherwise false
  150425. */
  150426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150427. private _beforeRenderingMesh;
  150428. private _afterRenderingMesh;
  150429. }
  150430. }
  150431. declare module BABYLON {
  150432. /**
  150433. * Defines the basic options interface of a Sprite Frame Source Size.
  150434. */
  150435. export interface ISpriteJSONSpriteSourceSize {
  150436. /**
  150437. * number of the original width of the Frame
  150438. */
  150439. w: number;
  150440. /**
  150441. * number of the original height of the Frame
  150442. */
  150443. h: number;
  150444. }
  150445. /**
  150446. * Defines the basic options interface of a Sprite Frame Data.
  150447. */
  150448. export interface ISpriteJSONSpriteFrameData {
  150449. /**
  150450. * number of the x offset of the Frame
  150451. */
  150452. x: number;
  150453. /**
  150454. * number of the y offset of the Frame
  150455. */
  150456. y: number;
  150457. /**
  150458. * number of the width of the Frame
  150459. */
  150460. w: number;
  150461. /**
  150462. * number of the height of the Frame
  150463. */
  150464. h: number;
  150465. }
  150466. /**
  150467. * Defines the basic options interface of a JSON Sprite.
  150468. */
  150469. export interface ISpriteJSONSprite {
  150470. /**
  150471. * string name of the Frame
  150472. */
  150473. filename: string;
  150474. /**
  150475. * ISpriteJSONSpriteFrame basic object of the frame data
  150476. */
  150477. frame: ISpriteJSONSpriteFrameData;
  150478. /**
  150479. * boolean to flag is the frame was rotated.
  150480. */
  150481. rotated: boolean;
  150482. /**
  150483. * boolean to flag is the frame was trimmed.
  150484. */
  150485. trimmed: boolean;
  150486. /**
  150487. * ISpriteJSONSpriteFrame basic object of the source data
  150488. */
  150489. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150490. /**
  150491. * ISpriteJSONSpriteFrame basic object of the source data
  150492. */
  150493. sourceSize: ISpriteJSONSpriteSourceSize;
  150494. }
  150495. /**
  150496. * Defines the basic options interface of a JSON atlas.
  150497. */
  150498. export interface ISpriteJSONAtlas {
  150499. /**
  150500. * Array of objects that contain the frame data.
  150501. */
  150502. frames: Array<ISpriteJSONSprite>;
  150503. /**
  150504. * object basic object containing the sprite meta data.
  150505. */
  150506. meta?: object;
  150507. }
  150508. }
  150509. declare module BABYLON {
  150510. /** @hidden */
  150511. export var spriteMapPixelShader: {
  150512. name: string;
  150513. shader: string;
  150514. };
  150515. }
  150516. declare module BABYLON {
  150517. /** @hidden */
  150518. export var spriteMapVertexShader: {
  150519. name: string;
  150520. shader: string;
  150521. };
  150522. }
  150523. declare module BABYLON {
  150524. /**
  150525. * Defines the basic options interface of a SpriteMap
  150526. */
  150527. export interface ISpriteMapOptions {
  150528. /**
  150529. * Vector2 of the number of cells in the grid.
  150530. */
  150531. stageSize?: Vector2;
  150532. /**
  150533. * Vector2 of the size of the output plane in World Units.
  150534. */
  150535. outputSize?: Vector2;
  150536. /**
  150537. * Vector3 of the position of the output plane in World Units.
  150538. */
  150539. outputPosition?: Vector3;
  150540. /**
  150541. * Vector3 of the rotation of the output plane.
  150542. */
  150543. outputRotation?: Vector3;
  150544. /**
  150545. * number of layers that the system will reserve in resources.
  150546. */
  150547. layerCount?: number;
  150548. /**
  150549. * number of max animation frames a single cell will reserve in resources.
  150550. */
  150551. maxAnimationFrames?: number;
  150552. /**
  150553. * number cell index of the base tile when the system compiles.
  150554. */
  150555. baseTile?: number;
  150556. /**
  150557. * boolean flip the sprite after its been repositioned by the framing data.
  150558. */
  150559. flipU?: boolean;
  150560. /**
  150561. * Vector3 scalar of the global RGB values of the SpriteMap.
  150562. */
  150563. colorMultiply?: Vector3;
  150564. }
  150565. /**
  150566. * Defines the IDisposable interface in order to be cleanable from resources.
  150567. */
  150568. export interface ISpriteMap extends IDisposable {
  150569. /**
  150570. * String name of the SpriteMap.
  150571. */
  150572. name: string;
  150573. /**
  150574. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150575. */
  150576. atlasJSON: ISpriteJSONAtlas;
  150577. /**
  150578. * Texture of the SpriteMap.
  150579. */
  150580. spriteSheet: Texture;
  150581. /**
  150582. * The parameters to initialize the SpriteMap with.
  150583. */
  150584. options: ISpriteMapOptions;
  150585. }
  150586. /**
  150587. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150588. */
  150589. export class SpriteMap implements ISpriteMap {
  150590. /** The Name of the spriteMap */
  150591. name: string;
  150592. /** The JSON file with the frame and meta data */
  150593. atlasJSON: ISpriteJSONAtlas;
  150594. /** The systems Sprite Sheet Texture */
  150595. spriteSheet: Texture;
  150596. /** Arguments passed with the Constructor */
  150597. options: ISpriteMapOptions;
  150598. /** Public Sprite Storage array, parsed from atlasJSON */
  150599. sprites: Array<ISpriteJSONSprite>;
  150600. /** Returns the Number of Sprites in the System */
  150601. get spriteCount(): number;
  150602. /** Returns the Position of Output Plane*/
  150603. get position(): Vector3;
  150604. /** Returns the Position of Output Plane*/
  150605. set position(v: Vector3);
  150606. /** Returns the Rotation of Output Plane*/
  150607. get rotation(): Vector3;
  150608. /** Returns the Rotation of Output Plane*/
  150609. set rotation(v: Vector3);
  150610. /** Sets the AnimationMap*/
  150611. get animationMap(): RawTexture;
  150612. /** Sets the AnimationMap*/
  150613. set animationMap(v: RawTexture);
  150614. /** Scene that the SpriteMap was created in */
  150615. private _scene;
  150616. /** Texture Buffer of Float32 that holds tile frame data*/
  150617. private _frameMap;
  150618. /** Texture Buffers of Float32 that holds tileMap data*/
  150619. private _tileMaps;
  150620. /** Texture Buffer of Float32 that holds Animation Data*/
  150621. private _animationMap;
  150622. /** Custom ShaderMaterial Central to the System*/
  150623. private _material;
  150624. /** Custom ShaderMaterial Central to the System*/
  150625. private _output;
  150626. /** Systems Time Ticker*/
  150627. private _time;
  150628. /**
  150629. * Creates a new SpriteMap
  150630. * @param name defines the SpriteMaps Name
  150631. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150632. * @param spriteSheet is the Texture that the Sprites are on.
  150633. * @param options a basic deployment configuration
  150634. * @param scene The Scene that the map is deployed on
  150635. */
  150636. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150637. /**
  150638. * Returns tileID location
  150639. * @returns Vector2 the cell position ID
  150640. */
  150641. getTileID(): Vector2;
  150642. /**
  150643. * Gets the UV location of the mouse over the SpriteMap.
  150644. * @returns Vector2 the UV position of the mouse interaction
  150645. */
  150646. getMousePosition(): Vector2;
  150647. /**
  150648. * Creates the "frame" texture Buffer
  150649. * -------------------------------------
  150650. * Structure of frames
  150651. * "filename": "Falling-Water-2.png",
  150652. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150653. * "rotated": true,
  150654. * "trimmed": true,
  150655. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150656. * "sourceSize": {"w":32,"h":32}
  150657. * @returns RawTexture of the frameMap
  150658. */
  150659. private _createFrameBuffer;
  150660. /**
  150661. * Creates the tileMap texture Buffer
  150662. * @param buffer normally and array of numbers, or a false to generate from scratch
  150663. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150664. * @returns RawTexture of the tileMap
  150665. */
  150666. private _createTileBuffer;
  150667. /**
  150668. * Modifies the data of the tileMaps
  150669. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150670. * @param pos is the iVector2 Coordinates of the Tile
  150671. * @param tile The SpriteIndex of the new Tile
  150672. */
  150673. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150674. /**
  150675. * Creates the animationMap texture Buffer
  150676. * @param buffer normally and array of numbers, or a false to generate from scratch
  150677. * @returns RawTexture of the animationMap
  150678. */
  150679. private _createTileAnimationBuffer;
  150680. /**
  150681. * Modifies the data of the animationMap
  150682. * @param cellID is the Index of the Sprite
  150683. * @param _frame is the target Animation frame
  150684. * @param toCell is the Target Index of the next frame of the animation
  150685. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150686. * @param speed is a global scalar of the time variable on the map.
  150687. */
  150688. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150689. /**
  150690. * Exports the .tilemaps file
  150691. */
  150692. saveTileMaps(): void;
  150693. /**
  150694. * Imports the .tilemaps file
  150695. * @param url of the .tilemaps file
  150696. */
  150697. loadTileMaps(url: string): void;
  150698. /**
  150699. * Release associated resources
  150700. */
  150701. dispose(): void;
  150702. }
  150703. }
  150704. declare module BABYLON {
  150705. /**
  150706. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150707. * @see https://doc.babylonjs.com/babylon101/sprites
  150708. */
  150709. export class SpritePackedManager extends SpriteManager {
  150710. /** defines the packed manager's name */
  150711. name: string;
  150712. /**
  150713. * Creates a new sprite manager from a packed sprite sheet
  150714. * @param name defines the manager's name
  150715. * @param imgUrl defines the sprite sheet url
  150716. * @param capacity defines the maximum allowed number of sprites
  150717. * @param scene defines the hosting scene
  150718. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150719. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150720. * @param samplingMode defines the smapling mode to use with spritesheet
  150721. * @param fromPacked set to true; do not alter
  150722. */
  150723. constructor(
  150724. /** defines the packed manager's name */
  150725. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150726. }
  150727. }
  150728. declare module BABYLON {
  150729. /**
  150730. * Defines the list of states available for a task inside a AssetsManager
  150731. */
  150732. export enum AssetTaskState {
  150733. /**
  150734. * Initialization
  150735. */
  150736. INIT = 0,
  150737. /**
  150738. * Running
  150739. */
  150740. RUNNING = 1,
  150741. /**
  150742. * Done
  150743. */
  150744. DONE = 2,
  150745. /**
  150746. * Error
  150747. */
  150748. ERROR = 3
  150749. }
  150750. /**
  150751. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150752. */
  150753. export abstract class AbstractAssetTask {
  150754. /**
  150755. * Task name
  150756. */ name: string;
  150757. /**
  150758. * Callback called when the task is successful
  150759. */
  150760. onSuccess: (task: any) => void;
  150761. /**
  150762. * Callback called when the task is not successful
  150763. */
  150764. onError: (task: any, message?: string, exception?: any) => void;
  150765. /**
  150766. * Creates a new AssetsManager
  150767. * @param name defines the name of the task
  150768. */
  150769. constructor(
  150770. /**
  150771. * Task name
  150772. */ name: string);
  150773. private _isCompleted;
  150774. private _taskState;
  150775. private _errorObject;
  150776. /**
  150777. * Get if the task is completed
  150778. */
  150779. get isCompleted(): boolean;
  150780. /**
  150781. * Gets the current state of the task
  150782. */
  150783. get taskState(): AssetTaskState;
  150784. /**
  150785. * Gets the current error object (if task is in error)
  150786. */
  150787. get errorObject(): {
  150788. message?: string;
  150789. exception?: any;
  150790. };
  150791. /**
  150792. * Internal only
  150793. * @hidden
  150794. */
  150795. _setErrorObject(message?: string, exception?: any): void;
  150796. /**
  150797. * Execute the current task
  150798. * @param scene defines the scene where you want your assets to be loaded
  150799. * @param onSuccess is a callback called when the task is successfully executed
  150800. * @param onError is a callback called if an error occurs
  150801. */
  150802. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150803. /**
  150804. * Execute the current task
  150805. * @param scene defines the scene where you want your assets to be loaded
  150806. * @param onSuccess is a callback called when the task is successfully executed
  150807. * @param onError is a callback called if an error occurs
  150808. */
  150809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150810. /**
  150811. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150812. * This can be used with failed tasks that have the reason for failure fixed.
  150813. */
  150814. reset(): void;
  150815. private onErrorCallback;
  150816. private onDoneCallback;
  150817. }
  150818. /**
  150819. * Define the interface used by progress events raised during assets loading
  150820. */
  150821. export interface IAssetsProgressEvent {
  150822. /**
  150823. * Defines the number of remaining tasks to process
  150824. */
  150825. remainingCount: number;
  150826. /**
  150827. * Defines the total number of tasks
  150828. */
  150829. totalCount: number;
  150830. /**
  150831. * Defines the task that was just processed
  150832. */
  150833. task: AbstractAssetTask;
  150834. }
  150835. /**
  150836. * Class used to share progress information about assets loading
  150837. */
  150838. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150839. /**
  150840. * Defines the number of remaining tasks to process
  150841. */
  150842. remainingCount: number;
  150843. /**
  150844. * Defines the total number of tasks
  150845. */
  150846. totalCount: number;
  150847. /**
  150848. * Defines the task that was just processed
  150849. */
  150850. task: AbstractAssetTask;
  150851. /**
  150852. * Creates a AssetsProgressEvent
  150853. * @param remainingCount defines the number of remaining tasks to process
  150854. * @param totalCount defines the total number of tasks
  150855. * @param task defines the task that was just processed
  150856. */
  150857. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150858. }
  150859. /**
  150860. * Define a task used by AssetsManager to load assets into a container
  150861. */
  150862. export class ContainerAssetTask extends AbstractAssetTask {
  150863. /**
  150864. * Defines the name of the task
  150865. */
  150866. name: string;
  150867. /**
  150868. * Defines the list of mesh's names you want to load
  150869. */
  150870. meshesNames: any;
  150871. /**
  150872. * Defines the root url to use as a base to load your meshes and associated resources
  150873. */
  150874. rootUrl: string;
  150875. /**
  150876. * Defines the filename or File of the scene to load from
  150877. */
  150878. sceneFilename: string | File;
  150879. /**
  150880. * Get the loaded asset container
  150881. */
  150882. loadedContainer: AssetContainer;
  150883. /**
  150884. * Gets the list of loaded meshes
  150885. */
  150886. loadedMeshes: Array<AbstractMesh>;
  150887. /**
  150888. * Gets the list of loaded particle systems
  150889. */
  150890. loadedParticleSystems: Array<IParticleSystem>;
  150891. /**
  150892. * Gets the list of loaded skeletons
  150893. */
  150894. loadedSkeletons: Array<Skeleton>;
  150895. /**
  150896. * Gets the list of loaded animation groups
  150897. */
  150898. loadedAnimationGroups: Array<AnimationGroup>;
  150899. /**
  150900. * Callback called when the task is successful
  150901. */
  150902. onSuccess: (task: ContainerAssetTask) => void;
  150903. /**
  150904. * Callback called when the task is successful
  150905. */
  150906. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  150907. /**
  150908. * Creates a new ContainerAssetTask
  150909. * @param name defines the name of the task
  150910. * @param meshesNames defines the list of mesh's names you want to load
  150911. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150912. * @param sceneFilename defines the filename or File of the scene to load from
  150913. */
  150914. constructor(
  150915. /**
  150916. * Defines the name of the task
  150917. */
  150918. name: string,
  150919. /**
  150920. * Defines the list of mesh's names you want to load
  150921. */
  150922. meshesNames: any,
  150923. /**
  150924. * Defines the root url to use as a base to load your meshes and associated resources
  150925. */
  150926. rootUrl: string,
  150927. /**
  150928. * Defines the filename or File of the scene to load from
  150929. */
  150930. sceneFilename: string | File);
  150931. /**
  150932. * Execute the current task
  150933. * @param scene defines the scene where you want your assets to be loaded
  150934. * @param onSuccess is a callback called when the task is successfully executed
  150935. * @param onError is a callback called if an error occurs
  150936. */
  150937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150938. }
  150939. /**
  150940. * Define a task used by AssetsManager to load meshes
  150941. */
  150942. export class MeshAssetTask extends AbstractAssetTask {
  150943. /**
  150944. * Defines the name of the task
  150945. */
  150946. name: string;
  150947. /**
  150948. * Defines the list of mesh's names you want to load
  150949. */
  150950. meshesNames: any;
  150951. /**
  150952. * Defines the root url to use as a base to load your meshes and associated resources
  150953. */
  150954. rootUrl: string;
  150955. /**
  150956. * Defines the filename or File of the scene to load from
  150957. */
  150958. sceneFilename: string | File;
  150959. /**
  150960. * Gets the list of loaded meshes
  150961. */
  150962. loadedMeshes: Array<AbstractMesh>;
  150963. /**
  150964. * Gets the list of loaded particle systems
  150965. */
  150966. loadedParticleSystems: Array<IParticleSystem>;
  150967. /**
  150968. * Gets the list of loaded skeletons
  150969. */
  150970. loadedSkeletons: Array<Skeleton>;
  150971. /**
  150972. * Gets the list of loaded animation groups
  150973. */
  150974. loadedAnimationGroups: Array<AnimationGroup>;
  150975. /**
  150976. * Callback called when the task is successful
  150977. */
  150978. onSuccess: (task: MeshAssetTask) => void;
  150979. /**
  150980. * Callback called when the task is successful
  150981. */
  150982. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150983. /**
  150984. * Creates a new MeshAssetTask
  150985. * @param name defines the name of the task
  150986. * @param meshesNames defines the list of mesh's names you want to load
  150987. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150988. * @param sceneFilename defines the filename or File of the scene to load from
  150989. */
  150990. constructor(
  150991. /**
  150992. * Defines the name of the task
  150993. */
  150994. name: string,
  150995. /**
  150996. * Defines the list of mesh's names you want to load
  150997. */
  150998. meshesNames: any,
  150999. /**
  151000. * Defines the root url to use as a base to load your meshes and associated resources
  151001. */
  151002. rootUrl: string,
  151003. /**
  151004. * Defines the filename or File of the scene to load from
  151005. */
  151006. sceneFilename: string | File);
  151007. /**
  151008. * Execute the current task
  151009. * @param scene defines the scene where you want your assets to be loaded
  151010. * @param onSuccess is a callback called when the task is successfully executed
  151011. * @param onError is a callback called if an error occurs
  151012. */
  151013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151014. }
  151015. /**
  151016. * Define a task used by AssetsManager to load text content
  151017. */
  151018. export class TextFileAssetTask extends AbstractAssetTask {
  151019. /**
  151020. * Defines the name of the task
  151021. */
  151022. name: string;
  151023. /**
  151024. * Defines the location of the file to load
  151025. */
  151026. url: string;
  151027. /**
  151028. * Gets the loaded text string
  151029. */
  151030. text: string;
  151031. /**
  151032. * Callback called when the task is successful
  151033. */
  151034. onSuccess: (task: TextFileAssetTask) => void;
  151035. /**
  151036. * Callback called when the task is successful
  151037. */
  151038. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151039. /**
  151040. * Creates a new TextFileAssetTask object
  151041. * @param name defines the name of the task
  151042. * @param url defines the location of the file to load
  151043. */
  151044. constructor(
  151045. /**
  151046. * Defines the name of the task
  151047. */
  151048. name: string,
  151049. /**
  151050. * Defines the location of the file to load
  151051. */
  151052. url: string);
  151053. /**
  151054. * Execute the current task
  151055. * @param scene defines the scene where you want your assets to be loaded
  151056. * @param onSuccess is a callback called when the task is successfully executed
  151057. * @param onError is a callback called if an error occurs
  151058. */
  151059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151060. }
  151061. /**
  151062. * Define a task used by AssetsManager to load binary data
  151063. */
  151064. export class BinaryFileAssetTask extends AbstractAssetTask {
  151065. /**
  151066. * Defines the name of the task
  151067. */
  151068. name: string;
  151069. /**
  151070. * Defines the location of the file to load
  151071. */
  151072. url: string;
  151073. /**
  151074. * Gets the lodaded data (as an array buffer)
  151075. */
  151076. data: ArrayBuffer;
  151077. /**
  151078. * Callback called when the task is successful
  151079. */
  151080. onSuccess: (task: BinaryFileAssetTask) => void;
  151081. /**
  151082. * Callback called when the task is successful
  151083. */
  151084. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151085. /**
  151086. * Creates a new BinaryFileAssetTask object
  151087. * @param name defines the name of the new task
  151088. * @param url defines the location of the file to load
  151089. */
  151090. constructor(
  151091. /**
  151092. * Defines the name of the task
  151093. */
  151094. name: string,
  151095. /**
  151096. * Defines the location of the file to load
  151097. */
  151098. url: string);
  151099. /**
  151100. * Execute the current task
  151101. * @param scene defines the scene where you want your assets to be loaded
  151102. * @param onSuccess is a callback called when the task is successfully executed
  151103. * @param onError is a callback called if an error occurs
  151104. */
  151105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151106. }
  151107. /**
  151108. * Define a task used by AssetsManager to load images
  151109. */
  151110. export class ImageAssetTask extends AbstractAssetTask {
  151111. /**
  151112. * Defines the name of the task
  151113. */
  151114. name: string;
  151115. /**
  151116. * Defines the location of the image to load
  151117. */
  151118. url: string;
  151119. /**
  151120. * Gets the loaded images
  151121. */
  151122. image: HTMLImageElement;
  151123. /**
  151124. * Callback called when the task is successful
  151125. */
  151126. onSuccess: (task: ImageAssetTask) => void;
  151127. /**
  151128. * Callback called when the task is successful
  151129. */
  151130. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151131. /**
  151132. * Creates a new ImageAssetTask
  151133. * @param name defines the name of the task
  151134. * @param url defines the location of the image to load
  151135. */
  151136. constructor(
  151137. /**
  151138. * Defines the name of the task
  151139. */
  151140. name: string,
  151141. /**
  151142. * Defines the location of the image to load
  151143. */
  151144. url: string);
  151145. /**
  151146. * Execute the current task
  151147. * @param scene defines the scene where you want your assets to be loaded
  151148. * @param onSuccess is a callback called when the task is successfully executed
  151149. * @param onError is a callback called if an error occurs
  151150. */
  151151. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151152. }
  151153. /**
  151154. * Defines the interface used by texture loading tasks
  151155. */
  151156. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151157. /**
  151158. * Gets the loaded texture
  151159. */
  151160. texture: TEX;
  151161. }
  151162. /**
  151163. * Define a task used by AssetsManager to load 2D textures
  151164. */
  151165. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151166. /**
  151167. * Defines the name of the task
  151168. */
  151169. name: string;
  151170. /**
  151171. * Defines the location of the file to load
  151172. */
  151173. url: string;
  151174. /**
  151175. * Defines if mipmap should not be generated (default is false)
  151176. */
  151177. noMipmap?: boolean | undefined;
  151178. /**
  151179. * Defines if texture must be inverted on Y axis (default is true)
  151180. */
  151181. invertY: boolean;
  151182. /**
  151183. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151184. */
  151185. samplingMode: number;
  151186. /**
  151187. * Gets the loaded texture
  151188. */
  151189. texture: Texture;
  151190. /**
  151191. * Callback called when the task is successful
  151192. */
  151193. onSuccess: (task: TextureAssetTask) => void;
  151194. /**
  151195. * Callback called when the task is successful
  151196. */
  151197. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151198. /**
  151199. * Creates a new TextureAssetTask object
  151200. * @param name defines the name of the task
  151201. * @param url defines the location of the file to load
  151202. * @param noMipmap defines if mipmap should not be generated (default is false)
  151203. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151204. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151205. */
  151206. constructor(
  151207. /**
  151208. * Defines the name of the task
  151209. */
  151210. name: string,
  151211. /**
  151212. * Defines the location of the file to load
  151213. */
  151214. url: string,
  151215. /**
  151216. * Defines if mipmap should not be generated (default is false)
  151217. */
  151218. noMipmap?: boolean | undefined,
  151219. /**
  151220. * Defines if texture must be inverted on Y axis (default is true)
  151221. */
  151222. invertY?: boolean,
  151223. /**
  151224. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151225. */
  151226. samplingMode?: number);
  151227. /**
  151228. * Execute the current task
  151229. * @param scene defines the scene where you want your assets to be loaded
  151230. * @param onSuccess is a callback called when the task is successfully executed
  151231. * @param onError is a callback called if an error occurs
  151232. */
  151233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151234. }
  151235. /**
  151236. * Define a task used by AssetsManager to load cube textures
  151237. */
  151238. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  151239. /**
  151240. * Defines the name of the task
  151241. */
  151242. name: string;
  151243. /**
  151244. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151245. */
  151246. url: string;
  151247. /**
  151248. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151249. */
  151250. extensions?: string[] | undefined;
  151251. /**
  151252. * Defines if mipmaps should not be generated (default is false)
  151253. */
  151254. noMipmap?: boolean | undefined;
  151255. /**
  151256. * Defines the explicit list of files (undefined by default)
  151257. */
  151258. files?: string[] | undefined;
  151259. /**
  151260. * Gets the loaded texture
  151261. */
  151262. texture: CubeTexture;
  151263. /**
  151264. * Callback called when the task is successful
  151265. */
  151266. onSuccess: (task: CubeTextureAssetTask) => void;
  151267. /**
  151268. * Callback called when the task is successful
  151269. */
  151270. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  151271. /**
  151272. * Creates a new CubeTextureAssetTask
  151273. * @param name defines the name of the task
  151274. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151275. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151276. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151277. * @param files defines the explicit list of files (undefined by default)
  151278. */
  151279. constructor(
  151280. /**
  151281. * Defines the name of the task
  151282. */
  151283. name: string,
  151284. /**
  151285. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151286. */
  151287. url: string,
  151288. /**
  151289. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151290. */
  151291. extensions?: string[] | undefined,
  151292. /**
  151293. * Defines if mipmaps should not be generated (default is false)
  151294. */
  151295. noMipmap?: boolean | undefined,
  151296. /**
  151297. * Defines the explicit list of files (undefined by default)
  151298. */
  151299. files?: string[] | undefined);
  151300. /**
  151301. * Execute the current task
  151302. * @param scene defines the scene where you want your assets to be loaded
  151303. * @param onSuccess is a callback called when the task is successfully executed
  151304. * @param onError is a callback called if an error occurs
  151305. */
  151306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151307. }
  151308. /**
  151309. * Define a task used by AssetsManager to load HDR cube textures
  151310. */
  151311. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  151312. /**
  151313. * Defines the name of the task
  151314. */
  151315. name: string;
  151316. /**
  151317. * Defines the location of the file to load
  151318. */
  151319. url: string;
  151320. /**
  151321. * Defines the desired size (the more it increases the longer the generation will be)
  151322. */
  151323. size: number;
  151324. /**
  151325. * Defines if mipmaps should not be generated (default is false)
  151326. */
  151327. noMipmap: boolean;
  151328. /**
  151329. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151330. */
  151331. generateHarmonics: boolean;
  151332. /**
  151333. * 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)
  151334. */
  151335. gammaSpace: boolean;
  151336. /**
  151337. * Internal Use Only
  151338. */
  151339. reserved: boolean;
  151340. /**
  151341. * Gets the loaded texture
  151342. */
  151343. texture: HDRCubeTexture;
  151344. /**
  151345. * Callback called when the task is successful
  151346. */
  151347. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  151348. /**
  151349. * Callback called when the task is successful
  151350. */
  151351. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  151352. /**
  151353. * Creates a new HDRCubeTextureAssetTask object
  151354. * @param name defines the name of the task
  151355. * @param url defines the location of the file to load
  151356. * @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.
  151357. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151358. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151359. * @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)
  151360. * @param reserved Internal use only
  151361. */
  151362. constructor(
  151363. /**
  151364. * Defines the name of the task
  151365. */
  151366. name: string,
  151367. /**
  151368. * Defines the location of the file to load
  151369. */
  151370. url: string,
  151371. /**
  151372. * Defines the desired size (the more it increases the longer the generation will be)
  151373. */
  151374. size: number,
  151375. /**
  151376. * Defines if mipmaps should not be generated (default is false)
  151377. */
  151378. noMipmap?: boolean,
  151379. /**
  151380. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151381. */
  151382. generateHarmonics?: boolean,
  151383. /**
  151384. * 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)
  151385. */
  151386. gammaSpace?: boolean,
  151387. /**
  151388. * Internal Use Only
  151389. */
  151390. reserved?: boolean);
  151391. /**
  151392. * Execute the current task
  151393. * @param scene defines the scene where you want your assets to be loaded
  151394. * @param onSuccess is a callback called when the task is successfully executed
  151395. * @param onError is a callback called if an error occurs
  151396. */
  151397. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151398. }
  151399. /**
  151400. * Define a task used by AssetsManager to load Equirectangular cube textures
  151401. */
  151402. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151403. /**
  151404. * Defines the name of the task
  151405. */
  151406. name: string;
  151407. /**
  151408. * Defines the location of the file to load
  151409. */
  151410. url: string;
  151411. /**
  151412. * Defines the desired size (the more it increases the longer the generation will be)
  151413. */
  151414. size: number;
  151415. /**
  151416. * Defines if mipmaps should not be generated (default is false)
  151417. */
  151418. noMipmap: boolean;
  151419. /**
  151420. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151421. * but the standard material would require them in Gamma space) (default is true)
  151422. */
  151423. gammaSpace: boolean;
  151424. /**
  151425. * Gets the loaded texture
  151426. */
  151427. texture: EquiRectangularCubeTexture;
  151428. /**
  151429. * Callback called when the task is successful
  151430. */
  151431. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151432. /**
  151433. * Callback called when the task is successful
  151434. */
  151435. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151436. /**
  151437. * Creates a new EquiRectangularCubeTextureAssetTask object
  151438. * @param name defines the name of the task
  151439. * @param url defines the location of the file to load
  151440. * @param size defines the desired size (the more it increases the longer the generation will be)
  151441. * If the size is omitted this implies you are using a preprocessed cubemap.
  151442. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151443. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151444. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151445. * (default is true)
  151446. */
  151447. constructor(
  151448. /**
  151449. * Defines the name of the task
  151450. */
  151451. name: string,
  151452. /**
  151453. * Defines the location of the file to load
  151454. */
  151455. url: string,
  151456. /**
  151457. * Defines the desired size (the more it increases the longer the generation will be)
  151458. */
  151459. size: number,
  151460. /**
  151461. * Defines if mipmaps should not be generated (default is false)
  151462. */
  151463. noMipmap?: boolean,
  151464. /**
  151465. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151466. * but the standard material would require them in Gamma space) (default is true)
  151467. */
  151468. gammaSpace?: boolean);
  151469. /**
  151470. * Execute the current task
  151471. * @param scene defines the scene where you want your assets to be loaded
  151472. * @param onSuccess is a callback called when the task is successfully executed
  151473. * @param onError is a callback called if an error occurs
  151474. */
  151475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151476. }
  151477. /**
  151478. * This class can be used to easily import assets into a scene
  151479. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151480. */
  151481. export class AssetsManager {
  151482. private _scene;
  151483. private _isLoading;
  151484. protected _tasks: AbstractAssetTask[];
  151485. protected _waitingTasksCount: number;
  151486. protected _totalTasksCount: number;
  151487. /**
  151488. * Callback called when all tasks are processed
  151489. */
  151490. onFinish: (tasks: AbstractAssetTask[]) => void;
  151491. /**
  151492. * Callback called when a task is successful
  151493. */
  151494. onTaskSuccess: (task: AbstractAssetTask) => void;
  151495. /**
  151496. * Callback called when a task had an error
  151497. */
  151498. onTaskError: (task: AbstractAssetTask) => void;
  151499. /**
  151500. * Callback called when a task is done (whatever the result is)
  151501. */
  151502. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151503. /**
  151504. * Observable called when all tasks are processed
  151505. */
  151506. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151507. /**
  151508. * Observable called when a task had an error
  151509. */
  151510. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151511. /**
  151512. * Observable called when all tasks were executed
  151513. */
  151514. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151515. /**
  151516. * Observable called when a task is done (whatever the result is)
  151517. */
  151518. onProgressObservable: Observable<IAssetsProgressEvent>;
  151519. /**
  151520. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151521. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151522. */
  151523. useDefaultLoadingScreen: boolean;
  151524. /**
  151525. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151526. * when all assets have been downloaded.
  151527. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151528. */
  151529. autoHideLoadingUI: boolean;
  151530. /**
  151531. * Creates a new AssetsManager
  151532. * @param scene defines the scene to work on
  151533. */
  151534. constructor(scene: Scene);
  151535. /**
  151536. * Add a ContainerAssetTask to the list of active tasks
  151537. * @param taskName defines the name of the new task
  151538. * @param meshesNames defines the name of meshes to load
  151539. * @param rootUrl defines the root url to use to locate files
  151540. * @param sceneFilename defines the filename of the scene file
  151541. * @returns a new ContainerAssetTask object
  151542. */
  151543. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  151544. /**
  151545. * Add a MeshAssetTask to the list of active tasks
  151546. * @param taskName defines the name of the new task
  151547. * @param meshesNames defines the name of meshes to load
  151548. * @param rootUrl defines the root url to use to locate files
  151549. * @param sceneFilename defines the filename of the scene file
  151550. * @returns a new MeshAssetTask object
  151551. */
  151552. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151553. /**
  151554. * Add a TextFileAssetTask to the list of active tasks
  151555. * @param taskName defines the name of the new task
  151556. * @param url defines the url of the file to load
  151557. * @returns a new TextFileAssetTask object
  151558. */
  151559. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151560. /**
  151561. * Add a BinaryFileAssetTask to the list of active tasks
  151562. * @param taskName defines the name of the new task
  151563. * @param url defines the url of the file to load
  151564. * @returns a new BinaryFileAssetTask object
  151565. */
  151566. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151567. /**
  151568. * Add a ImageAssetTask to the list of active tasks
  151569. * @param taskName defines the name of the new task
  151570. * @param url defines the url of the file to load
  151571. * @returns a new ImageAssetTask object
  151572. */
  151573. addImageTask(taskName: string, url: string): ImageAssetTask;
  151574. /**
  151575. * Add a TextureAssetTask to the list of active tasks
  151576. * @param taskName defines the name of the new task
  151577. * @param url defines the url of the file to load
  151578. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151579. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151580. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151581. * @returns a new TextureAssetTask object
  151582. */
  151583. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151584. /**
  151585. * Add a CubeTextureAssetTask to the list of active tasks
  151586. * @param taskName defines the name of the new task
  151587. * @param url defines the url of the file to load
  151588. * @param extensions defines the extension to use to load the cube map (can be null)
  151589. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151590. * @param files defines the list of files to load (can be null)
  151591. * @returns a new CubeTextureAssetTask object
  151592. */
  151593. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151594. /**
  151595. *
  151596. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151597. * @param taskName defines the name of the new task
  151598. * @param url defines the url of the file to load
  151599. * @param size defines the size you want for the cubemap (can be null)
  151600. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151601. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151602. * @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)
  151603. * @param reserved Internal use only
  151604. * @returns a new HDRCubeTextureAssetTask object
  151605. */
  151606. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151607. /**
  151608. *
  151609. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151610. * @param taskName defines the name of the new task
  151611. * @param url defines the url of the file to load
  151612. * @param size defines the size you want for the cubemap (can be null)
  151613. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151614. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151615. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151616. * @returns a new EquiRectangularCubeTextureAssetTask object
  151617. */
  151618. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151619. /**
  151620. * Remove a task from the assets manager.
  151621. * @param task the task to remove
  151622. */
  151623. removeTask(task: AbstractAssetTask): void;
  151624. private _decreaseWaitingTasksCount;
  151625. private _runTask;
  151626. /**
  151627. * Reset the AssetsManager and remove all tasks
  151628. * @return the current instance of the AssetsManager
  151629. */
  151630. reset(): AssetsManager;
  151631. /**
  151632. * Start the loading process
  151633. * @return the current instance of the AssetsManager
  151634. */
  151635. load(): AssetsManager;
  151636. /**
  151637. * Start the loading process as an async operation
  151638. * @return a promise returning the list of failed tasks
  151639. */
  151640. loadAsync(): Promise<void>;
  151641. }
  151642. }
  151643. declare module BABYLON {
  151644. /**
  151645. * Wrapper class for promise with external resolve and reject.
  151646. */
  151647. export class Deferred<T> {
  151648. /**
  151649. * The promise associated with this deferred object.
  151650. */
  151651. readonly promise: Promise<T>;
  151652. private _resolve;
  151653. private _reject;
  151654. /**
  151655. * The resolve method of the promise associated with this deferred object.
  151656. */
  151657. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151658. /**
  151659. * The reject method of the promise associated with this deferred object.
  151660. */
  151661. get reject(): (reason?: any) => void;
  151662. /**
  151663. * Constructor for this deferred object.
  151664. */
  151665. constructor();
  151666. }
  151667. }
  151668. declare module BABYLON {
  151669. /**
  151670. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151671. */
  151672. export class MeshExploder {
  151673. private _centerMesh;
  151674. private _meshes;
  151675. private _meshesOrigins;
  151676. private _toCenterVectors;
  151677. private _scaledDirection;
  151678. private _newPosition;
  151679. private _centerPosition;
  151680. /**
  151681. * Explodes meshes from a center mesh.
  151682. * @param meshes The meshes to explode.
  151683. * @param centerMesh The mesh to be center of explosion.
  151684. */
  151685. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151686. private _setCenterMesh;
  151687. /**
  151688. * Get class name
  151689. * @returns "MeshExploder"
  151690. */
  151691. getClassName(): string;
  151692. /**
  151693. * "Exploded meshes"
  151694. * @returns Array of meshes with the centerMesh at index 0.
  151695. */
  151696. getMeshes(): Array<Mesh>;
  151697. /**
  151698. * Explodes meshes giving a specific direction
  151699. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151700. */
  151701. explode(direction?: number): void;
  151702. }
  151703. }
  151704. declare module BABYLON {
  151705. /**
  151706. * Class used to help managing file picking and drag'n'drop
  151707. */
  151708. export class FilesInput {
  151709. /**
  151710. * List of files ready to be loaded
  151711. */
  151712. static get FilesToLoad(): {
  151713. [key: string]: File;
  151714. };
  151715. /**
  151716. * Callback called when a file is processed
  151717. */
  151718. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151719. private _engine;
  151720. private _currentScene;
  151721. private _sceneLoadedCallback;
  151722. private _progressCallback;
  151723. private _additionalRenderLoopLogicCallback;
  151724. private _textureLoadingCallback;
  151725. private _startingProcessingFilesCallback;
  151726. private _onReloadCallback;
  151727. private _errorCallback;
  151728. private _elementToMonitor;
  151729. private _sceneFileToLoad;
  151730. private _filesToLoad;
  151731. /**
  151732. * Creates a new FilesInput
  151733. * @param engine defines the rendering engine
  151734. * @param scene defines the hosting scene
  151735. * @param sceneLoadedCallback callback called when scene is loaded
  151736. * @param progressCallback callback called to track progress
  151737. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151738. * @param textureLoadingCallback callback called when a texture is loading
  151739. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151740. * @param onReloadCallback callback called when a reload is requested
  151741. * @param errorCallback callback call if an error occurs
  151742. */
  151743. 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>);
  151744. private _dragEnterHandler;
  151745. private _dragOverHandler;
  151746. private _dropHandler;
  151747. /**
  151748. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151749. * @param elementToMonitor defines the DOM element to track
  151750. */
  151751. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151752. /** Gets the current list of files to load */
  151753. get filesToLoad(): File[];
  151754. /**
  151755. * Release all associated resources
  151756. */
  151757. dispose(): void;
  151758. private renderFunction;
  151759. private drag;
  151760. private drop;
  151761. private _traverseFolder;
  151762. private _processFiles;
  151763. /**
  151764. * Load files from a drop event
  151765. * @param event defines the drop event to use as source
  151766. */
  151767. loadFiles(event: any): void;
  151768. private _processReload;
  151769. /**
  151770. * Reload the current scene from the loaded files
  151771. */
  151772. reload(): void;
  151773. }
  151774. }
  151775. declare module BABYLON {
  151776. /**
  151777. * Defines the root class used to create scene optimization to use with SceneOptimizer
  151778. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151779. */
  151780. export class SceneOptimization {
  151781. /**
  151782. * Defines the priority of this optimization (0 by default which means first in the list)
  151783. */
  151784. priority: number;
  151785. /**
  151786. * Gets a string describing the action executed by the current optimization
  151787. * @returns description string
  151788. */
  151789. getDescription(): string;
  151790. /**
  151791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151792. * @param scene defines the current scene where to apply this optimization
  151793. * @param optimizer defines the current optimizer
  151794. * @returns true if everything that can be done was applied
  151795. */
  151796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151797. /**
  151798. * Creates the SceneOptimization object
  151799. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151800. * @param desc defines the description associated with the optimization
  151801. */
  151802. constructor(
  151803. /**
  151804. * Defines the priority of this optimization (0 by default which means first in the list)
  151805. */
  151806. priority?: number);
  151807. }
  151808. /**
  151809. * Defines an optimization used to reduce the size of render target textures
  151810. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151811. */
  151812. export class TextureOptimization extends SceneOptimization {
  151813. /**
  151814. * Defines the priority of this optimization (0 by default which means first in the list)
  151815. */
  151816. priority: number;
  151817. /**
  151818. * 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
  151819. */
  151820. maximumSize: number;
  151821. /**
  151822. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151823. */
  151824. step: number;
  151825. /**
  151826. * Gets a string describing the action executed by the current optimization
  151827. * @returns description string
  151828. */
  151829. getDescription(): string;
  151830. /**
  151831. * Creates the TextureOptimization object
  151832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151833. * @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
  151834. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151835. */
  151836. constructor(
  151837. /**
  151838. * Defines the priority of this optimization (0 by default which means first in the list)
  151839. */
  151840. priority?: number,
  151841. /**
  151842. * 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
  151843. */
  151844. maximumSize?: number,
  151845. /**
  151846. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151847. */
  151848. step?: number);
  151849. /**
  151850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151851. * @param scene defines the current scene where to apply this optimization
  151852. * @param optimizer defines the current optimizer
  151853. * @returns true if everything that can be done was applied
  151854. */
  151855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151856. }
  151857. /**
  151858. * Defines an optimization used to increase or decrease the rendering resolution
  151859. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151860. */
  151861. export class HardwareScalingOptimization extends SceneOptimization {
  151862. /**
  151863. * Defines the priority of this optimization (0 by default which means first in the list)
  151864. */
  151865. priority: number;
  151866. /**
  151867. * Defines the maximum scale to use (2 by default)
  151868. */
  151869. maximumScale: number;
  151870. /**
  151871. * Defines the step to use between two passes (0.5 by default)
  151872. */
  151873. step: number;
  151874. private _currentScale;
  151875. private _directionOffset;
  151876. /**
  151877. * Gets a string describing the action executed by the current optimization
  151878. * @return description string
  151879. */
  151880. getDescription(): string;
  151881. /**
  151882. * Creates the HardwareScalingOptimization object
  151883. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151884. * @param maximumScale defines the maximum scale to use (2 by default)
  151885. * @param step defines the step to use between two passes (0.5 by default)
  151886. */
  151887. constructor(
  151888. /**
  151889. * Defines the priority of this optimization (0 by default which means first in the list)
  151890. */
  151891. priority?: number,
  151892. /**
  151893. * Defines the maximum scale to use (2 by default)
  151894. */
  151895. maximumScale?: number,
  151896. /**
  151897. * Defines the step to use between two passes (0.5 by default)
  151898. */
  151899. step?: number);
  151900. /**
  151901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151902. * @param scene defines the current scene where to apply this optimization
  151903. * @param optimizer defines the current optimizer
  151904. * @returns true if everything that can be done was applied
  151905. */
  151906. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151907. }
  151908. /**
  151909. * Defines an optimization used to remove shadows
  151910. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151911. */
  151912. export class ShadowsOptimization extends SceneOptimization {
  151913. /**
  151914. * Gets a string describing the action executed by the current optimization
  151915. * @return description string
  151916. */
  151917. getDescription(): string;
  151918. /**
  151919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151920. * @param scene defines the current scene where to apply this optimization
  151921. * @param optimizer defines the current optimizer
  151922. * @returns true if everything that can be done was applied
  151923. */
  151924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151925. }
  151926. /**
  151927. * Defines an optimization used to turn post-processes off
  151928. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151929. */
  151930. export class PostProcessesOptimization extends SceneOptimization {
  151931. /**
  151932. * Gets a string describing the action executed by the current optimization
  151933. * @return description string
  151934. */
  151935. getDescription(): string;
  151936. /**
  151937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151938. * @param scene defines the current scene where to apply this optimization
  151939. * @param optimizer defines the current optimizer
  151940. * @returns true if everything that can be done was applied
  151941. */
  151942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151943. }
  151944. /**
  151945. * Defines an optimization used to turn lens flares off
  151946. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151947. */
  151948. export class LensFlaresOptimization extends SceneOptimization {
  151949. /**
  151950. * Gets a string describing the action executed by the current optimization
  151951. * @return description string
  151952. */
  151953. getDescription(): string;
  151954. /**
  151955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151956. * @param scene defines the current scene where to apply this optimization
  151957. * @param optimizer defines the current optimizer
  151958. * @returns true if everything that can be done was applied
  151959. */
  151960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151961. }
  151962. /**
  151963. * Defines an optimization based on user defined callback.
  151964. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151965. */
  151966. export class CustomOptimization extends SceneOptimization {
  151967. /**
  151968. * Callback called to apply the custom optimization.
  151969. */
  151970. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151971. /**
  151972. * Callback called to get custom description
  151973. */
  151974. onGetDescription: () => string;
  151975. /**
  151976. * Gets a string describing the action executed by the current optimization
  151977. * @returns description string
  151978. */
  151979. getDescription(): string;
  151980. /**
  151981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151982. * @param scene defines the current scene where to apply this optimization
  151983. * @param optimizer defines the current optimizer
  151984. * @returns true if everything that can be done was applied
  151985. */
  151986. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151987. }
  151988. /**
  151989. * Defines an optimization used to turn particles off
  151990. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151991. */
  151992. export class ParticlesOptimization extends SceneOptimization {
  151993. /**
  151994. * Gets a string describing the action executed by the current optimization
  151995. * @return description string
  151996. */
  151997. getDescription(): string;
  151998. /**
  151999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152000. * @param scene defines the current scene where to apply this optimization
  152001. * @param optimizer defines the current optimizer
  152002. * @returns true if everything that can be done was applied
  152003. */
  152004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152005. }
  152006. /**
  152007. * Defines an optimization used to turn render targets off
  152008. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152009. */
  152010. export class RenderTargetsOptimization extends SceneOptimization {
  152011. /**
  152012. * Gets a string describing the action executed by the current optimization
  152013. * @return description string
  152014. */
  152015. getDescription(): string;
  152016. /**
  152017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152018. * @param scene defines the current scene where to apply this optimization
  152019. * @param optimizer defines the current optimizer
  152020. * @returns true if everything that can be done was applied
  152021. */
  152022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152023. }
  152024. /**
  152025. * Defines an optimization used to merge meshes with compatible materials
  152026. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152027. */
  152028. export class MergeMeshesOptimization extends SceneOptimization {
  152029. private static _UpdateSelectionTree;
  152030. /**
  152031. * Gets or sets a boolean which defines if optimization octree has to be updated
  152032. */
  152033. static get UpdateSelectionTree(): boolean;
  152034. /**
  152035. * Gets or sets a boolean which defines if optimization octree has to be updated
  152036. */
  152037. static set UpdateSelectionTree(value: boolean);
  152038. /**
  152039. * Gets a string describing the action executed by the current optimization
  152040. * @return description string
  152041. */
  152042. getDescription(): string;
  152043. private _canBeMerged;
  152044. /**
  152045. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152046. * @param scene defines the current scene where to apply this optimization
  152047. * @param optimizer defines the current optimizer
  152048. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152049. * @returns true if everything that can be done was applied
  152050. */
  152051. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152052. }
  152053. /**
  152054. * Defines a list of options used by SceneOptimizer
  152055. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152056. */
  152057. export class SceneOptimizerOptions {
  152058. /**
  152059. * Defines the target frame rate to reach (60 by default)
  152060. */
  152061. targetFrameRate: number;
  152062. /**
  152063. * Defines the interval between two checkes (2000ms by default)
  152064. */
  152065. trackerDuration: number;
  152066. /**
  152067. * Gets the list of optimizations to apply
  152068. */
  152069. optimizations: SceneOptimization[];
  152070. /**
  152071. * Creates a new list of options used by SceneOptimizer
  152072. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152073. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152074. */
  152075. constructor(
  152076. /**
  152077. * Defines the target frame rate to reach (60 by default)
  152078. */
  152079. targetFrameRate?: number,
  152080. /**
  152081. * Defines the interval between two checkes (2000ms by default)
  152082. */
  152083. trackerDuration?: number);
  152084. /**
  152085. * Add a new optimization
  152086. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152087. * @returns the current SceneOptimizerOptions
  152088. */
  152089. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152090. /**
  152091. * Add a new custom optimization
  152092. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152093. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152094. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152095. * @returns the current SceneOptimizerOptions
  152096. */
  152097. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152098. /**
  152099. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152100. * @param targetFrameRate defines the target frame rate (60 by default)
  152101. * @returns a SceneOptimizerOptions object
  152102. */
  152103. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152104. /**
  152105. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152106. * @param targetFrameRate defines the target frame rate (60 by default)
  152107. * @returns a SceneOptimizerOptions object
  152108. */
  152109. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152110. /**
  152111. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152112. * @param targetFrameRate defines the target frame rate (60 by default)
  152113. * @returns a SceneOptimizerOptions object
  152114. */
  152115. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152116. }
  152117. /**
  152118. * Class used to run optimizations in order to reach a target frame rate
  152119. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152120. */
  152121. export class SceneOptimizer implements IDisposable {
  152122. private _isRunning;
  152123. private _options;
  152124. private _scene;
  152125. private _currentPriorityLevel;
  152126. private _targetFrameRate;
  152127. private _trackerDuration;
  152128. private _currentFrameRate;
  152129. private _sceneDisposeObserver;
  152130. private _improvementMode;
  152131. /**
  152132. * Defines an observable called when the optimizer reaches the target frame rate
  152133. */
  152134. onSuccessObservable: Observable<SceneOptimizer>;
  152135. /**
  152136. * Defines an observable called when the optimizer enables an optimization
  152137. */
  152138. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152139. /**
  152140. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152141. */
  152142. onFailureObservable: Observable<SceneOptimizer>;
  152143. /**
  152144. * Gets a boolean indicating if the optimizer is in improvement mode
  152145. */
  152146. get isInImprovementMode(): boolean;
  152147. /**
  152148. * Gets the current priority level (0 at start)
  152149. */
  152150. get currentPriorityLevel(): number;
  152151. /**
  152152. * Gets the current frame rate checked by the SceneOptimizer
  152153. */
  152154. get currentFrameRate(): number;
  152155. /**
  152156. * Gets or sets the current target frame rate (60 by default)
  152157. */
  152158. get targetFrameRate(): number;
  152159. /**
  152160. * Gets or sets the current target frame rate (60 by default)
  152161. */
  152162. set targetFrameRate(value: number);
  152163. /**
  152164. * Gets or sets the current interval between two checks (every 2000ms by default)
  152165. */
  152166. get trackerDuration(): number;
  152167. /**
  152168. * Gets or sets the current interval between two checks (every 2000ms by default)
  152169. */
  152170. set trackerDuration(value: number);
  152171. /**
  152172. * Gets the list of active optimizations
  152173. */
  152174. get optimizations(): SceneOptimization[];
  152175. /**
  152176. * Creates a new SceneOptimizer
  152177. * @param scene defines the scene to work on
  152178. * @param options defines the options to use with the SceneOptimizer
  152179. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152180. * @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)
  152181. */
  152182. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152183. /**
  152184. * Stops the current optimizer
  152185. */
  152186. stop(): void;
  152187. /**
  152188. * Reset the optimizer to initial step (current priority level = 0)
  152189. */
  152190. reset(): void;
  152191. /**
  152192. * Start the optimizer. By default it will try to reach a specific framerate
  152193. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152194. */
  152195. start(): void;
  152196. private _checkCurrentState;
  152197. /**
  152198. * Release all resources
  152199. */
  152200. dispose(): void;
  152201. /**
  152202. * Helper function to create a SceneOptimizer with one single line of code
  152203. * @param scene defines the scene to work on
  152204. * @param options defines the options to use with the SceneOptimizer
  152205. * @param onSuccess defines a callback to call on success
  152206. * @param onFailure defines a callback to call on failure
  152207. * @returns the new SceneOptimizer object
  152208. */
  152209. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152210. }
  152211. }
  152212. declare module BABYLON {
  152213. /**
  152214. * Class used to serialize a scene into a string
  152215. */
  152216. export class SceneSerializer {
  152217. /**
  152218. * Clear cache used by a previous serialization
  152219. */
  152220. static ClearCache(): void;
  152221. /**
  152222. * Serialize a scene into a JSON compatible object
  152223. * @param scene defines the scene to serialize
  152224. * @returns a JSON compatible object
  152225. */
  152226. static Serialize(scene: Scene): any;
  152227. /**
  152228. * Serialize a mesh into a JSON compatible object
  152229. * @param toSerialize defines the mesh to serialize
  152230. * @param withParents defines if parents must be serialized as well
  152231. * @param withChildren defines if children must be serialized as well
  152232. * @returns a JSON compatible object
  152233. */
  152234. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152235. }
  152236. }
  152237. declare module BABYLON {
  152238. /**
  152239. * Class used to host texture specific utilities
  152240. */
  152241. export class TextureTools {
  152242. /**
  152243. * Uses the GPU to create a copy texture rescaled at a given size
  152244. * @param texture Texture to copy from
  152245. * @param width defines the desired width
  152246. * @param height defines the desired height
  152247. * @param useBilinearMode defines if bilinear mode has to be used
  152248. * @return the generated texture
  152249. */
  152250. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  152251. }
  152252. }
  152253. declare module BABYLON {
  152254. /**
  152255. * This represents the different options available for the video capture.
  152256. */
  152257. export interface VideoRecorderOptions {
  152258. /** Defines the mime type of the video. */
  152259. mimeType: string;
  152260. /** Defines the FPS the video should be recorded at. */
  152261. fps: number;
  152262. /** Defines the chunk size for the recording data. */
  152263. recordChunckSize: number;
  152264. /** The audio tracks to attach to the recording. */
  152265. audioTracks?: MediaStreamTrack[];
  152266. }
  152267. /**
  152268. * This can help with recording videos from BabylonJS.
  152269. * This is based on the available WebRTC functionalities of the browser.
  152270. *
  152271. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  152272. */
  152273. export class VideoRecorder {
  152274. private static readonly _defaultOptions;
  152275. /**
  152276. * Returns whether or not the VideoRecorder is available in your browser.
  152277. * @param engine Defines the Babylon Engine.
  152278. * @returns true if supported otherwise false.
  152279. */
  152280. static IsSupported(engine: Engine): boolean;
  152281. private readonly _options;
  152282. private _canvas;
  152283. private _mediaRecorder;
  152284. private _recordedChunks;
  152285. private _fileName;
  152286. private _resolve;
  152287. private _reject;
  152288. /**
  152289. * True when a recording is already in progress.
  152290. */
  152291. get isRecording(): boolean;
  152292. /**
  152293. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  152294. * @param engine Defines the BabylonJS Engine you wish to record.
  152295. * @param options Defines options that can be used to customize the capture.
  152296. */
  152297. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  152298. /**
  152299. * Stops the current recording before the default capture timeout passed in the startRecording function.
  152300. */
  152301. stopRecording(): void;
  152302. /**
  152303. * Starts recording the canvas for a max duration specified in parameters.
  152304. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  152305. * If null no automatic download will start and you can rely on the promise to get the data back.
  152306. * @param maxDuration Defines the maximum recording time in seconds.
  152307. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  152308. * @return A promise callback at the end of the recording with the video data in Blob.
  152309. */
  152310. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  152311. /**
  152312. * Releases internal resources used during the recording.
  152313. */
  152314. dispose(): void;
  152315. private _handleDataAvailable;
  152316. private _handleError;
  152317. private _handleStop;
  152318. }
  152319. }
  152320. declare module BABYLON {
  152321. /**
  152322. * Class containing a set of static utilities functions for screenshots
  152323. */
  152324. export class ScreenshotTools {
  152325. /**
  152326. * Captures a screenshot of the current rendering
  152327. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152328. * @param engine defines the rendering engine
  152329. * @param camera defines the source camera
  152330. * @param size This parameter can be set to a single number or to an object with the
  152331. * following (optional) properties: precision, width, height. If a single number is passed,
  152332. * it will be used for both width and height. If an object is passed, the screenshot size
  152333. * will be derived from the parameters. The precision property is a multiplier allowing
  152334. * rendering at a higher or lower resolution
  152335. * @param successCallback defines the callback receives a single parameter which contains the
  152336. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152337. * src parameter of an <img> to display it
  152338. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152339. * Check your browser for supported MIME types
  152340. */
  152341. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  152342. /**
  152343. * Captures a screenshot of the current rendering
  152344. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152345. * @param engine defines the rendering engine
  152346. * @param camera defines the source camera
  152347. * @param size This parameter can be set to a single number or to an object with the
  152348. * following (optional) properties: precision, width, height. If a single number is passed,
  152349. * it will be used for both width and height. If an object is passed, the screenshot size
  152350. * will be derived from the parameters. The precision property is a multiplier allowing
  152351. * rendering at a higher or lower resolution
  152352. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152353. * Check your browser for supported MIME types
  152354. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152355. * to the src parameter of an <img> to display it
  152356. */
  152357. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  152358. /**
  152359. * Generates an image screenshot from the specified camera.
  152360. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152361. * @param engine The engine to use for rendering
  152362. * @param camera The camera to use for rendering
  152363. * @param size This parameter can be set to a single number or to an object with the
  152364. * following (optional) properties: precision, width, height. If a single number is passed,
  152365. * it will be used for both width and height. If an object is passed, the screenshot size
  152366. * will be derived from the parameters. The precision property is a multiplier allowing
  152367. * rendering at a higher or lower resolution
  152368. * @param successCallback The callback receives a single parameter which contains the
  152369. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152370. * src parameter of an <img> to display it
  152371. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152372. * Check your browser for supported MIME types
  152373. * @param samples Texture samples (default: 1)
  152374. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152375. * @param fileName A name for for the downloaded file.
  152376. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152377. */
  152378. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152379. /**
  152380. * Generates an image screenshot from the specified camera.
  152381. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152382. * @param engine The engine to use for rendering
  152383. * @param camera The camera to use for rendering
  152384. * @param size This parameter can be set to a single number or to an object with the
  152385. * following (optional) properties: precision, width, height. If a single number is passed,
  152386. * it will be used for both width and height. If an object is passed, the screenshot size
  152387. * will be derived from the parameters. The precision property is a multiplier allowing
  152388. * rendering at a higher or lower resolution
  152389. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152390. * Check your browser for supported MIME types
  152391. * @param samples Texture samples (default: 1)
  152392. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152393. * @param fileName A name for for the downloaded file.
  152394. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152395. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152396. * to the src parameter of an <img> to display it
  152397. */
  152398. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152399. /**
  152400. * Gets height and width for screenshot size
  152401. * @private
  152402. */
  152403. private static _getScreenshotSize;
  152404. }
  152405. }
  152406. declare module BABYLON {
  152407. /**
  152408. * Interface for a data buffer
  152409. */
  152410. export interface IDataBuffer {
  152411. /**
  152412. * Reads bytes from the data buffer.
  152413. * @param byteOffset The byte offset to read
  152414. * @param byteLength The byte length to read
  152415. * @returns A promise that resolves when the bytes are read
  152416. */
  152417. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152418. /**
  152419. * The byte length of the buffer.
  152420. */
  152421. readonly byteLength: number;
  152422. }
  152423. /**
  152424. * Utility class for reading from a data buffer
  152425. */
  152426. export class DataReader {
  152427. /**
  152428. * The data buffer associated with this data reader.
  152429. */
  152430. readonly buffer: IDataBuffer;
  152431. /**
  152432. * The current byte offset from the beginning of the data buffer.
  152433. */
  152434. byteOffset: number;
  152435. private _dataView;
  152436. private _dataByteOffset;
  152437. /**
  152438. * Constructor
  152439. * @param buffer The buffer to read
  152440. */
  152441. constructor(buffer: IDataBuffer);
  152442. /**
  152443. * Loads the given byte length.
  152444. * @param byteLength The byte length to load
  152445. * @returns A promise that resolves when the load is complete
  152446. */
  152447. loadAsync(byteLength: number): Promise<void>;
  152448. /**
  152449. * Read a unsigned 32-bit integer from the currently loaded data range.
  152450. * @returns The 32-bit integer read
  152451. */
  152452. readUint32(): number;
  152453. /**
  152454. * Read a byte array from the currently loaded data range.
  152455. * @param byteLength The byte length to read
  152456. * @returns The byte array read
  152457. */
  152458. readUint8Array(byteLength: number): Uint8Array;
  152459. /**
  152460. * Read a string from the currently loaded data range.
  152461. * @param byteLength The byte length to read
  152462. * @returns The string read
  152463. */
  152464. readString(byteLength: number): string;
  152465. /**
  152466. * Skips the given byte length the currently loaded data range.
  152467. * @param byteLength The byte length to skip
  152468. */
  152469. skipBytes(byteLength: number): void;
  152470. }
  152471. }
  152472. declare module BABYLON {
  152473. /**
  152474. * Class for storing data to local storage if available or in-memory storage otherwise
  152475. */
  152476. export class DataStorage {
  152477. private static _Storage;
  152478. private static _GetStorage;
  152479. /**
  152480. * Reads a string from the data storage
  152481. * @param key The key to read
  152482. * @param defaultValue The value if the key doesn't exist
  152483. * @returns The string value
  152484. */
  152485. static ReadString(key: string, defaultValue: string): string;
  152486. /**
  152487. * Writes a string to the data storage
  152488. * @param key The key to write
  152489. * @param value The value to write
  152490. */
  152491. static WriteString(key: string, value: string): void;
  152492. /**
  152493. * Reads a boolean from the data storage
  152494. * @param key The key to read
  152495. * @param defaultValue The value if the key doesn't exist
  152496. * @returns The boolean value
  152497. */
  152498. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152499. /**
  152500. * Writes a boolean to the data storage
  152501. * @param key The key to write
  152502. * @param value The value to write
  152503. */
  152504. static WriteBoolean(key: string, value: boolean): void;
  152505. /**
  152506. * Reads a number from the data storage
  152507. * @param key The key to read
  152508. * @param defaultValue The value if the key doesn't exist
  152509. * @returns The number value
  152510. */
  152511. static ReadNumber(key: string, defaultValue: number): number;
  152512. /**
  152513. * Writes a number to the data storage
  152514. * @param key The key to write
  152515. * @param value The value to write
  152516. */
  152517. static WriteNumber(key: string, value: number): void;
  152518. }
  152519. }
  152520. declare module BABYLON {
  152521. /**
  152522. * Class used to record delta files between 2 scene states
  152523. */
  152524. export class SceneRecorder {
  152525. private _trackedScene;
  152526. private _savedJSON;
  152527. /**
  152528. * Track a given scene. This means the current scene state will be considered the original state
  152529. * @param scene defines the scene to track
  152530. */
  152531. track(scene: Scene): void;
  152532. /**
  152533. * Get the delta between current state and original state
  152534. * @returns a string containing the delta
  152535. */
  152536. getDelta(): any;
  152537. private _compareArray;
  152538. private _compareObjects;
  152539. private _compareCollections;
  152540. private static GetShadowGeneratorById;
  152541. /**
  152542. * Apply a given delta to a given scene
  152543. * @param deltaJSON defines the JSON containing the delta
  152544. * @param scene defines the scene to apply the delta to
  152545. */
  152546. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152547. private static _ApplyPropertiesToEntity;
  152548. private static _ApplyDeltaForEntity;
  152549. }
  152550. }
  152551. declare module BABYLON {
  152552. /**
  152553. * An interface for all Hit test features
  152554. */
  152555. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152556. /**
  152557. * Triggered when new babylon (transformed) hit test results are available
  152558. */
  152559. onHitTestResultObservable: Observable<T[]>;
  152560. }
  152561. /**
  152562. * Options used for hit testing
  152563. */
  152564. export interface IWebXRLegacyHitTestOptions {
  152565. /**
  152566. * Only test when user interacted with the scene. Default - hit test every frame
  152567. */
  152568. testOnPointerDownOnly?: boolean;
  152569. /**
  152570. * The node to use to transform the local results to world coordinates
  152571. */
  152572. worldParentNode?: TransformNode;
  152573. }
  152574. /**
  152575. * Interface defining the babylon result of raycasting/hit-test
  152576. */
  152577. export interface IWebXRLegacyHitResult {
  152578. /**
  152579. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152580. */
  152581. transformationMatrix: Matrix;
  152582. /**
  152583. * The native hit test result
  152584. */
  152585. xrHitResult: XRHitResult | XRHitTestResult;
  152586. }
  152587. /**
  152588. * The currently-working hit-test module.
  152589. * Hit test (or Ray-casting) is used to interact with the real world.
  152590. * For further information read here - https://github.com/immersive-web/hit-test
  152591. */
  152592. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152593. /**
  152594. * options to use when constructing this feature
  152595. */
  152596. readonly options: IWebXRLegacyHitTestOptions;
  152597. private _direction;
  152598. private _mat;
  152599. private _onSelectEnabled;
  152600. private _origin;
  152601. /**
  152602. * The module's name
  152603. */
  152604. static readonly Name: string;
  152605. /**
  152606. * The (Babylon) version of this module.
  152607. * This is an integer representing the implementation version.
  152608. * This number does not correspond to the WebXR specs version
  152609. */
  152610. static readonly Version: number;
  152611. /**
  152612. * Populated with the last native XR Hit Results
  152613. */
  152614. lastNativeXRHitResults: XRHitResult[];
  152615. /**
  152616. * Triggered when new babylon (transformed) hit test results are available
  152617. */
  152618. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152619. /**
  152620. * Creates a new instance of the (legacy version) hit test feature
  152621. * @param _xrSessionManager an instance of WebXRSessionManager
  152622. * @param options options to use when constructing this feature
  152623. */
  152624. constructor(_xrSessionManager: WebXRSessionManager,
  152625. /**
  152626. * options to use when constructing this feature
  152627. */
  152628. options?: IWebXRLegacyHitTestOptions);
  152629. /**
  152630. * execute a hit test with an XR Ray
  152631. *
  152632. * @param xrSession a native xrSession that will execute this hit test
  152633. * @param xrRay the ray (position and direction) to use for ray-casting
  152634. * @param referenceSpace native XR reference space to use for the hit-test
  152635. * @param filter filter function that will filter the results
  152636. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152637. */
  152638. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152639. /**
  152640. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152641. * @param event the (select) event to use to select with
  152642. * @param referenceSpace the reference space to use for this hit test
  152643. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152644. */
  152645. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152646. /**
  152647. * attach this feature
  152648. * Will usually be called by the features manager
  152649. *
  152650. * @returns true if successful.
  152651. */
  152652. attach(): boolean;
  152653. /**
  152654. * detach this feature.
  152655. * Will usually be called by the features manager
  152656. *
  152657. * @returns true if successful.
  152658. */
  152659. detach(): boolean;
  152660. /**
  152661. * Dispose this feature and all of the resources attached
  152662. */
  152663. dispose(): void;
  152664. protected _onXRFrame(frame: XRFrame): void;
  152665. private _onHitTestResults;
  152666. private _onSelect;
  152667. }
  152668. }
  152669. declare module BABYLON {
  152670. /**
  152671. * Options used for hit testing (version 2)
  152672. */
  152673. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152674. /**
  152675. * Do not create a permanent hit test. Will usually be used when only
  152676. * transient inputs are needed.
  152677. */
  152678. disablePermanentHitTest?: boolean;
  152679. /**
  152680. * Enable transient (for example touch-based) hit test inspections
  152681. */
  152682. enableTransientHitTest?: boolean;
  152683. /**
  152684. * Offset ray for the permanent hit test
  152685. */
  152686. offsetRay?: Vector3;
  152687. /**
  152688. * Offset ray for the transient hit test
  152689. */
  152690. transientOffsetRay?: Vector3;
  152691. /**
  152692. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152693. */
  152694. useReferenceSpace?: boolean;
  152695. }
  152696. /**
  152697. * Interface defining the babylon result of hit-test
  152698. */
  152699. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152700. /**
  152701. * The input source that generated this hit test (if transient)
  152702. */
  152703. inputSource?: XRInputSource;
  152704. /**
  152705. * Is this a transient hit test
  152706. */
  152707. isTransient?: boolean;
  152708. /**
  152709. * Position of the hit test result
  152710. */
  152711. position: Vector3;
  152712. /**
  152713. * Rotation of the hit test result
  152714. */
  152715. rotationQuaternion: Quaternion;
  152716. /**
  152717. * The native hit test result
  152718. */
  152719. xrHitResult: XRHitTestResult;
  152720. }
  152721. /**
  152722. * The currently-working hit-test module.
  152723. * Hit test (or Ray-casting) is used to interact with the real world.
  152724. * For further information read here - https://github.com/immersive-web/hit-test
  152725. *
  152726. * Tested on chrome (mobile) 80.
  152727. */
  152728. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152729. /**
  152730. * options to use when constructing this feature
  152731. */
  152732. readonly options: IWebXRHitTestOptions;
  152733. private _tmpMat;
  152734. private _tmpPos;
  152735. private _tmpQuat;
  152736. private _transientXrHitTestSource;
  152737. private _xrHitTestSource;
  152738. private initHitTestSource;
  152739. /**
  152740. * The module's name
  152741. */
  152742. static readonly Name: string;
  152743. /**
  152744. * The (Babylon) version of this module.
  152745. * This is an integer representing the implementation version.
  152746. * This number does not correspond to the WebXR specs version
  152747. */
  152748. static readonly Version: number;
  152749. /**
  152750. * When set to true, each hit test will have its own position/rotation objects
  152751. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152752. * the developers will clone them or copy them as they see fit.
  152753. */
  152754. autoCloneTransformation: boolean;
  152755. /**
  152756. * Triggered when new babylon (transformed) hit test results are available
  152757. */
  152758. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152759. /**
  152760. * Use this to temporarily pause hit test checks.
  152761. */
  152762. paused: boolean;
  152763. /**
  152764. * Creates a new instance of the hit test feature
  152765. * @param _xrSessionManager an instance of WebXRSessionManager
  152766. * @param options options to use when constructing this feature
  152767. */
  152768. constructor(_xrSessionManager: WebXRSessionManager,
  152769. /**
  152770. * options to use when constructing this feature
  152771. */
  152772. options?: IWebXRHitTestOptions);
  152773. /**
  152774. * attach this feature
  152775. * Will usually be called by the features manager
  152776. *
  152777. * @returns true if successful.
  152778. */
  152779. attach(): boolean;
  152780. /**
  152781. * detach this feature.
  152782. * Will usually be called by the features manager
  152783. *
  152784. * @returns true if successful.
  152785. */
  152786. detach(): boolean;
  152787. /**
  152788. * Dispose this feature and all of the resources attached
  152789. */
  152790. dispose(): void;
  152791. protected _onXRFrame(frame: XRFrame): void;
  152792. private _processWebXRHitTestResult;
  152793. }
  152794. }
  152795. declare module BABYLON {
  152796. /**
  152797. * Configuration options of the anchor system
  152798. */
  152799. export interface IWebXRAnchorSystemOptions {
  152800. /**
  152801. * a node that will be used to convert local to world coordinates
  152802. */
  152803. worldParentNode?: TransformNode;
  152804. /**
  152805. * If set to true a reference of the created anchors will be kept until the next session starts
  152806. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  152807. */
  152808. doNotRemoveAnchorsOnSessionEnded?: boolean;
  152809. }
  152810. /**
  152811. * A babylon container for an XR Anchor
  152812. */
  152813. export interface IWebXRAnchor {
  152814. /**
  152815. * A babylon-assigned ID for this anchor
  152816. */
  152817. id: number;
  152818. /**
  152819. * Transformation matrix to apply to an object attached to this anchor
  152820. */
  152821. transformationMatrix: Matrix;
  152822. /**
  152823. * The native anchor object
  152824. */
  152825. xrAnchor: XRAnchor;
  152826. /**
  152827. * if defined, this object will be constantly updated by the anchor's position and rotation
  152828. */
  152829. attachedNode?: TransformNode;
  152830. }
  152831. /**
  152832. * An implementation of the anchor system for WebXR.
  152833. * For further information see https://github.com/immersive-web/anchors/
  152834. */
  152835. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  152836. private _options;
  152837. private _lastFrameDetected;
  152838. private _trackedAnchors;
  152839. private _referenceSpaceForFrameAnchors;
  152840. private _futureAnchors;
  152841. /**
  152842. * The module's name
  152843. */
  152844. static readonly Name: string;
  152845. /**
  152846. * The (Babylon) version of this module.
  152847. * This is an integer representing the implementation version.
  152848. * This number does not correspond to the WebXR specs version
  152849. */
  152850. static readonly Version: number;
  152851. /**
  152852. * Observers registered here will be executed when a new anchor was added to the session
  152853. */
  152854. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152855. /**
  152856. * Observers registered here will be executed when an anchor was removed from the session
  152857. */
  152858. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152859. /**
  152860. * Observers registered here will be executed when an existing anchor updates
  152861. * This can execute N times every frame
  152862. */
  152863. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152864. /**
  152865. * Set the reference space to use for anchor creation, when not using a hit test.
  152866. * Will default to the session's reference space if not defined
  152867. */
  152868. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152869. /**
  152870. * constructs a new anchor system
  152871. * @param _xrSessionManager an instance of WebXRSessionManager
  152872. * @param _options configuration object for this feature
  152873. */
  152874. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152875. private _tmpVector;
  152876. private _tmpQuaternion;
  152877. private _populateTmpTransformation;
  152878. /**
  152879. * Create a new anchor point using a hit test result at a specific point in the scene
  152880. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152881. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152882. *
  152883. * @param hitTestResult The hit test result to use for this anchor creation
  152884. * @param position an optional position offset for this anchor
  152885. * @param rotationQuaternion an optional rotation offset for this anchor
  152886. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152887. */
  152888. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  152889. /**
  152890. * Add a new anchor at a specific position and rotation
  152891. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  152892. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  152893. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152894. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152895. *
  152896. * @param position the position in which to add an anchor
  152897. * @param rotationQuaternion an optional rotation for the anchor transformation
  152898. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  152899. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  152900. */
  152901. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  152902. /**
  152903. * detach this feature.
  152904. * Will usually be called by the features manager
  152905. *
  152906. * @returns true if successful.
  152907. */
  152908. detach(): boolean;
  152909. /**
  152910. * Dispose this feature and all of the resources attached
  152911. */
  152912. dispose(): void;
  152913. protected _onXRFrame(frame: XRFrame): void;
  152914. /**
  152915. * avoiding using Array.find for global support.
  152916. * @param xrAnchor the plane to find in the array
  152917. */
  152918. private _findIndexInAnchorArray;
  152919. private _updateAnchorWithXRFrame;
  152920. private _createAnchorAtTransformation;
  152921. }
  152922. }
  152923. declare module BABYLON {
  152924. /**
  152925. * Options used in the plane detector module
  152926. */
  152927. export interface IWebXRPlaneDetectorOptions {
  152928. /**
  152929. * The node to use to transform the local results to world coordinates
  152930. */
  152931. worldParentNode?: TransformNode;
  152932. /**
  152933. * If set to true a reference of the created planes will be kept until the next session starts
  152934. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  152935. */
  152936. doNotRemovePlanesOnSessionEnded?: boolean;
  152937. }
  152938. /**
  152939. * A babylon interface for a WebXR plane.
  152940. * A Plane is actually a polygon, built from N points in space
  152941. *
  152942. * Supported in chrome 79, not supported in canary 81 ATM
  152943. */
  152944. export interface IWebXRPlane {
  152945. /**
  152946. * a babylon-assigned ID for this polygon
  152947. */
  152948. id: number;
  152949. /**
  152950. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  152951. */
  152952. polygonDefinition: Array<Vector3>;
  152953. /**
  152954. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  152955. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  152956. */
  152957. transformationMatrix: Matrix;
  152958. /**
  152959. * the native xr-plane object
  152960. */
  152961. xrPlane: XRPlane;
  152962. }
  152963. /**
  152964. * The plane detector is used to detect planes in the real world when in AR
  152965. * For more information see https://github.com/immersive-web/real-world-geometry/
  152966. */
  152967. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  152968. private _options;
  152969. private _detectedPlanes;
  152970. private _enabled;
  152971. private _lastFrameDetected;
  152972. /**
  152973. * The module's name
  152974. */
  152975. static readonly Name: string;
  152976. /**
  152977. * The (Babylon) version of this module.
  152978. * This is an integer representing the implementation version.
  152979. * This number does not correspond to the WebXR specs version
  152980. */
  152981. static readonly Version: number;
  152982. /**
  152983. * Observers registered here will be executed when a new plane was added to the session
  152984. */
  152985. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152986. /**
  152987. * Observers registered here will be executed when a plane is no longer detected in the session
  152988. */
  152989. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  152990. /**
  152991. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  152992. * This can execute N times every frame
  152993. */
  152994. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  152995. /**
  152996. * construct a new Plane Detector
  152997. * @param _xrSessionManager an instance of xr Session manager
  152998. * @param _options configuration to use when constructing this feature
  152999. */
  153000. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153001. /**
  153002. * detach this feature.
  153003. * Will usually be called by the features manager
  153004. *
  153005. * @returns true if successful.
  153006. */
  153007. detach(): boolean;
  153008. /**
  153009. * Dispose this feature and all of the resources attached
  153010. */
  153011. dispose(): void;
  153012. protected _onXRFrame(frame: XRFrame): void;
  153013. private _init;
  153014. private _updatePlaneWithXRPlane;
  153015. /**
  153016. * avoiding using Array.find for global support.
  153017. * @param xrPlane the plane to find in the array
  153018. */
  153019. private findIndexInPlaneArray;
  153020. }
  153021. }
  153022. declare module BABYLON {
  153023. /**
  153024. * Options interface for the background remover plugin
  153025. */
  153026. export interface IWebXRBackgroundRemoverOptions {
  153027. /**
  153028. * Further background meshes to disable when entering AR
  153029. */
  153030. backgroundMeshes?: AbstractMesh[];
  153031. /**
  153032. * flags to configure the removal of the environment helper.
  153033. * If not set, the entire background will be removed. If set, flags should be set as well.
  153034. */
  153035. environmentHelperRemovalFlags?: {
  153036. /**
  153037. * Should the skybox be removed (default false)
  153038. */
  153039. skyBox?: boolean;
  153040. /**
  153041. * Should the ground be removed (default false)
  153042. */
  153043. ground?: boolean;
  153044. };
  153045. /**
  153046. * don't disable the environment helper
  153047. */
  153048. ignoreEnvironmentHelper?: boolean;
  153049. }
  153050. /**
  153051. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153052. */
  153053. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153054. /**
  153055. * read-only options to be used in this module
  153056. */
  153057. readonly options: IWebXRBackgroundRemoverOptions;
  153058. /**
  153059. * The module's name
  153060. */
  153061. static readonly Name: string;
  153062. /**
  153063. * The (Babylon) version of this module.
  153064. * This is an integer representing the implementation version.
  153065. * This number does not correspond to the WebXR specs version
  153066. */
  153067. static readonly Version: number;
  153068. /**
  153069. * registered observers will be triggered when the background state changes
  153070. */
  153071. onBackgroundStateChangedObservable: Observable<boolean>;
  153072. /**
  153073. * constructs a new background remover module
  153074. * @param _xrSessionManager the session manager for this module
  153075. * @param options read-only options to be used in this module
  153076. */
  153077. constructor(_xrSessionManager: WebXRSessionManager,
  153078. /**
  153079. * read-only options to be used in this module
  153080. */
  153081. options?: IWebXRBackgroundRemoverOptions);
  153082. /**
  153083. * attach this feature
  153084. * Will usually be called by the features manager
  153085. *
  153086. * @returns true if successful.
  153087. */
  153088. attach(): boolean;
  153089. /**
  153090. * detach this feature.
  153091. * Will usually be called by the features manager
  153092. *
  153093. * @returns true if successful.
  153094. */
  153095. detach(): boolean;
  153096. /**
  153097. * Dispose this feature and all of the resources attached
  153098. */
  153099. dispose(): void;
  153100. protected _onXRFrame(_xrFrame: XRFrame): void;
  153101. private _setBackgroundState;
  153102. }
  153103. }
  153104. declare module BABYLON {
  153105. /**
  153106. * Options for the controller physics feature
  153107. */
  153108. export class IWebXRControllerPhysicsOptions {
  153109. /**
  153110. * Should the headset get its own impostor
  153111. */
  153112. enableHeadsetImpostor?: boolean;
  153113. /**
  153114. * Optional parameters for the headset impostor
  153115. */
  153116. headsetImpostorParams?: {
  153117. /**
  153118. * The type of impostor to create. Default is sphere
  153119. */
  153120. impostorType: number;
  153121. /**
  153122. * the size of the impostor. Defaults to 10cm
  153123. */
  153124. impostorSize?: number | {
  153125. width: number;
  153126. height: number;
  153127. depth: number;
  153128. };
  153129. /**
  153130. * Friction definitions
  153131. */
  153132. friction?: number;
  153133. /**
  153134. * Restitution
  153135. */
  153136. restitution?: number;
  153137. };
  153138. /**
  153139. * The physics properties of the future impostors
  153140. */
  153141. physicsProperties?: {
  153142. /**
  153143. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153144. * Note that this requires a physics engine that supports mesh impostors!
  153145. */
  153146. useControllerMesh?: boolean;
  153147. /**
  153148. * The type of impostor to create. Default is sphere
  153149. */
  153150. impostorType?: number;
  153151. /**
  153152. * the size of the impostor. Defaults to 10cm
  153153. */
  153154. impostorSize?: number | {
  153155. width: number;
  153156. height: number;
  153157. depth: number;
  153158. };
  153159. /**
  153160. * Friction definitions
  153161. */
  153162. friction?: number;
  153163. /**
  153164. * Restitution
  153165. */
  153166. restitution?: number;
  153167. };
  153168. /**
  153169. * the xr input to use with this pointer selection
  153170. */
  153171. xrInput: WebXRInput;
  153172. }
  153173. /**
  153174. * Add physics impostor to your webxr controllers,
  153175. * including naive calculation of their linear and angular velocity
  153176. */
  153177. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153178. private readonly _options;
  153179. private _attachController;
  153180. private _controllers;
  153181. private _debugMode;
  153182. private _delta;
  153183. private _headsetImpostor?;
  153184. private _headsetMesh?;
  153185. private _lastTimestamp;
  153186. private _tmpQuaternion;
  153187. private _tmpVector;
  153188. /**
  153189. * The module's name
  153190. */
  153191. static readonly Name: string;
  153192. /**
  153193. * The (Babylon) version of this module.
  153194. * This is an integer representing the implementation version.
  153195. * This number does not correspond to the webxr specs version
  153196. */
  153197. static readonly Version: number;
  153198. /**
  153199. * Construct a new Controller Physics Feature
  153200. * @param _xrSessionManager the corresponding xr session manager
  153201. * @param _options options to create this feature with
  153202. */
  153203. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153204. /**
  153205. * @hidden
  153206. * enable debugging - will show console outputs and the impostor mesh
  153207. */
  153208. _enablePhysicsDebug(): void;
  153209. /**
  153210. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153211. * @param xrController the controller to add
  153212. */
  153213. addController(xrController: WebXRInputSource): void;
  153214. /**
  153215. * attach this feature
  153216. * Will usually be called by the features manager
  153217. *
  153218. * @returns true if successful.
  153219. */
  153220. attach(): boolean;
  153221. /**
  153222. * detach this feature.
  153223. * Will usually be called by the features manager
  153224. *
  153225. * @returns true if successful.
  153226. */
  153227. detach(): boolean;
  153228. /**
  153229. * Get the headset impostor, if enabled
  153230. * @returns the impostor
  153231. */
  153232. getHeadsetImpostor(): PhysicsImpostor | undefined;
  153233. /**
  153234. * Get the physics impostor of a specific controller.
  153235. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  153236. * @param controller the controller or the controller id of which to get the impostor
  153237. * @returns the impostor or null
  153238. */
  153239. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  153240. /**
  153241. * Update the physics properties provided in the constructor
  153242. * @param newProperties the new properties object
  153243. */
  153244. setPhysicsProperties(newProperties: {
  153245. impostorType?: number;
  153246. impostorSize?: number | {
  153247. width: number;
  153248. height: number;
  153249. depth: number;
  153250. };
  153251. friction?: number;
  153252. restitution?: number;
  153253. }): void;
  153254. protected _onXRFrame(_xrFrame: any): void;
  153255. private _detachController;
  153256. }
  153257. }
  153258. declare module BABYLON {
  153259. /**
  153260. * The motion controller class for all microsoft mixed reality controllers
  153261. */
  153262. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  153263. protected readonly _mapping: {
  153264. defaultButton: {
  153265. valueNodeName: string;
  153266. unpressedNodeName: string;
  153267. pressedNodeName: string;
  153268. };
  153269. defaultAxis: {
  153270. valueNodeName: string;
  153271. minNodeName: string;
  153272. maxNodeName: string;
  153273. };
  153274. buttons: {
  153275. "xr-standard-trigger": {
  153276. rootNodeName: string;
  153277. componentProperty: string;
  153278. states: string[];
  153279. };
  153280. "xr-standard-squeeze": {
  153281. rootNodeName: string;
  153282. componentProperty: string;
  153283. states: string[];
  153284. };
  153285. "xr-standard-touchpad": {
  153286. rootNodeName: string;
  153287. labelAnchorNodeName: string;
  153288. touchPointNodeName: string;
  153289. };
  153290. "xr-standard-thumbstick": {
  153291. rootNodeName: string;
  153292. componentProperty: string;
  153293. states: string[];
  153294. };
  153295. };
  153296. axes: {
  153297. "xr-standard-touchpad": {
  153298. "x-axis": {
  153299. rootNodeName: string;
  153300. };
  153301. "y-axis": {
  153302. rootNodeName: string;
  153303. };
  153304. };
  153305. "xr-standard-thumbstick": {
  153306. "x-axis": {
  153307. rootNodeName: string;
  153308. };
  153309. "y-axis": {
  153310. rootNodeName: string;
  153311. };
  153312. };
  153313. };
  153314. };
  153315. /**
  153316. * The base url used to load the left and right controller models
  153317. */
  153318. static MODEL_BASE_URL: string;
  153319. /**
  153320. * The name of the left controller model file
  153321. */
  153322. static MODEL_LEFT_FILENAME: string;
  153323. /**
  153324. * The name of the right controller model file
  153325. */
  153326. static MODEL_RIGHT_FILENAME: string;
  153327. profileId: string;
  153328. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153329. protected _getFilenameAndPath(): {
  153330. filename: string;
  153331. path: string;
  153332. };
  153333. protected _getModelLoadingConstraints(): boolean;
  153334. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153335. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153336. protected _updateModel(): void;
  153337. }
  153338. }
  153339. declare module BABYLON {
  153340. /**
  153341. * The motion controller class for oculus touch (quest, rift).
  153342. * This class supports legacy mapping as well the standard xr mapping
  153343. */
  153344. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  153345. private _forceLegacyControllers;
  153346. private _modelRootNode;
  153347. /**
  153348. * The base url used to load the left and right controller models
  153349. */
  153350. static MODEL_BASE_URL: string;
  153351. /**
  153352. * The name of the left controller model file
  153353. */
  153354. static MODEL_LEFT_FILENAME: string;
  153355. /**
  153356. * The name of the right controller model file
  153357. */
  153358. static MODEL_RIGHT_FILENAME: string;
  153359. /**
  153360. * Base Url for the Quest controller model.
  153361. */
  153362. static QUEST_MODEL_BASE_URL: string;
  153363. profileId: string;
  153364. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  153365. protected _getFilenameAndPath(): {
  153366. filename: string;
  153367. path: string;
  153368. };
  153369. protected _getModelLoadingConstraints(): boolean;
  153370. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153371. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153372. protected _updateModel(): void;
  153373. /**
  153374. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153375. * between the touch and touch 2.
  153376. */
  153377. private _isQuest;
  153378. }
  153379. }
  153380. declare module BABYLON {
  153381. /**
  153382. * The motion controller class for the standard HTC-Vive controllers
  153383. */
  153384. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153385. private _modelRootNode;
  153386. /**
  153387. * The base url used to load the left and right controller models
  153388. */
  153389. static MODEL_BASE_URL: string;
  153390. /**
  153391. * File name for the controller model.
  153392. */
  153393. static MODEL_FILENAME: string;
  153394. profileId: string;
  153395. /**
  153396. * Create a new Vive motion controller object
  153397. * @param scene the scene to use to create this controller
  153398. * @param gamepadObject the corresponding gamepad object
  153399. * @param handedness the handedness of the controller
  153400. */
  153401. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153402. protected _getFilenameAndPath(): {
  153403. filename: string;
  153404. path: string;
  153405. };
  153406. protected _getModelLoadingConstraints(): boolean;
  153407. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153408. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153409. protected _updateModel(): void;
  153410. }
  153411. }
  153412. declare module BABYLON {
  153413. /**
  153414. * A cursor which tracks a point on a path
  153415. */
  153416. export class PathCursor {
  153417. private path;
  153418. /**
  153419. * Stores path cursor callbacks for when an onchange event is triggered
  153420. */
  153421. private _onchange;
  153422. /**
  153423. * The value of the path cursor
  153424. */
  153425. value: number;
  153426. /**
  153427. * The animation array of the path cursor
  153428. */
  153429. animations: Animation[];
  153430. /**
  153431. * Initializes the path cursor
  153432. * @param path The path to track
  153433. */
  153434. constructor(path: Path2);
  153435. /**
  153436. * Gets the cursor point on the path
  153437. * @returns A point on the path cursor at the cursor location
  153438. */
  153439. getPoint(): Vector3;
  153440. /**
  153441. * Moves the cursor ahead by the step amount
  153442. * @param step The amount to move the cursor forward
  153443. * @returns This path cursor
  153444. */
  153445. moveAhead(step?: number): PathCursor;
  153446. /**
  153447. * Moves the cursor behind by the step amount
  153448. * @param step The amount to move the cursor back
  153449. * @returns This path cursor
  153450. */
  153451. moveBack(step?: number): PathCursor;
  153452. /**
  153453. * Moves the cursor by the step amount
  153454. * If the step amount is greater than one, an exception is thrown
  153455. * @param step The amount to move the cursor
  153456. * @returns This path cursor
  153457. */
  153458. move(step: number): PathCursor;
  153459. /**
  153460. * Ensures that the value is limited between zero and one
  153461. * @returns This path cursor
  153462. */
  153463. private ensureLimits;
  153464. /**
  153465. * Runs onchange callbacks on change (used by the animation engine)
  153466. * @returns This path cursor
  153467. */
  153468. private raiseOnChange;
  153469. /**
  153470. * Executes a function on change
  153471. * @param f A path cursor onchange callback
  153472. * @returns This path cursor
  153473. */
  153474. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153475. }
  153476. }
  153477. declare module BABYLON {
  153478. /** @hidden */
  153479. export var blurPixelShader: {
  153480. name: string;
  153481. shader: string;
  153482. };
  153483. }
  153484. declare module BABYLON {
  153485. /** @hidden */
  153486. export var pointCloudVertexDeclaration: {
  153487. name: string;
  153488. shader: string;
  153489. };
  153490. }
  153491. // Mixins
  153492. interface Window {
  153493. mozIndexedDB: IDBFactory;
  153494. webkitIndexedDB: IDBFactory;
  153495. msIndexedDB: IDBFactory;
  153496. webkitURL: typeof URL;
  153497. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153498. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153499. WebGLRenderingContext: WebGLRenderingContext;
  153500. MSGesture: MSGesture;
  153501. CANNON: any;
  153502. AudioContext: AudioContext;
  153503. webkitAudioContext: AudioContext;
  153504. PointerEvent: any;
  153505. Math: Math;
  153506. Uint8Array: Uint8ArrayConstructor;
  153507. Float32Array: Float32ArrayConstructor;
  153508. mozURL: typeof URL;
  153509. msURL: typeof URL;
  153510. VRFrameData: any; // WebVR, from specs 1.1
  153511. DracoDecoderModule: any;
  153512. setImmediate(handler: (...args: any[]) => void): number;
  153513. }
  153514. interface HTMLCanvasElement {
  153515. requestPointerLock(): void;
  153516. msRequestPointerLock?(): void;
  153517. mozRequestPointerLock?(): void;
  153518. webkitRequestPointerLock?(): void;
  153519. /** Track wether a record is in progress */
  153520. isRecording: boolean;
  153521. /** Capture Stream method defined by some browsers */
  153522. captureStream(fps?: number): MediaStream;
  153523. }
  153524. interface CanvasRenderingContext2D {
  153525. msImageSmoothingEnabled: boolean;
  153526. }
  153527. interface MouseEvent {
  153528. mozMovementX: number;
  153529. mozMovementY: number;
  153530. webkitMovementX: number;
  153531. webkitMovementY: number;
  153532. msMovementX: number;
  153533. msMovementY: number;
  153534. }
  153535. interface Navigator {
  153536. mozGetVRDevices: (any: any) => any;
  153537. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153538. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153539. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153540. webkitGetGamepads(): Gamepad[];
  153541. msGetGamepads(): Gamepad[];
  153542. webkitGamepads(): Gamepad[];
  153543. }
  153544. interface HTMLVideoElement {
  153545. mozSrcObject: any;
  153546. }
  153547. interface Math {
  153548. fround(x: number): number;
  153549. imul(a: number, b: number): number;
  153550. }
  153551. interface WebGLRenderingContext {
  153552. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153553. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153554. vertexAttribDivisor(index: number, divisor: number): void;
  153555. createVertexArray(): any;
  153556. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153557. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153558. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153559. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153560. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153561. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153562. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153563. // Queries
  153564. createQuery(): WebGLQuery;
  153565. deleteQuery(query: WebGLQuery): void;
  153566. beginQuery(target: number, query: WebGLQuery): void;
  153567. endQuery(target: number): void;
  153568. getQueryParameter(query: WebGLQuery, pname: number): any;
  153569. getQuery(target: number, pname: number): any;
  153570. MAX_SAMPLES: number;
  153571. RGBA8: number;
  153572. READ_FRAMEBUFFER: number;
  153573. DRAW_FRAMEBUFFER: number;
  153574. UNIFORM_BUFFER: number;
  153575. HALF_FLOAT_OES: number;
  153576. RGBA16F: number;
  153577. RGBA32F: number;
  153578. R32F: number;
  153579. RG32F: number;
  153580. RGB32F: number;
  153581. R16F: number;
  153582. RG16F: number;
  153583. RGB16F: number;
  153584. RED: number;
  153585. RG: number;
  153586. R8: number;
  153587. RG8: number;
  153588. UNSIGNED_INT_24_8: number;
  153589. DEPTH24_STENCIL8: number;
  153590. MIN: number;
  153591. MAX: number;
  153592. /* Multiple Render Targets */
  153593. drawBuffers(buffers: number[]): void;
  153594. readBuffer(src: number): void;
  153595. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153596. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153597. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153598. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153599. // Occlusion Query
  153600. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153601. ANY_SAMPLES_PASSED: number;
  153602. QUERY_RESULT_AVAILABLE: number;
  153603. QUERY_RESULT: number;
  153604. }
  153605. interface WebGLProgram {
  153606. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153607. }
  153608. interface EXT_disjoint_timer_query {
  153609. QUERY_COUNTER_BITS_EXT: number;
  153610. TIME_ELAPSED_EXT: number;
  153611. TIMESTAMP_EXT: number;
  153612. GPU_DISJOINT_EXT: number;
  153613. QUERY_RESULT_EXT: number;
  153614. QUERY_RESULT_AVAILABLE_EXT: number;
  153615. queryCounterEXT(query: WebGLQuery, target: number): void;
  153616. createQueryEXT(): WebGLQuery;
  153617. beginQueryEXT(target: number, query: WebGLQuery): void;
  153618. endQueryEXT(target: number): void;
  153619. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153620. deleteQueryEXT(query: WebGLQuery): void;
  153621. }
  153622. interface WebGLUniformLocation {
  153623. _currentState: any;
  153624. }
  153625. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153626. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153627. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153628. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153629. interface WebGLRenderingContext {
  153630. readonly RASTERIZER_DISCARD: number;
  153631. readonly DEPTH_COMPONENT24: number;
  153632. readonly TEXTURE_3D: number;
  153633. readonly TEXTURE_2D_ARRAY: number;
  153634. readonly TEXTURE_COMPARE_FUNC: number;
  153635. readonly TEXTURE_COMPARE_MODE: number;
  153636. readonly COMPARE_REF_TO_TEXTURE: number;
  153637. readonly TEXTURE_WRAP_R: number;
  153638. readonly HALF_FLOAT: number;
  153639. readonly RGB8: number;
  153640. readonly RED_INTEGER: number;
  153641. readonly RG_INTEGER: number;
  153642. readonly RGB_INTEGER: number;
  153643. readonly RGBA_INTEGER: number;
  153644. readonly R8_SNORM: number;
  153645. readonly RG8_SNORM: number;
  153646. readonly RGB8_SNORM: number;
  153647. readonly RGBA8_SNORM: number;
  153648. readonly R8I: number;
  153649. readonly RG8I: number;
  153650. readonly RGB8I: number;
  153651. readonly RGBA8I: number;
  153652. readonly R8UI: number;
  153653. readonly RG8UI: number;
  153654. readonly RGB8UI: number;
  153655. readonly RGBA8UI: number;
  153656. readonly R16I: number;
  153657. readonly RG16I: number;
  153658. readonly RGB16I: number;
  153659. readonly RGBA16I: number;
  153660. readonly R16UI: number;
  153661. readonly RG16UI: number;
  153662. readonly RGB16UI: number;
  153663. readonly RGBA16UI: number;
  153664. readonly R32I: number;
  153665. readonly RG32I: number;
  153666. readonly RGB32I: number;
  153667. readonly RGBA32I: number;
  153668. readonly R32UI: number;
  153669. readonly RG32UI: number;
  153670. readonly RGB32UI: number;
  153671. readonly RGBA32UI: number;
  153672. readonly RGB10_A2UI: number;
  153673. readonly R11F_G11F_B10F: number;
  153674. readonly RGB9_E5: number;
  153675. readonly RGB10_A2: number;
  153676. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153677. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153678. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153679. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153680. readonly DEPTH_COMPONENT32F: number;
  153681. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153682. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153683. 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;
  153684. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153685. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153686. readonly TRANSFORM_FEEDBACK: number;
  153687. readonly INTERLEAVED_ATTRIBS: number;
  153688. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153689. createTransformFeedback(): WebGLTransformFeedback;
  153690. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153691. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153692. beginTransformFeedback(primitiveMode: number): void;
  153693. endTransformFeedback(): void;
  153694. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153695. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153696. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153697. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153698. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153699. }
  153700. interface ImageBitmap {
  153701. readonly width: number;
  153702. readonly height: number;
  153703. close(): void;
  153704. }
  153705. interface WebGLQuery extends WebGLObject {
  153706. }
  153707. declare var WebGLQuery: {
  153708. prototype: WebGLQuery;
  153709. new(): WebGLQuery;
  153710. };
  153711. interface WebGLSampler extends WebGLObject {
  153712. }
  153713. declare var WebGLSampler: {
  153714. prototype: WebGLSampler;
  153715. new(): WebGLSampler;
  153716. };
  153717. interface WebGLSync extends WebGLObject {
  153718. }
  153719. declare var WebGLSync: {
  153720. prototype: WebGLSync;
  153721. new(): WebGLSync;
  153722. };
  153723. interface WebGLTransformFeedback extends WebGLObject {
  153724. }
  153725. declare var WebGLTransformFeedback: {
  153726. prototype: WebGLTransformFeedback;
  153727. new(): WebGLTransformFeedback;
  153728. };
  153729. interface WebGLVertexArrayObject extends WebGLObject {
  153730. }
  153731. declare var WebGLVertexArrayObject: {
  153732. prototype: WebGLVertexArrayObject;
  153733. new(): WebGLVertexArrayObject;
  153734. };
  153735. // Type definitions for WebVR API
  153736. // Project: https://w3c.github.io/webvr/
  153737. // Definitions by: six a <https://github.com/lostfictions>
  153738. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153739. interface VRDisplay extends EventTarget {
  153740. /**
  153741. * Dictionary of capabilities describing the VRDisplay.
  153742. */
  153743. readonly capabilities: VRDisplayCapabilities;
  153744. /**
  153745. * z-depth defining the far plane of the eye view frustum
  153746. * enables mapping of values in the render target depth
  153747. * attachment to scene coordinates. Initially set to 10000.0.
  153748. */
  153749. depthFar: number;
  153750. /**
  153751. * z-depth defining the near plane of the eye view frustum
  153752. * enables mapping of values in the render target depth
  153753. * attachment to scene coordinates. Initially set to 0.01.
  153754. */
  153755. depthNear: number;
  153756. /**
  153757. * An identifier for this distinct VRDisplay. Used as an
  153758. * association point in the Gamepad API.
  153759. */
  153760. readonly displayId: number;
  153761. /**
  153762. * A display name, a user-readable name identifying it.
  153763. */
  153764. readonly displayName: string;
  153765. readonly isConnected: boolean;
  153766. readonly isPresenting: boolean;
  153767. /**
  153768. * If this VRDisplay supports room-scale experiences, the optional
  153769. * stage attribute contains details on the room-scale parameters.
  153770. */
  153771. readonly stageParameters: VRStageParameters | null;
  153772. /**
  153773. * Passing the value returned by `requestAnimationFrame` to
  153774. * `cancelAnimationFrame` will unregister the callback.
  153775. * @param handle Define the hanle of the request to cancel
  153776. */
  153777. cancelAnimationFrame(handle: number): void;
  153778. /**
  153779. * Stops presenting to the VRDisplay.
  153780. * @returns a promise to know when it stopped
  153781. */
  153782. exitPresent(): Promise<void>;
  153783. /**
  153784. * Return the current VREyeParameters for the given eye.
  153785. * @param whichEye Define the eye we want the parameter for
  153786. * @returns the eye parameters
  153787. */
  153788. getEyeParameters(whichEye: string): VREyeParameters;
  153789. /**
  153790. * Populates the passed VRFrameData with the information required to render
  153791. * the current frame.
  153792. * @param frameData Define the data structure to populate
  153793. * @returns true if ok otherwise false
  153794. */
  153795. getFrameData(frameData: VRFrameData): boolean;
  153796. /**
  153797. * Get the layers currently being presented.
  153798. * @returns the list of VR layers
  153799. */
  153800. getLayers(): VRLayer[];
  153801. /**
  153802. * Return a VRPose containing the future predicted pose of the VRDisplay
  153803. * when the current frame will be presented. The value returned will not
  153804. * change until JavaScript has returned control to the browser.
  153805. *
  153806. * The VRPose will contain the position, orientation, velocity,
  153807. * and acceleration of each of these properties.
  153808. * @returns the pose object
  153809. */
  153810. getPose(): VRPose;
  153811. /**
  153812. * Return the current instantaneous pose of the VRDisplay, with no
  153813. * prediction applied.
  153814. * @returns the current instantaneous pose
  153815. */
  153816. getImmediatePose(): VRPose;
  153817. /**
  153818. * The callback passed to `requestAnimationFrame` will be called
  153819. * any time a new frame should be rendered. When the VRDisplay is
  153820. * presenting the callback will be called at the native refresh
  153821. * rate of the HMD. When not presenting this function acts
  153822. * identically to how window.requestAnimationFrame acts. Content should
  153823. * make no assumptions of frame rate or vsync behavior as the HMD runs
  153824. * asynchronously from other displays and at differing refresh rates.
  153825. * @param callback Define the eaction to run next frame
  153826. * @returns the request handle it
  153827. */
  153828. requestAnimationFrame(callback: FrameRequestCallback): number;
  153829. /**
  153830. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  153831. * Repeat calls while already presenting will update the VRLayers being displayed.
  153832. * @param layers Define the list of layer to present
  153833. * @returns a promise to know when the request has been fulfilled
  153834. */
  153835. requestPresent(layers: VRLayer[]): Promise<void>;
  153836. /**
  153837. * Reset the pose for this display, treating its current position and
  153838. * orientation as the "origin/zero" values. VRPose.position,
  153839. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153840. * updated when calling resetPose(). This should be called in only
  153841. * sitting-space experiences.
  153842. */
  153843. resetPose(): void;
  153844. /**
  153845. * The VRLayer provided to the VRDisplay will be captured and presented
  153846. * in the HMD. Calling this function has the same effect on the source
  153847. * canvas as any other operation that uses its source image, and canvases
  153848. * created without preserveDrawingBuffer set to true will be cleared.
  153849. * @param pose Define the pose to submit
  153850. */
  153851. submitFrame(pose?: VRPose): void;
  153852. }
  153853. declare var VRDisplay: {
  153854. prototype: VRDisplay;
  153855. new(): VRDisplay;
  153856. };
  153857. interface VRLayer {
  153858. leftBounds?: number[] | Float32Array | null;
  153859. rightBounds?: number[] | Float32Array | null;
  153860. source?: HTMLCanvasElement | null;
  153861. }
  153862. interface VRDisplayCapabilities {
  153863. readonly canPresent: boolean;
  153864. readonly hasExternalDisplay: boolean;
  153865. readonly hasOrientation: boolean;
  153866. readonly hasPosition: boolean;
  153867. readonly maxLayers: number;
  153868. }
  153869. interface VREyeParameters {
  153870. /** @deprecated */
  153871. readonly fieldOfView: VRFieldOfView;
  153872. readonly offset: Float32Array;
  153873. readonly renderHeight: number;
  153874. readonly renderWidth: number;
  153875. }
  153876. interface VRFieldOfView {
  153877. readonly downDegrees: number;
  153878. readonly leftDegrees: number;
  153879. readonly rightDegrees: number;
  153880. readonly upDegrees: number;
  153881. }
  153882. interface VRFrameData {
  153883. readonly leftProjectionMatrix: Float32Array;
  153884. readonly leftViewMatrix: Float32Array;
  153885. readonly pose: VRPose;
  153886. readonly rightProjectionMatrix: Float32Array;
  153887. readonly rightViewMatrix: Float32Array;
  153888. readonly timestamp: number;
  153889. }
  153890. interface VRPose {
  153891. readonly angularAcceleration: Float32Array | null;
  153892. readonly angularVelocity: Float32Array | null;
  153893. readonly linearAcceleration: Float32Array | null;
  153894. readonly linearVelocity: Float32Array | null;
  153895. readonly orientation: Float32Array | null;
  153896. readonly position: Float32Array | null;
  153897. readonly timestamp: number;
  153898. }
  153899. interface VRStageParameters {
  153900. sittingToStandingTransform?: Float32Array;
  153901. sizeX?: number;
  153902. sizeY?: number;
  153903. }
  153904. interface Navigator {
  153905. getVRDisplays(): Promise<VRDisplay[]>;
  153906. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  153907. }
  153908. interface Window {
  153909. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  153910. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  153911. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  153912. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153913. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  153914. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  153915. }
  153916. interface Gamepad {
  153917. readonly displayId: number;
  153918. }
  153919. type XRSessionMode =
  153920. | "inline"
  153921. | "immersive-vr"
  153922. | "immersive-ar";
  153923. type XRReferenceSpaceType =
  153924. | "viewer"
  153925. | "local"
  153926. | "local-floor"
  153927. | "bounded-floor"
  153928. | "unbounded";
  153929. type XREnvironmentBlendMode =
  153930. | "opaque"
  153931. | "additive"
  153932. | "alpha-blend";
  153933. type XRVisibilityState =
  153934. | "visible"
  153935. | "visible-blurred"
  153936. | "hidden";
  153937. type XRHandedness =
  153938. | "none"
  153939. | "left"
  153940. | "right";
  153941. type XRTargetRayMode =
  153942. | "gaze"
  153943. | "tracked-pointer"
  153944. | "screen";
  153945. type XREye =
  153946. | "none"
  153947. | "left"
  153948. | "right";
  153949. type XREventType =
  153950. | "devicechange"
  153951. | "visibilitychange"
  153952. | "end"
  153953. | "inputsourceschange"
  153954. | "select"
  153955. | "selectstart"
  153956. | "selectend"
  153957. | "squeeze"
  153958. | "squeezestart"
  153959. | "squeezeend"
  153960. | "reset";
  153961. interface XRSpace extends EventTarget {
  153962. }
  153963. interface XRRenderState {
  153964. depthNear?: number;
  153965. depthFar?: number;
  153966. inlineVerticalFieldOfView?: number;
  153967. baseLayer?: XRWebGLLayer;
  153968. }
  153969. interface XRInputSource {
  153970. handedness: XRHandedness;
  153971. targetRayMode: XRTargetRayMode;
  153972. targetRaySpace: XRSpace;
  153973. gripSpace: XRSpace | undefined;
  153974. gamepad: Gamepad | undefined;
  153975. profiles: Array<string>;
  153976. }
  153977. interface XRSessionInit {
  153978. optionalFeatures?: string[];
  153979. requiredFeatures?: string[];
  153980. }
  153981. interface XRSession {
  153982. addEventListener: Function;
  153983. removeEventListener: Function;
  153984. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153985. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153986. requestAnimationFrame: Function;
  153987. end(): Promise<void>;
  153988. renderState: XRRenderState;
  153989. inputSources: Array<XRInputSource>;
  153990. // hit test
  153991. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  153992. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  153993. // legacy AR hit test
  153994. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153995. // legacy plane detection
  153996. updateWorldTrackingState(options: {
  153997. planeDetectionState?: { enabled: boolean; }
  153998. }): void;
  153999. }
  154000. interface XRReferenceSpace extends XRSpace {
  154001. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154002. onreset: any;
  154003. }
  154004. type XRPlaneSet = Set<XRPlane>;
  154005. type XRAnchorSet = Set<XRAnchor>;
  154006. interface XRFrame {
  154007. session: XRSession;
  154008. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154009. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154010. // AR
  154011. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154012. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154013. // Anchors
  154014. trackedAnchors?: XRAnchorSet;
  154015. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154016. // Planes
  154017. worldInformation: {
  154018. detectedPlanes?: XRPlaneSet;
  154019. };
  154020. }
  154021. interface XRViewerPose extends XRPose {
  154022. views: Array<XRView>;
  154023. }
  154024. interface XRPose {
  154025. transform: XRRigidTransform;
  154026. emulatedPosition: boolean;
  154027. }
  154028. interface XRWebGLLayerOptions {
  154029. antialias?: boolean;
  154030. depth?: boolean;
  154031. stencil?: boolean;
  154032. alpha?: boolean;
  154033. multiview?: boolean;
  154034. framebufferScaleFactor?: number;
  154035. }
  154036. declare var XRWebGLLayer: {
  154037. prototype: XRWebGLLayer;
  154038. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154039. };
  154040. interface XRWebGLLayer {
  154041. framebuffer: WebGLFramebuffer;
  154042. framebufferWidth: number;
  154043. framebufferHeight: number;
  154044. getViewport: Function;
  154045. }
  154046. declare class XRRigidTransform {
  154047. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154048. position: DOMPointReadOnly;
  154049. orientation: DOMPointReadOnly;
  154050. matrix: Float32Array;
  154051. inverse: XRRigidTransform;
  154052. }
  154053. interface XRView {
  154054. eye: XREye;
  154055. projectionMatrix: Float32Array;
  154056. transform: XRRigidTransform;
  154057. }
  154058. interface XRInputSourceChangeEvent {
  154059. session: XRSession;
  154060. removed: Array<XRInputSource>;
  154061. added: Array<XRInputSource>;
  154062. }
  154063. interface XRInputSourceEvent extends Event {
  154064. readonly frame: XRFrame;
  154065. readonly inputSource: XRInputSource;
  154066. }
  154067. // Experimental(er) features
  154068. declare class XRRay {
  154069. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154070. origin: DOMPointReadOnly;
  154071. direction: DOMPointReadOnly;
  154072. matrix: Float32Array;
  154073. }
  154074. declare enum XRHitTestTrackableType {
  154075. "point",
  154076. "plane"
  154077. }
  154078. interface XRHitResult {
  154079. hitMatrix: Float32Array;
  154080. }
  154081. interface XRTransientInputHitTestResult {
  154082. readonly inputSource: XRInputSource;
  154083. readonly results: Array<XRHitTestResult>;
  154084. }
  154085. interface XRHitTestResult {
  154086. getPose(baseSpace: XRSpace): XRPose | undefined;
  154087. // When anchor system is enabled
  154088. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154089. }
  154090. interface XRHitTestSource {
  154091. cancel(): void;
  154092. }
  154093. interface XRTransientInputHitTestSource {
  154094. cancel(): void;
  154095. }
  154096. interface XRHitTestOptionsInit {
  154097. space: XRSpace;
  154098. entityTypes?: Array<XRHitTestTrackableType>;
  154099. offsetRay?: XRRay;
  154100. }
  154101. interface XRTransientInputHitTestOptionsInit {
  154102. profile: string;
  154103. entityTypes?: Array<XRHitTestTrackableType>;
  154104. offsetRay?: XRRay;
  154105. }
  154106. interface XRAnchor {
  154107. anchorSpace: XRSpace;
  154108. delete(): void;
  154109. }
  154110. interface XRPlane {
  154111. orientation: "Horizontal" | "Vertical";
  154112. planeSpace: XRSpace;
  154113. polygon: Array<DOMPointReadOnly>;
  154114. lastChangedTime: number;
  154115. }